Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integer attribute of particle #348

Merged
merged 176 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 163 commits
Commits
Show all changes
176 commits
Select commit Hold shift + click to select a range
8749e3d
Change PAR_NATT_* to PAR_NATT_FLT_*
ChunYen-Chen May 24, 2024
43a2bd9
Merge branch 'hyschive:main' into par_attribute
ChunYen-Chen May 24, 2024
a2b0b2f
Change _PAR_TOTAL to _PAR_FLT_TOTAL
ChunYen-Chen May 24, 2024
ca6c656
Change Par_NAttStored to Par_NAttFltStored
ChunYen-Chen May 24, 2024
a56f486
Change Par_NAttUser to Par_NAttFltUser
ChunYen-Chen May 24, 2024
2f58511
Change ParAttLabel to ParAttFltLabel
ChunYen-Chen May 24, 2024
0c6a45e
Change ParAtt_Copy to ParAttFlt_Copy
ChunYen-Chen May 24, 2024
d8b08c1
Change variable names
ChunYen-Chen May 27, 2024
16001eb
Change ParAtt_Old to ParAttFlt_Old
ChunYen-Chen May 27, 2024
3809086
Change H5_SetID_ParData to H5_SetID_ParFltData
ChunYen-Chen May 27, 2024
9e221f5
Change ParBuf to ParFltBuf
ChunYen-Chen May 27, 2024
bb367f6
Change ParAtt to ParAttFlt
ChunYen-Chen May 27, 2024
87fa3a9
Change AttIntIdx to FltAttIntIdx
ChunYen-Chen May 27, 2024
e2b0fbe
Change AttBitIdx to FltAttBitIdx
ChunYen-Chen May 27, 2024
0c3d40b
Change NDefinedAtt to NDefinedAttFlt
ChunYen-Chen May 27, 2024
d4480e9
Change SendAttPtr to SendAttFltPtr
ChunYen-Chen May 27, 2024
34f5884
Change par_attribute to par_attribute_flt
ChunYen-Chen May 29, 2024
8d081d5
Change MPI Send/Recv pointer.
ChunYen-Chen May 30, 2024
f2bccc7
Change OldAttPtrPtr to OldAttFltPtrPtr
ChunYen-Chen May 30, 2024
037d907
Change attribute_buff to attribute_flt_buff
ChunYen-Chen May 30, 2024
e5764c4
Change par_natt_stored to par_natt_flt_stored
ChunYen-Chen May 30, 2024
ca972ee
Change ParData1 to ParFltData1
ChunYen-Chen May 30, 2024
205df91
Bug fix
ChunYen-Chen May 30, 2024
349682a
Bug fix
ChunYen-Chen May 30, 2024
438c75e
Change par_natt_user to par_natt_flt_user
ChunYen-Chen May 30, 2024
fe39c76
Change more pointers and minor bug fix
ChunYen-Chen Jun 3, 2024
05c6a0b
Add PAR_NATT_INT_*
ChunYen-Chen Jun 3, 2024
add07b3
Record PAR_NATT_INT_* to Record__Note
ChunYen-Chen Jun 3, 2024
5de167c
Add --par_attribute_int
ChunYen-Chen Jun 3, 2024
32914bb
Add ParAttIntLabel
ChunYen-Chen Jun 3, 2024
e51c463
Add integer array
ChunYen-Chen Jun 3, 2024
1010037
Change Par_Init_ByFunction_* function
ChunYen-Chen Jun 6, 2024
324679e
Change FB_User_* function
ChunYen-Chen Jun 6, 2024
a5463df
Add ParAttInt_Copy
ChunYen-Chen Jun 6, 2024
894c82c
Change Par_AddParticleAfterInit
ChunYen-Chen Jun 6, 2024
19ef0d8
Update LB_Init_LoadBalance.cpp
ChunYen-Chen Jun 12, 2024
d9939be
Update Par_LB_CollectParticle2OneLevel
ChunYen-Chen Jun 12, 2024
80b0296
Update Par_LB_CollectParticleFromRealPatch
ChunYen-Chen Jun 12, 2024
53f2cee
Update Par_LB_ExchangeParticleBetweenPatch
ChunYen-Chen Jun 13, 2024
8199a1a
Update Par_LB_SendParticleData
ChunYen-Chen Jun 13, 2024
c155963
Update Par_CollectParticle2OneLevel
ChunYen-Chen Jun 13, 2024
c76b198
Update Par_FindHomePatch_UniformGrid
ChunYen-Chen Jun 13, 2024
81866d5
minor
ChunYen-Chen Jun 13, 2024
6cdf8d4
Update Par_Init_Attribute
ChunYen-Chen Jun 13, 2024
295b866
Update Par_ScatterParticleData
ChunYen-Chen Jun 13, 2024
81d0de5
Update SF_CreateStar_AGORA
ChunYen-Chen Jun 13, 2024
32c30b4
Update AddOneParticle
ChunYen-Chen Jun 13, 2024
ba43bce
Update Output_Patch
ChunYen-Chen Jun 13, 2024
befd53b
Update Par_Output_TextFile
ChunYen-Chen Jun 13, 2024
47270bd
Update FB_User
ChunYen-Chen Jun 14, 2024
5164b3d
Minor
ChunYen-Chen Jun 14, 2024
0529ef9
Update function
ChunYen-Chen Jun 14, 2024
5640748
Update FB_AdvanceDt
ChunYen-Chen Jun 14, 2024
f8c0047
Update Par_LB_SendParticleData
ChunYen-Chen Jun 14, 2024
dc7354e
Update HDF5
ChunYen-Chen Jun 17, 2024
a1c06f4
Add INT8_PAR option for particle
ChunYen-Chen Jun 17, 2024
c5264ed
Update default value
ChunYen-Chen Jun 17, 2024
2246573
Add new type
ChunYen-Chen Jun 17, 2024
40e6004
change type long to long_par
ChunYen-Chen Jun 17, 2024
8593702
Update Par_Output_BinaryFile
ChunYen-Chen Jun 17, 2024
aaca021
Update type
ChunYen-Chen Jun 24, 2024
f08e3e4
Update output and restart
ChunYen-Chen Jul 8, 2024
85e0471
Bug fix
ChunYen-Chen Jul 8, 2024
1405db6
Bug fix
ChunYen-Chen Jul 8, 2024
d2ec06e
Merge branch 'hyschive:main' into par_attribute
ChunYen-Chen Jul 8, 2024
15595ea
Temporary solution of wrong format
ChunYen-Chen Jul 11, 2024
1c4f6e6
Add check
ChunYen-Chen Jul 11, 2024
7a6047d
Update include
ChunYen-Chen Jul 11, 2024
881daa9
Update SF_CreateStar_AGORA.cpp
ChunYen-Chen Jul 11, 2024
10a0924
Update AGROA testproblem
ChunYen-Chen Jul 11, 2024
916e33e
Update Par_LB_ExchangeParticleBetweenPatch.cpp
ChunYen-Chen Jul 11, 2024
0bfcac5
Update Par_FindHomePatch_UniformGrid.cpp
ChunYen-Chen Jul 11, 2024
1762bce
Update Par_GetTimeStep_VelAcc.cpp
ChunYen-Chen Jul 11, 2024
d5b3ac5
Update Par_PassParticle2Sibling.cpp
ChunYen-Chen Jul 11, 2024
9ca90bc
Update Par_Init_Attribute.cpp
ChunYen-Chen Jul 11, 2024
7848f01
Update LB_Init_LoadBalance.cpp
ChunYen-Chen Jul 11, 2024
ca4829c
Update test problems
ChunYen-Chen Jul 11, 2024
f811389
Update Patch.h
ChunYen-Chen Jul 11, 2024
39ddf50
Update Par_MassAssignment()
ChunYen-Chen Jul 11, 2024
ee4f24a
Record INT8 option
ChunYen-Chen Jul 11, 2024
c25933d
Update Output_DumpData_Total_HDF5.cpp
ChunYen-Chen Jul 11, 2024
a5b9216
Update Par_CollectParticle2OneLevel()
ChunYen-Chen Jul 12, 2024
6d7702c
Update
ChunYen-Chen Jul 12, 2024
ec897cf
Update Par_MapMesh2Particles()
ChunYen-Chen Jul 12, 2024
da6a768
Update Par_Init_ByFunction.cpp
ChunYen-Chen Jul 12, 2024
be1bfe8
Update PType type
ChunYen-Chen Jul 12, 2024
f037c8a
Minor
ChunYen-Chen Jul 15, 2024
7de482f
Update type
ChunYen-Chen Jul 16, 2024
27754d4
Update type
ChunYen-Chen Jul 16, 2024
c3f94a8
Update
ChunYen-Chen Jul 16, 2024
4d65c9d
Bug fix
ChunYen-Chen Jul 18, 2024
43bb658
Bug fix
ChunYen-Chen Jul 30, 2024
1c9aac4
Bug fix
ChunYen-Chen Jul 30, 2024
7407436
Align output
ChunYen-Chen Jul 30, 2024
b69c5b3
Add HDF5 restart
ChunYen-Chen Aug 1, 2024
4bfadf4
Add restart from bin
ChunYen-Chen Aug 1, 2024
508e840
Remove debug message
ChunYen-Chen Aug 22, 2024
ffbc758
Add check
ChunYen-Chen Aug 22, 2024
4aff9a9
Bug fix
ChunYen-Chen Aug 22, 2024
20f711e
Bug fix
ChunYen-Chen Aug 22, 2024
7e6b2d7
Fix type
ChunYen-Chen Aug 22, 2024
201ea76
Typo
ChunYen-Chen Aug 26, 2024
9302718
Minor
ChunYen-Chen Aug 26, 2024
0c98ad6
Remove test script
ChunYen-Chen Aug 26, 2024
c1258d8
Update wiki
ChunYen-Chen Aug 26, 2024
f0bea04
Update wiki
ChunYen-Chen Aug 26, 2024
d3edc55
Add PAR_IC script
ChunYen-Chen Aug 27, 2024
fe6dd69
Record PAR_IC_INT8 and bug fix
ChunYen-Chen Aug 27, 2024
c5cfc28
Support int attribute
ChunYen-Chen Aug 27, 2024
0c3c0dc
Update wiki
ChunYen-Chen Aug 27, 2024
13ae7e8
Update Initial-Conditions.md
ChunYen-Chen Aug 27, 2024
88defe0
Merge branch 'hyschive:main' into par_attribute
ChunYen-Chen Aug 27, 2024
970e4f4
Restore
ChunYen-Chen Aug 27, 2024
963b5f3
Update comment
ChunYen-Chen Aug 27, 2024
05db766
Merge branch 'par_attribute' of https://github.com/ChunYen-Chen/gamer…
ChunYen-Chen Aug 27, 2024
637eb40
Bug fix
ChunYen-Chen Sep 3, 2024
165ef12
Bug fix
ChunYen-Chen Sep 3, 2024
a5d593a
Merge branch 'master' into par_attribute
ChunYen-Chen Nov 11, 2024
30ebfbe
Merge branch 'master' into par_attribute
ChunYen-Chen Nov 26, 2024
fd3ba3d
Merge branch 'hyschive:main' into par_attribute
ChunYen-Chen Dec 5, 2024
3ea7140
Merge branch 'master' into par_attribute
ChunYen-Chen Dec 12, 2024
f259aa5
Update test problem
ChunYen-Chen Dec 15, 2024
17a3334
Merge branch 'master' into par_attribute
ChunYen-Chen Dec 24, 2024
53a2484
Merge branch 'master' into par_attribute
ChunYen-Chen Dec 25, 2024
6fcfe9e
Update
ChunYen-Chen Dec 25, 2024
a47cb91
Minor
ChunYen-Chen Dec 25, 2024
bc0d08f
Minor
ChunYen-Chen Dec 26, 2024
b7a9e72
Typo
ChunYen-Chen Dec 30, 2024
91a0166
Typo
ChunYen-Chen Dec 31, 2024
d335459
Typo
ChunYen-Chen Dec 31, 2024
8a4bfc3
Update wiki
ChunYen-Chen Dec 31, 2024
a8af189
Add comment
ChunYen-Chen Dec 31, 2024
e9833c7
Bug fix hydro feedback
ChunYen-Chen Dec 31, 2024
4a38614
Bugfix prototype
ChunYen-Chen Dec 31, 2024
59d6807
Bugfix prototype
ChunYen-Chen Dec 31, 2024
7ffdc45
Bugfix incorrect type
ChunYen-Chen Dec 31, 2024
2327c8e
Bugfix incorrect preprocessor
ChunYen-Chen Dec 31, 2024
0597caa
Replace `0L` with `_NONE`
ChunYen-Chen Dec 31, 2024
f163910
Optimize output
ChunYen-Chen Dec 31, 2024
48c22c4
Optimize check
ChunYen-Chen Dec 31, 2024
2814f24
Add content of PAR_INT8
ChunYen-Chen Jan 1, 2025
09f643f
Optimization
ChunYen-Chen Jan 1, 2025
3e8e8cf
Optimize file reading
ChunYen-Chen Jan 1, 2025
0e56ddc
Remove useless code
ChunYen-Chen Jan 1, 2025
5a53cc5
Typo
ChunYen-Chen Jan 1, 2025
b9f815a
Update the version number of the binary file
ChunYen-Chen Jan 2, 2025
3fcc904
Update the version number of the HDF5 file
ChunYen-Chen Jan 2, 2025
77b1aa5
Restore the original code method
ChunYen-Chen Jan 2, 2025
d9b9647
Rename PAR_TYPE_IDX_OLD as ParTypeIdx_old
ChunYen-Chen Jan 2, 2025
66aa277
Minor
ChunYen-Chen Jan 2, 2025
9abdb50
Merge branch 'master' into par_attribute
ChunYen-Chen Jan 2, 2025
a27b471
Correct data type
ChunYen-Chen Jan 2, 2025
6d25fe2
Merge branch 'master' into par_attribute
ChunYen-Chen Jan 6, 2025
80ed409
Remove TODO
ChunYen-Chen Jan 6, 2025
11d4808
Update the error message of binary output
ChunYen-Chen Jan 6, 2025
558a8c5
Update GAMER_CompareData
ChunYen-Chen Jan 6, 2025
f480be6
Minor
ChunYen-Chen Jan 6, 2025
8d3340c
Update GAMER_ExtractProfile
ChunYen-Chen Jan 6, 2025
9902a5b
Update GAMER_ExtractUniform
ChunYen-Chen Jan 6, 2025
66f678a
Fix backward compatibility
ChunYen-Chen Jan 7, 2025
261cf2a
Update PAR_IC file
ChunYen-Chen Jan 7, 2025
61f7145
Merge branch 'master' into par_attribute
ChunYen-Chen Jan 7, 2025
4eecd48
Update
ChunYen-Chen Jan 7, 2025
c734ea6
Apply suggestions from code review
ChunYen-Chen Jan 14, 2025
c32acdd
Apply suggestions from code review
ChunYen-Chen Jan 14, 2025
b3f6dd7
Minor
ChunYen-Chen Jan 14, 2025
961fbc1
Minor
ChunYen-Chen Jan 14, 2025
78b73f8
Remove useless
ChunYen-Chen Jan 14, 2025
98b3f52
Remove duplicate check
ChunYen-Chen Jan 14, 2025
fbea632
[Workflow] Update all parameters wiki page
ChunYen-Chen Jan 14, 2025
6cba429
Merge branch 'master' into par_attribute
ChunYen-Chen Jan 14, 2025
d886c95
Rename variable
ChunYen-Chen Jan 14, 2025
31025ea
Add --long_par wiki
ChunYen-Chen Jan 14, 2025
3038186
[Workflow] Update all parameters wiki page
ChunYen-Chen Jan 14, 2025
0572fff
Rename PAR_IC to DiskHeating_PAR_IC
ChunYen-Chen Jan 14, 2025
fae9b63
Rename DiskHeating_PAR_IC to DiskParticleParticleIC
ChunYen-Chen Jan 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions doc/wiki/Adding-New-Simulations.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,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 @@ -287,14 +287,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 @@ -303,38 +305,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
140 changes: 92 additions & 48 deletions doc/wiki/Initial-Conditions.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,14 @@ The particle IC function has the following prototype:

```C++
void Par_Init_ByFunction( 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] )
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] )
```
It should set the particle IC in the arrays `ParMass`, `ParPosX/Y/Z`,
`ParVelX/Y/Z`, `ParTime`, `ParType`, and, optionally, the pointer array `*AllAttribute[PAR_NATT_TOTAL]`,
`ParVelX/Y/Z`, `ParTime`, `ParType`, and, optionally, the pointer arrays
`*AllAttributeFlt[PAR_NATT_FLT_TOTAL]` and `*AllAttributeInt[PAR_NATT_INT_TOTAL]`,
all of which have the size of `NPar_ThisRank` &#8212; the number of particles
to be set by this MPI rank. Note that particles set by this function
are only temporarily stored in this MPI rank and will later be
Expand Down Expand Up @@ -221,25 +223,29 @@ The following example shows `Par_Init_ByFunction()` in
// and LB_Init_LoadBalance()
// --> Therefore, there is no constraint on which particles should be set by this function
//
// Parameter : NPar_ThisRank : Number of particles to be set by this MPI rank
// NPar_AllRank : Total Number of particles in all MPI ranks
// ParMass : Particle mass array with the size of NPar_ThisRank
// ParPosX/Y/Z : Particle position array with the size of NPar_ThisRank
// ParVelX/Y/Z : Particle velocity array with the size of NPar_ThisRank
// ParTime : Particle time array with the size of NPar_ThisRank
// ParType : Particle type array with the size of NPar_ThisRank
// AllAttribute : Pointer array for all particle attributes
// --> Dimension = [PAR_NATT_TOTAL][NPar_ThisRank]
// --> Use the attribute indices defined in Field.h (e.g., Idx_ParCreTime)
// to access the data
// Parameter : NPar_ThisRank : Number of particles to be set by this MPI rank
// NPar_AllRank : Total Number of particles in all MPI ranks
// ParMass : Particle mass array with the size of NPar_ThisRank
// ParPosX/Y/Z : Particle position array with the size of NPar_ThisRank
// ParVelX/Y/Z : Particle velocity array with the size of NPar_ThisRank
// ParTime : Particle time array with the size of NPar_ThisRank
// ParType : Particle type array with the size of NPar_ThisRank
// AllAttributeFlt : Pointer array for all particle floating-point attributes
// --> Dimension = [PAR_NATT_FLT_TOTAL][NPar_ThisRank]
// --> Use the attribute indices defined in Field.h (e.g., Idx_ParCreTime)
// to access the data
// AllAttributeInt : Pointer array for all particle integer attributes
// --> Dimension = [PAR_NATT_INT_TOTAL][NPar_ThisRank]
// --> Use the attribute indices defined in Field.h to access the data

//
// Return : ParMass, ParPosX/Y/Z, ParVelX/Y/Z, ParTime, ParType, AllAttribute
//-------------------------------------------------------------------------------------------------------
void Par_Init_ByFunction( 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] )
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] )
{

// synchronize all particles to the physical time on the base level
Expand All @@ -254,26 +260,26 @@ void Par_Init_ByFunction( const long NPar_ThisRank, const long NPar_AllRank,
real *ParPos[3] = { ParPosX, ParPosY, ParPosZ };
real *ParVel[3] = { ParVelX, ParVelY, ParVelZ };

const uint RSeed = 2; // random seed
const real MassMin = 1.0e-2; // minimum value of particle mass
const real MassMax = 1.0; // maximum value of particle mass
const real PosMin[3] = { 0.0, 0.0, 0.0 }; // minimum value of particle position
const real PosMax[3] = { real( amr->BoxSize[0]*(1.0-1.0e-5) ), // maximum value of particle position
real( amr->BoxSize[1]*(1.0-1.0e-5) ),
real( amr->BoxSize[2]*(1.0-1.0e-5) ) };
const real VelMin[3] = { -1.0, -1.0, -1.0 }; // minimum value of particle velocity
const real VelMax[3] = { +1.0, +1.0, +1.0 }; // maximum value of particle velocity
const uint RSeed = 2; // random seed
const real_par MassMin = 1.0e-2; // minimum value of particle mass
const real_par MassMax = 1.0; // maximum value of particle mass
const real_par PosMin[3] = { 0.0, 0.0, 0.0 }; // minimum value of particle position
const real_par PosMax[3] = { real( amr->BoxSize[0]*(1.0-1.0e-5) ), // maximum value of particle position
real( amr->BoxSize[1]*(1.0-1.0e-5) ),
real( amr->BoxSize[2]*(1.0-1.0e-5) ) };
const real_par VelMin[3] = { -1.0, -1.0, -1.0 }; // minimum value of particle velocity
const real_par VelMax[3] = { +1.0, +1.0, +1.0 }; // maximum value of particle velocity

srand( RSeed );

for (long p=0; p<NPar_ThisRank; p++)
{
ParMass[p] = ( (real)rand()/RAND_MAX )*( MassMax - MassMin ) + MassMin;
ParMass[p] = ( (real_par)rand()/RAND_MAX )*( MassMax - MassMin ) + MassMin;

for (int d=0; d<3; d++)
{
ParPos[d][p] = ( (real)rand()/RAND_MAX )*( PosMax[d] - PosMin[d] ) + PosMin[d];
ParVel[d][p] = ( (real)rand()/RAND_MAX )*( VelMax[d] - VelMin[d] ) + VelMin[d];
ParPos[d][p] = ( (real_par)rand()/RAND_MAX )*( PosMax[d] - PosMin[d] ) + PosMin[d];
ParVel[d][p] = ( (real_par)rand()/RAND_MAX )*( VelMax[d] - VelMin[d] ) + VelMin[d];
}
}

Expand Down Expand Up @@ -397,7 +403,7 @@ row-major array) can be either
and `NUM_PARTICLE` is the total number of particles
(i.e., [[PAR_NPAR | Particles#par_npar]]).
By default, `NUM_ATTRIBUTE` is equal to
`8` + [[--par_attribute | Installation:-Option-List#--par_attribute]],
`7` + [[--par_attribute_flt | Installation:-Option-List#--par_attribute_flt]] + [[--par_attribute_int | Installation:-Option-List#--par_attribute_int]],
corresponding to particle mass, position x/y/z, velocity x/y/z,
type, and user-specified attributes (and in exactly this order).
One can also use [[PAR_IC_MASS | Particles#par_ic_mass]] / [[PAR_IC_TYPE | Particles#par_ic_type]]
Expand All @@ -412,37 +418,74 @@ and [[PAR_IC_FORMAT | Particles#par_ic_format]]=1.
```c++
#include <cstdio>

//#define FLOAT8_PAR
#define INT8_PAR


#ifdef FLOAT8_PAR
typedef double real_par;
#else
typedef float real_par;
#endif

#ifdef INT8_PAR
typedef long long_par;
#else
typedef int long_par;
#endif


int main()
{
const int NUM_PARTICLE = 1000;
const int NUM_ATTRIBUTE = 8;

float (*ParIC)[NUM_PARTICLE] = new float [NUM_ATTRIBUTE][NUM_PARTICLE];
const int NUM_PARTICLE = 1000;
const int NUM_ATTRIBUTE_FLT = 7;
const int NUM_ATTRIBUTE_INT = 1;
const bool PAR_IC_ATT_ID = true; // data format of PAR_IC: (true: [attribute][id], false: [id][attribute]; row-major)

real_par (*ParIC_Flt)[NUM_PARTICLE] = new real_par [NUM_ATTRIBUTE_FLT][NUM_PARTICLE];
long_par (*ParIC_Int)[NUM_PARTICLE] = new long_par [NUM_ATTRIBUTE_INT][NUM_PARTICLE];

for (int p=0; p<NUM_PARTICLE; p++)
{
// replace the following lines by your particle initial condition
ParIC[0][p] = 1.1; // mass
ParIC[1][p] = 2.2; // position x
ParIC[2][p] = 3.3; // position y
ParIC[3][p] = 4.4; // position z
ParIC[4][p] = 5.5; // velocity x
ParIC[5][p] = 6.6; // velocity y
ParIC[6][p] = 7.7; // velocity z
ParIC[7][p] = 1.0; // type (generic massive)
ParIC_Flt[0][p] = 1.1; // mass
ParIC_Flt[1][p] = 2.2; // position x
ParIC_Flt[2][p] = 3.3; // position y
ParIC_Flt[3][p] = 4.4; // position z
ParIC_Flt[4][p] = 5.5; // velocity x
ParIC_Flt[5][p] = 6.6; // velocity y
ParIC_Flt[6][p] = 7.7; // velocity z

ParIC_Int[0][p] = 1; // type (generic massive)
}

FILE *File = fopen( "PAR_IC", "wb" );
fwrite( ParIC, sizeof(float), NUM_PARTICLE*NUM_ATTRIBUTE, File );

if ( PAR_IC_ID_ATT )
{
for (int p=0; p<NUM_PARTICLE; p++)
{
for (int v=0; v<NUM_ATTRIBUTE_FLT; v++) fwrite( &ParIC_Flt[v][p], sizeof(real_par), 1, File );
for (int v=0; v<NUM_ATTRIBUTE_INT; v++) fwrite( &ParIC_Int[v][p], sizeof(long_par), 1, File );
}
}
else
{
for (int v=0; v<NUM_ATTRIBUTE_FLT; v++) fwrite( ParIC_Flt[v], sizeof(real_par), NUM_PARTICLE, File );
for (int v=0; v<NUM_ATTRIBUTE_INT; v++) fwrite( ParIC_Int[v], sizeof(long_par), NUM_PARTICLE, File );
}

fclose( File );

delete [] ParIC;
}
delete [] ParIC_Flt;
delete [] ParIC_Int;

} // FUNCTION : main
```

The built-in particle types (defined in `include/Macro.h`) include
`PTYPE_TRACER=0.0`, `PTYPE_GENERIC_MASSIVE=1.0`, `PTYPE_DARK_MATTER=2.0`, and `PTYPE_STAR=3.0`.
They have the floating-point types for now but will be changed to integers in the future.
`PTYPE_TRACER=0`, `PTYPE_GENERIC_MASSIVE=1`, `PTYPE_DARK_MATTER=2`, and `PTYPE_STAR=3`.
For `PTYPE_TRACER`, one must also enable the compilation option
[[--tracer | Installation:-Option-List#--tracer]].

Expand All @@ -456,7 +499,8 @@ function and load the particle initial condition from a file (and vice versa).

Related options:
[[--passive | Installation:-Option-List#--passive]], &nbsp;
[[--par_attribute | Installation:-Option-List#--par_attribute]] &nbsp;
[[--par_attribute_flt | Installation:-Option-List#--par_attribute_flt]] &nbsp;
[[--par_attribute_int | Installation:-Option-List#--par_attribute_int]] &nbsp;


## Runtime Parameters
Expand Down
Loading