Skip to content

Commit fd3326d

Browse files
committed
Converter: corr. bug hdffsdm
1 parent e65c141 commit fd3326d

File tree

2 files changed

+26
-63
lines changed

2 files changed

+26
-63
lines changed

Cassiopee/Connector/Connector/AMR.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def prepareAMRData(t_case, t, IBM_parameters=None, check=False, dim=3, localDir=
149149
Cmpi.trace("Extract front faces of IBM target points [end] ", master=True, cpu=False)
150150

151151
Cmpi.trace(" Removing blanked cells [start]", master=True, cpu=False)
152-
t = P.selectCells(t,"{cellN}==1.", strict=1)
152+
t = P.selectCells(t, "{cellN}==1.", strict=1)
153153
Internal._rmNodesFromName(t,"FlowSolution")
154154
for node in Internal.getNodesFromType(t, "Elements_t"):
155155
if node[0] != "GridElements":
@@ -207,14 +207,14 @@ def prepareAMRData(t_case, t, IBM_parameters=None, check=False, dim=3, localDir=
207207

208208
if VPM == False:
209209
Cmpi.trace(" Extracting front of the donor points [start]", master=True, cpu=False)
210-
if frontTypeDP=="1":
210+
if frontTypeDP == "1":
211211
frontDP_gath = extractFrontDP(t, frontIP_gath, dim, sym3D, check, localDir=localDir)
212212
else:
213213
frontDP_gath = None
214214
del frontIP_gath
215215
Cmpi.trace(" Extracting front of the donor points [end] ", master=True, cpu=False)
216216

217-
if dimfrontIP>0:
217+
if dimfrontIP > 0:
218218
if IBM_parameters["spatial discretization"]["type"] == "FV":
219219
Cmpi.trace(" Computing normals via project ortho [start]", master=False, cpu=False)
220220
_computeNormalsViaProjectOrtho__(frontIP, tb2)
@@ -409,18 +409,18 @@ def extractIBMPoints(tb, frontIP, frontIP_C, frontDP, bbo, IBM_parameters, check
409409
nzonesR = len(allInterpPts)
410410

411411
nameZone = ['IBM', 'Wall', 'Image']
412-
tLocal3 = C.newPyTree(nameZone)
413-
tLocal4 = C.newPyTree(nameZone)
414-
isWrite3 = 0
415-
isWrite4 = 0
412+
tLocal3 = C.newPyTree(nameZone)
413+
tLocal4 = C.newPyTree(nameZone)
414+
isWrite3 = 0
415+
isWrite4 = 0
416416
allProjectPts = res[3]
417417
allProjectPts = Converter.extractVars(allProjectPts, ['ProjectionType'])
418418
outputProjection3 = [[],[],[],[],[],[],[],[],[]]
419419
outputProjection4 = [[],[],[],[],[],[],[],[],[]]
420420
for noz in range(nzonesR):
421421
arrayLocal = allProjectPts[noz][1][0]
422-
type_3 = numpy.count_nonzero(arrayLocal==3)
423-
type_4 = numpy.count_nonzero(arrayLocal==4)
422+
type_3 = numpy.count_nonzero(arrayLocal==3)
423+
type_4 = numpy.count_nonzero(arrayLocal==4)
424424

425425
if type_3 > 0: X_IBM._prepOutputProject__(outputProjection3, 3, arrayLocal, allCorrectedPts[noz][1], allWallPts[noz][1], allInterpPts[noz][1])
426426
if type_4 > 0: X_IBM._prepOutputProject__(outputProjection4, 4, arrayLocal, allCorrectedPts[noz][1], allWallPts[noz][1], allInterpPts[noz][1])
@@ -995,7 +995,7 @@ def prepareAMRIBM(tb, levelMax, vmins, dim, IBM_parameters, toffset=None, check=
995995

996996
Cmpi.trace('AMR Mesh Dist2Walls...start', master=True)
997997
tb2 = Internal.copyTree(tb)
998-
if dim == 2:tb2 = T.addkplane(tb)
998+
if dim == 2: tb2 = T.addkplane(tb)
999999
else:
10001000
baseSYM = Internal.getNodesFromName1(tb2, "SYM")
10011001
if baseSYM:
@@ -1009,17 +1009,17 @@ def prepareAMRIBM(tb, levelMax, vmins, dim, IBM_parameters, toffset=None, check=
10091009

10101010
if OutputAMRMesh: Cmpi.convertPyTree2File(t_AMR, localDir+'tAMRMesh.cgns')
10111011
## Ncells output
1012-
Ncells=C.getNCells(t_AMR)
1013-
Ncells=Cmpi.allreduce(Ncells, op=Cmpi.SUM)
1012+
Ncells = C.getNCells(t_AMR)
1013+
Ncells = Cmpi.allreduce(Ncells, op=Cmpi.SUM)
10141014
if Cmpi.master: print("[MESH GEN.] Number of Cells::%ge06"%(Ncells/1e06), flush=True)
10151015

10161016
## ==================
10171017
## ==== IBM Prep ====
10181018
## ==================
10191019
t_AMR = prepareAMRData(tb, t_AMR, IBM_parameters=IBM_parameters, dim=dim, check=check, localDir=localDir, forceAlignment=forceAlignment)
10201020
## Ncells output
1021-
Ncells=C.getNCells(t_AMR)
1022-
Ncells=Cmpi.allreduce(Ncells, op=Cmpi.SUM)
1021+
Ncells = C.getNCells(t_AMR)
1022+
Ncells = Cmpi.allreduce(Ncells, op=Cmpi.SUM)
10231023
if Cmpi.master: print("[IBM PREP.] Number of Cells::%ge06"%(Ncells/1e06), flush=True)
10241024

10251025
if fileName is not None:

Cassiopee/Converter/Converter/IO/GenIO_hdffsdm.cpp

Lines changed: 12 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,8 @@ E_Int K_IO::GenIO::hdffsdmread(char* file, PyObject*& tree)
666666

667667
// Create FlowSolution
668668
if (H5Lexists(fid, "/FS:Mesh/UnstructuredCells/Datasets/AugState", H5P_DEFAULT) > 0 ||
669-
H5Lexists(fid, "/FS:Mesh/UnstructuredCells/Datasets/State", H5P_DEFAULT) > 0)
669+
H5Lexists(fid, "/FS:Mesh/UnstructuredCells/Datasets/State", H5P_DEFAULT) > 0 ||
670+
H5Lexists(fid, "/FS:Mesh/UnstructuredCells/Datasets/CellAvgState", H5P_DEFAULT) > 0)
670671
{
671672
// Create FlowSolution#Centers and GridLocation
672673
PyObject* childrenFS = PyList_New(0);
@@ -680,60 +681,22 @@ E_Int K_IO::GenIO::hdffsdmread(char* file, PyObject*& tree)
680681
PyObject* gl = Py_BuildValue("[sOOs]", "GridLocation", r14, children14, "GridLocation_t");
681682
PyList_Append(childrenFS, gl); Py_DECREF(gl);
682683

684+
node = 0;
683685
if (H5Lexists(fid, "/FS:Mesh/UnstructuredCells/Datasets/AugState", H5P_DEFAULT) > 0)
684686
{
685687
node = H5Gopen(fid, "/FS:Mesh/UnstructuredCells/Datasets/AugState", H5P_DEFAULT);
686-
hid_t aid = H5Aopen_by_name(node, ".", "NumberOfVariables", H5P_DEFAULT, H5P_DEFAULT);
687-
E_Int nvars = 0;
688-
H5Aread(aid, H5T_NATIVE_INT, &nvars);
689-
H5Aclose(aid);
690-
aid = H5Aopen_by_name(node, ".", "NumberOfCells", H5P_DEFAULT, H5P_DEFAULT);
691-
E_Int ncells = 0;
692-
H5Aread(aid, H5T_NATIVE_INT, &ncells);
693-
H5Aclose(aid);
694-
//printf("nvars = %d, ncells=%d\n", nvars, ncells);
695-
696-
dims[0] = ncells; dims[1] = nvars;
697-
did = H5Screate_simple(2, dims, NULL);
698-
tid = H5Tcopy(H5T_NATIVE_DOUBLE); H5Tset_precision(tid, 64);
699-
hid_t vid = H5Dopen2(node, "Values", H5P_DEFAULT);
700-
701-
hsize_t start[2]; hsize_t scount[2];
702-
char name[35]; char name2[76];
703-
for (E_Int n = 0; n < nvars; n++)
704-
{
705-
// Read name
706-
sprintf(name, "Variable" SF_D_, n);
707-
hid_t gid2 = H5Gopen(node, name, H5P_DEFAULT);
708-
aid = H5Aopen_by_name(gid2, ".", "Name", H5P_DEFAULT, H5P_DEFAULT);
709-
hid_t atype = H5Aget_type(aid);
710-
size = H5Tget_size(atype);
711-
H5Aread(aid, atype, name2);
712-
name2[size] = '\0';
713-
//H5Aread(aid, H5T_C_S1, name2);
714-
H5Aclose(aid); H5Gclose(gid2);
715-
716-
// Read values (partial)
717-
npy_dim_vals[0] = ncells;
718-
hid_t sid = H5Scopy(did);
719-
start[0] = 0; start[1] = n;
720-
scount[0] = ncells; scount[1] = 1;
721-
H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, NULL, scount, NULL);
722-
hid_t memspace = H5Screate_simple(2, scount, NULL);
723-
PyArrayObject* f = (PyArrayObject*)PyArray_EMPTY(1, &npy_dim_vals[0], NPY_FLOAT64, 1);
724-
E_Float* fp = (E_Float*)PyArray_DATA(f);
725-
H5Dread(vid, tid, memspace, sid, H5P_DEFAULT, fp);
726-
PyObject* fc = PyList_New(0);
727-
PyObject* fl = Py_BuildValue("[sOOs]", name2, f, fc, "DataArray_t");
728-
PyList_Append(childrenFS, fl); Py_DECREF(fl);
729-
}
730-
H5Dclose(vid); H5Sclose(did);
731-
H5Gclose(node);
688+
}
689+
else if (H5Lexists(fid, "/FS:Mesh/UnstructuredCells/Datasets/CellAvgState", H5P_DEFAULT) > 0)
690+
{
691+
node = H5Gopen(fid, "/FS:Mesh/UnstructuredCells/Datasets/CellAvgState", H5P_DEFAULT);
692+
}
693+
else if (H5Lexists(fid, "/FS:Mesh/UnstructuredCells/Datasets/State", H5P_DEFAULT) > 0)
694+
{
695+
node = H5Gopen(fid, "/FS:Mesh/UnstructuredCells/Datasets/State", H5P_DEFAULT);
732696
}
733697

734-
if (H5Lexists(fid, "/FS:Mesh/UnstructuredCells/Datasets/State", H5P_DEFAULT) > 0)
698+
if (node != 0)
735699
{
736-
node = H5Gopen(fid, "/FS:Mesh/UnstructuredCells/Datasets/State", H5P_DEFAULT);
737700
hid_t aid = H5Aopen_by_name(node, ".", "NumberOfVariables", H5P_DEFAULT, H5P_DEFAULT);
738701
E_Int nvars = 0;
739702
H5Aread(aid, H5T_NATIVE_INT, &nvars);

0 commit comments

Comments
 (0)