Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
hfhsieh committed Aug 2, 2024
1 parent 6e36703 commit 1b36ac0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
9 changes: 8 additions & 1 deletion example/test_problem/Hydro/ParticleTest/check_mesh2tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@


import re
from glob import glob

import h5py
import numpy as np
Expand Down Expand Up @@ -73,7 +74,10 @@ def comp_velx(ParX, ParY, Center, Ang_Freq):


### load data
fn_in = "Data_000000"
fn_list = glob("Data_" + "[0-9]" * 6)
fn_in = sorted(fn_list)[-1] # use the final snapshot
print("Loading data in {}".format(fn_in))

hdf_data = h5py.File(fn_in, "r")

field_par = ["ParPosX", "ParPosY", "ParType"]
Expand All @@ -84,6 +88,8 @@ def comp_velx(ParX, ParY, Center, Ang_Freq):
cmd = "{} = hdf_data['Particle']['{}'][:]".format(key, key)
exec(cmd)

time_phys = hdf_data["Info"]["KeyInfo"]["Time"][0]

hdf_data.close()


Expand Down Expand Up @@ -168,6 +174,7 @@ def comp_velx(ParX, ParY, Center, Ang_Freq):
ax.set_xlabel("Radius of Tracer Particles")
ax.set_ylabel("Relative Difference")

fig.suptitle("Time = {}".format(time_phys))
fig.tight_layout()
plt.savefig("check_mesh2tracer.png", bbox_inches = "tight")
plt.close()
6 changes: 3 additions & 3 deletions src/Output/Output_DumpData_Total_HDF5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ void Output_DumpData_Total_HDF5( const char *FileName )
// --> solution: we can output a fixed number of particles at a time (see Output_DumpData_Total.cpp)
long (*NParLv_EachRank)[NLEVEL] = new long [MPI_NRank][NLEVEL]; // number of particles at each level in each rank
real_par (*ParBuf1v1Lv) = NULL; // buffer storing the data of one particle attribute at one level
int PAR_NATT_MESH = amr->Par->Mesh_Attr_Num;
int Par_NAtt_Mesh = amr->Par->Mesh_Attr_Num;

long GParID_Offset[NLEVEL]; // GParID = global particle index (==> unique for each particle)
long NParLv_AllRank[NLEVEL];
Expand Down Expand Up @@ -1283,7 +1283,7 @@ void Output_DumpData_Total_HDF5( const char *FileName )
if ( H5_GroupID_Particle < 0 ) Aux_Error( ERROR_INFO, "failed to create the group \"%s\" !!\n", "Particle" );

// create the datasets of all particle attributes
for (int v=0; v<PAR_NATT_STORED+PAR_NATT_MESH; v++)
for (int v=0; v<PAR_NATT_STORED+Par_NAtt_Mesh; v++)
{
char *ParLabel = ( v < PAR_NATT_STORED ) ? ParAttLabel[v] : amr->Par->Mesh_Attr_Label[v - PAR_NATT_STORED];

Expand Down Expand Up @@ -1333,7 +1333,7 @@ void Output_DumpData_Total_HDF5( const char *FileName )

// output one particle attribute at one level in one rank at a time
// --> skip the last PAR_NATT_UNSTORED attributes since we do not want to store them on disk
for (int v=0; v<PAR_NATT_STORED+PAR_NATT_MESH; v++)
for (int v=0; v<PAR_NATT_STORED+Par_NAtt_Mesh; v++)
{
// 6-3-3. collect particle data from all patches at the current target level
NParInBuf = 0;
Expand Down
16 changes: 8 additions & 8 deletions src/Particle/Par_Output_TracerParticle_Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@ void Par_Output_TracerParticle_Mesh()

for (int PID=PID0; PID<PID0+8; PID++)
{
if ( amr->patch[0][lv][PID]->NParType[(int)PTYPE_TRACER] > 0 ) GotYou = true;

if ( GotYou ) break;
if ( amr->patch[0][lv][PID]->NParType[(int)PTYPE_TRACER] > 0 )
{
GotYou = true;
break;
}
}

// nothing to do if there are no target tracer particles in the target patch group
Expand All @@ -110,7 +112,7 @@ void Par_Output_TracerParticle_Mesh()
{
const long TVar = ParAttrIdx[v];

// 2. prepare the mesh data for the patch group with particles (need NSIDE_26 for ParGhost>0 )
// 2. prepare the mesh data for the patch group with particles (need NSIDE_26 for ParGhost>0)
if ( TVar & AllVar_PreparePatch )
Prepare_PatchData( lv, TimeNew, Var, NULL, ParGhost, 1, &PID0, TVar, _NONE,
OPT__FLU_INT_SCHEME, INT_NONE, UNIT_PATCH, NSIDE_26, IntPhase_No,
Expand Down Expand Up @@ -141,8 +143,7 @@ void Par_Output_TracerParticle_Mesh()
{
ParID = amr->patch[0][lv][PID]->ParList[p];

if ( ParType[ParID] != PTYPE_TRACER )
continue;
if ( ParType[ParID] != PTYPE_TRACER ) continue;

for (int d=0; d<3; d++) InterpParPos[d][p] = ParPos[d][ParID];
}
Expand All @@ -157,8 +158,7 @@ void Par_Output_TracerParticle_Mesh()
{
ParID = amr->patch[0][lv][PID]->ParList[p];

if ( ParType[ParID] != PTYPE_TRACER )
continue;
if ( ParType[ParID] != PTYPE_TRACER ) continue;

amr->Par->Mesh_Attr[v][ParID] = Var_Temp[p];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Particle/Par_UpdateTracerParticle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void Par_UpdateTracerParticle( const int lv, const double TimeNew, const double
if ( !GotYou ) continue;


// 2. prepare the velocity data for the patch group with particles (need NSIDE_26 for ParGhost>0 )
// 2. prepare the velocity data for the patch group with particles (need NSIDE_26 for ParGhost>0)
Prepare_PatchData( lv, TimeNew, VelX, NULL, ParGhost, 1, &PID0, _VELX, _NONE,
OPT__FLU_INT_SCHEME, INT_NONE, UNIT_PATCH, NSIDE_26, IntPhase_No,
OPT__BC_FLU, BC_POT_NONE, MinDens_No, MinPres_No, MinTemp_No, MinEntr_No, DE_Consistency_No );
Expand Down

0 comments on commit 1b36ac0

Please sign in to comment.