MP-Gadget  5.0.1.dev1-76bc7d4726-dirty
Classes | Functions | Variables
run.c File Reference

iterates over timesteps, main loop More...

#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <unistd.h>
#include <ctype.h>
#include <omp.h>
#include "utils.h"
#include "walltime.h"
#include "gravity.h"
#include "density.h"
#include "domain.h"
#include "run.h"
#include "init.h"
#include "cooling.h"
#include "checkpoint.h"
#include "petaio.h"
#include "petapm.h"
#include "timestep.h"
#include "drift.h"
#include "forcetree.h"
#include "blackhole.h"
#include "hydra.h"
#include "sfr_eff.h"
#include "metal_return.h"
#include "slotsmanager.h"
#include "hci.h"
#include "fof.h"
#include "cooling_qso_lightup.h"
#include "lightcone.h"
#include "timefac.h"
#include "neutrinos_lra.h"
#include "stats.h"
Include dependency graph for run.c:

Go to the source code of this file.

Classes

struct  run_params
 

Functions

void set_all_global_params (ParameterSet *ps)
 
int find_last_snapshot (void)
 
inttime_t begrun (const int RestartSnapNum, struct header_data *head)
 
static int use_pairwise_gravity (ActiveParticles *Act, struct part_manager_type *PartManager)
 
void run (const int RestartSnapNum, const inttime_t ti_init, const struct header_data *header)
 
void runtests (const int RestartSnapNum, const inttime_t Ti_Current, const struct header_data *header)
 
void runfof (const int RestartSnapNum, const inttime_t Ti_Current, const struct header_data *header)
 
void runpower (const struct header_data *header)
 

Variables

static struct ClockTable Clocks
 
static struct run_params All
 

Detailed Description

iterates over timesteps, main loop

Definition in file run.c.

Function Documentation

◆ begrun()

inttime_t begrun ( const int  RestartSnapNum,
struct header_data head 
)

This function performs the initial set-up of the simulation. First, the parameterfile is set, then routines for setting units, reading ICs/restart-files are called, auxialiary memory is allocated, etc.

Definition at line 194 of file run.c.

195 {
196  petapm_module_init(omp_get_max_threads());
197  petaio_init();
199 
200  *head = petaio_read_header(RestartSnapNum, All.OutputDir, &All.CP);
201  /*Set Nmesh to triple the mean grid spacing of the dark matter by default.*/
202  if(All.Nmesh < 0)
203  All.Nmesh = 3*pow(2, (int)(log(head->NTotal[1])/3./log(2)) );
204  if(head->neutrinonk <= 0)
205  head->neutrinonk = All.Nmesh;
206 
208  /* Enable the slots: stars and BHs are allocated if there are some,
209  * or if some will form*/
210  if(head->NTotalInit[0] > 0)
212  if(All.StarformationOn || head->NTotalInit[4] > 0)
214  if(All.BlackHoleOn || head->NTotalInit[5] > 0)
215  slots_set_enabled(5, sizeof(struct bh_particle_data), SlotsManager);
216 
217  const struct UnitSystem units = get_unitsystem(head->UnitLength_in_cm, head->UnitMass_in_g, head->UnitVelocity_in_cm_per_s);
218  /* convert some physical input parameters to internal units */
219  init_cosmology(&All.CP, head->TimeIC, units);
220 
221  check_units(&All.CP, units);
222 
223 #ifdef DEBUG
224  char * pidfile = fastpm_strdup_printf("%s/%s", All.OutputDir, "PIDs.txt");
225 
226  MPIU_write_pids(pidfile);
227  myfree(pidfile);
228 #endif
229 
231 
233 
235 
237 
238  if(All.LightconeOn)
240 
241  init_timeline(RestartSnapNum, All.TimeMax, head, All.SnapshotWithFOF);
242 
243  /* Get the nk and do allocation. */
246 
247  /* ... read initial model and initialise the times*/
248  inttime_t ti_init = init(RestartSnapNum, All.OutputDir, head, &All.CP);
249 
250  if(RestartSnapNum < 0) {
251  DomainDecomp ddecomp[1] = {0};
252  domain_decompose_full(ddecomp); /* do initial domain decomposition (gives equal numbers of particles) so density() is safe*/
253  /* On first run, generate smoothing lengths and set initial entropies based on CMB temperature*/
254  setup_smoothinglengths(RestartSnapNum, ddecomp, &All.CP, All.BlackHoleOn, get_MinEgySpec(), units.UnitInternalEnergy_in_cgs, ti_init, head->TimeSnapshot, head->NTotalInit[0]);
255  domain_free(ddecomp);
256  }
257  else
258  /* When we restart, validate the SPH properties of the particles.
259  * This also allows us to increase MinEgySpec on a restart if we choose.*/
261 
262  return ti_init;
263 }
void check_units(const Cosmology *CP, const struct UnitSystem units)
Definition: cosmology.c:260
void init_cosmology(Cosmology *CP, const double TimeBegin, const struct UnitSystem units)
Definition: cosmology.c:15
void domain_free(DomainDecomp *ddecomp)
Definition: domain.c:320
void domain_decompose_full(DomainDecomp *ddecomp)
Definition: domain.c:155
void init_forcetree_params(const int FastParticleType)
Definition: forcetree.c:43
void gravshort_fill_ntab(const enum ShortRangeForceWindowType ShortRangeForceWindowType, const double Asmth)
Definition: gravity.c:23
void check_density_entropy(Cosmology *CP, const double MinEgySpec, const double atime)
Definition: init.c:344
void setup_smoothinglengths(int RestartSnapNum, DomainDecomp *ddecomp, Cosmology *CP, int BlackHoleOn, double MinEgySpec, double uu_in_cgs, const inttime_t Ti_Current, const double atime, const int64_t NTotGasInit)
Definition: init.c:439
inttime_t init(int RestartSnapNum, const char *OutputDir, struct header_data *header, Cosmology *CP)
Definition: init.c:86
void init_timeline(int RestartSnapNum, double TimeMax, const struct header_data *header, const int SnapshotWithFOF)
Definition: init.c:56
void lightcone_init(Cosmology *CP, double timeBegin, const double UnitLength_in_cm, const char *OutputDir)
Definition: lightcone.c:91
#define myfree(x)
Definition: mymalloc.h:19
void init_neutrinos_lra(const int nk_in, const double TimeTransfer, const double TimeMax, const double Omega0, const _omega_nu *const omnu, const double UnitTime_in_s, const double UnitLength_in_cm)
struct part_manager_type PartManager[1]
Definition: partmanager.c:11
struct header_data petaio_read_header(int num, const char *OutputDir, Cosmology *CP)
Definition: petaio.c:219
void petaio_init(void)
Definition: petaio.c:88
void petapm_module_init(int Nthreads)
Definition: petapm.c:82
#define CM_PER_MPC
Definition: physconst.h:20
static struct ClockTable Clocks
Definition: run.c:38
static struct run_params All
void init_cooling_and_star_formation(int CoolingOn, int StarformationOn, Cosmology *CP, const double avg_baryon_mass, const double BoxSize, const struct UnitSystem units)
Definition: sfr_eff.c:805
double get_MinEgySpec(void)
Definition: sfr_eff.c:797
void slots_set_enabled(int ptype, size_t elsize, struct slots_manager_type *sman)
Definition: slotsmanager.c:560
struct slots_manager_type SlotsManager[1]
Definition: slotsmanager.c:7
void slots_init(double increase, struct slots_manager_type *sman)
Definition: slotsmanager.c:550
char * fastpm_strdup_printf(const char *fmt,...)
Definition: string.c:41
double Omega0
Definition: cosmology.h:10
double UnitTime_in_s
Definition: cosmology.h:22
int MassiveNuLinRespOn
Definition: cosmology.h:26
_omega_nu ONu
Definition: cosmology.h:24
double UnitInternalEnergy_in_cgs
Definition: unitsystem.h:14
double TimeIC
Definition: petaio.h:24
int64_t NTotalInit[6]
Definition: petaio.h:20
double TimeSnapshot
Definition: petaio.h:26
double UnitMass_in_g
Definition: petaio.h:31
double MassTable[6]
Definition: petaio.h:22
double UnitVelocity_in_cm_per_s
Definition: petaio.h:32
double UnitLength_in_cm
Definition: petaio.h:30
int neutrinonk
Definition: petaio.h:34
double BoxSize
Definition: petaio.h:28
int64_t NTotal[6]
Definition: petaio.h:18
Cosmology CP
Definition: run.c:59
int RandomSeed
Definition: run.c:101
int BlackHoleOn
Definition: run.c:67
enum ShortRangeForceWindowType ShortRangeForceWindowType
Definition: run.c:93
int FastParticleType
Definition: run.c:75
int LightconeOn
Definition: run.c:70
double Asmth
Definition: run.c:92
int Nmesh
Definition: run.c:85
int SnapshotWithFOF
Definition: run.c:99
double SlotsIncreaseFactor
Definition: run.c:47
int CoolingOn
Definition: run.c:62
double TimeMax
Definition: run.c:83
int StarformationOn
Definition: run.c:68
char OutputDir[100]
Definition: run.c:96
void MPIU_write_pids(char *filename)
Definition: system.c:552
void set_random_numbers(int seed)
Definition: system.c:65
int32_t inttime_t
Definition: types.h:8
struct UnitSystem get_unitsystem(double UnitLength_in_cm, double UnitMass_in_g, double UnitVelocity_in_cm_per_s)
Definition: unitsystem.c:6
void walltime_init(struct ClockTable *ct)
Definition: walltime.c:19

References All, run_params::Asmth, run_params::BlackHoleOn, header_data::BoxSize, check_density_entropy(), check_units(), Clocks, CM_PER_MPC, run_params::CoolingOn, run_params::CP, domain_decompose_full(), domain_free(), run_params::FastParticleType, fastpm_strdup_printf(), get_MinEgySpec(), get_unitsystem(), gravshort_fill_ntab(), init(), init_cooling_and_star_formation(), init_cosmology(), init_forcetree_params(), init_neutrinos_lra(), init_timeline(), lightcone_init(), run_params::LightconeOn, Cosmology::MassiveNuLinRespOn, header_data::MassTable, part_manager_type::MaxPart, MPIU_write_pids(), myfree, header_data::neutrinonk, run_params::Nmesh, header_data::NTotal, header_data::NTotalInit, Cosmology::Omega0, Cosmology::ONu, run_params::OutputDir, PartManager, petaio_init(), petaio_read_header(), petapm_module_init(), run_params::RandomSeed, set_random_numbers(), setup_smoothinglengths(), run_params::ShortRangeForceWindowType, slots_init(), slots_set_enabled(), run_params::SlotsIncreaseFactor, SlotsManager, run_params::SnapshotWithFOF, run_params::StarformationOn, header_data::TimeIC, run_params::TimeMax, header_data::TimeSnapshot, UnitSystem::UnitInternalEnergy_in_cgs, header_data::UnitLength_in_cm, header_data::UnitMass_in_g, Cosmology::UnitTime_in_s, header_data::UnitVelocity_in_cm_per_s, and walltime_init().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_last_snapshot()

int find_last_snapshot ( void  )

Definition at line 182 of file run.c.

183 {
184  int RestartSnapNum = find_last_snapnum(All.OutputDir);
185  message(0, "Last Snapshot number is %d.\n", RestartSnapNum);
186  return RestartSnapNum;
187 }
int find_last_snapnum(const char *OutputDir)
Definition: checkpoint.c:63
void message(int where, const char *fmt,...)
Definition: endrun.c:175

References All, find_last_snapnum(), message(), and run_params::OutputDir.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

void run ( const int  RestartSnapNum,
const inttime_t  ti_init,
const struct header_data header 
)

This routine contains the main simulation loop that iterates over single timesteps. The loop terminates when the cpu-time limit is reached, when a ‘stop’ file is found in the output directory, or when the simulation ends because we arrived at TimeMax.

Definition at line 284 of file run.c.

