Skip to content

Commit

Permalink
Merge pull request #51 from vincentcasseau/main
Browse files Browse the repository at this point in the history
Converter: cleaning (close) mesh at the end of convertArray2NGon
  • Loading branch information
vincentcasseau authored Jun 18, 2024
2 parents 3d58b2a + d68533b commit 986376f
Show file tree
Hide file tree
Showing 30 changed files with 61 additions and 71 deletions.
4 changes: 2 additions & 2 deletions Cassiopee/Connector/test/applyBCOverlapsPT_t2.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
# NGON
a = G.cylinder((0,0,0), 1., 1.5, 360., 0., 1., (30,30,10))
s = T.subzone(a,(1,30,1),(-1,-1,-1))
s = C.convertArray2NGon(s); s = G.close(s, 1.e-12)
a = C.convertArray2NGon(a); a = G.close(a, 1.e-12)
s = C.convertArray2NGon(s)
a = C.convertArray2NGon(a)
a = C.addBC2Zone(a, 'overlap1', 'BCOverlap', subzone=s)
C._initVars(a, 'Density', 1.)
t = C.newPyTree(['Base',a])
Expand Down
9 changes: 7 additions & 2 deletions Cassiopee/Converter/Converter/convertStruct2NGon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,12 @@ PyObject* K_CONVERTER::convertStruct2NGon(PyObject* self, PyObject* args)
for (E_Int i = 0; i < npts; i++) f2p[i] = fp[i];
}
}

RELEASESHAREDS(array, f);
RELEASESHAREDU(tpl, f2, cn2);

// Clean connectivity
E_Float tol = 1.e-12;
tpl = K_CONNECT::V_cleanConnectivity(varString, *f2, *cn2, "NGON", tol);
delete f2; delete cn2;
return tpl;
}
}
8 changes: 6 additions & 2 deletions Cassiopee/Converter/Converter/convertUnstruct2NGon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ PyObject* K_CONVERTER::convertUnstruct2NGon(PyObject* self, PyObject* args)
}

RELEASESHAREDU(array, f, cnl);
RELEASESHAREDU(tpl, f2, cn2);

// Clean connectivity
E_Float tol = 1.e-12;
tpl = K_CONNECT::V_cleanConnectivity(varString, *f2, *cn2, "NGON", tol);
delete f2; delete cn2;
return tpl;
}
}
9 changes: 3 additions & 6 deletions Cassiopee/Converter/test/addGhostCellsPT_t2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
a = D.sphere((0,0,0),1,N=10)
dhk = G.cart((0,0,0),(0.1,1,1),(2,1,1))
a = G.addNormalLayers(a,dhk)
a = C.convertArray2NGon(a); a = G.close(a, 1.e-12)
a = G.close(a)
a = C.convertArray2NGon(a)
a = C.initVars(a, '{centers:F}={centers:CoordinateX}')
a = C.initVars(a,'{Density}={CoordinateX}')
t = C.newPyTree(['Base',a])
Expand All @@ -21,8 +20,7 @@
a = D.sphere((0,0,0),1,N=10)
dhk = G.cart((0,0,0),(0.1,1,1),(2,1,1))
a = G.addNormalLayers(a,dhk)
a = C.convertArray2NGon(a); a = G.close(a, 1.e-12)
a = G.close(a)
a = C.convertArray2NGon(a)
a = C.initVars(a, '{centers:F}={centers:CoordinateX}**2')
a = C.initVars(a,'{Density}=3*{CoordinateX}+2*{CoordinateY}')
t = C.newPyTree(['Base',a])
Expand All @@ -31,8 +29,7 @@

# 2D sans frontieres exterieures
a = D.sphere((0,0,0),1,N=10)
a = C.convertArray2NGon(a); a = G.close(a, 1.e-12)
#a = G.close(a)
a = C.convertArray2NGon(a)
a = C.initVars(a, '{centers:F}={centers:CoordinateX}**2')
a = C.initVars(a,'{Density}=3*{CoordinateX}+2*{CoordinateY}')
t = C.newPyTree(['Base',a])
Expand Down
7 changes: 1 addition & 6 deletions Cassiopee/Converter/test/convertArray2NGonPT_t1.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# - convertArray2NGon(pyTree) -
import Generator.PyTree as G
import Converter.PyTree as C
import KCore.test as test

