Skip to content

Commit

Permalink
Merge branch 'main' into mac_updates
Browse files Browse the repository at this point in the history
* main: (430 commits)
  Minor
  Minor
  Add comments
  Add execute premission check
  Bugfix string length
  Apply suggestions from code review
  [Workflow] Update all parameters wiki page
  Update output format
  Update description
  Load Opt__Output_Text_Length_Int when restert
  Rename DUMP_DIR to OUTPUT_DIR
  [Workflow] Update all parameters wiki page
  Let OUTPUT_DIR shorter
  Add file premission check
  Fix file path
  Remove useless variable
  Fix Input__Note output
  Update missed filename
  Rename DUMP_DIR to OUTPUT_DIR
  Apply suggestions from code review
  ...
  • Loading branch information
jzuhone committed Jan 19, 2025
2 parents ceb0923 + 5fd2415 commit d17502b
Show file tree
Hide file tree
Showing 290 changed files with 6,852 additions and 3,059 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/update_all_parameter_page.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Update all parameters wiki page

on:
workflow_dispatch:
push:
paths:
- 'example/test_problem/Template/Input__Parameter'
- 'tool/wiki/sync_runtime_parameter.py'
- 'src/Init/Init_Load_Parameter.cpp'

env:
GIT_AUTHOR_NAME: ${{ github.actor }}
GIT_AUTHOR_EMAIL: ${{ secrets.MY_EMAIL }}

