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

Store conserved variable values to HDF5 #314

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
adfc72c
Record conserved variables to HDF5
ChunYen-Chen May 22, 2024
6e12b12
Load conserved variables from HDF5
ChunYen-Chen May 22, 2024
261c546
Align
ChunYen-Chen May 22, 2024
b82d1ea
Switch back the format
ChunYen-Chen May 22, 2024
ce11d2e
Merge branch 'hyschive:main' into save_conserved_vars
ChunYen-Chen Jun 3, 2024
e2a78c5
Merge branch 'master' into save_conserved_vars
ChunYen-Chen Jun 5, 2024
93f9b4e
Add the changes of ELBDM
ChunYen-Chen Jun 5, 2024
3f179ef
Record AngMom_All and Mom_All for ELBDM
ChunYen-Chen Jun 5, 2024
2bd6f55
Change HDF5 version
ChunYen-Chen Jun 5, 2024
8f582f9
Add version check.
ChunYen-Chen Jun 6, 2024
d737d92
Add a loaded check
ChunYen-Chen Jun 6, 2024
144ff91
Force record reference value once
ChunYen-Chen Jun 25, 2024
ed73022
Free memory and update comment
ChunYen-Chen Jul 5, 2024
0325af5
Remove OPT__CK_CONSERVATION check
ChunYen-Chen Jul 5, 2024
8fdd009
Rename variables and bug fix.
ChunYen-Chen Jul 6, 2024
2e5d069
Remove debug message
ChunYen-Chen Jul 12, 2024
4500ed5
Always record ANGMOM_ORIGIN_*
ChunYen-Chen Jul 12, 2024
f4ec797
Merge branch 'hyschive:main' into save_conserved_vars
ChunYen-Chen Jul 16, 2024
4c1db06
Remove comments
ChunYen-Chen Aug 1, 2024
30026ec
Merge branch 'save_conserved_vars' of https://github.com/ChunYen-Chen…
ChunYen-Chen Aug 1, 2024
b440e89
Merge branch 'master' into save_conserved_vars
ChunYen-Chen Nov 10, 2024
1101036
Merge branch 'master' into save_conserved_vars
ChunYen-Chen Dec 11, 2024
24a7a6c
Merge branch 'master' into save_conserved_vars
ChunYen-Chen Jan 16, 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
31 changes: 30 additions & 1 deletion include/Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,35 @@ extern OptLohnerForm_t OPT__FLAG_LOHNER_FORM;
extern OptCorrAfterSync_t OPT__CORR_AFTER_ALL_SYNC;
extern OptTimeStepLevel_t OPT__DT_LEVEL;

extern bool ConservedRefLoaded;
extern double Time_ConservedRef;
#if ( MODEL == HYDRO )
#ifdef MHD
extern double Fluid_ConservedRef[12+NCOMP_PASSIVE+1];
#else
extern double Fluid_ConservedRef[11+NCOMP_PASSIVE+1];
#endif
#elif ( MODEL == ELBDM )
extern double Fluid_ConservedRef[11+NCOMP_PASSIVE+1];
#endif

extern double CoM_Gas_ConservedRef[3];

#ifdef MASSIVE_PARTICLES
extern double Mass_Par_ConservedRef;
extern double CoMX_Par_ConservedRef, CoMY_Par_ConservedRef, CoMZ_Par_ConservedRef;
extern double MomX_Par_ConservedRef, MomY_Par_ConservedRef, MomZ_Par_ConservedRef;
extern double AngMomX_Par_ConservedRef, AngMomY_Par_ConservedRef, AngMomZ_Par_ConservedRef;
extern double Ekin_Par_ConservedRef, Eint_Par_ConservedRef, Epot_Par_ConservedRef, Etot_Par_ConservedRef;
#if ( MODEL != PAR_ONLY )
extern double Mass_All_ConservedRef;
extern double CoMX_All_ConservedRef, CoMY_All_ConservedRef, CoMZ_All_ConservedRef;
extern double MomX_All_ConservedRef, MomY_All_ConservedRef, MomZ_All_ConservedRef;
extern double AngMomX_All_ConservedRef, AngMomY_All_ConservedRef, AngMomZ_All_ConservedRef;
extern double Etot_All_ConservedRef;
#endif // if ( MODEL != PAR_ONLY )
#endif // #ifdef MASSIVE_PARTICLES



