You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working on extracting planes from a 3D tree, where only a subset of processes contain the relevant plane data. Unfortunately, when I attempt to save the planes to a single file, some blocks are missing.
We suspect that this issue arises because Cmpi is being called for all processes, even though the data is only available on a few. This occurs in a cylindrical case using the tranche strategy.
Is there a way to restrict Cmpi to only the processes that contain the relevant data?
Here is my routine:
defsave_planes(t, planes_fldr, snap_num, rank=0, hlo_rhs=0, time_dict=None, mpi=False, axes=['z'], target=0):
n=time_dict["n"]
zones=Int.getZones(t)
if"z"inaxes:
coords=getValueFromName(zones[0], "CoordinateZ")
if"x"inaxes:
coords=getValueFromName(zones[0], "CoordinateX")
if"y"inaxes:
coords=getValueFromName(zones[0], "CoordinateY")
# Check if target is within the range of this processor's domainifcoords[hlo_rhs,hlo_rhs,0] <=target<=coords[hlo_rhs,hlo_rhs,-1]:
# Find the largest index where z <= targetarray=coords[hlo_rhs,hlo_rhs,:] #-> [0. 0.025 0.05 0.075 0.1 0.125]p=np.argwhere(array<=target)[-1][0] #--> [[0][1][2]]# Extract plane at this index for each zoneplane= []
forzinzones:
if"x"inaxes: # (imin,jmin,kmin), (imax,jmax,kmax)plane.append(T.subzone(z, (p, 1, 1), (p, -1, -1)))
elif"y"inaxes:
plane.append(T.subzone(z, (1, p, 1), (-1, p, -1)))
elif"z"inaxes:
plane.append(T.subzone(z, (1, 1, p), (-1, -1, p)))
one_file_per_time=Falseifone_file_per_time:
file_name=f"{planes_fldr}plane_{axes[0]}_{target}_{rank}.cgns"base_name=f"t{n}"# Check if the file exists first instead of using try-exceptifos.path.isfile(file_name):
# File exists -> t > 0plane_tree=C.convertFile2PyTree(file_name)
plane_tree=C.addBase2PyTree(plane_tree, base_name)
else:
# File doesn't exist, create from scratchensure_folder_exists(planes_fldr, rank=rankifmpielseNone)
plane_tree=C.newPyTree([base_name]) # -> t0C._addState(plane_tree, "EquationDimension", 2)
# base_node = Int.getNodeFromName(t, base_name)# Get the base node to add planes to#for z in Int.getZones(plane_tree):Int._append(plane_tree, plane, base_name)
# ISSUE HERE !#Cmpi.convertPyTree2File(plane_tree, file_name) # --> single file (missing blocks)#C.convertPyTree2File(plane_tree, file_name) # works but makes a lot of filesprint0(rank, f"Finished saving plane {axes[0]}_{target} to {file_name}")
else: # a folder per time and one file per zone (not ideal)# lets create a folder structureensure_folder_exists(planes_fldr, rank=rankifmpielseNone)
# Create a more organized folder structure# Format: planes_fldr/axis_target/t{n}/axis_folder=f"{planes_fldr}{axes[0]}_{target}/"ensure_folder_exists(axis_folder, rank=rankifmpielseNone)
time_folder=f"{axis_folder}t{n}/"ensure_folder_exists(time_folder, rank=rankifmpielseNone)
# Save the file in the organized folder structurefile_name=f"{time_folder}plane_{rank}.cgns"C.convertPyTree2File(plane, file_name)
print0(rank, f"Saved plane {axes[0]}_{target} at t{n} to {file_name}", flush=True)
The text was updated successfully, but these errors were encountered:
Hello,
I am working on extracting planes from a 3D tree, where only a subset of processes contain the relevant plane data. Unfortunately, when I attempt to save the planes to a single file, some blocks are missing.
We suspect that this issue arises because Cmpi is being called for all processes, even though the data is only available on a few. This occurs in a cylindrical case using the tranche strategy.
Is there a way to restrict Cmpi to only the processes that contain the relevant data?
Here is my routine:
The text was updated successfully, but these errors were encountered: