Skip to content

Commit bd677ec

Browse files
authored
Merge branch 'main' into issue#262
2 parents d20cde3 + 72b6a93 commit bd677ec

12 files changed

Lines changed: 121 additions & 40 deletions

testExportData/section_box1.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pyMagix3D as Mgx3D
2+
import os
23

34
ctx = Mgx3D.getStdContext()
45
gm = ctx.getGeomManager()
@@ -44,5 +45,10 @@
4445
# Création du maillage pour tous les blocs
4546
mm.newAllBlocksMesh()
4647
# Sauvegarde du maillage (mli)
47-
filename = "section.mli2"
48-
mm.writeMli(filename)
48+
filename = "/dev/shm/section.mli2"
49+
mm.writeMli(filename)
50+
51+
assert os.path.exists(filename)
52+
assert os.path.getsize(filename) > 0
53+
54+
os.remove(filename)

test_link/test_export_cgns.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def test_export_demicyl_3d(capfd):
55
ctx = Mgx3D.getStdContext()
66
ctx.clearSession() # Clean the session after the previous test
77

8-
cgnsfilename = "demiCylinder.cgns"
8+
cgnsfilename = "/dev/shm/demiCylinder.cgns"
99
ctx.getTopoManager().newCylinderWithTopo (Mgx3D.Point(0, 0, 0), 1, Mgx3D.Vector(10, 0, 0), 360, True, .5, 10, 10, 10)
1010
ctx.getTopoManager().splitAllBlocks ("Ar0013",.5)
1111
ctx.getTopoManager().splitAllBlocks ("Ar0004",.5)
@@ -34,13 +34,13 @@ def test_export_demicyl_3d(capfd):
3434
out, err = capfd.readouterr()
3535
assert len(err) == 0
3636

37-
37+
os.remove(cgnsfilename)
3838

3939
def test_export_quad_2d(capfd):
4040
ctx = Mgx3D.getStdContext()
4141
ctx.clearSession() # Clean the session after the previous test
4242

43-
cgnsfilename = "quadOGrid.cgns"
43+
cgnsfilename = "/dev/shm/quadOGrid.cgns"
4444
ctx.getGeomManager().newVertex (Mgx3D.Point(0, 0, 0))
4545
ctx.getGeomManager().newVertex (Mgx3D.Point(1, 0, 0))
4646
ctx.getGeomManager().newVertex (Mgx3D.Point(1, 1, 0))
@@ -69,3 +69,5 @@ def test_export_quad_2d(capfd):
6969
assert os.path.getsize(cgnsfilename) > 0
7070
out, err = capfd.readouterr()
7171
assert len(err) == 0
72+
73+
os.remove(cgnsfilename)

test_link/test_export_vtk.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def test_export_box(capfd):
66
ctx = Mgx3D.getStdContext()
77
ctx.clearSession() # Clean the session after the previous test
88

9-
vtkfilename = "box.vtk"
9+
vtkfilename = "/dev/shm/box.vtk"
1010
ctx.getGeomManager().newBox (Mgx3D.Point(0, 0, 0), Mgx3D.Point(1, 1, 1))
1111
ctx.getTopoManager().newUnstructuredTopoOnGeometry("Vol0000")
1212
ctx.getMeshManager().newAllFacesMesh()
@@ -17,11 +17,13 @@ def test_export_box(capfd):
1717
out, err = capfd.readouterr()
1818
assert len(err) == 0
1919

20+
os.remove(vtkfilename)
21+
2022
def test_export_cylinder(capfd):
2123
ctx = Mgx3D.getStdContext()
2224
ctx.clearSession() # Clean the session after the previous test
2325

24-
vtkfilename = "cylinder.vtk"
26+
vtkfilename = "/dev/shm/cylinder.vtk"
2527
ctx.getGeomManager().newCylinder(Mgx3D.Point(0.3, 0.5, 0.5), 0.4, Mgx3D.Vector(0.4, 0, 0), 360)
2628
ctx.getTopoManager().newUnstructuredTopoOnGeometry("Vol0000")
2729
ctx.getMeshManager().newAllFacesMesh()
@@ -32,6 +34,8 @@ def test_export_cylinder(capfd):
3234
out, err = capfd.readouterr()
3335
assert len(err) == 0
3436

37+
os.remove(vtkfilename)
38+
3539
def test_export_imported_step(capfd):
3640
ctx = Mgx3D.getStdContext()
3741
ctx.clearSession() # Clean the session after the previous test
@@ -44,7 +48,7 @@ def test_export_imported_step(capfd):
4448
# Import STEP
4549
ctx.getGeomManager().importSTEP(step_file_path)
4650

47-
vtkfilename = "B0.vtk"
51+
vtkfilename = "/dev/shm/B0.vtk"
4852
ctx.getTopoManager().newUnstructuredTopoOnGeometry("Vol0000")
4953
ctx.getMeshManager().newAllFacesMesh()
5054
ctx.getGeomManager().exportVTK(vtkfilename)
@@ -53,3 +57,5 @@ def test_export_imported_step(capfd):
5357
assert os.path.getsize(vtkfilename) > 0
5458
out, err = capfd.readouterr()
5559
assert len(err) == 0
60+
61+
os.remove(vtkfilename)

test_link/test_io_blocks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_export_no_assoc():
3838
tm = ctx.getTopoManager ()
3939

4040
ctx.getTopoManager().newSphereWithTopo (Mgx3D.Point(0, 0, 0), 1, Mgx3D.Portion.DEMI, True, .5, 10, 10)
41-
mgxt_filename = os.path.join(test_folder, "data/half_sphere_export.mgxt")
41+
mgxt_filename = "/dev/shm/half_sphere_export.mgxt"
4242
tm.exportBlocks(mgxt_filename, False)
4343
assert os.path.exists(mgxt_filename)
4444
assert os.path.getsize(mgxt_filename) > 0
@@ -49,3 +49,5 @@ def test_export_no_assoc():
4949
assert tm.getNbFaces()==26
5050
assert tm.getNbEdges()==39
5151
assert len(tm.getVertices()) == 20
52+
53+
os.remove(mgxt_filename)

test_link/test_law_beta.py

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
import pytest
33
import math
44
import LimaScripting as lima
5+
import os
56

67
def l2_norme(n0, n1):
78
return math.sqrt( pow(n1.x()-n0.x(),2) + pow(n1.y()-n0.y(),2) + pow(n1.z()-n0.z(),2) )
89

910

11+
1012
def test_law_beta(capfd):
1113
ctx = Mgx3D.getStdContext()
1214
ctx.clearSession() # Clean the session after the previous test
@@ -28,7 +30,7 @@ def test_law_beta(capfd):
2830
ctx.getMeshManager().newAllBlocksMesh()
2931

3032
# Sauvegarde du maillage (mli)
31-
filename = "meshing_law_beta.mli2"
33+
filename = "/dev/shm/meshing_law_beta.mli2"
3234
mm.writeMli(filename)
3335
mesh_lima = lima.Maillage()
3436
mesh_lima.lire(filename)
@@ -46,6 +48,8 @@ def test_law_beta(capfd):
4648
n25 = mesh_lima.noeud(25)
4749
assert( abs(l2_norme(n2, n25) - s1_ar0000) < eps )
4850

51+
os.remove(filename)
52+
4953

5054

5155
# Beta law with target first mesh edge size seems to work only if this
@@ -73,7 +77,7 @@ def test_law_beta_onCurve_1(capfd):
7377
ctx.getMeshManager().newAllBlocksMesh()
7478

7579
# Sauvegarde du maillage (mli)
76-
filename = "meshing_law_beta_2.mli2"
80+
filename = "/dev/shm/meshing_law_beta_2.mli2"
7781
mm.writeMli(filename)
7882
mesh_lima = lima.Maillage()
7983
mesh_lima.lire(filename)
@@ -89,6 +93,8 @@ def test_law_beta_onCurve_1(capfd):
8993
# real meshing edge size
9094
assert( abs(l2_norme(n0, n8) - 0.000123750926732273) < eps )
9195

96+
os.remove(filename)
97+
9298

9399

94100
# Beta law with target first mesh edge size for a topological
@@ -131,7 +137,7 @@ def test_law_beta_onCurve_2(capfd):
131137
ctx.getMeshManager().newAllBlocksMesh()
132138

133139
# Sauvegarde du maillage (mli)
134-
filename = "meshing_law_beta_3.mli2"
140+
filename = "/dev/shm/meshing_law_beta_3.mli2"
135141
mm.writeMli(filename)
136142
mesh_lima = lima.Maillage()
137143
mesh_lima.lire(filename)
@@ -145,4 +151,31 @@ def test_law_beta_onCurve_2(capfd):
145151
# target meshing edge size (not respected)
146152
assert( abs(l2_norme(n2, n17) - s1_ar0001) > eps )
147153
# real meshing edge size
148-
assert( abs(l2_norme(n2, n17) - 0.0000594519721850694) < eps )
154+
assert( abs(l2_norme(n2, n17) - 0.0000594519721850694) < eps )
155+
156+
os.remove(filename)
157+
158+
159+
160+
# This test case shows that the "Inverser le sens" option doesn't work when the
161+
# beta law is used with a target first mesh edge size. To show this, we use the
162+
# same test as "test_law_beta", which is successful, and the only
163+
# difference is we turn false the direction option.
164+
def test_law_beta_fail(capfd):
165+
ctx = Mgx3D.getStdContext()
166+
ctx.clearSession() # Clean the session after the previous test
167+
168+
# chosen first mesh edge size
169+
s1_ar0000 = 0.005
170+
171+
# Création d'une boite avec une topologie
172+
ctx.getTopoManager().newBoxWithTopo (Mgx3D.Point(0, 0, 0), Mgx3D.Point(1, 1, 1), 10, 10, 10)
173+
174+
# Changement de discrétisation pour les arêtes Ar0000
175+
emp = Mgx3D.EdgeMeshingPropertyBeta(10, 1.1, False, True, s1_ar0000)
176+
ctx.getTopoManager().setMeshingProperty (emp, ["Ar0000"])
177+
with pytest.raises(RuntimeError) as excinfo:
178+
# Création du maillage pour tous les blocs
179+
ctx.getMeshManager().newAllBlocksMesh()
180+
expected = "EdgeMeshingPropertyBeta, on ne peut pas trouver de beta"
181+
assert expected in str(excinfo.value)

test_link/test_law_biexponential.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import pytest
33
import math
44
import LimaScripting as lima
5+
import os
56

67
def l2_norme(n0, n1):
78
return math.sqrt( pow(n1.x()-n0.x(),2) + pow(n1.y()-n0.y(),2) + pow(n1.z()-n0.z(),2) )
@@ -32,7 +33,7 @@ def test_law_biexponential_Linear(capfd):
3233
ctx.getMeshManager().newAllBlocksMesh()
3334

3435
# Sauvegarde du maillage (mli)
35-
filename = "meshing_law_biexponential.mli2"
36+
filename = "/dev/shm/meshing_law_biexponential.mli2"
3637
mm.writeMli(filename)
3738
mesh_lima = lima.Maillage()
3839
mesh_lima.lire(filename)
@@ -60,6 +61,8 @@ def test_law_biexponential_Linear(capfd):
6061
n107 = mesh_lima.noeud(107)
6162
assert( abs(l2_norme(n2, n107) - s2_ar0011) < eps )
6263

64+
os.remove(filename)
65+
6366
# Target sizes are not respected here. It is due to how
6467
# the projected topological edge length is computed in
6568
# the code. This also affects the other laws.
@@ -86,7 +89,7 @@ def test_law_biexponential_onCurve_1(capfd):
8689
ctx.getMeshManager().newAllBlocksMesh()
8790

8891
# Sauvegarde du maillage (mli)
89-
filename = "meshing_law_biexponential.mli2"
92+
filename = "/dev/shm/meshing_law_biexponential.mli2"
9093
mm.writeMli(filename)
9194
mesh_lima = lima.Maillage()
9295
mesh_lima.lire(filename)
@@ -126,6 +129,7 @@ def test_law_biexponential_onCurve_1(capfd):
126129
# because the topological edge is straight)
127130
assert( abs(l2_norme(n7, n203) - s2_ar0000) < eps )
128131

132+
os.remove
129133

130134
# Bi-exponential law with target first and last mesh edge size for a topological
131135
# edge associated to a geometric curve with the two topological
@@ -174,7 +178,7 @@ def test_law_biexponential_onCurve_2(capfd):
174178
ctx.getMeshManager().newAllBlocksMesh()
175179

176180
# Sauvegarde du maillage (mli)
177-
filename = "meshing_law_biexponential_3.mli2"
181+
filename = "/dev/shm/meshing_law_biexponential_3.mli2"
178182
mm.writeMli(filename)
179183
mesh_lima = lima.Maillage()
180184
mesh_lima.lire(filename)
@@ -215,6 +219,7 @@ def test_law_biexponential_onCurve_2(capfd):
215219
# real meshing edge size
216220
assert( abs(l2_norme(n7, n123) - 3.97338661590123e-1) < eps )
217221

222+
os.remove(filename)
218223

219224
# Bi-exponential law with target first and last mesh edge size for a topological
220225
# edge associated to a geometric surface.
@@ -268,7 +273,7 @@ def test_law_biexponential_onSurface(capfd):
268273
ctx.getMeshManager().newAllBlocksMesh()
269274

270275
# Sauvegarde du maillage (mli)
271-
filename = "meshing_law_geometric_3.mli2"
276+
filename = "/dev/shm/meshing_law_geometric_3.mli2"
272277
mm.writeMli(filename)
273278
mesh_lima = lima.Maillage()
274279
mesh_lima.lire(filename)
@@ -307,4 +312,6 @@ def test_law_biexponential_onSurface(capfd):
307312
# target meshing edge size (not respected)
308313
assert( abs(l2_norme(n8, n192) - s2_ar0022) > eps )
309314
# real meshing edge size
310-
assert( abs(l2_norme(n8, n192) - 4.9378232958398e-1) < eps )
315+
assert( abs(l2_norme(n8, n192) - 4.9378232958398e-1) < eps )
316+
317+
os.remove(filename)

test_link/test_law_bigeometric.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import pytest
33
import math
44
import LimaScripting as lima
5+
import os
56

67
def l2_norme(n0, n1):
78
return math.sqrt( pow(n1.x()-n0.x(),2) + pow(n1.y()-n0.y(),2) + pow(n1.z()-n0.z(),2) )
@@ -35,7 +36,7 @@ def test_law_bigeometric_Linear(capfd):
3536
ctx.getMeshManager().newAllBlocksMesh()
3637

3738
# Sauvegarde du maillage (mli)
38-
filename = "meshing_law_bigeometric.mli2"
39+
filename = "/dev/shm/meshing_law_bigeometric.mli2"
3940
mm.writeMli(filename)
4041
mesh_lima = lima.Maillage()
4142
mesh_lima.lire(filename)
@@ -75,6 +76,7 @@ def test_law_bigeometric_Linear(capfd):
7576
assert( abs(l2_norme(n2, n107) - s2_ar0000) > eps )
7677
assert( abs(l2_norme(n2, n107) - 0.25) < eps )
7778

79+
os.remove(filename)
7880

7981
# This test shows an example of "Découpage polaire" option, with geometric law.
8082
# In 3D, it's difficult to get a suitable situation to use this option.
@@ -144,7 +146,7 @@ def test_law_bigeometric_polar(capfd):
144146
ctx.getMeshManager().newAllBlocksMesh()
145147

146148
# Sauvegarde du maillage (mli)
147-
filename = "meshing_law_bigeometric_polar.mli2"
149+
filename = "/dev/shm/meshing_law_bigeometric_polar.mli2"
148150
mm.writeMli(filename)
149151
mesh_lima = lima.Maillage()
150152
mesh_lima.lire(filename)
@@ -166,4 +168,6 @@ def test_law_bigeometric_polar(capfd):
166168
# target meshing edge size (not respected)
167169
assert( abs(l2_norme(n1, n16) - s_ar0000) > eps )
168170
# real meshing edge size
169-
assert( abs(l2_norme(n1, n16) - 3.13783707036233e-1) < eps )
171+
assert( abs(l2_norme(n1, n16) - 3.13783707036233e-1) < eps )
172+
173+
os.remove(filename)

0 commit comments

Comments
 (0)