diff --git a/doc/wiki/Runtime-Parameters-related/Runtime-Parameters:-All.md b/doc/wiki/Runtime-Parameters-related/Runtime-Parameters:-All.md index 0288725ab3..9129bf3665 100644 --- a/doc/wiki/Runtime-Parameters-related/Runtime-Parameters:-All.md +++ b/doc/wiki/Runtime-Parameters-related/Runtime-Parameters:-All.md @@ -307,6 +307,7 @@ For variables with `Default/Min/Max` labeled as `Depend`, click the parameter na | [[ OPT__OUTPUT_USER_FIELD \| Runtime-Parameters:-Outputs#OPT__OUTPUT_USER_FIELD ]] | 0 | None | None | output user-defined derived fields [0] -> edit "Flu_DerivedField_User.cpp" | | OPT__OVERLAP_MPI | 0 | None | None | overlap MPI communication with CPU/GPU computations [0] ##NOT SUPPORTED YET## | | [[ OPT__PARTICLE_COUNT \| Runtime-Parameters:-Refinement#OPT__PARTICLE_COUNT ]] | 1 | 0 | 2 | record the # of particles at each level: (0=off, 1=every step, 2=every sub-step) [1] | +| [[ OPT__PAR_INIT_CHECK \| Runtime-Parameters:-Particles#OPT__PAR_INIT_CHECK ]] | 1 | None | None | check particle initialization (only works for PAR_INIT != 2) [1] | | [[ OPT__PATCH_COUNT \| Runtime-Parameters:-Refinement#OPT__PATCH_COUNT ]] | 1 | 0 | 2 | record the # of patches at each level: (0=off, 1=every step, 2=every sub-step) [1] | | [[ OPT__POT_INT_SCHEME \| Runtime-Parameters:-Interpolation#OPT__POT_INT_SCHEME ]] | INT_CQUAD | 4 | 5 | ghost-zone potential for the Poisson solver (only supports 4 & 5) [4] | | [[ OPT__RECORD_CENTER \| Runtime-Parameters:-Miscellaneous#OPT__RECORD_CENTER ]] | 0 | None | None | record the position of maximum density, minimum potential, and center of mass [0] | diff --git a/doc/wiki/Runtime-Parameters-related/Runtime-Parameters:-Particles.md b/doc/wiki/Runtime-Parameters-related/Runtime-Parameters:-Particles.md index ed6a212ba0..87947a1e17 100644 --- a/doc/wiki/Runtime-Parameters-related/Runtime-Parameters:-Particles.md +++ b/doc/wiki/Runtime-Parameters-related/Runtime-Parameters:-Particles.md @@ -13,7 +13,8 @@ Parameters described on this page: [PAR_IMPROVE_ACC](#PAR_IMPROVE_ACC),   [PAR_PREDICT_POS](#PAR_PREDICT_POS),   [PAR_REMOVE_CELL](#PAR_REMOVE_CELL),   -[OPT__FREEZE_PAR](#OPT__FREEZE_PAR)   +[OPT__FREEZE_PAR](#OPT__FREEZE_PAR),   +[OPT__PAR_INIT_CHECK](#OPT__PAR_INIT_CHECK)   Parameters below are shown in the format:   **`Name`   (Valid Values)   [Default Value]** @@ -150,6 +151,13 @@ Do not update particle position and velocity (except for tracer particles). It can be useful for evolving fluid in a static gravitational potential of particles. * **Restriction:** + +* #### `OPT__PAR_INIT_CHECK`   (0=off, 1=on)   [1] + * **Description:** +Check particle initialization by calling `Par_Aux_InitCheck()` function after particle initialization (only works for [PAR_INIT](#PAR_INIT)!=`2`). +Disable this check when particles are initialized _after_ setting grid fields, such as by `Init_User_Ptr()`. + * **Restriction:** + ## Remarks diff --git a/example/test_problem/Template/Input__Parameter b/example/test_problem/Template/Input__Parameter index ad73dfe255..d7742ab30f 100644 --- a/example/test_problem/Template/Input__Parameter +++ b/example/test_problem/Template/Input__Parameter @@ -99,6 +99,7 @@ PAR_PREDICT_POS 1 # predict particle position during mas PAR_REMOVE_CELL -1.0 # remove particles X-root-cells from the boundaries (non-periodic BC only; <0=auto) [-1.0] OPT__FREEZE_PAR 0 # do not update particles (except for tracers) [0] PAR_TR_VEL_CORR 0 # correct tracer particle velocities in regions of discontinuous flow [0] +OPT__PAR_INIT_CHECK 1 # check particle initialization (only works for PAR_INIT != 2) [1] # cosmology (COMOVING only) A_INIT 0.01 # initial scale factor diff --git a/include/Global.h b/include/Global.h index e61e8da28e..ac1d5eb66e 100644 --- a/include/Global.h +++ b/include/Global.h @@ -240,7 +240,7 @@ extern bool FFTW3_Double_OMP_Enabled, FFTW3_Single_OMP_Enabled; // ============================================================================================================ #ifdef PARTICLE extern double DT__PARVEL, DT__PARVEL_MAX, DT__PARACC; -extern bool OPT__CK_PARTICLE, OPT__FLAG_NPAR_CELL, OPT__FLAG_PAR_MASS_CELL, OPT__FREEZE_PAR, OPT__OUTPUT_PAR_MESH; +extern bool OPT__CK_PARTICLE, OPT__FLAG_NPAR_CELL, OPT__FLAG_PAR_MASS_CELL, OPT__FREEZE_PAR, OPT__OUTPUT_PAR_MESH, OPT__PAR_INIT_CHECK; extern int OPT__OUTPUT_PAR_MODE, OPT__PARTICLE_COUNT, OPT__FLAG_NPAR_PATCH, FlagTable_NParPatch[NLEVEL-1], FlagTable_NParCell[NLEVEL-1]; extern double FlagTable_ParMassCell[NLEVEL-1]; extern ParOutputDens_t OPT__OUTPUT_PAR_DENS; diff --git a/include/HDF5_Typedef.h b/include/HDF5_Typedef.h index f6169399b3..8b60e10636 100644 --- a/include/HDF5_Typedef.h +++ b/include/HDF5_Typedef.h @@ -443,6 +443,7 @@ struct InputPara_t int Par_GhostSize; int Par_GhostSizeTracer; int Par_TracerVelCorr; + int Opt__ParInitCheck; char *ParAttFltLabel[PAR_NATT_FLT_TOTAL]; char *ParAttIntLabel[PAR_NATT_INT_TOTAL]; # endif diff --git a/src/Auxiliary/Aux_TakeNote.cpp b/src/Auxiliary/Aux_TakeNote.cpp index 1b3a165c3a..9a2bf84886 100644 --- a/src/Auxiliary/Aux_TakeNote.cpp +++ b/src/Auxiliary/Aux_TakeNote.cpp @@ -1445,6 +1445,9 @@ void Aux_TakeNote() default: fprintf( Note, "UNKNOWN\n" ); } // switch ( OPT__FFTW_STARTUP ) # endif // # ifdef SUPPORT_FFTW +# ifdef PARTICLE + fprintf( Note, "OPT__PAR_INIT_CHECK % d\n", OPT__PAR_INIT_CHECK ); +# endif // refinement region for OPT__UM_IC_NLEVEL>1 if ( OPT__INIT == INIT_BY_FILE && OPT__UM_IC_NLEVEL > 1 ) { diff --git a/src/Init/Init_ByRestart_HDF5.cpp b/src/Init/Init_ByRestart_HDF5.cpp index 88c3af4c93..f3e5efa4e5 100644 --- a/src/Init/Init_ByRestart_HDF5.cpp +++ b/src/Init/Init_ByRestart_HDF5.cpp @@ -1981,6 +1981,7 @@ void Check_InputPara( const char *FileName, const int FormatVersion ) LoadField( "Par_GhostSize", &RS.Par_GhostSize, SID, TID, NonFatal, &RT.Par_GhostSize, 1, NonFatal ); LoadField( "Par_GhostSizeTracer", &RS.Par_GhostSizeTracer, SID, TID, NonFatal, &RT.Par_GhostSizeTracer, 1, NonFatal ); LoadField( "Par_TracerVelCorr", &RS.Par_TracerVelCorr, SID, TID, NonFatal, &RT.Par_TracerVelCorr, 1, NonFatal ); + LoadField( "Opt__ParInitCheck", &RS.Opt__ParInitCheck, SID, TID, NonFatal, &RT.Opt__ParInitCheck, 1, NonFatal ); # endif // cosmology diff --git a/src/Init/Init_GAMER.cpp b/src/Init/Init_GAMER.cpp index fc0bfa840a..d6d48c9313 100644 --- a/src/Init/Init_GAMER.cpp +++ b/src/Init/Init_GAMER.cpp @@ -220,7 +220,7 @@ void Init_GAMER( int *argc, char ***argv ) "PAR_INIT", (int)amr->Par->Init ); } - if ( amr->Par->Init != PAR_INIT_BY_RESTART ) Par_Aux_InitCheck(); + if ( amr->Par->Init != PAR_INIT_BY_RESTART && OPT__PAR_INIT_CHECK ) Par_Aux_InitCheck(); # endif // #ifdef PARTICLE diff --git a/src/Init/Init_Load_Parameter.cpp b/src/Init/Init_Load_Parameter.cpp index b19f86e3d4..7149d02b3a 100644 --- a/src/Init/Init_Load_Parameter.cpp +++ b/src/Init/Init_Load_Parameter.cpp @@ -90,6 +90,7 @@ void Init_Load_Parameter() ReadPara->Add( "PAR_REMOVE_CELL", &amr->Par->RemoveCell, -1.0, NoMin_double, NoMax_double ); ReadPara->Add( "OPT__FREEZE_PAR", &OPT__FREEZE_PAR, false, Useless_bool, Useless_bool ); ReadPara->Add( "PAR_TR_VEL_CORR", &amr->Par->TracerVelCorr, false, Useless_bool, Useless_bool ); + ReadPara->Add( "OPT__PAR_INIT_CHECK", &OPT__PAR_INIT_CHECK, true, Useless_bool, Useless_bool ); # endif // #ifdef PARTICLE diff --git a/src/Main/Main.cpp b/src/Main/Main.cpp index 703305e807..a495c688a5 100644 --- a/src/Main/Main.cpp +++ b/src/Main/Main.cpp @@ -228,7 +228,7 @@ bool FFTW3_Double_OMP_Enabled, FFTW3_Single_OMP_Enabled; // (2-5) particle #ifdef PARTICLE double DT__PARVEL, DT__PARVEL_MAX, DT__PARACC; -bool OPT__CK_PARTICLE, OPT__FLAG_NPAR_CELL, OPT__FLAG_PAR_MASS_CELL, OPT__FREEZE_PAR, OPT__OUTPUT_PAR_MESH; +bool OPT__CK_PARTICLE, OPT__FLAG_NPAR_CELL, OPT__FLAG_PAR_MASS_CELL, OPT__FREEZE_PAR, OPT__OUTPUT_PAR_MESH, OPT__PAR_INIT_CHECK; int OPT__OUTPUT_PAR_MODE, OPT__PARTICLE_COUNT, OPT__FLAG_NPAR_PATCH, PAR_IC_FLOAT8, PAR_IC_INT8, FlagTable_NParPatch[NLEVEL-1], FlagTable_NParCell[NLEVEL-1]; double FlagTable_ParMassCell[NLEVEL-1]; ParOutputDens_t OPT__OUTPUT_PAR_DENS; diff --git a/src/Output/Output_DumpData_Total_HDF5.cpp b/src/Output/Output_DumpData_Total_HDF5.cpp index 02d993c150..8e7a9f1430 100644 --- a/src/Output/Output_DumpData_Total_HDF5.cpp +++ b/src/Output/Output_DumpData_Total_HDF5.cpp @@ -79,7 +79,7 @@ Procedure for outputting new variables: //------------------------------------------------------------------------------------------------------- -// Function : Output_DumpData_Total_HDF5 (FormatVersion = 2503) +// Function : Output_DumpData_Total_HDF5 (FormatVersion = 2504) // Description : Output all simulation data in the HDF5 format, which can be used as a restart file // or loaded by YT // @@ -277,6 +277,7 @@ Procedure for outputting new variables: // 2502 : 2025/01/16 --> output ConRef[] // 2503 : 2025/01/17 --> output user-defined parameters in "User/UserPara" and // Input__TestProb parameters in "Info/InputTest" +// 2504 : 2025/04/29 --> output OPT__PAR_INIT_CHECK //------------------------------------------------------------------------------------------------------- void Output_DumpData_Total_HDF5( const char *FileName ) { @@ -1665,7 +1666,7 @@ void FillIn_KeyInfo( KeyInfo_t &KeyInfo, const int NFieldStored ) const time_t CalTime = time( NULL ); // calendar time - KeyInfo.FormatVersion = 2503; + KeyInfo.FormatVersion = 2504; KeyInfo.Model = MODEL; KeyInfo.NLevel = NLEVEL; KeyInfo.NCompFluid = NCOMP_FLUID; @@ -2410,11 +2411,12 @@ void FillIn_InputPara( InputPara_t &InputPara, const int NFieldStored, char Fiel InputPara.Par_IntegTracer = amr->Par->IntegTracer; InputPara.Par_ImproveAcc = amr->Par->ImproveAcc; InputPara.Par_PredictPos = amr->Par->PredictPos; - InputPara.Par_TracerVelCorr = amr->Par->TracerVelCorr; InputPara.Par_RemoveCell = amr->Par->RemoveCell; InputPara.Opt__FreezePar = OPT__FREEZE_PAR; InputPara.Par_GhostSize = amr->Par->GhostSize; InputPara.Par_GhostSizeTracer = amr->Par->GhostSizeTracer; + InputPara.Par_TracerVelCorr = amr->Par->TracerVelCorr; + InputPara.Opt__ParInitCheck = OPT__PAR_INIT_CHECK; for (int v=0; v