285 {
286  /*Number of timesteps performed this run*/
287  int NumCurrentTiStep = 0;
288  /*Is gas physics enabled?*/
289  int GasEnabled = SlotsManager->info[0].enabled;
290 
291  HCIManager HCI_DEFAULT_MANAGER[1] = {0};
293 
294  const struct UnitSystem units = get_unitsystem(header->UnitLength_in_cm, header->UnitMass_in_g, header->UnitVelocity_in_cm_per_s);
295 
296  int SnapshotFileCount = RestartSnapNum;
297 
298  const double MinEgySpec = get_MinEgySpec();
299 
300  PetaPM pm = {0};
302 
303  DomainDecomp ddecomp[1] = {0};
304 
305  /* Stored scale factor of the next black hole seeding check*/
306  double TimeNextSeedingCheck = header->TimeSnapshot;
307 
308  walltime_measure("/Misc");
309  struct OutputFD fds;
311 
312  write_cpu_log(NumCurrentTiStep, header->TimeSnapshot, fds.FdCPU, Clocks.ElapsedTime); /* produce some CPU usage info */
313 
314  DriftKickTimes times = init_driftkicktime(ti_init);
315 
316  double atime = get_atime(times.Ti_Current);
317 
318  while(1) /* main loop */
319  {
320  /* Find next synchronization point and the timebins active during this timestep.
321  *
322  * Note that on startup, P[i].TimeBin == 0 for all particles,
323  * all bins except the zeroth are inactive and so we return 0 from this function.
324  * This ensures we run the force calculation for the first timestep.
325  */
326  inttime_t Ti_Next = find_next_kick(times.Ti_Current, times.mintimebin);
327  inttime_t Ti_Last = times.Ti_Current;
328 
329  times.Ti_Current = Ti_Next;
330 
331  /*Convert back to floating point time*/
332  double newatime = get_atime(times.Ti_Current);
333  if(newatime < atime)
334  endrun(1, "Negative timestep: %g New Time: %g Old time %g!\n", newatime - atime, newatime, atime);
335  atime = newatime;
336 
337  /* Compute the list of particles that cross a lightcone and write it to disc.*/
338  if(All.LightconeOn)
339  lightcone_compute(atime, PartManager->BoxSize, &All.CP, Ti_Last, Ti_Next);
340 
341  int is_PM = is_PM_timestep(&times);
342 
343  SyncPoint * next_sync; /* if we are out of planned sync points, terminate */
344  SyncPoint * planned_sync; /* NULL; if the step is not a planned sync point. */
345 
346  next_sync = find_next_sync_point(times.Ti_Current);
347  planned_sync = find_current_sync_point(times.Ti_Current);
348 
349  HCIAction action[1];
350 
351  hci_action_init(action); /* init to no action */
352 
353  int stop = 0;
354 
355  if(is_PM) {
356  /* query HCI requests only on PM step; where kick and drifts are synced */
357  stop = hci_query(HCI_DEFAULT_MANAGER, action);
358 
359  if(action->type == HCI_TERMINATE) {
360  endrun(0, "Human triggered termination.\n");
361  }
362  }
363 
364  double rel_random_shift[3] = {0};
365  if(NumCurrentTiStep > 0 && is_PM && All.RandomParticleOffset > 0) {
367  }
368 
369  int extradomain = is_timebin_active(times.mintimebin + All.MaxDomainTimeBinDepth, times.Ti_Current);
370  /* drift and ddecomp decomposition */
371  /* at first step this is a noop */
372  if(extradomain || is_PM) {
373  /* Sync positions of all particles */
374  drift_all_particles(Ti_Last, times.Ti_Current, &All.CP, rel_random_shift);
375  /* full decomposition rebuilds the domain, needs keys.*/
376  domain_decompose_full(ddecomp);
377  } else {
378  /* FIXME: add a parameter for ddecomp_decompose_incremental */
379  /* currently we drift all particles every step */
380  /* If it is not a PM step, do a shorter version
381  * of the ddecomp decomp which just exchanges particles.*/
382  struct DriftData drift;
383  drift.CP = &All.CP;
384  drift.ti0 = Ti_Last;
385  drift.ti1 = times.Ti_Current;
386  domain_maintain(ddecomp, &drift);
387  }
388  update_lastactive_drift(&times);
389 
390 
391  ActiveParticles Act = {0};
392  rebuild_activelist(&Act, &times, NumCurrentTiStep, atime);
393 
395 
396  /* Are the particle neutrinos gravitating this timestep?
397  * If so we need to add them to the tree.*/
398  int HybridNuTracer = hybrid_nu_tracer(&All.CP, atime);
399 
400  /* Collective: total number of active particles must be small enough*/
401  int pairwisestep = use_pairwise_gravity(&Act, PartManager);
402 
403  MyFloat * GradRho = NULL;
405  GradRho = (MyFloat *) mymalloc2("SPH_GradRho", sizeof(MyFloat) * 3 * SlotsManager->info[0].size);
406 
407  /* Need to rebuild the force tree because all TopLeaves are out of date.*/
408  ForceTree Tree = {0};
409  force_tree_rebuild(&Tree, ddecomp, HybridNuTracer, !pairwisestep && All.TreeGravOn, All.OutputDir);
410 
411  /* density() happens before gravity because it also initializes the predicted variables.
412  * This ensures that prediction consistently uses the grav and hydro accel from the
413  * timestep before this one, which matches Gadget-2/3. It was tested to make a small difference,
414  * since prediction is only really used for artificial viscosity.
415  *
416  * Doing it first also means the density is up to date for
417  * adaptive gravitational softenings. */
418  if(GasEnabled)
419  {
420  /*Allocate the memory for predicted SPH data.*/
422 
423  if(All.DensityOn)
424  density(&Act, 1, DensityIndependentSphOn(), All.BlackHoleOn, MinEgySpec, times, &All.CP, &sph_predicted, GradRho, &Tree); /* computes density, and pressure */
425 
426  /***** update smoothing lengths in tree *****/
427  force_update_hmax(Act.ActiveParticle, Act.NumActiveParticle, &Tree, ddecomp);
428  /***** hydro forces *****/
429  MPIU_Barrier(MPI_COMM_WORLD);
430 
431  /* adds hydrodynamical accelerations and computes du/dt */
432  if(All.HydroOn)
433  hydro_force(&Act, atime, &sph_predicted, MinEgySpec, times, &All.CP, &Tree);
434 
435  /* Scratch data cannot be used checkpoint because FOF does an exchange.*/
436  slots_free_sph_pred_data(&sph_predicted);
437  }
438 
439  /* The opening criterion for the gravtree
440  * uses the *total* gravitational acceleration
441  * from the last timestep, GravPM+GravAccel.
442  * So we must compute GravAccel for this timestep
443  * before gravpm_force() writes the PM acc. for
444  * this timestep to GravPM. Note initially both
445  * are zero and so the tree is opened maximally
446  * on the first timestep.*/
447  const double rho0 = All.CP.Omega0 * 3 * All.CP.Hubble * All.CP.Hubble / (8 * M_PI * All.CP.GravInternal);
448 
449  if(All.TreeGravOn) {
450  /* Do a short range pairwise only step if desired*/
451  if(pairwisestep) {
453  grav_short_pair(&Act, &pm, &Tree, gtp.Rcut, rho0, HybridNuTracer, All.FastParticleType);
454  }
455  else
456  grav_short_tree(&Act, &pm, &Tree, rho0, HybridNuTracer, All.FastParticleType);
457  }
458 
459  /* We use the total gravitational acc.
460  * to open the tree and total acc for the timestep.
461  * Note that any of (GravAccel, GravPM,
462  * HydroAccel) may change much faster than
463  * the total acc.
464  * We do the same as Gadget-2, but one could
465  * instead use short-range tree acc. only
466  * for opening angle or short-range timesteps,
467  * or include hydro in the opening angle.*/
468  if(is_PM)
469  {
470  gravpm_force(&pm, &Tree, &All.CP, atime, units.UnitLength_in_cm, All.OutputDir, header->TimeIC, All.FastParticleType);
471 
472  /* compute and output energy statistics if desired. */
473  if(fds.FdEnergy)
474  energy_statistics(fds.FdEnergy, atime, PartManager);
475  }
476 
477  MPIU_Barrier(MPI_COMM_WORLD);
478  message(0, "Forces computed.\n");
479 
480  /* Update velocity to Ti_Current; this synchronizes TiKick and TiDrift for the active particles
481  * and sets Ti_Kick in the times structure.*/
482  if(is_PM) {
483  apply_PM_half_kick(&All.CP, &times);
484  }
485 
486  /* Need a scale factor for entropy and velocity limiters*/
487  apply_half_kick(&Act, &All.CP, &times, atime, MinEgySpec);
488 
489  /* Cooling and extra physics show up as a source term in the evolution equations.
490  * Formally you can write the structure of the partial differential equations:
491  dU/dt + div(F) = S
492  * where the cooling, BH and SFR are the source term S.
493  * The extra physics is done after the kick, using a Strang split operator.
494  * Gadget3/Arepo tries to follow the general operator splitting ansatz (often called Strang splitting).
495  * Here you alternate the evolution under the operator generating the time evolution of the homogenous system (ie, without S)
496  * with the operator generating the time evolution under the source function alone.
497  * This means to advance the full system by dt, you first evolve dU/dt = S
498  * by dt, and then dU/dt + div(F) = 0 by dt.
499  * [Actually, for second-order convergence in time, you should rather evolve S for dt/2, then the homogenous part for dt, and then S again for dt/2.]
500 
501  * The operator-split approach offers a number of practical advantages when the source function is stiff.
502  * You can, for example, solve dU/dt = S in a robust and stable fashion with an implict solver, whereas the Gadget2 approach is severely challenged
503  * and either requires an artficial clipping of the maximum allowed cooling rate, or a severe reduction of the timestep, otherwise the
504  * predicted entropy due to cooling someting during the timestep can become severely wrong. Also, the source term approach can be easily
505  * used to treat effectively instantaneous injections of energy (like from BHs), which is again hard to properly incorporate in the
506  * time-integration approach where you want to have a "full" dU/dt all times. (Volker Springel 2020).
507  */
508  if(GasEnabled)
509  {
510  /* Do this before sfr and bh so the gas hsml always contains DesNumNgb neighbours.*/
511  if(All.MetalReturnOn) {
512  double AvgGasMass = All.CP.OmegaBaryon * 3 * All.CP.Hubble * All.CP.Hubble / (8 * M_PI * All.CP.GravInternal) * pow(PartManager->BoxSize, 3) / header->NTotalInit[0];
513  metal_return(&Act, ddecomp, &All.CP, atime, AvgGasMass);
514  }
515 
516  /* this will find new black hole seed halos.
517  * Note: the FOF code does not know about garbage particles,
518  * so ensure we do not have garbage present when we call this.
519  * Also a good idea to only run it on a PM step.
520  * This does not break the tree because the new black holes do not move or change mass, just type.
521  * It does not matter that the velocities are half a step off because they are not used in the FoF code.*/
522  if (is_PM && ((All.BlackHoleOn && atime >= TimeNextSeedingCheck) ||
524 
525  /* Seeding: builds its own tree.*/
526  FOFGroups fof = fof_fof(ddecomp, 0, MPI_COMM_WORLD);
527  if(All.BlackHoleOn && atime >= TimeNextSeedingCheck) {
528  fof_seed(&fof, &Act, atime, MPI_COMM_WORLD);
529  TimeNextSeedingCheck = atime * All.TimeBetweenSeedingSearch;
530  }
531 
532  if(during_helium_reionization(1/atime - 1)) {
533  /* Helium reionization by switching on quasar bubbles*/
534  do_heiii_reionization(atime, &fof, ddecomp, &All.CP, units.UnitInternalEnergy_in_cgs, fds.FdHelium);
535  }
536  fof_finish(&fof);
537  }
538 
539  if(is_PM) {
540  /*Rebuild the force tree we freed in gravpm to save memory. Means might be two trees during FOF.*/
541  force_tree_rebuild(&Tree, ddecomp, HybridNuTracer, 0, All.OutputDir);
542  }
543 
544  /* Black hole accretion and feedback */
545  if(All.BlackHoleOn) {
546  blackhole(&Act, atime, &All.CP, &Tree, units, fds.FdBlackHoles, fds.FdBlackholeDetails);
547  }
548 
549  /**** radiative cooling and star formation *****/
550  if(All.CoolingOn)
551  cooling_and_starformation(&Act, atime, get_dloga_for_bin(times.mintimebin, times.Ti_Current), &Tree, &All.CP, GradRho, fds.FdSfr);
552 
553  }
554  /* We don't need this timestep's tree anymore.*/
555  force_tree_free(&Tree);
556 
557  if(GradRho) {
558  myfree(GradRho);
559  GradRho = NULL;
560  }
561 
562  /* If a snapshot is requested, write it. *
563  * We only attempt to output on sync points. This is the only chance where all variables are
564  * synchronized in a consistent state in a K(KDDK)^mK scheme.
565  */
566 
567  int WriteSnapshot = 0;
568  int WriteFOF = 0;
569 
570  if(planned_sync) {
571  WriteSnapshot |= planned_sync->write_snapshot;
572  WriteFOF |= planned_sync->write_fof;
573  }
574 
575  if(is_PM) { /* the if here is unnecessary but to signify checkpointing occurs only at PM steps. */
576  WriteSnapshot |= action->write_snapshot;
577  WriteFOF |= action->write_fof;
578  }
579  if(WriteSnapshot || WriteFOF) {
580  /* Get a new snapshot*/
581  SnapshotFileCount++;
582  /* The accel may have created garbage -- collect them before writing a snapshot.
583  * If we do collect, reset active list size.*/
584  int compact[6] = {0};
585  if(slots_gc(compact, PartManager, SlotsManager))
587  }
588  FOFGroups fof = {0};
589  if(WriteFOF) {
590  /* Compute FOF and assign GrNr so it can be written in checkpoint.*/
591  fof = fof_fof(ddecomp, 1, MPI_COMM_WORLD);
592  }
593 
594  /* WriteFOF just reminds the checkpoint code to save GroupID*/
595  if(WriteSnapshot)
596  write_checkpoint(SnapshotFileCount, WriteFOF, All.MetalReturnOn, atime, &All.CP, All.OutputDir, All.OutputDebugFields);
597 
598  /* Save FOF tables after checkpoint so that if there is a FOF save bug we have particle tables available to debug it*/
599  if(WriteFOF) {
600  fof_save_groups(&fof, All.OutputDir, All.FOFFileBase, SnapshotFileCount, &All.CP, atime, header->MassTable, All.MetalReturnOn, All.BlackHoleOn, MPI_COMM_WORLD);
601  fof_finish(&fof);
602  }
603 
604  write_cpu_log(NumCurrentTiStep, atime, fds.FdCPU, Clocks.ElapsedTime); /* produce some CPU usage info */
605 
606  report_memory_usage("RUN");
607 
608  if(!next_sync || stop) {
609  /* out of sync points, or a requested stop, the run has finally finished! Yay.*/
610  if(action->type == HCI_TIMEOUT)
611  message(0, "Stopping: not enough time for another PM step before TimeLimitCPU is reached.\n");
612  break;
613  }
614 
615  /* more steps to go. */
616 
617  /* assign new timesteps to the active particles,
618  * now that we know they have synched TiKick and TiDrift,
619  * and advance the PM timestep.*/
620  const double asmth = All.Asmth * PartManager->BoxSize / All.Nmesh;
621  int badtimestep = find_timesteps(&Act, &times, atime, All.FastParticleType, &All.CP, asmth, NumCurrentTiStep == 0);
622  if(badtimestep) {
623  message(0, "bad timestep spotted: terminating and saving snapshot.\n");
624  dump_snapshot("TIMESTEP-DUMP", atime, &All.CP, All.OutputDir);
625  endrun(0, "Ending due to bad timestep");
626  }
627 
628  /* Update velocity and ti_kick to the new step, with the newly computed step size */
629  apply_half_kick(&Act, &All.CP, &times, atime, MinEgySpec);
630 
631  if(is_PM) {
632  apply_PM_half_kick(&All.CP, &times);
633  }
634 
635  /* We can now free the active list: the new step have new active particles*/
636  free_activelist(&Act);
637 
638  NumCurrentTiStep++;
639  }
640 
641  close_outputfiles(&fds);
642 }
void blackhole(const ActiveParticles *act, double atime, Cosmology *CP, ForceTree *tree, const struct UnitSystem units, FILE *FdBlackHoles, FILE *FdBlackholeDetails)
Definition: blackhole.c:516
void write_checkpoint(int snapnum, int WriteGroupID, int MetalReturnOn, double Time, const Cosmology *CP, const char *OutputDir, const int OutputDebugFields)
Definition: checkpoint.c:24
void dump_snapshot(const char *dump, const double Time, const Cosmology *CP, const char *OutputDir)
Definition: checkpoint.c:52
void do_heiii_reionization(double atime, FOFGroups *fof, DomainDecomp *ddecomp, Cosmology *CP, double uu_in_cgs, FILE *FdHelium)
int need_change_helium_ionization_fraction(double atime)
int during_helium_reionization(double redshift)
int hybrid_nu_tracer(const Cosmology *CP, double atime)
Definition: cosmology.c:53
struct sph_pred_data slots_allocate_sph_pred_data(int nsph)
Definition: density.c:654
void slots_free_sph_pred_data(struct sph_pred_data *sph_scratch)
Definition: density.c:665
void density(const ActiveParticles *act, int update_hsml, int DoEgyDensity, int BlackHoleOn, double MinEgySpec, const DriftKickTimes times, Cosmology *CP, struct sph_pred_data *SPH_predicted, MyFloat *GradRho, const ForceTree *const tree)
Definition: density.c:203
void domain_maintain(DomainDecomp *ddecomp, struct DriftData *drift)
Definition: domain.c:234
void drift_all_particles(inttime_t ti0, inttime_t ti1, Cosmology *CP, const double random_shift[3])
Definition: drift.c:91
void endrun(int where, const char *fmt,...)
Definition: endrun.c:147
void fof_save_groups(FOFGroups *fof, const char *OutputDir, const char *FOFFileBase, int num, Cosmology *CP, double atime, const double *MassTable, int MetalReturnOn, int BlackholeOn, MPI_Comm Comm)
Definition: fof.c:1113
void fof_finish(FOFGroups *fof)
Definition: fof.c:257
void fof_seed(FOFGroups *fof, ActiveParticles *act, double atime, MPI_Comm Comm)
Definition: fof.c:1290
FOFGroups fof_fof(DomainDecomp *ddecomp, const int StoreGrNr, MPI_Comm Comm)
Definition: fof.c:151
void force_tree_rebuild(ForceTree *tree, DomainDecomp *ddecomp, const int HybridNuGrav, const int DoMoments, const char *EmergencyOutputDir)
Definition: forcetree.c:140
void force_update_hmax(int *activeset, int size, ForceTree *tree, DomainDecomp *ddecomp)
Definition: forcetree.c:1271
void force_tree_free(ForceTree *tree)
Definition: forcetree.c:1409
struct gravshort_tree_params get_gravshort_treepar(void)
void grav_short_pair(const ActiveParticles *act, PetaPM *pm, ForceTree *tree, double Rcut, double rho0, int NeutrinoTracer, int FastParticleType)
void gravpm_force(PetaPM *pm, ForceTree *tree, Cosmology *CP, double Time, double UnitLength_in_cm, const char *PowerOutputDir, double TimeIC, int FastParticleType)
Definition: gravpm.c:62
void grav_short_tree(const ActiveParticles *act, PetaPM *pm, ForceTree *tree, double rho0, int NeutrinoTracer, int FastParticleType)
void gravpm_init_periodic(PetaPM *pm, double BoxSize, double Asmth, int Nmesh, double G)
Definition: gravpm.c:53
void hci_init(HCIManager *manager, char *prefix, double WallClockTimeLimit, double AutoCheckPointTime, int FOFEnabled)
Definition: hci.c:25
int hci_query(HCIManager *manager, HCIAction *action)
Definition: hci.c:152
void hci_action_init(HCIAction *action)
Definition: hci.c:38
@ HCI_TERMINATE
Definition: hci.h:26
@ HCI_TIMEOUT
Definition: hci.h:23
void hydro_force(const ActiveParticles *act, const double atime, struct sph_pred_data *SPH_predicted, double MinEgySpec, const DriftKickTimes times, Cosmology *CP, const ForceTree *const tree)
Definition: hydra.c:147
int DensityIndependentSphOn(void)
Definition: hydra.c:49
void lightcone_compute(double a, double BoxSize, Cosmology *CP, inttime_t ti_curr, inttime_t ti_next)
Definition: lightcone.c:177
void metal_return(const ActiveParticles *act, DomainDecomp *const ddecomp, Cosmology *CP, const double atime, const double AvgGasMass)
Definition: metal_return.c:517
#define mymalloc2(name, size)
Definition: mymalloc.h:16
#define report_memory_usage(x)
Definition: mymalloc.h:30
void update_random_offset(struct part_manager_type *PartManager, double *rel_random_shift, double RandomParticleOffset)
Definition: partmanager.c:43
static int use_pairwise_gravity(ActiveParticles *Act, struct part_manager_type *PartManager)
Definition: run.c:267
void cooling_and_starformation(ActiveParticles *act, double Time, double dloga, ForceTree *tree, const Cosmology *CP, MyFloat *GradRho, FILE *FdSfr)
Definition: sfr_eff.c:167
int sfr_need_to_compute_sph_grad_rho(void)
Definition: sfr_eff.c:952
int slots_gc(int *compact_slots, struct part_manager_type *pman, struct slots_manager_type *sman)
Definition: slotsmanager.c:145
void write_cpu_log(int NumCurrentTiStep, const double atime, FILE *FdCPU, double ElapsedTime)
Definition: stats.c:165
void close_outputfiles(struct OutputFD *fds)
Definition: stats.c:150
void energy_statistics(FILE *FdEnergy, const double Time, struct part_manager_type *PartManager)
Definition: stats.c:334
void open_outputfiles(int RestartSnapNum, struct OutputFD *fds, const char *OutputDir, int BlackHoleOn, int StarformationOn)
Definition: stats.c:73
int * ActiveParticle
Definition: timestep.h:13
int64_t NumActiveParticle
Definition: timestep.h:12
double ElapsedTime
Definition: walltime.h:54
double GravInternal
Definition: cosmology.h:32
double OmegaBaryon
Definition: cosmology.h:19
double Hubble
Definition: cosmology.h:21
Cosmology * CP
Definition: drift.h:17
inttime_t Ti_Current
Definition: timestep.h:27
int mintimebin
Definition: timestep.h:20
Definition: fof.h:62
Definition: hci.h:31
enum HCIActionType type
Definition: hci.h:32
int write_snapshot
Definition: hci.h:33
int write_fof
Definition: hci.h:34
Definition: hci.h:4
Definition: stats.h:8
Definition: petapm.h:62
int write_fof
Definition: timebinmgr.h:27
int write_snapshot
Definition: timebinmgr.h:26
double UnitLength_in_cm
Definition: unitsystem.h:10
int OutputDebugFields
Definition: run.c:48
double TimeLimitCPU
Definition: run.c:89
double RandomParticleOffset
Definition: run.c:50
int DensityOn
Definition: run.c:64
int TreeGravOn
Definition: run.c:65
int HydroOn
Definition: run.c:63
double TimeBetweenSeedingSearch
Definition: run.c:81
char FOFFileBase[100]
Definition: run.c:97
int MetalReturnOn
Definition: run.c:69
double AutoSnapshotTime
Definition: run.c:80
int MaxDomainTimeBinDepth
Definition: run.c:73
int64_t size
Definition: slotsmanager.h:12
struct slot_info info[6]
Definition: slotsmanager.h:112
#define MPIU_Barrier(comm)
Definition: system.h:103
SyncPoint * find_next_sync_point(inttime_t ti)
Definition: timebinmgr.c:174
double get_dloga_for_bin(int timebin, const inttime_t Ti_Current)
Definition: timebinmgr.c:279
SyncPoint * find_current_sync_point(inttime_t ti)
Definition: timebinmgr.c:188
void apply_PM_half_kick(Cosmology *CP, DriftKickTimes *times)
Definition: timestep.c:373
int is_PM_timestep(const DriftKickTimes *const times)
Definition: timestep.c:160
double get_atime(const inttime_t Ti_Current)
Definition: timestep.c:168
DriftKickTimes init_driftkicktime(inttime_t Ti_Current)
Definition: timestep.c:133
int find_timesteps(const ActiveParticles *act, DriftKickTimes *times, const double atime, int FastParticleType, const Cosmology *CP, const double asmth, const int isFirstTimeStep)
Definition: timestep.c:176
int rebuild_activelist(ActiveParticles *act, const DriftKickTimes *const times, int NumCurrentTiStep, const double Time)
Definition: timestep.c:721
int is_timebin_active(int i, inttime_t current)
Definition: timestep.c:149
void apply_half_kick(const ActiveParticles *act, Cosmology *CP, DriftKickTimes *times, const double atime, const double MinEgySpec)
Definition: timestep.c:323
inttime_t find_next_kick(inttime_t Ti_Current, int minTimeBin)
Definition: timestep.c:712
void update_lastactive_drift(DriftKickTimes *times)
Definition: timestep.c:309
void free_activelist(ActiveParticles *act)
Definition: timestep.c:795
LOW_PRECISION MyFloat
Definition: types.h:19
#define walltime_measure(name)
Definition: walltime.h:8

References ActiveParticles::ActiveParticle, All, apply_half_kick(), apply_PM_half_kick(), run_params::Asmth, run_params::AutoSnapshotTime, blackhole(), run_params::BlackHoleOn, part_manager_type::BoxSize, Clocks, close_outputfiles(), cooling_and_starformation(), run_params::CoolingOn, DriftData::CP, run_params::CP, density(), DensityIndependentSphOn(), run_params::DensityOn, do_heiii_reionization(), domain_decompose_full(), domain_maintain(), drift_all_particles(), dump_snapshot(), during_helium_reionization(), ClockTable::ElapsedTime, slot_info::enabled, endrun(), energy_statistics(), run_params::FastParticleType, OutputFD::FdBlackholeDetails, OutputFD::FdBlackHoles, OutputFD::FdCPU, OutputFD::FdEnergy, OutputFD::FdHelium, OutputFD::FdSfr, find_current_sync_point(), find_next_kick(), find_next_sync_point(), find_timesteps(), fof_finish(), fof_fof(), fof_save_groups(), fof_seed(), run_params::FOFFileBase, force_tree_free(), force_tree_rebuild(), force_update_hmax(), free_activelist(), get_atime(), get_dloga_for_bin(), get_gravshort_treepar(), get_MinEgySpec(), get_unitsystem(), grav_short_pair(), grav_short_tree(), Cosmology::GravInternal, gravpm_force(), gravpm_init_periodic(), hci_action_init(), hci_init(), hci_query(), HCI_TERMINATE, HCI_TIMEOUT, Cosmology::Hubble, hybrid_nu_tracer(), hydro_force(), run_params::HydroOn, slots_manager_type::info, init_driftkicktime(), is_PM_timestep(), is_timebin_active(), lightcone_compute(), run_params::LightconeOn, header_data::MassTable, run_params::MaxDomainTimeBinDepth, message(), metal_return(), run_params::MetalReturnOn, DriftKickTimes::mintimebin, MPIU_Barrier, myfree, mymalloc2, need_change_helium_ionization_fraction(), run_params::Nmesh, header_data::NTotalInit, ActiveParticles::NumActiveParticle, part_manager_type::NumPart, Cosmology::Omega0, Cosmology::OmegaBaryon, open_outputfiles(), run_params::OutputDebugFields, run_params::OutputDir, PartManager, run_params::RandomParticleOffset, run_params::RandomSeed, gravshort_tree_params::Rcut, rebuild_activelist(), report_memory_usage, set_random_numbers(), sfr_need_to_compute_sph_grad_rho(), slot_info::size, slots_allocate_sph_pred_data(), slots_free_sph_pred_data(), slots_gc(), SlotsManager, run_params::SnapshotWithFOF, run_params::StarformationOn, DriftData::ti0, DriftData::ti1, DriftKickTimes::Ti_Current, run_params::TimeBetweenSeedingSearch, header_data::TimeIC, run_params::TimeLimitCPU, header_data::TimeSnapshot, run_params::TreeGravOn, HCIAction::type, UnitSystem::UnitInternalEnergy_in_cgs, header_data::UnitLength_in_cm, UnitSystem::UnitLength_in_cm, header_data::UnitMass_in_g, header_data::UnitVelocity_in_cm_per_s, update_lastactive_drift(), update_random_offset(), use_pairwise_gravity(), walltime_measure, write_checkpoint(), write_cpu_log(), HCIAction::write_fof, SyncPoint::write_fof, HCIAction::write_snapshot, and SyncPoint::write_snapshot.

Referenced by main().

Here is the caller graph for this function:

◆ runfof()

void runfof ( const int  RestartSnapNum,
const inttime_t  Ti_Current,
const struct header_data header 
)

Definition at line 652 of file run.c.

653 {
654  PetaPM pm = {0};
656  DomainDecomp ddecomp[1] = {0};
657  /* ... read in initial model */
658 
659  domain_decompose_full(ddecomp); /* do initial domain decomposition (gives equal numbers of particles) */
660 
661  DriftKickTimes times = init_driftkicktime(Ti_Current);
662  /*FoF needs a tree*/
663  int HybridNuGrav = hybrid_nu_tracer(&All.CP, header->TimeSnapshot);
664  /* Regenerate the star formation rate for the FOF table.*/
665  if(All.StarformationOn) {
666  ActiveParticles Act = {0};
668  MyFloat * GradRho = NULL;
670  ForceTree gasTree = {0};
671  GradRho = (MyFloat *) mymalloc2("SPH_GradRho", sizeof(MyFloat) * 3 * SlotsManager->info[0].size);
672  /*Allocate the memory for predicted SPH data.*/
674  force_tree_rebuild(&gasTree, ddecomp, HybridNuGrav, 0, All.OutputDir);
675  /* computes GradRho with a treewalk. No hsml update as we are reading from a snapshot.*/
676  density(&Act, 0, 0, All.BlackHoleOn, get_MinEgySpec(), times, &All.CP, &sph_predicted, GradRho, &gasTree);
677  force_tree_free(&gasTree);
678  slots_free_sph_pred_data(&sph_predicted);
679  }
680  ForceTree Tree = {0};
681  cooling_and_starformation(&Act, header->TimeSnapshot, 0, &Tree, &All.CP, GradRho, NULL);
682  if(GradRho)
683  myfree(GradRho);
684  }
685  FOFGroups fof = fof_fof(ddecomp, 1, MPI_COMM_WORLD);
686  fof_save_groups(&fof, All.OutputDir, All.FOFFileBase, RestartSnapNum, &All.CP, header->TimeSnapshot, header->MassTable, All.MetalReturnOn, All.BlackHoleOn, MPI_COMM_WORLD);
687  fof_finish(&fof);
688 }