def convertArray2NGon(a):
a = C.convertArray2NGon(a); a = G.close(a, tol=1e-12)
return a

test.stdTestT(convertArray2NGon)
test.stdTestT(C.convertArray2NGon)
7 changes: 1 addition & 6 deletions Cassiopee/Converter/test/convertArray2NGonPT_t2.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# - convertArray2NGon(pyTree) -
import Generator.PyTree as G
import Converter.PyTree as C
import KCore.test as test

def convertArray2NGon(a):
a = C.convertArray2NGon(a); a = G.close(a, tol=1e-12)
return a

test.stdTestT(convertArray2NGon,0)
test.stdTestT(C.convertArray2NGon,0)
3 changes: 1 addition & 2 deletions Cassiopee/Converter/test/identifyFaces_t1.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# - identifyFaces (array) -
import Generator as G
import Converter as C
import Post as P
import KCore.test as test

def identify(a):
a = C.convertArray2NGon(a); a = G.close(a, tol=1e-12)
a = C.convertArray2NGon(a)
f = P.exteriorElts(a)
if isinstance(a[0], list): a=a[0]
hook = C.createHook(a, function='faceCenters')
Expand Down
2 changes: 1 addition & 1 deletion Cassiopee/Converter/test/identifySolutionsPT_t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
test.testT([a2],2)

# NGON
a1 = C.convertArray2NGon(a); a1 = G.close(a1, 1.e-12)
a1 = C.convertArray2NGon(a)
a2 = C.identifySolutions(a1,m,hookN,hookC,tol=1000.)
test.testT([a2],3)
2 changes: 1 addition & 1 deletion Cassiopee/Converter/test/identifySolutionsPT_t2.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
test.testT([a2],2)

# NGON
a1 = C.convertArray2NGon(a); a1 = G.close(a1, 1.e-12)
a1 = C.convertArray2NGon(a)
a2 = C.identifySolutions(a1, m, hookN, hookC, tol=1000.)
test.testT([a2],3)
2 changes: 1 addition & 1 deletion Cassiopee/Converter/test/identifySolutionsPT_t3.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
test.testT([a2],2)

# NGON
a1 = C.convertArray2NGon(a); a1 = G.close(a1, 1.e-12)
a1 = C.convertArray2NGon(a)
a2 = C.identifySolutions(a1, m, hookN, hookC, tol=1000.)
test.testT([a2],3)
5 changes: 2 additions & 3 deletions Cassiopee/Converter/test/identifySolutions_t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
a2 = C.identifySolutions(a1,sol,hook,tol=1000.)
test.testA([a2],2)
# RCV NGON
a1 = C.convertArray2NGon(a); a1 = G.close(a1, 1.e-12)
a1 = C.convertArray2NGon(a)
a2 = C.identifySolutions(a1,sol,hook,tol=1000.)
test.testA([a2],3)
#
Expand All @@ -35,7 +35,6 @@
m[2] = C.convertArray2Tetra(m[2])
m[10] = C.convertArray2Hexa(m[10])
m[nzones-1] = C.convertArray2NGon(m[nzones-1])
m[nzones-1] = G.close(m[nzones-1], 1.e-12)
hook = C.createGlobalHook(m,function='nodes')
sol = C.initVars(m, '{ro}={x}')
sol = C.extractVars(sol,['ro'])
Expand All @@ -48,7 +47,7 @@
a2 = C.identifySolutions(a1,sol,hook,tol=1000.)
test.testA([a2],5)
# NGON
a1 = C.convertArray2NGon(a); a1 = G.close(a1, 1.e-12)
a1 = C.convertArray2NGon(a)
a2 = C.identifySolutions(a1,sol,hook,tol=1000.)
test.testA([a2],6)
C.freeHook(hook)
2 changes: 1 addition & 1 deletion Cassiopee/Converter/test/recoverBCsPT_t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
a = G.cartHexa((0,0,0),(1,1,1),(10,10,2))
C._addBC2Zone(a, 'wall', 'BCWall', faceList=[1,2])
(BCs,BCNames,BCTypes) = C.getBCs(a)
b = C.convertArray2NGon(a); b = G.close(b, tol=1e-12)
b = C.convertArray2NGon(a)
C._recoverBCs(b,(BCs,BCNames,BCTypes))
test.testT(b, 2)

