22import pytest
33import math
44import LimaScripting as lima
5+ import os
56
67def 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+
1012def 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 )
0 commit comments