References All, run_params::Asmth, run_params::BlackHoleOn, part_manager_type::BoxSize, cooling_and_starformation(), run_params::CP, density(), domain_decompose_full(), fof_finish(), fof_fof(), fof_save_groups(), run_params::FOFFileBase, force_tree_free(), force_tree_rebuild(), get_MinEgySpec(), Cosmology::GravInternal, gravpm_init_periodic(), hybrid_nu_tracer(), slots_manager_type::info, init_driftkicktime(), header_data::MassTable, run_params::MetalReturnOn, myfree, mymalloc2, run_params::Nmesh, ActiveParticles::NumActiveParticle, part_manager_type::NumPart, run_params::OutputDir, PartManager, sfr_need_to_compute_sph_grad_rho(), slot_info::size, slots_allocate_sph_pred_data(), slots_free_sph_pred_data(), SlotsManager, run_params::StarformationOn, and header_data::TimeSnapshot.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ runpower()

void runpower ( const struct header_data header)

Definition at line 691 of file run.c.

692 {
693  PetaPM pm = {0};
695  DomainDecomp ddecomp[1] = {0};
696  /* ... read in initial model */
697  domain_decompose_full(ddecomp); /* do initial domain decomposition (gives equal numbers of particles) */
698 
699  /*PM needs a tree*/
700  ForceTree Tree = {0};
701  int HybridNuGrav = hybrid_nu_tracer(&All.CP, header->TimeSnapshot);
702  force_tree_rebuild(&Tree, ddecomp, HybridNuGrav, 1, All.OutputDir);
703  gravpm_force(&pm, &Tree, &All.CP, header->TimeSnapshot, header->UnitLength_in_cm, All.OutputDir, header->TimeSnapshot, All.FastParticleType);
704  force_tree_free(&Tree);
705 }