Expand Down
10 changes: 4 additions & 6 deletions Cassiopee/Converter/test/rmGhostCellsPT_t2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
a = D.sphere((0,0,0),1,N=10)
dhk = G.cart((0,0,0),(0.1,1,1),(2,1,1))
a = G.addNormalLayers(a,dhk)
a = C.convertArray2NGon(a); a = G.close(a, 1.e-12)
a = G.close(a)
a = C.convertArray2NGon(a)
a = C.initVars(a, '{centers:F}={centers:CoordinateX}')
a = C.initVars(a,'{Density}={CoordinateX}')
t = C.newPyTree(['Base']); t[2][1][2] = [a]
Expand All @@ -22,8 +21,7 @@
a = D.sphere((0,0,0),1,N=10)
dhk = G.cart((0,0,0),(0.1,1,1),(2,1,1))
a = G.addNormalLayers(a,dhk)
a = C.convertArray2NGon(a); a = G.close(a, 1.e-12)
a = G.close(a)
a = C.convertArray2NGon(a)
a = C.initVars(a, '{centers:F}={centers:CoordinateX}**2')
a = C.initVars(a,'{Density}=3*{CoordinateX}+2*{CoordinateY}')
t = C.newPyTree(['Base']); t[2][1][2] = [a]
Expand All @@ -33,7 +31,7 @@

# 2D sans frontieres exterieures
a = D.sphere((0,0,0),1,N=10)
a = C.convertArray2NGon(a); a = G.close(a, 1.e-12)
a = C.convertArray2NGon(a)
a = C.initVars(a, '{centers:F}={centers:CoordinateX}**2')
a = C.initVars(a,'{Density}=3*{CoordinateX}+2*{CoordinateY}')
t = C.newPyTree(['Base']); t[2][1][2] = [a]
Expand All @@ -42,7 +40,7 @@
test.testT(t,3)

# 2D avec frontieres exterieures
a = G.cartNGon((0,0,0),(1,1,1),(21,21,1)); a = G.close(a, 1.e-12)
a = G.cartNGon((0,0,0),(1,1,1),(21,21,1))
a = C.initVars(a, '{centers:F}={centers:CoordinateX}**2')
a = C.initVars(a,'{Density}=3*{CoordinateX}+2*{CoordinateY}')
t = C.newPyTree(['Base']); t[2][1][2] = [a]
Expand Down
8 changes: 3 additions & 5 deletions Cassiopee/Converter/test/rmGhostCellsPT_t3.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
a = D.sphere((0,0,0),1,N=10)
dhk = G.cart((0,0,0),(0.1,1,1),(2,1,1))
a = G.addNormalLayers(a,dhk)
a = C.convertArray2NGon(a); a = G.close(a, 1.e-12)
a = G.close(a)
a = C.convertArray2NGon(a)
a = C.initVars(a, '{centers:F}={centers:CoordinateX}')
a = C.initVars(a,'{Density}={CoordinateX}')
t = C.newPyTree(['Base',a])
Expand All @@ -22,8 +21,7 @@
a = D.sphere((0,0,0),1,N=10)
dhk = G.cart((0,0,0),(0.1,1,1),(2,1,1))
a = G.addNormalLayers(a,dhk)
a = C.convertArray2NGon(a); a = G.close(a, 1.e-12)
a = G.close(a)
a = C.convertArray2NGon(a)
a = C.initVars(a, '{centers:F}={centers:CoordinateX}**2')
a = C.initVars(a,'{Density}=3*{CoordinateX}+2*{CoordinateY}')
t = C.newPyTree(['Base',a])
Expand All @@ -33,7 +31,7 @@

# 2D sans frontieres exterieures
a = D.sphere((0,0,0),1,N=10)
a = C.convertArray2NGon(a); a = G.close(a, 1.e-12)
a = C.convertArray2NGon(a)
a = C.initVars(a, '{centers:F}={centers:CoordinateX}**2')
a = C.initVars(a,'{Density}=3*{CoordinateX}+2*{CoordinateY}')
t = C.newPyTree(['Base',a])
Expand Down
2 changes: 1 addition & 1 deletion Cassiopee/Generator/test/getNormalMapPT_t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

