00001
00016 #ifndef ALLVARS_H
00017 #define ALLVARS_H
00018
00019 #include <stdio.h>
00020 #include <gsl/gsl_rng.h>
00021 #include "tags.h"
00022
00023 #define GADGETVERSION "2.0"
00025 #define TIMEBASE (1<<28)
00029 #define MAXTOPNODES 200000
00032 typedef long long peanokey;
00034 #define BITS_PER_DIMENSION 18
00038 #define PEANOCELLS (((peanokey)1)<<(3*BITS_PER_DIMENSION))
00041 #define RNDTABLE 256
00044 #define MAX_REAL_NUMBER 1e37
00045 #define MIN_REAL_NUMBER 1e-37
00046
00047 #define MAXLEN_FILENAME 100
00049 #ifdef ISOTHERM_EQS
00050 #define GAMMA (1.0)
00051 #else
00052 #define GAMMA (5.0/3)
00053 #endif
00054
00055 #define GAMMA_MINUS1 (GAMMA-1)
00056
00057 #define HYDROGEN_MASSFRAC 0.76
00059
00060
00061 #define GRAVITY 6.672e-8
00062 #define SOLAR_MASS 1.989e33
00063 #define SOLAR_LUM 3.826e33
00064 #define RAD_CONST 7.565e-15
00065 #define AVOGADRO 6.0222e23
00066 #define BOLTZMANN 1.3806e-16
00067 #define GAS_CONST 8.31425e7
00068 #define C 2.9979e10
00069 #define PLANCK 6.6262e-27
00070 #define CM_PER_MPC 3.085678e24
00071 #define PROTONMASS 1.6726e-24
00072 #define ELECTRONMASS 9.10953e-28
00073 #define THOMPSON 6.65245e-25
00074 #define ELECTRONCHARGE 4.8032e-10
00075 #define HUBBLE 3.2407789e-18
00076
00077
00078
00079 #define SEC_PER_MEGAYEAR 3.155e13
00080 #define SEC_PER_YEAR 3.155e7
00081
00082 #ifndef ASMTH
00083 #define ASMTH 1.25
00084 #endif
00085
00086 #ifndef RCUT
00087 #define RCUT 4.5
00089 #endif
00090
00091 #define MAX_NGB 20000
00093 #define MAXLEN_OUTPUTLIST 500
00095 #define DRIFT_TABLE_LENGTH 1000
00097 #define MAXITER 150
00100 #ifdef DOUBLEPRECISION
00101 #define FLOAT double
00102 #else
00103 #define FLOAT float
00104 #endif
00105
00106
00107 #ifndef TWODIMS
00108 #define NUMDIMS 3
00109 #define KERNEL_COEFF_1 2.546479089470
00110 #define KERNEL_COEFF_2 15.278874536822
00111 #define KERNEL_COEFF_3 45.836623610466
00112 #define KERNEL_COEFF_4 30.557749073644
00113 #define KERNEL_COEFF_5 5.092958178941
00114 #define KERNEL_COEFF_6 (-15.278874536822)
00115 #define NORM_COEFF 4.188790204786
00116 #else
00117 #define NUMDIMS 2
00118 #define KERNEL_COEFF_1 (5.0/7*2.546479089470)
00119 #define KERNEL_COEFF_2 (5.0/7*15.278874536822)
00120 #define KERNEL_COEFF_3 (5.0/7*45.836623610466)
00121 #define KERNEL_COEFF_4 (5.0/7*30.557749073644)
00122 #define KERNEL_COEFF_5 (5.0/7*5.092958178941)
00123 #define KERNEL_COEFF_6 (5.0/7*(-15.278874536822))
00124 #define NORM_COEFF M_PI
00125 #endif
00126
00127
00128
00129 extern int ThisTask;
00130 extern int NTask;
00131 extern int PTask;
00133 extern int NumPart;
00134 extern int N_gas;
00135 extern long long Ntype[6];
00136 extern int NtypeLocal[6];
00138 extern int NumForceUpdate;
00139 extern int NumSphUpdate;
00141 extern double CPUThisRun;
00144 extern int RestartFlag;
00148 extern char *Exportflag;
00150 extern int *Ngblist;
00152 extern int TreeReconstructFlag;
00154 extern int Flag_FullStep;
00157 extern gsl_rng *random_generator;
00159 extern double RndTable[RNDTABLE];
00162 extern double DomainCorner[3];
00163 extern double DomainCenter[3];
00164 extern double DomainLen;
00165 extern double DomainFac;
00166 extern int DomainMyStart;
00167 extern int DomainMyLast;
00168 extern int *DomainStartList;
00169 extern int *DomainEndList;
00170 extern double *DomainWork;
00171 extern int *DomainCount;
00172 extern int *DomainCountSph;
00174 extern int *DomainTask;
00175 extern int *DomainNodeIndex;
00176 extern FLOAT *DomainTreeNodeLen;
00177 extern FLOAT *DomainHmax;
00179 extern struct DomainNODE
00180 {
00181 FLOAT s[3];
00182 FLOAT vs[3];
00183 FLOAT mass;
00184 #ifdef UNEQUALSOFTENINGS
00185 int bitflags;
00186 #endif
00187 }
00188 *DomainMoment;
00190 extern peanokey *DomainKeyBuf;
00192 extern peanokey *Key;
00193 extern peanokey *KeySorted;
00196 extern int NTopnodes;
00197 extern int NTopleaves;
00199 extern struct topnode_data
00200 {
00201 int Daughter;
00202 int Pstart;
00203 int Blocks;
00204 int Leaf;
00205 peanokey Size;
00206 peanokey StartKey;
00207 long long Count;
00208 }
00209 *TopNodes;
00212 extern double TimeOfLastTreeConstruction;
00216
00217
00218 extern char ParameterFile[MAXLEN_FILENAME];
00220 extern FILE *FdInfo;
00221 extern FILE *FdEnergy;
00222 extern FILE *FdTimings;
00223 extern FILE *FdCPU;
00225 #ifdef FORCETEST
00226 extern FILE *FdForceTest;
00227 #endif
00228
00229
00230 extern double DriftTable[DRIFT_TABLE_LENGTH];
00231 extern double GravKickTable[DRIFT_TABLE_LENGTH];
00232 extern double HydroKickTable[DRIFT_TABLE_LENGTH];
00234 extern void *CommBuffer;
00244 extern struct global_data_all_processes
00245 {
00246 long long TotNumPart;
00247 long long TotN_gas;
00249 int MaxPart;
00250 int MaxPartSph;
00252 double BoxSize;
00254 int ICFormat;
00256 int SnapFormat;
00258 int NumFilesPerSnapshot;
00259 int NumFilesWrittenInParallel;
00262 int BufferSize;
00263 int BunchSizeForce;
00264 int BunchSizeDensity;
00265 int BunchSizeHydro;
00266 int BunchSizeDomain;
00268 double PartAllocFactor;
00272 double TreeAllocFactor;
00276
00277
00278 double DesNumNgb;
00279 double MaxNumNgbDeviation;
00281 double ArtBulkViscConst;
00282 double InitGasTemp;
00283 double MinGasTemp;
00284 double MinEgySpec;
00287
00288
00289 long long TotNumOfForces;
00290 long long NumForcesSinceLastDomainDecomp;
00293
00294
00295 double G;
00296 double UnitTime_in_s;
00297 double UnitMass_in_g;
00298 double UnitVelocity_in_cm_per_s;
00299 double UnitLength_in_cm;
00300 double UnitPressure_in_cgs;
00301 double UnitDensity_in_cgs;
00302 double UnitCoolingRate_in_cgs;
00303 double UnitEnergy_in_cgs;
00304 double UnitTime_in_Megayears;
00305 double GravityConstantInternal;
00310
00311
00312 double Hubble;
00313 double Omega0;
00314 double OmegaLambda;
00315 double OmegaBaryon;
00316 double HubbleParam;
00319
00320
00321 int ComovingIntegrationOn;
00322 int PeriodicBoundariesOn;
00323 int ResubmitOn;
00324 int TypeOfOpeningCriterion;
00325 int TypeOfTimestepCriterion;
00326 int OutputListOn;
00329
00330
00331 int SnapshotFileCount;
00332 double TimeBetSnapshot;
00333 double TimeOfFirstSnapshot;
00334 double CpuTimeBetRestartFile;
00335 double TimeLastRestartFile;
00336 double TimeBetStatistics;
00337 double TimeLastStatistics;
00338 int NumCurrentTiStep;
00341
00342
00343 double Time;
00344 double TimeBegin;
00345 double TimeStep;
00346 double TimeMax;
00349
00350
00351 double Timebase_interval;
00352 int Ti_Current;
00353 int Ti_nextoutput;
00354 #ifdef FLEXSTEPS
00355 int PresentMinStep;
00356 #endif
00357 #ifdef PMGRID
00358 int PM_Ti_endstep;
00359 int PM_Ti_begstep;
00360 #endif
00361
00362
00363
00364
00365 #ifdef PMGRID
00366 double Asmth[2];
00367 double Rcut[2];
00368 double Corner[2][3];
00369 double UpperCorner[2][3];
00370 double Xmintot[2][3];
00371 double Xmaxtot[2][3];
00372 double TotalMeshSize[2];
00373 #endif
00374
00375
00376
00377
00378 double TimeLimitCPU;
00379 double CPU_TreeConstruction;
00380 double CPU_TreeWalk;
00381 double CPU_Gravity;
00382 double CPU_Potential;
00383 double CPU_Domain;
00384 double CPU_Snapshot;
00385 double CPU_Total;
00386 double CPU_CommSum;
00387 double CPU_Imbalance;
00388 double CPU_HydCompWalk;
00389 double CPU_HydCommSumm;
00390 double CPU_HydImbalance;
00391 double CPU_Hydro;
00392 double CPU_EnsureNgb;
00393 double CPU_Predict;
00394 double CPU_TimeLine;
00395 double CPU_PM;
00396 double CPU_Peano;
00398
00399
00400 double ErrTolTheta;
00401 double ErrTolForceAcc;
00404
00405
00406 double ErrTolIntAccuracy;
00409 double MinSizeTimestep;
00411 double MaxSizeTimestep;
00413 double MaxRMSDisplacementFac;
00420 double CourantFac;
00423
00424
00425 double TreeDomainUpdateFrequency;
00428
00429
00430
00431
00432 double MinGasHsmlFractional;
00433 double MinGasHsml;
00436 double SofteningGas;
00437 double SofteningHalo;
00438 double SofteningDisk;
00439 double SofteningBulge;
00440 double SofteningStars;
00441 double SofteningBndry;
00443 double SofteningGasMaxPhys;
00444 double SofteningHaloMaxPhys;
00445 double SofteningDiskMaxPhys;
00446 double SofteningBulgeMaxPhys;
00447 double SofteningStarsMaxPhys;
00448 double SofteningBndryMaxPhys;
00450 double SofteningTable[6];
00451 double ForceSoftening[6];
00454 double MassTable[6];
00460
00461
00462 char InitCondFile[MAXLEN_FILENAME];
00463 char OutputDir[MAXLEN_FILENAME];
00464 char SnapshotFileBase[MAXLEN_FILENAME];
00465 char EnergyFile[MAXLEN_FILENAME];
00466 char CpuFile[MAXLEN_FILENAME];
00467 char InfoFile[MAXLEN_FILENAME];
00468 char TimingsFile[MAXLEN_FILENAME];
00469 char RestartFile[MAXLEN_FILENAME];
00470 char ResubmitCommand[MAXLEN_FILENAME];
00471 char OutputListFilename[MAXLEN_FILENAME];
00473 double OutputListTimes[MAXLEN_OUTPUTLIST];
00474 int OutputListLength;
00476 }
00477 All;
00484 extern struct particle_data
00485 {
00486 FLOAT Pos[3];
00487 FLOAT Mass;
00488 FLOAT Vel[3];
00489 FLOAT GravAccel[3];
00490 #ifdef PMGRID
00491 FLOAT GravPM[3];
00492 #endif
00493 #ifdef FORCETEST
00494 FLOAT GravAccelDirect[3];
00495 #endif
00496 FLOAT Potential;
00497 FLOAT OldAcc;
00498 #ifndef LONGIDS
00499 unsigned int ID;
00500 #else
00501 unsigned long long ID;
00502 #endif
00503
00504 int Type;
00505 int Ti_endstep;
00506 int Ti_begstep;
00507 float GravCost;
00508 #ifdef PSEUDOSYMMETRIC
00509 float AphysOld;
00513 #endif
00514 }
00515 *P,
00516 *DomainPartBuf;
00519
00520
00521
00522 extern struct sph_particle_data
00523 {
00524 FLOAT Entropy;
00525 FLOAT Density;
00526 FLOAT Hsml;
00527 FLOAT Left;
00528 FLOAT Right;
00529 FLOAT NumNgb;
00530 FLOAT Pressure;
00531 FLOAT DtEntropy;
00532 FLOAT HydroAccel[3];
00533 FLOAT VelPred[3];
00534 FLOAT DivVel;
00535 FLOAT CurlVel;
00536 FLOAT Rot[3];
00537 FLOAT DhsmlDensityFactor;
00538 FLOAT MaxSignalVel;
00539 }
00540 *SphP,
00541 *DomainSphBuf;
00547
00548
00549
00550 extern int MaxNodes;
00551 extern int Numnodestree;
00553 extern struct NODE
00554 {
00555 FLOAT len;
00556 FLOAT center[3];
00557 #ifdef ADAPTIVE_GRAVSOFT_FORGAS
00558 FLOAT maxsoft;
00560 #endif
00561 union
00562 {
00563 int suns[8];
00564 struct
00565 {
00566 FLOAT s[3];
00567 FLOAT mass;
00568 int bitflags;
00569 int sibling;
00570 int nextnode;
00571 int father;
00572 }
00573 d;
00574 }
00575 u;
00576 }
00577 *Nodes_base,
00578 *Nodes;
00582 extern int *Nextnode;
00583 extern int *Father;
00586 extern struct extNODE
00587 {
00588 FLOAT hmax;
00589 FLOAT vs[3];
00590 }
00591 *Extnodes_base,
00592 *Extnodes;
00600 extern struct io_header
00601 {
00602 int npart[6];
00603 double mass[6];
00605 double time;
00606 double redshift;
00607 int flag_sfr;
00608 int flag_feedback;
00609 unsigned int npartTotal[6];
00611 int flag_cooling;
00612 int num_files;
00613 double BoxSize;
00614 double Omega0;
00615 double OmegaLambda;
00616 double HubbleParam;
00617 int flag_stellarage;
00618 int flag_metals;
00619 unsigned int npartTotalHighWord[6];
00620 int flag_entropy_instead_u;
00621 char fill[60];
00622 }
00623 header;
00626 #define IO_NBLOCKS 11
00629 enum iofields
00630 {
00631 IO_POS,
00632 IO_VEL,
00633 IO_ID,
00634 IO_MASS,
00635 IO_U,
00636 IO_RHO,
00637 IO_HSML,
00638 IO_POT,
00639 IO_ACCEL,
00640 IO_DTENTR,
00641 IO_TSTP,
00642 };
00643
00644
00645 extern char Tab_IO_Labels[IO_NBLOCKS][4];
00646
00647
00648
00649
00650 extern struct state_of_system
00651 {
00652 double Mass;
00653 double EnergyKin;
00654 double EnergyPot;
00655 double EnergyInt;
00656 double EnergyTot;
00657 double Momentum[4];
00658 double AngMomentum[4];
00659 double CenterOfMass[4];
00660 double MassComp[6];
00661 double EnergyKinComp[6];
00662 double EnergyPotComp[6];
00663 double EnergyIntComp[6];
00664 double EnergyTotComp[6];
00665 double MomentumComp[6][4];
00666 double AngMomentumComp[6][4];
00667 double CenterOfMassComp[6][4];
00668 }
00669 SysState;
00670
00671
00672
00673
00674
00675 extern struct gravdata_in
00676 {
00677 union
00678 {
00679 FLOAT Pos[3];
00680 FLOAT Acc[3];
00681 FLOAT Potential;
00682 }
00683 u;
00684 #ifdef UNEQUALSOFTENINGS
00685 int Type;
00686 #ifdef ADAPTIVE_GRAVSOFT_FORGAS
00687 FLOAT Soft;
00688 #endif
00689 #endif
00690 union
00691 {
00692 FLOAT OldAcc;
00693 int Ninteractions;
00694 }
00695 w;
00696 }
00697 *GravDataIn,
00698 *GravDataGet,
00699 *GravDataResult,
00700 *GravDataOut;
00702 extern struct gravdata_index
00703 {
00704 int Task;
00705 int Index;
00706 int SortIndex;
00707 }
00708 *GravDataIndexTable;
00712 extern struct densdata_in
00713 {
00714 FLOAT Pos[3];
00715 FLOAT Vel[3];
00716 FLOAT Hsml;
00717 int Index;
00718 int Task;
00719 }
00720 *DensDataIn,
00721 *DensDataGet;
00723 extern struct densdata_out
00724 {
00725 FLOAT Rho;
00726 FLOAT Div, Rot[3];
00727 FLOAT DhsmlDensity;
00728 FLOAT Ngb;
00729 }
00730 *DensDataResult,
00731 *DensDataPartialResult;
00735 extern struct hydrodata_in
00736 {
00737 FLOAT Pos[3];
00738 FLOAT Vel[3];
00739 FLOAT Hsml;
00740 FLOAT Mass;
00741 FLOAT Density;
00742 FLOAT Pressure;
00743 FLOAT F1;
00744 FLOAT DhsmlDensityFactor;
00745 int Timestep;
00746 int Task;
00747 int Index;
00748 }
00749 *HydroDataIn,
00750 *HydroDataGet;
00752 extern struct hydrodata_out
00753 {
00754 FLOAT Acc[3];
00755 FLOAT DtEntropy;
00756 FLOAT MaxSignalVel;
00757 }
00758 *HydroDataResult,
00759 *HydroDataPartialResult;
00762 #endif
00763