References All, run_params::Asmth, part_manager_type::BoxSize, run_params::CP, domain_decompose_full(), run_params::FastParticleType, force_tree_free(), force_tree_rebuild(), Cosmology::GravInternal, gravpm_force(), gravpm_init_periodic(), hybrid_nu_tracer(), run_params::Nmesh, run_params::OutputDir, PartManager, header_data::TimeSnapshot, and header_data::UnitLength_in_cm.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ runtests()

void runtests ( const int  RestartSnapNum,
const inttime_t  Ti_Current,
const struct header_data header 
)

Definition at line 646 of file run.c.

647 {
648  run_gravity_test(RestartSnapNum, &All.CP, All.Asmth, All.Nmesh, All.FastParticleType, Ti_Current, All.OutputDir, header);
649 }
void run_gravity_test(int RestartSnapNum, Cosmology *CP, const double Asmth, const int Nmesh, const int FastParticleType, const inttime_t Ti_Current, const char *OutputDir, const struct header_data *header)
Definition: runtests.c:71

References All, run_params::Asmth, run_params::CP, run_params::FastParticleType, run_params::Nmesh, run_params::OutputDir, and run_gravity_test().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_all_global_params()

void set_all_global_params ( ParameterSet ps)

Definition at line 106 of file run.c.