// 2. global variables for different applications
Expand Down Expand Up @@ -343,7 +372,7 @@ extern int FB_ParaBuf;
// =======================================================================================================
#ifdef COSMIC_RAY
extern double GAMMA_CR;
extern bool OPT__FLAG_CRAY, OPT__FLAG_LOHNER_CRAY;
extern bool OPT__FLAG_CRAY, OPT__FLAG_LOHNER_CRAY;
extern double FlagTable_CRay[NLEVEL-1];
#endif

Expand Down
71 changes: 71 additions & 0 deletions include/HDF5_Typedef.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,77 @@ struct KeyInfo_t
char *GitCommit;
long UniqueDataID;

// conserved variables
double Time_ConservedRef;
# if ( MODEL == HYDRO )
double Mass_Gas_ConservedRef;
double CoMX_Gas_ConservedRef;
double CoMY_Gas_ConservedRef;
double CoMZ_Gas_ConservedRef;
double MomX_Gas_ConservedRef;
double MomY_Gas_ConservedRef;
double MomZ_Gas_ConservedRef;
double AngMomX_Gas_ConservedRef;
double AngMomY_Gas_ConservedRef;
double AngMomZ_Gas_ConservedRef;
double Ekin_Gas_ConservedRef;
double Eint_Gas_ConservedRef;
double Epot_Gas_ConservedRef;
# ifdef MHD
double Emag_Gas_ConservedRef;
# endif
double Etot_Gas_ConservedRef;
# elif ( MODEL == ELBDM )
double Mass_Psi_ConservedRef;
double CoMX_Psi_ConservedRef;
double CoMY_Psi_ConservedRef;
double CoMZ_Psi_ConservedRef;
double MomX_Psi_ConservedRef;
double MomY_Psi_ConservedRef;
double MomZ_Psi_ConservedRef;
double AngMomX_Psi_ConservedRef;
double AngMomY_Psi_ConservedRef;
double AngMomZ_Psi_ConservedRef;
double Ekin_Psi_ConservedRef;
double Epot_Psi_ConservedRef;
double Esel_Psi_ConservedRef;
double Etot_Psi_ConservedRef;
# endif

# if ( NCOMP_PASSIVE > 0 )
double Passive_ConservedRef[NCOMP_PASSIVE];
double Passive_Sum_ConservedRef;
# endif

# ifdef MASSIVE_PARTICLES
double Mass_Par_ConservedRef;
double CoMX_Par_ConservedRef;
double CoMY_Par_ConservedRef;
double CoMZ_Par_ConservedRef;
double MomX_Par_ConservedRef;
double MomY_Par_ConservedRef;
double MomZ_Par_ConservedRef;
double AngMomX_Par_ConservedRef;
double AngMomY_Par_ConservedRef;
double AngMomZ_Par_ConservedRef;
double Ekin_Par_ConservedRef;
double Epot_Par_ConservedRef;
double Etot_Par_ConservedRef;
# if ( MODEL != PAR_ONLY )
double Mass_All_ConservedRef;
double CoMX_All_ConservedRef;
double CoMY_All_ConservedRef;
double CoMZ_All_ConservedRef;
double MomX_All_ConservedRef;
double MomY_All_ConservedRef;
double MomZ_All_ConservedRef;
double AngMomX_All_ConservedRef;
double AngMomY_All_ConservedRef;
double AngMomZ_All_ConservedRef;
double Etot_All_ConservedRef;
# endif // #if ( MODEL != PAR_ONLY )
# endif // #ifdef MASSIVE_PARTICLES

}; // struct KeyInfo_t


