Skip to content

Commit 6a253a5

Browse files
authored
Merge pull request #460 from ChunYen-Chen/par_init_opt
Add new runtime parameter `OPT__PAR_INIT_CHECK`
2 parents 3f3471f + d24d9fa commit 6a253a5

File tree

11 files changed

+27
-8
lines changed

11 files changed

+27
-8
lines changed

doc/wiki/Runtime-Parameters-related/Runtime-Parameters:-All.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ For variables with `Default/Min/Max` labeled as `Depend`, click the parameter na
307307
| [[ 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" |
308308
| OPT__OVERLAP_MPI | 0 | None | None | overlap MPI communication with CPU/GPU computations [0] ##NOT SUPPORTED YET## |
309309
| [[ 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] |
310+
| [[ OPT__PAR_INIT_CHECK \| Runtime-Parameters:-Particles#OPT__PAR_INIT_CHECK ]] | 1 | None | None | check particle initialization (only works for PAR_INIT != 2) [1] |
310311
| [[ 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] |
311312
| [[ 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] |
312313
| [[ 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] |

doc/wiki/Runtime-Parameters-related/Runtime-Parameters:-Particles.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ Parameters described on this page:
1313
[PAR_IMPROVE_ACC](#PAR_IMPROVE_ACC),  
1414
[PAR_PREDICT_POS](#PAR_PREDICT_POS),  
1515
[PAR_REMOVE_CELL](#PAR_REMOVE_CELL),  
16-
[OPT__FREEZE_PAR](#OPT__FREEZE_PAR)  
16+
[OPT__FREEZE_PAR](#OPT__FREEZE_PAR),  
17+
[OPT__PAR_INIT_CHECK](#OPT__PAR_INIT_CHECK)  
1718

1819

1920
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).
150151
It can be useful for evolving fluid in a static gravitational potential of particles.
151152
* **Restriction:**
152153

154+
<a name="OPT__PAR_INIT_CHECK"></a>
155+
* #### `OPT__PAR_INIT_CHECK` &ensp; (0=off, 1=on) &ensp; [1]
156+
* **Description:**
157+
Check particle initialization by calling `Par_Aux_InitCheck()` function after particle initialization (only works for [PAR_INIT](#PAR_INIT)!=`2`).
158+
Disable this check when particles are initialized _after_ setting grid fields, such as by `Init_User_Ptr()`.
159+
* **Restriction:**
160+
153161

154162
## Remarks
155163

example/test_problem/Template/Input__Parameter

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ PAR_PREDICT_POS 1 # predict particle position during mas
9999
PAR_REMOVE_CELL -1.0 # remove particles X-root-cells from the boundaries (non-periodic BC only; <0=auto) [-1.0]
100100
OPT__FREEZE_PAR 0 # do not update particles (except for tracers) [0]
101101
PAR_TR_VEL_CORR 0 # correct tracer particle velocities in regions of discontinuous flow [0]
102+
OPT__PAR_INIT_CHECK 1 # check particle initialization (only works for PAR_INIT != 2) [1]
102103

103104
# cosmology (COMOVING only)
104105
A_INIT 0.01 # initial scale factor

include/Global.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ extern bool FFTW3_Double_OMP_Enabled, FFTW3_Single_OMP_Enabled;
240240
// ============================================================================================================
241241
#ifdef PARTICLE
242242
extern double DT__PARVEL, DT__PARVEL_MAX, DT__PARACC;
243-
extern bool OPT__CK_PARTICLE, OPT__FLAG_NPAR_CELL, OPT__FLAG_PAR_MASS_CELL, OPT__FREEZE_PAR, OPT__OUTPUT_PAR_MESH;
243+
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;
244244
extern int OPT__OUTPUT_PAR_MODE, OPT__PARTICLE_COUNT, OPT__FLAG_NPAR_PATCH, FlagTable_NParPatch[NLEVEL-1], FlagTable_NParCell[NLEVEL-1];
245245
extern double FlagTable_ParMassCell[NLEVEL-1];
246246
extern ParOutputDens_t OPT__OUTPUT_PAR_DENS;

include/HDF5_Typedef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ struct InputPara_t
443443
int Par_GhostSize;
444444
int Par_GhostSizeTracer;
445445
int Par_TracerVelCorr;
446+
int Opt__ParInitCheck;
446447
char *ParAttFltLabel[PAR_NATT_FLT_TOTAL];
447448
char *ParAttIntLabel[PAR_NATT_INT_TOTAL];
448449
# endif

src/Auxiliary/Aux_TakeNote.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,6 +1445,9 @@ void Aux_TakeNote()
14451445
default: fprintf( Note, "UNKNOWN\n" );
14461446
} // switch ( OPT__FFTW_STARTUP )
14471447
# endif // # ifdef SUPPORT_FFTW
1448+
# ifdef PARTICLE
1449+
fprintf( Note, "OPT__PAR_INIT_CHECK % d\n", OPT__PAR_INIT_CHECK );
1450+
# endif
14481451

14491452
// refinement region for OPT__UM_IC_NLEVEL>1
14501453
if ( OPT__INIT == INIT_BY_FILE && OPT__UM_IC_NLEVEL > 1 ) {

src/Init/Init_ByRestart_HDF5.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,6 +1981,7 @@ void Check_InputPara( const char *FileName, const int FormatVersion )
19811981
LoadField( "Par_GhostSize", &RS.Par_GhostSize, SID, TID, NonFatal, &RT.Par_GhostSize, 1, NonFatal );
19821982
LoadField( "Par_GhostSizeTracer", &RS.Par_GhostSizeTracer, SID, TID, NonFatal, &RT.Par_GhostSizeTracer, 1, NonFatal );
19831983
LoadField( "Par_TracerVelCorr", &RS.Par_TracerVelCorr, SID, TID, NonFatal, &RT.Par_TracerVelCorr, 1, NonFatal );
1984+
LoadField( "Opt__ParInitCheck", &RS.Opt__ParInitCheck, SID, TID, NonFatal, &RT.Opt__ParInitCheck, 1, NonFatal );
19841985
# endif
19851986

19861987
// cosmology

src/Init/Init_GAMER.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ void Init_GAMER( int *argc, char ***argv )
220220
"PAR_INIT", (int)amr->Par->Init );
221221
}
222222

223-
if ( amr->Par->Init != PAR_INIT_BY_RESTART ) Par_Aux_InitCheck();
223+
if ( amr->Par->Init != PAR_INIT_BY_RESTART && OPT__PAR_INIT_CHECK ) Par_Aux_InitCheck();
224224
# endif // #ifdef PARTICLE
225225

226226

src/Init/Init_Load_Parameter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ void Init_Load_Parameter()
9090
ReadPara->Add( "PAR_REMOVE_CELL", &amr->Par->RemoveCell, -1.0, NoMin_double, NoMax_double );
9191
ReadPara->Add( "OPT__FREEZE_PAR", &OPT__FREEZE_PAR, false, Useless_bool, Useless_bool );
9292
ReadPara->Add( "PAR_TR_VEL_CORR", &amr->Par->TracerVelCorr, false, Useless_bool, Useless_bool );
93+
ReadPara->Add( "OPT__PAR_INIT_CHECK", &OPT__PAR_INIT_CHECK, true, Useless_bool, Useless_bool );
9394
# endif // #ifdef PARTICLE
9495

9596

src/Main/Main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ bool FFTW3_Double_OMP_Enabled, FFTW3_Single_OMP_Enabled;
228228
// (2-5) particle
229229
#ifdef PARTICLE
230230
double DT__PARVEL, DT__PARVEL_MAX, DT__PARACC;
231-
bool OPT__CK_PARTICLE, OPT__FLAG_NPAR_CELL, OPT__FLAG_PAR_MASS_CELL, OPT__FREEZE_PAR, OPT__OUTPUT_PAR_MESH;
231+
bool OPT__CK_PARTICLE, OPT__FLAG_NPAR_CELL, OPT__FLAG_PAR_MASS_CELL, OPT__FREEZE_PAR, OPT__OUTPUT_PAR_MESH, OPT__PAR_INIT_CHECK;
232232
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];
233233
double FlagTable_ParMassCell[NLEVEL-1];
234234
ParOutputDens_t OPT__OUTPUT_PAR_DENS;

0 commit comments

Comments
 (0)