107 {
108  int ThisTask;
109  MPI_Comm_rank(MPI_COMM_WORLD, &ThisTask);
110  if(ThisTask == 0) {
111  /* Start reading the values */
112  param_get_string2(ps, "OutputDir", All.OutputDir, sizeof(All.OutputDir));
113  param_get_string2(ps, "FOFFileBase", All.FOFFileBase, sizeof(All.FOFFileBase));
114 
115  All.CP.CMBTemperature = param_get_double(ps, "CMBTemperature");
116  All.CP.RadiationOn = param_get_int(ps, "RadiationOn");
117  All.CP.Omega0 = param_get_double(ps, "Omega0");
118  All.CP.OmegaBaryon = param_get_double(ps, "OmegaBaryon");
119  All.CP.OmegaLambda = param_get_double(ps, "OmegaLambda");
120  All.CP.Omega_fld = param_get_double(ps, "Omega_fld");
121  if(All.CP.OmegaLambda > 0 && All.CP.Omega_fld > 0)
122  endrun(0, "Cannot have OmegaLambda and Omega_fld (evolving dark energy) at the same time!\n");
123  All.CP.w0_fld = param_get_double(ps,"w0_fld");
124  All.CP.wa_fld = param_get_double(ps,"wa_fld");
125  All.CP.Omega_ur = param_get_double(ps, "Omega_ur");
126  All.CP.HubbleParam = param_get_double(ps, "HubbleParam");
127 
128  All.OutputDebugFields = param_get_int(ps, "OutputDebugFields");
129 
130  All.TimeMax = param_get_double(ps, "TimeMax");
131  All.Asmth = param_get_double(ps, "Asmth");
132  All.ShortRangeForceWindowType = (enum ShortRangeForceWindowType) param_get_enum(ps, "ShortRangeForceWindowType");
133  All.Nmesh = param_get_int(ps, "Nmesh");
134 
135  All.CoolingOn = param_get_int(ps, "CoolingOn");
136  All.HydroOn = param_get_int(ps, "HydroOn");
137  All.DensityOn = param_get_int(ps, "DensityOn");
138  All.TreeGravOn = param_get_int(ps, "TreeGravOn");
139  All.LightconeOn = param_get_int(ps, "LightconeOn");
140  All.FastParticleType = param_get_int(ps, "FastParticleType");
141  All.PairwiseActiveFraction = param_get_double(ps, "PairwiseActiveFraction");
142  All.TimeLimitCPU = param_get_double(ps, "TimeLimitCPU");
143  All.AutoSnapshotTime = param_get_double(ps, "AutoSnapshotTime");
144  All.TimeBetweenSeedingSearch = param_get_double(ps, "TimeBetweenSeedingSearch");
145  All.RandomParticleOffset = param_get_double(ps, "RandomParticleOffset");
146  /* Convert to a fraction of the box, from a fraction of a PM mesh cell*/
148 
149  All.SlotsIncreaseFactor = param_get_double(ps, "SlotsIncreaseFactor");
150 
151  All.SnapshotWithFOF = param_get_int(ps, "SnapshotWithFOF");
152 
153  All.RandomSeed = param_get_int(ps, "RandomSeed");
154 
155  All.BlackHoleOn = param_get_int(ps, "BlackHoleOn");
156 
157  All.StarformationOn = param_get_int(ps, "StarformationOn");
158  All.MetalReturnOn = param_get_int(ps, "MetalReturnOn");
159  All.MaxDomainTimeBinDepth = param_get_int(ps, "MaxDomainTimeBinDepth");
160 
161  /*Massive neutrino parameters*/
162  All.CP.MassiveNuLinRespOn = param_get_int(ps, "MassiveNuLinRespOn");
163  All.CP.HybridNeutrinosOn = param_get_int(ps, "HybridNeutrinosOn");
164  All.CP.MNu[0] = param_get_double(ps, "MNue");
165  All.CP.MNu[1] = param_get_double(ps, "MNum");
166  All.CP.MNu[2] = param_get_double(ps, "MNut");
167  All.CP.HybridVcrit = param_get_double(ps, "Vcrit");
168  All.CP.HybridNuPartTime = param_get_double(ps, "NuPartTime");
170  endrun(2, "You have enabled (kspace) massive neutrinos without radiation, but this will give an inconsistent cosmology!\n");
171  /*End massive neutrino parameters*/
172 
173  if(All.StarformationOn != 0 && All.CoolingOn == 0)
174  {
175  endrun(1, "You try to use the code with star formation enabled,\n"
176  "but you did not switch on cooling.\nThis mode is not supported.\n");
177  }
178  }
179  MPI_Bcast(&All, sizeof(All), MPI_BYTE, 0, MPI_COMM_WORLD);
180 }
ShortRangeForceWindowType
Definition: gravity.h:23
double param_get_double(ParameterSet *ps, const char *name)
Definition: paramset.c:336
void param_get_string2(ParameterSet *ps, const char *name, char *dst, size_t len)
Definition: paramset.c:355
int param_get_int(ParameterSet *ps, const char *name)
Definition: paramset.c:368
int param_get_enum(ParameterSet *ps, const char *name)
Definition: paramset.c:378
double wa_fld
Definition: cosmology.h:17
double Omega_ur
Definition: cosmology.h:18
int HybridNeutrinosOn
Definition: cosmology.h:28
double Omega_fld
Definition: cosmology.h:15
int RadiationOn
Definition: cosmology.h:23
double HubbleParam
Definition: cosmology.h:20
double HybridVcrit
Definition: cosmology.h:29
double CMBTemperature
Definition: cosmology.h:9
double OmegaLambda
Definition: cosmology.h:14
double HybridNuPartTime
Definition: cosmology.h:31
double MNu[3]
Definition: cosmology.h:25
double w0_fld
Definition: cosmology.h:16
double PairwiseActiveFraction
Definition: run.c:77
int ThisTask
Definition: test_exchange.c:23