Expand Down
26 changes: 13 additions & 13 deletions src/Auxiliary/Aux_Check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,45 @@ void Aux_Check( )
{

if ( OPT__CK_REFINE )
for (int lv=0; lv<NLEVEL-1; lv++) Aux_Check_Refinement( lv, "DIAGNOSIS" );
for (int lv=0; lv<NLEVEL-1; lv++) Aux_Check_Refinement( lv, "DIAGNOSIS" );

if ( OPT__CK_PROPER_NESTING )
for (int lv=1; lv<NLEVEL; lv++) Aux_Check_ProperNesting( lv, "DIAGNOSIS" );
for (int lv=1; lv<NLEVEL; lv++) Aux_Check_ProperNesting( lv, "DIAGNOSIS" );

if ( OPT__CK_CONSERVATION ) Aux_Check_Conservation( "DIAGNOSIS" );
if ( OPT__CK_CONSERVATION || !ConservedRefLoaded ) Aux_Check_Conservation( "DIAGNOSIS" );

# if ( NCOMP_PASSIVE > 0 )
if ( OPT__CK_NORMALIZE_PASSIVE )
for (int lv=0; lv<NLEVEL; lv++) Aux_Check_NormalizePassive( lv, "DIAGNOSIS" );
for (int lv=0; lv<NLEVEL; lv++) Aux_Check_NormalizePassive( lv, "DIAGNOSIS" );
# endif

if ( OPT__CK_RESTRICT )
for (int lv=0; lv<NLEVEL-1; lv++) Aux_Check_Restrict( lv, "DIAGNOSIS" );
for (int lv=0; lv<NLEVEL-1; lv++) Aux_Check_Restrict( lv, "DIAGNOSIS" );

if ( OPT__CK_FINITE )
for (int lv=0; lv<NLEVEL; lv++) Aux_Check_Finite( lv, "DIAGNOSIS" );
for (int lv=0; lv<NLEVEL; lv++) Aux_Check_Finite( lv, "DIAGNOSIS" );

if ( OPT__CK_PATCH_ALLOCATE )
for (int lv=0; lv<NLEVEL; lv++) Aux_Check_PatchAllocate( lv, "DIAGNOSIS" );
for (int lv=0; lv<NLEVEL; lv++) Aux_Check_PatchAllocate( lv, "DIAGNOSIS" );

if ( OPT__CK_FLUX_ALLOCATE )
for (int lv=0; lv<NLEVEL-1; lv++) Aux_Check_FluxAllocate( lv, "DIAGNOSIS" );
for (int lv=0; lv<NLEVEL-1; lv++) Aux_Check_FluxAllocate( lv, "DIAGNOSIS" );

# if ( MODEL == HYDRO )
if ( OPT__CK_NEGATIVE )
for (int lv=0; lv<NLEVEL; lv++) Hydro_Aux_Check_Negative( lv, OPT__CK_NEGATIVE, "DIAGNOSIS" );
for (int lv=0; lv<NLEVEL; lv++) Hydro_Aux_Check_Negative( lv, OPT__CK_NEGATIVE, "DIAGNOSIS" );
# endif

# ifdef PARTICLE
if ( OPT__CK_PARTICLE ) Par_Aux_Check_Particle( "DIAGNOSIS" );
if ( OPT__CK_PARTICLE ) Par_Aux_Check_Particle( "DIAGNOSIS" );
# endif

# ifdef MHD
if ( OPT__CK_INTERFACE_B ) MHD_Aux_Check_InterfaceB( "DIAGNOSIS" );
if ( OPT__CK_INTERFACE_B ) MHD_Aux_Check_InterfaceB( "DIAGNOSIS" );

if ( OPT__CK_DIVERGENCE_B ) MHD_Aux_Check_DivergenceB( OPT__CK_DIVERGENCE_B==2, "DIAGNOSIS" );
if ( OPT__CK_DIVERGENCE_B ) MHD_Aux_Check_DivergenceB( OPT__CK_DIVERGENCE_B==2, "DIAGNOSIS" );
# endif

if ( OPT__CK_MEMFREE != 0.0 ) Aux_Check_MemFree( OPT__CK_MEMFREE, "DIAGNOSIS" );
if ( OPT__CK_MEMFREE != 0.0 ) Aux_Check_MemFree( OPT__CK_MEMFREE, "DIAGNOSIS" );

} // FUNCTION : Aux_Check
Loading