# test NGon surfacique
a = D.sphere((0,0,0), 1, 10)
a = C.convertArray2NGon(a); a = G.close(a, 1.e-12)
a = C.convertArray2NGon(a)
a = C.initVars(a,'Density',2.); a = C.initVars(a,'centers:cellN',1.)
a = G.getNormalMap(a)
test.testT(a,4)
2 changes: 1 addition & 1 deletion Cassiopee/Intersector/Intersector/PyTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -4075,7 +4075,7 @@ def _convertTree2NUGANGON(t, keep_BC=False):
#print((typ,d))
if typ == 'BASIC':
#print('BASic -> NGON cassiopee')
C._convertArray2NGon(z); G._close(z, tol=1e-12)
C._convertArray2NGon(z)
if d == 2 : typ = 'NGON_CASSIOPEE'
# now it s a NGON (cassiopee or NUGA)
if typ == 'NGON_CASSIOPEE':
Expand Down
4 changes: 2 additions & 2 deletions Cassiopee/Intersector/test/P1ConsInterpolationPT_t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
N = 20

aD = G.cartHexa((0.,0.,0.), (0.1,0.1,0.2), (N,N,N))
aD = C.convertArray2NGon(aD); aD = G.close(aD)
aD = C.convertArray2NGon(aD)
aD = C.initVars(aD, '{centers:Density} = {centers:CoordinateX} + {centers:CoordinateY}')
#C.convertPyTree2File(aD, 'aD.cgns')

aR = G.cartHexa((0.,0.,0.), (0.1,0.1,0.2), (N+1,N+1,N+1))
aR = C.convertArray2NGon(aR); aR = G.close(aR)
aR = C.convertArray2NGon(aR)

#import time
#t0 = time.time()
Expand Down
4 changes: 2 additions & 2 deletions Cassiopee/Intersector/test/adaptCellsPT_t3.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
zones = I.getZones(t)
p1 = zones[0]
p1 = C.convertArray2Tetra(p1, split='withBarycenters')
p1 = C.convertArray2NGon(p1); p1 = G.close(p1)
p1 = C.convertArray2NGon(p1)

p2 = C.convertArray2NGon(zones[1]); p2 = G.close(p2)
p2 = C.convertArray2NGon(zones[1])

mesh = XOR.booleanUnion(p1,p2) #conformize the join
#C.convertPyTree2File(mesh, 'u.cgns')
Expand Down
6 changes: 3 additions & 3 deletions Cassiopee/Intersector/test/agglomerateSmallCellsPT_t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
t = G.octree([s],[snear], dfar=5., balancing=1,ratio=2)

print("ngon conversion...")
t = C.convertArray2NGon(t); t = G.close(t)
t = C.convertArray2NGon(t)
print("ngon conformization...")
t = C.conformizeNGon(t)
t = C.conformizeNGon(t); t = G.close(t)
print("ngon close cells...")
t = XOR.closeCells(t)
#t = XOR.reorientExternalFaces(t)

s = C.convertArray2NGon(s); s = G.close(s, 1.e-12)
s = C.convertArray2NGon(s)
s = XOR.convertNGON2DToNGON3D(s)
#s = XOR.reorientExternalFaces(s)

Expand Down
2 changes: 1 addition & 1 deletion Cassiopee/Intersector/test/agglomerateSmallCells_t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
t = XOR.closeCells(t)
#t = XOR.reorientExternalFaces(t)

s = C.convertArray2NGon(s); s = G.close(s, 1.e-12)
s = C.convertArray2NGon(s)
s = XOR.convertNGON2DToNGON3D(s)
#s = XOR.reorientExternalFaces(s)

Expand Down
6 changes: 3 additions & 3 deletions Cassiopee/Intersector/test/concatenatePT_t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# ----------------------------------------------------------------
# Maillages
a = G.cartHexa((0.,0.,0.), (1.,1.,1.), (3,2,2))
a = C.convertArray2NGon(a); a = G.close(a)
a = C.convertArray2NGon(a)
a = C.initVars(a,'{centers:varA} = 5.')
b = G.cartHexa((2.,0.,0.), (1.,1.,1.), (3,2,2))
b = C.convertArray2NGon(b); b = G.close(b)
b = C.convertArray2NGon(b)
b = C.initVars(b,'{centers:varB} = 9.')