References All, run_params::Asmth, run_params::AutoSnapshotTime, run_params::BlackHoleOn, Cosmology::CMBTemperature, run_params::CoolingOn, run_params::CP, run_params::DensityOn, endrun(), run_params::FastParticleType, run_params::FOFFileBase, Cosmology::HubbleParam, Cosmology::HybridNeutrinosOn, Cosmology::HybridNuPartTime, Cosmology::HybridVcrit, run_params::HydroOn, run_params::LightconeOn, Cosmology::MassiveNuLinRespOn, run_params::MaxDomainTimeBinDepth, run_params::MetalReturnOn, Cosmology::MNu, run_params::Nmesh, Cosmology::Omega0, Cosmology::Omega_fld, Cosmology::Omega_ur, Cosmology::OmegaBaryon, Cosmology::OmegaLambda, run_params::OutputDebugFields, run_params::OutputDir, run_params::PairwiseActiveFraction, param_get_double(), param_get_enum(), param_get_int(), param_get_string2(), Cosmology::RadiationOn, run_params::RandomParticleOffset, run_params::RandomSeed, run_params::ShortRangeForceWindowType, run_params::SlotsIncreaseFactor, run_params::SnapshotWithFOF, run_params::StarformationOn, ThisTask, run_params::TimeBetweenSeedingSearch, run_params::TimeLimitCPU, run_params::TimeMax, run_params::TreeGravOn, Cosmology::w0_fld, and Cosmology::wa_fld.

Referenced by read_parameter_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ use_pairwise_gravity()

static int use_pairwise_gravity ( ActiveParticles Act,
struct part_manager_type PartManager 
)
static

Definition at line 267 of file run.c.

268 {
269  /* Find total number of active particles*/
270  int64_t total_active, total_particle;
271  MPI_Allreduce(&Act->NumActiveParticle, &total_active, 1, MPI_INT64, MPI_SUM, MPI_COMM_WORLD);
272  MPI_Allreduce(&PartManager->NumPart, &total_particle, 1, MPI_INT64, MPI_SUM, MPI_COMM_WORLD);
273 
274  /* Since the pairwise step is O(N^2) and tree is O(NlogN) we should scale the condition like O(N)*/
275  return total_active < All.PairwiseActiveFraction * total_particle;
276 }
#define MPI_INT64
Definition: system.h:12

References All, MPI_INT64, ActiveParticles::NumActiveParticle, part_manager_type::NumPart, run_params::PairwiseActiveFraction, and PartManager.

Referenced by run().

Here is the caller graph for this function:

Variable Documentation

◆ All

struct run_params All
static

◆ Clocks

struct ClockTable Clocks
static

Definition at line 1 of file run.c.

Referenced by begrun(), main(), and run().