jobs:
Update-all-parameters-page:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
token: ${{ secrets.TOKEN_FOR_WIKI }}
- name: run script
run: |
cd tool/wiki
python --version
python sync_runtime_parameter.py
- name: move markdown
run: |
mv tool/wiki/Runtime-Parameters:-All.md doc/wiki/Runtime-Parameters-related
- name: set git config
run: |
git config --global user.email "${{env.GIT_AUTHOR_EMAIL}}"
git config --global user.name "${{env.GIT_AUTHOR_NAME}}"
- name: make a commit and push if the file changed
run: |
git diff --exit-code doc/wiki/Runtime-Parameters-related/Runtime-Parameters:-All.md || \
( git add doc/wiki/Runtime-Parameters-related/Runtime-Parameters:-All.md && \
git commit -m "[Workflow] Update all parameters wiki page" && \
git push )
110 changes: 79 additions & 31 deletions doc/wiki/Adding-New-Simulations.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ Mandatory steps are marked by 📌.
5. [Add Problem-specific Grid Fields and Particle Attributes](#v-add-problem-specific-grid-fields-and-particle-attributes)
6. [Add Problem-specific Functionalities](#vi-add-problem-specific-functionalities)
* [Output](#output)
* [Initial Condition from Files - Grids](#initial-condition-from-files---grids)
* [Initial Condition from Files - Particles](#initial-condition-from-files---particles)
* [Work Before Output](#work-before-output)
* [Refinement Criteria](#refinement-criteria)
* [Work Before Refine](#work-before-refine)
* [Timestep Constraints](#timestep-constraints)
* [Boundary Conditions](#boundary-conditions)
* [Fields Resetting](#fields-resetting)
Expand Down Expand Up @@ -112,11 +115,11 @@ For details see

```C++
#ifdef PARTICLE
void Par_Init_ByFunction_NewProblem(
const long NPar_ThisRank, const long NPar_AllRank,
real *ParMass, real *ParPosX, real *ParPosY, real *ParPosZ,
real *ParVelX, real *ParVelY, real *ParVelZ, real *ParTime,
real *ParType, real *AllAttribute[PAR_NATT_TOTAL] );
void Par_Init_ByFunction_NewProblem( const long NPar_ThisRank, const long NPar_AllRank,
real_par *ParMass, real_par *ParPosX, real_par *ParPosY, real_par *ParPosZ,
real_par *ParVelX, real_par *ParVelY, real_par *ParVelZ, real_par *ParTime,
long_par *ParType, real_par *AllAttributeFlt[PAR_NATT_FLT_TOTAL],
long_par *AllAttributeInt[PAR_NATT_INT_TOTAL] )
#endif
```

Expand Down Expand Up @@ -192,7 +195,7 @@ during the runtime.
```
4. Add these parameters to the input file `Input__TestProb`
(see [[Input__TestProb | Runtime-Parameters#input__testprob]]
(see [[Input__TestProb | Runtime-Parameters:-Input__TestProb]]
for the file format).
This file must be put in the same directory as the executable `gamer`
when running the code.
Expand Down Expand Up @@ -224,7 +227,7 @@ file to store the new field index. For example,
Note that some field index variables have been pre-declared in
`include/Field.h` (e.g., `Idx_Metal` for the field `Metal` used by,
for example, [[ GRACKLE_METAL | Chemistry-and-Radiation#GRACKLE_METAL ]]).
for example, [[ GRACKLE_METAL | Runtime-Parameters:-Chemistry-and-Radiation#GRACKLE_METAL ]]).
Whenever applicable, skip this step and use these pre-declared index variables
directly.
Expand All @@ -248,12 +251,12 @@ is just to avoid redundant assignments to the same field index variable.
The second parameter should be set to either `NORMALIZE_YES` or `NORMALIZE_NO`.
It controls whether the new field will be renormalized by the total gas density
after every update when enabling
[[ OPT__NORMALIZE_PASSIVE | Hydro#OPT__NORMALIZE_PASSIVE ]].
[[ OPT__NORMALIZE_PASSIVE | Runtime-Parameters:-Hydro#OPT__NORMALIZE_PASSIVE ]].
The third parameter should be set to either `INTERP_FRAC_YES` or `INTERP_FRAC_NO`.
It controls whether the new field will be converted to mass fraction during interpolation
when enabling
[[ OPT__INT_FRAC_PASSIVE_LR | Hydro#OPT__INT_FRAC_PASSIVE_LR ]].
[[ OPT__INT_FRAC_PASSIVE_LR | Runtime-Parameters:-Hydro#OPT__INT_FRAC_PASSIVE_LR ]].
One must also set the function pointer `Init_Field_User_Ptr` in the problem
initialization function `Init_TestProb_Hydro_NewProblem()`.
Expand All @@ -264,7 +267,7 @@ initialization function `Init_TestProb_Hydro_NewProblem()`.
> [!NOTE]
> The built-in field `Metal` with the field index `Idx_Metal`
will be added automatically when enabling [[ GRACKLE_METAL | Chemistry-and-Radiation#GRACKLE_METAL ]].
will be added automatically when enabling [[ GRACKLE_METAL | Runtime-Parameters:-Chemistry-and-Radiation#GRACKLE_METAL ]].
4. Assign initial values to the new field in `SetGridIC()` using the corresponding
field index. For example,
Expand All @@ -286,14 +289,16 @@ field index. For example,
Adding a new particle attribute is very similar to adding a new grid field.
So we only highlight the differences in each of the 4 steps above.
1. Set [[ --par_attribute | Installation:-Option-List#--par_attribute ]]
1. Set [[ --par_attribute_flt | Installation:-Option-List#--par_attribute_flt ]] and
[[ --par_attribute_int | Installation:-Option-List#--par_attribute_int ]]
instead when generating the Makefile.
2. Declare a global integer variable on the top of the problem source
file to store the new field index. For example,
```C++
static int NewParAttIdx = Idx_Undefined;
static int NewParAttFltIdx = Idx_Undefined;
static int NewParAttIntIdx = Idx_Undefined;
```
Note that some particle attribute index variables have been pre-declared in
Expand All @@ -302,38 +307,43 @@ metallicity fraction). Whenever applicable, skip this step and use these
pre-declared index variables directly.
3. Define a function called, for example, `AddNewParticleAttribute_NewProblem()`
and invoke `AddParticleAttribute()` for each of the new attribute. For example,
and invoke `AddParticleAttributeFlt()` and `AddParticleAttributeInt()` for each
of the new floating-point and integer attribute, respectively. For example,
```C++
void AddNewParticleAttribute_NewProblem()
{
if ( NewParAttIdx == Idx_Undefined )
NewParAttIdx = AddParticleAttribute( "NewParAttLabel" );
if ( NewParAttFltIdx == Idx_Undefined )
NewParAttFltIdx = AddParticleAttributeFlt( "NewParFltAttLabel" );
if ( NewParAttIntIdx == Idx_Undefined )
NewParAttIntIdx = AddParticleAttributeInt( "NewParIntAttLabel" );
}
```
The attribute index `NewParAttIdx` can be used to access the particle
attribute data (see the next step). One must also set the function pointer
The attribute indices `NewParAttFltIdx` and `NewParAttIntIdx` can be used to access the particle
floating-point and integer attribute data, respectively (see the next step). One must also set the function pointer
`Par_Init_Attribute_User_Ptr` in the problem initialization function.
```C++
Par_Init_Attribute_User_Ptr = AddNewParticleAttribute_NewProblem;
```
4. Assign initial values to the new particle attribute by using the
corresponding attribute index to access the pointer array
`*AllAttribute[PAR_NATT_TOTAL]` (see
corresponding attribute index to access the pointer arrays
`*AllAttributeFlt[PAR_NATT_FLT_TOTAL]` and `*AllAttributeInt[PAR_NATT_INT_TOTAL]` (see
[[Setting IC from Analytical Functions — Particles | Initial-Conditions#IC-Func-Particles]]).
For example,
```C++
void Par_Init_ByFunction_NewProblem( const long NPar_ThisRank, const long NPar_AllRank,
real *ParMass, real *ParPosX, real *ParPosY, real *ParPosZ,
real *ParVelX, real *ParVelY, real *ParVelZ, real *ParTime,
real *AllAttribute[PAR_NATT_TOTAL] )
real_par *ParMass, real_par *ParPosX, real_par *ParPosY, real_par *ParPosZ,
real_par *ParVelX, real_par *ParVelY, real_par *ParVelZ, real_par *ParTime,
long_par *ParType, real_par *AllAttributeFlt[PAR_NATT_FLT_TOTAL],
long_par *AllAttributeInt[PAR_NATT_INT_TOTAL] )
{
...
for (long p=0; p<NPar_ThisRank; p++) AllAttribute[NewParAttIdx][p] = 1.0;
for (long p=0; p<NPar_ThisRank; p++) AllAttributeFlt[NewParAttFltIdx][p] = 1.0;
for (long p=0; p<NPar_ThisRank; p++) AllAttributeInt[NewParAttIntIdx][p] = 2;
...
}
```
Expand Down Expand Up @@ -368,7 +378,7 @@ The following example illustrates the procedure to add a problem-specific
```
4. Turn on the corresponding runtime option
[[OPT__OUTPUT_USER | Outputs#OPT__OUTPUT_USER]].
[[OPT__OUTPUT_USER | Runtime-Parameters:-Outputs#OPT__OUTPUT_USER]].
when running the code.
```
Expand All @@ -378,6 +388,32 @@ when running the code.
Other user-specified functionalities such as refinement criteria and
timestep constraints can be added in a similar way and are outlined below.
### Initial Condition from Files - Grids
* **Description:**
Provide a custom routine for [[Setting IC from Files - Grids | Initial-Conditions#IC-File-Grids]].
* **Prototype:**
`void Init_ByFile_NewProblem( real fluid_out[], const real fluid_in[], const int nvar_in,
const double x, const double y, const double z, const double Time,
const int lv, double AuxArray[] );`
* **Function Pointer:**
`Init_ByFile_User_Ptr`
* **Runtime Option:**
[[OPT__INIT | Runtime-Parameters:-Initial-Conditions#OPT__INIT]]=3
* **Example:**
`src/Init/Init_ByFile.cpp` &#8594; `Init_ByFile_Default()`
### Initial Condition from Files - Particles
* **Description:**
Provide a custom routine for [[Setting IC from Files - Particles | Initial-Conditions#IC-File-Particles]].
* **Prototype:**
`void Par_Init_ByFile_NewProblem();`
* **Function Pointer:**
`Par_Init_ByFile_User_Ptr`
* **Runtime Option:**
[[PAR_INIT | Runtime-Parameters:-Particles#PAR_INIT]]=3
* **Example:**
`src/Particle/Par_Init_ByFile.cpp` &#8594; `Par_Init_ByFile_Default()`
### Work Before Output
* **Description:**
Perform user-specified work before dumping simulation data (e.g., `Data_xxxxxx`).
Expand Down Expand Up @@ -407,6 +443,18 @@ for details.
* **Example:**
`src/Refine/Flag_User.cpp`
### Work Before Refine
* **Description:**
Perform user-specified work before grid refinement.
* **Prototype:**
`void Flag_UserWorkBeforeFlag_NewProblem( const double Time, const int lv );`
* **Function Pointer:**
`Flag_UserWorkBeforeFlag_Ptr`
* **Runtime Option:**
None
* **Example:**
`src/Refine/Flag_UserWorkBeforeFlag.cpp`
### Timestep Constraints
* **Description:**
Add user-specified timestep constraints.
Expand All @@ -428,7 +476,7 @@ Add user-specified (i.e., inflow) boundary conditions.
`BC_User_Ptr` for the cell-centered fluid variables and
`BC_BField_User_Ptr` for the face-centered magnetic field
* **Runtime Option:**
[[OPT__BC_FLU_* | Hydro#OPT__BC_FLU_XM]] = 4
[[OPT__BC_FLU_* | Runtime-Parameters:-Hydro#OPT__BC_FLU_XM]] = 4
* **Example:**
`src/TestProblem/ELBDM/ExtPot/Init_TestProb_ELBDM_ExtPot.cpp`
&#8594; `BC()`
Expand All @@ -446,7 +494,7 @@ Using the vector potential is recommended since it reduces the divergence-free e
Note that one still needs to define `MHD_ResetByUser_BField_Ptr` when using the vector potential
(see the example below).
* **Restriction:**
* [[INIT_SUBSAMPLING_NCELL | Initial-Conditions#INIT_SUBSAMPLING_NCELL]] has no effect on resetting the initial magnetic field.
* [[INIT_SUBSAMPLING_NCELL | Runtime-Parameters:-Initial-Conditions#INIT_SUBSAMPLING_NCELL]] has no effect on resetting the initial magnetic field.
* To ensure that the reset magnetic field satisfies the divergence-free condition to the machine precision,
one must (i) use the vector potential and (ii) ensure that the reset fields do not touch any coarse-fine
AMR interfaces. Supporting resetting a divergence-free magnetic field across coarse-fine AMR interfaces
Expand All @@ -461,7 +509,7 @@ will be implemented in the future.
* **Function Pointer:**
`Flu_ResetByUser_Func_Ptr`, `MHD_ResetByUser_BField_Ptr`, `MHD_ResetByUser_VecPot_Ptr`
* **Runtime Option:**
[[OPT__RESET_FLUID | Hydro#OPT__RESET_FLUID]], [[OPT__RESET_FLUID_INIT | Hydro#OPT__RESET_FLUID_INIT]]
[[OPT__RESET_FLUID | Runtime-Parameters:-Hydro#OPT__RESET_FLUID]], [[OPT__RESET_FLUID_INIT | Runtime-Parameters:-Hydro#OPT__RESET_FLUID_INIT]]
* **Example:**
`src/Fluid/Flu_ResetByUser.cpp`, `src/Model_Hydro/MHD_ResetByUser.cpp`, `src/TestProblem/Hydro/BlastWave/MHD_ResetByUser_BlastWave.cpp`
Expand Down Expand Up @@ -518,7 +566,7 @@ for details.
* **Function Pointer:**
* `Init_ExtAcc_Ptr`
* **Runtime Option:**
[[OPT__EXT_ACC | Gravity#OPT__EXT_ACC]]
[[OPT__EXT_ACC | Runtime-Parameters:-Gravity#OPT__EXT_ACC]]
* **Example:**
* `src/TestProblem/Hydro/Plummer/Init_TestProb_Hydro_Plummer.cpp`
* `src/TestProblem/Hydro/Plummer/ExtAcc_Plummer.cpp`
Expand All @@ -534,7 +582,7 @@ for details.
* **Function Pointer:**
* `Init_ExtPot_Ptr`
* **Runtime Option:**
[[OPT__EXT_POT | Gravity#OPT__EXT_POT]]
[[OPT__EXT_POT | Runtime-Parameters:-Gravity#OPT__EXT_POT]]
* **Example:**
* `src/TestProblem/Hydro/Plummer/Init_TestProb_Hydro_Plummer.cpp`
* `src/TestProblem/Hydro/Plummer/ExtPot_Plummer.cpp`
Expand All @@ -555,13 +603,13 @@ Add a user-specified equation of state. See [[here | equation-of-state]] for det
### Feedback
* **Description:**
Add a user-specified feedback. See [[FB_USER | Feedback#FB_USER]] for details.
Add a user-specified feedback. See [[FB_USER | Runtime-Parameters:-Feedback#FB_USER]] for details.
* **Function Pointer:**
* `FB_Init_User_Ptr`
* **Compilation Option:**
[[--feedback | Installation:-Option-List#--feedback]]
* **Runtime Option:**
[[FB_USER | Feedback#FB_USER]]
[[FB_USER | Runtime-Parameters:-Feedback#FB_USER]]
* **Example:**
* `src/TestProblem/Hydro/Plummer/FB_Plummer.cpp`
Expand Down
Loading

0 comments on commit d17502b

Please sign in to comment.