Skip to content

Commit 5567d83

Browse files
Generator: getVolumeMap api3 (#531)
* KCore: WIP ngonTools compatibility in api3 * Apply autopep8 formatting * KCore: WIP ngonTools compatibility in api3 * Apply autopep8 formatting * Correct test case * Correct test case --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 3f7967d commit 5567d83

File tree

14 files changed

+743
-620
lines changed

14 files changed

+743
-620
lines changed

Cassiopee/Converter/Converter/Adapter/makeParentElements.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ PyObject* K_CONVERTER::makeParentElements(PyObject* self, PyObject* args)
7979
}
8080

8181
// Check mesh
82-
ret = K_CONNECT::check_overlapping_cells(*cn);
82+
ret = K_CONNECT::checkOverlappingCells(*cn);
8383
if (ret == 1) {
8484
PyErr_SetString(PyExc_ValueError,
8585
"makeParentElements: non-valid mesh.");

Cassiopee/Converter/Converter/Adapter/signNGonFaces.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ PyObject* K_CONVERTER::signNGonFaces(PyObject* self, PyObject* args)
8080

8181

8282
// Check mesh
83-
ret = K_CONNECT::check_overlapping_cells(*cn);
83+
ret = K_CONNECT::checkOverlappingCells(*cn);
8484
if (ret == 1) {
8585
PyErr_SetString(PyExc_ValueError,
8686
"signNGonFaces: non-valid mesh.");

Cassiopee/Generator/test/getVolumeMapPT_t1.py

Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,103 @@
22
import Generator.PyTree as G
33
import Converter.PyTree as C
44
import Geom.PyTree as D
5-
import KCore.test as T
5+
import KCore.test as test
66

7-
# Test 3D structure
7+
# --- Structured grids ---
8+
# 3D structured
89
a = G.cart((0.,0.,0.), (0.1,0.1,0.2), (10,10,3))
910
a = C.addBC2Zone(a, 'wall1','BCWall','jmin')
1011
a = C.addBC2Zone(a, 'match1','BCMatch','imin',a,'imax',[1,2,3])
1112
a = C.addBC2Zone(a, 'match2','BCMatch','imax',a,'imin',[1,2,3])
1213
a = C.fillEmptyBCWith(a,'overlap','BCOverlap')
1314
a = C.initVars(a,'Density',1.); a = C.initVars(a,'centers:cellN',1.)
1415
vol = G.getVolumeMap(a)
15-
T.testT(vol, 1)
16+
test.testT(vol, 1)
1617

17-
# Test 2D structure
18+
# 2D structured
1819
a = G.cart((0.,0.,0.), (0.1,0.1,0.2), (10,10,1))
1920
a = C.initVars(a,'Density',1.); a = C.initVars(a,'centers:cellN',1.)
2021
vol = G.getVolumeMap(a)
21-
T.testT(vol, 2)
22+
test.testT(vol, 2)
2223

23-
# Test 1D structure
24+
# 1D structured
2425
a = G.cart((0.,0.,0.), (0.1,0.1,0.2), (1,1,10))
2526
a = C.initVars(a,'Density',1.); a = C.initVars(a,'centers:cellN',1.)
2627
vol = G.getVolumeMap(a)
27-
T.testT(vol, 7)
28+
test.testT(vol, 7)
2829

29-
# Test 1d non-structure bar
30+
# --- BE ---
31+
# 1d unstructured bar
3032
a = D.line((0,0,0), (1,0,0),11)
3133
a2 = C.convertArray2Tetra(a)
3234
a = C.initVars(a,'Density',1.); a = C.initVars(a,'centers:cellN',1.)
3335
vol = G.getVolumeMap(a)
34-
T.testT(vol, 8)
36+
test.testT(vol, 8)
3537

36-
37-
# Test 2d non-structure hexa
38+
# 2D unstructured quad
3839
a = G.cartHexa((0.,0.,0.), (0.1,0.1,0.2), (10,10,1))
3940
a = C.initVars(a,'Density',1.); a = C.initVars(a,'centers:cellN',1.)
4041
vol = G.getVolumeMap(a)
41-
T.testT(vol, 3)
42+
test.testT(vol, 3)
4243

43-
# Test 3d non-structure hexa
44+
# 3D unstructured hexa
4445
a = G.cartHexa((0.,0.,0.), (0.1,0.1,0.2), (10,10,10))
4546
a = C.initVars(a,'Density',1.); a = C.initVars(a,'centers:cellN',1.)
4647
vol = G.getVolumeMap(a)
47-
T.testT(vol, 4)
48+
test.testT(vol, 4)
4849

49-
# Test 2d non-structure tetra
50+
# 2D unstructured tri
5051
a = G.cartTetra((0.,0.,0.), (0.1,0.1,0.2), (10,10,1))
5152
a = C.initVars(a,'Density',1.); a = C.initVars(a,'centers:cellN',1.)
5253
vol = G.getVolumeMap(a)
53-
T.testT(vol, 5)
54+
test.testT(vol, 5)
5455

55-
# Test 3d non-structure tetra
56+
# 3D unstructured tetra
5657
a = G.cartTetra((0.,0.,0.), (0.1,0.1,0.2), (10,10,10))
5758
a = C.initVars(a,'Density',1.); a = C.initVars(a,'centers:cellN',1.)
5859
vol = G.getVolumeMap(a)
59-
T.testT(vol, 6)
60+
test.testT(vol, 6)
61+
62+
# 3D unstructured pyra
63+
a = G.cartPyra((0., 0., 0.), (1., 1., 1.), (5, 5, 5))
64+
G._getVolumeMap(a)
65+
test.testT(a,9)
66+
67+
# 3D unstructured penta
68+
a = G.cartPenta((0., 0., 0.), (1., 1., 1.), (5, 5, 5))
69+
G._getVolumeMap(a)
70+
test.testT(a,10)
71+
72+
"""
73+
# 1D unstructured ME
74+
a = G.cartHexa((0.,0.,0.), (0.1,0.1,0.2), (5,1,1))
75+
b = G.cartHexa((0.4,0.,0.), (0.1,0.1,0.2), (1,10,1))
76+
c = G.cartHexa((0.8,0.,0.), (0.1,0.1,0.2), (4,1,1))
77+
d = G.cartHexa((0.4,-0.9,0.), (0.1,0.1,0.2), (1,1,12))
78+
a = C.mergeConnectivity([a, b, c, d], None)
79+
#G._getVolumeMap(a)
80+
#test.testT(a,11)
81+
82+
# --- ME ---
83+
# 2D unstructured ME: tri-quad-tri
84+
# |
85+
# tri
86+
a = G.cartTetra((0.,0.,0.), (0.1,0.1,0.2), (5,10,1))
87+
b = G.cartHexa((0.4,0.,0.), (0.1,0.1,0.2), (5,10,1))
88+
c = G.cartTetra((0.8,0.,0.), (0.1,0.1,0.2), (5,10,1))
89+
d = G.cartTetra((0.4,-0.9,0.), (0.1,0.1,0.2), (5,10,1))
90+
a = C.mergeConnectivity([a, b, c, d], None)
91+
#G._getVolumeMap(a)
92+
#test.testT(a,12)
93+
94+
# 3D unstructured ME: tetra - pyra
95+
# | |
96+
# penta hexa
97+
a = G.cartTetra((0.,0.4,0.), (0.1,0.1,0.1), (5,5,5))
98+
b = G.cartPyra((0.4,0.4,0.), (0.1,0.1,0.1), (5,5,5))
99+
c = G.cartPenta((0.,0.,0.), (0.1,0.1,0.1), (5,5,5))
100+
d = G.cartHexa((0.4,0.,0.), (0.1,0.1,0.1), (5,5,5))
101+
a = C.mergeConnectivity([a, b, c, d], None)
102+
#G._getVolumeMap(a)
103+
#test.testT(a,13)
104+
"""

Cassiopee/Generator/test/getVolumeMapPT_t2.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import Converter.PyTree as C
44
import KCore.test as T
55

6-
# Test 3D structure
6+
# 3D structured
77
a = G.cart((0.,0.,0.), (0.1,0.1,0.2), (10,10,3))
88
a = C.addBC2Zone(a, 'wall1','BCWall','jmin')
99
a = C.addBC2Zone(a, 'match1','BCMatch','imin',a,'imax',[1,2,3])
@@ -15,39 +15,39 @@
1515
t = G.getVolumeMap(t)
1616
T.testT(t,1)
1717

18-
# Test 2D structure
18+
# 2D structured
1919
a = G.cart((0.,0.,0.), (0.1,0.1,0.2), (10,10,1))
2020
t = C.newPyTree(['Base',2]); t[2][1][2].append(a)
2121
t[2][1] = C.addState(t[2][1], 'Mach', 0.6)
2222
t = C.initVars(t,'Density',2.); t = C.initVars(t,'centers:cellN',1.)
2323
t = G.getVolumeMap(t)
2424
T.testT(t,2)
2525

26-
# Test 2d non-structure hexa
26+
# 2D unstructured quad
2727
a = G.cartHexa((0.,0.,0.), (0.1,0.1,0.2), (10,10,1))
2828
t = C.newPyTree(['Base',2]); t[2][1][2].append(a)
2929
t[2][1] = C.addState(t[2][1], 'Mach', 0.6)
3030
t = C.initVars(t,'Density',2.); t = C.initVars(t,'centers:cellN',1.)
3131
t = G.getVolumeMap(t)
3232
T.testT(t,3)
3333

34-
# Test 3d non-structure hexa
34+
# 3D unstructured hexa
3535
a = G.cartHexa((0.,0.,0.), (0.1,0.1,0.2), (10,10,10))
3636
t = C.newPyTree(['Base']); t[2][1][2].append(a)
3737
t[2][1] = C.addState(t[2][1], 'Mach', 0.6)
3838
t = C.initVars(t,'Density',2.); t = C.initVars(t,'centers:cellN',1.)
3939
t = G.getVolumeMap(t)
4040
T.testT(t,4)
4141

42-
# Test 2d non-structure tri
42+
# 2D unstructured tri
4343
a = G.cartTetra((0.,0.,0.), (0.1,0.1,0.2), (10,10,1))
4444
t = C.newPyTree(['Base',2]); t[2][1][2].append(a)
4545
t[2][1] = C.addState(t[2][1], 'Mach', 0.6)
4646
t = C.initVars(t,'Density',2.); t = C.initVars(t,'centers:cellN',1.)
4747
t = G.getVolumeMap(t)
4848
T.testT(t,5)
4949

50-
# Test 3d non-structure tetra
50+
# 3D unstructured tetra
5151
a = G.cartTetra((0.,0.,0.), (0.1,0.1,0.2), (10,10,10))
5252
t = C.newPyTree(['Base']); t[2][1][2].append(a)
5353
t[2][1] = C.addState(t[2][1], 'Mach', 0.6)
Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
11
# - getVolumeMap (pyTree) -
22
import Generator.PyTree as G
33
import Converter.PyTree as C
4-
import KCore.test as T
4+
import Converter.Internal as Internal
5+
import KCore.test as test
56

7+
# --- NGon grids ---
68
# method=1
7-
a = G.cartNGon((0,0,0),(1,1,1),(3,5,7))
9+
a = G.cartNGon((0,0,0), (1,1,1), (3,5,7))
810
a = G.getVolumeMap(a, method=1)
9-
T.testT(a,1)
11+
C.convertPyTree2File(a, 'out.cgns')
12+
test.testT(a, 1)
13+
14+
# method=0, api 1
15+
a = G.cartNGon((0,0,0), (1,1,1), (3,5,7), api=1)
16+
a = G.getVolumeMap(a, method=0)
17+
vol = Internal.getNodeFromName(a, 'vol')[1]
18+
test.testO(vol, 2)
19+
20+
# method=0, api 3
21+
a = G.cartNGon((0,0,0), (1,1,1), (3,5,7), api=3)
22+
a = G.getVolumeMap(a, method=0)
23+
vol = Internal.getNodeFromName(a, 'vol')[1]
24+
test.testO(vol, 2)

Cassiopee/KCore/KCore/Connect/connect.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,8 @@ namespace K_CONNECT
514514
std::vector<E_Int>& ind);
515515

516516
/* ngon tools */
517-
E_Int check_open_cells(K_FLD::FldArrayI &cn, E_Int *is_cell_open);
518-
E_Int check_overlapping_cells(K_FLD::FldArrayI &cn);
517+
E_Int checkOpenCells(K_FLD::FldArrayI &cn, E_Int *isEltOpen);
518+
E_Int checkOverlappingCells(K_FLD::FldArrayI &cn);
519519
E_Int orient_boundary_ngon(E_Float *x, E_Float *y, E_Float *z,
520520
K_FLD::FldArrayI &cn);
521521
E_Int build_parent_elements_ngon(K_FLD::FldArrayI &cn, E_Int *owner,

0 commit comments

Comments
 (0)