# BCs
Expand Down Expand Up @@ -47,7 +47,7 @@
# ----------------------------------------------------------------
# Maillages
a = G.cartHexa((0.,0.,0.), (1.,1.,1.), (11,7,3))
a = C.convertArray2NGon(a); a = G.close(a)
a = C.convertArray2NGon(a)

# BCs
subz = G.cartNGon( (0,0,0), (1,1,1), (11,7,1) )
Expand Down
2 changes: 1 addition & 1 deletion Cassiopee/Intersector/test/diffMeshPT_t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#t = XOR.reorientExternalFaces(t)

# ngon converion of the sphere
s = C.convertArray2NGon(s); s = G.close(s, 1.e-12)
s = C.convertArray2NGon(s)
# ngon converion to the nuga format
s = XOR.convertNGON2DToNGON3D(s)
#s = XOR.reorientExternalFaces(s)
Expand Down
2 changes: 1 addition & 1 deletion Cassiopee/Intersector/test/diffMesh_t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#t = XOR.reorientExternalFaces(t)

# ngon converion of the sphere
s = C.convertArray2NGon(s); s = G.close(s, 1.e-12)
s = C.convertArray2NGon(s)
# ngon converion to the nuga format
s = XOR.convertNGON2DToNGON3D(s)
#s = XOR.reorientExternalFaces(s)
Expand Down
6 changes: 3 additions & 3 deletions Cassiopee/Intersector/test/diffSurfPT_t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
t = G.octree([s],[snear], dfar=5., balancing=1,ratio=2)

print("ngon conversion...")
t = C.convertArray2NGon(t); t = G.close(t)
t = C.convertArray2NGon(t)
print("ngon conformization...")
t = C.conformizeNGon(t)
t = C.conformizeNGon(t); t = G.close(t)
print("ngon close cells...")
t = XOR.closeCells(t)
#t = XOR.reorientExternalFaces(t)

s = C.convertArray2NGon(s); s = G.close(s, 1.e-12)
s = C.convertArray2NGon(s)
s = XOR.convertNGON2DToNGON3D(s)
#s = XOR.reorientExternalFaces(s)

Expand Down
2 changes: 1 addition & 1 deletion Cassiopee/Intersector/test/diffSurf_t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
t = XOR.closeCells(t)
#t = XOR.reorientExternalFaces(t)

s = C.convertArray2NGon(s); s = G.close(s, 1.e-12)
s = C.convertArray2NGon(s)
s = XOR.convertNGON2DToNGON3D(s)
#s = XOR.reorientExternalFaces(s)

Expand Down
2 changes: 1 addition & 1 deletion Cassiopee/Intersector/test/reorientExternalFacesPT_t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


a = G.cartHexa((0.,0.,0.), (0.1,0.1,0.2), (10,10,10))
a = C.convertArray2NGon(a); a = G.close(a)
a = C.convertArray2NGon(a)
a = XOR.reorient(a)

t = C.newPyTree(['Base',2]); t[2][1][2].append(a)
Expand Down
2 changes: 1 addition & 1 deletion Cassiopee/Intersector/test/syncPerioFacesPT_t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# ----------------------------------------------------------------
# Maillages
a = G.cartHexa((0.,0.,0.), (1.,1.,1.), (10,10,10))
a = C.convertArray2NGon(a); a = G.close(a)
a = C.convertArray2NGon(a)

XOR._reorient(a)

Expand Down
2 changes: 1 addition & 1 deletion Cassiopee/Post/test/computeGradLSQPT_m1.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def g(x, y, z): return 4.*x + 3.*y + 2.*z

if Cmpi.rank == 0:
t = G.cartHexa((0.,0.,0.), (1./10.,1./10.,1./10.), (11,11,2))
t = C.convertArray2NGon(t); t = G.close(t)
t = C.convertArray2NGon(t)
Internal._adaptNGon32NGon4(t)
t = C.initVars(t, 'centers:f', f, ['centers:CoordinateX', 'centers:CoordinateY', 'centers:CoordinateZ'])
t = C.initVars(t, 'centers:g', g, ['centers:CoordinateX', 'centers:CoordinateY', 'centers:CoordinateZ'])
Expand Down
Loading

0 comments on commit 986376f

Please sign in to comment.