1+ from pathlib import Path
12import assembly_mesh_plugin .plugin
23from tests .sample_assemblies import (
34 generate_simple_nested_boxes ,
@@ -14,8 +15,16 @@ def test_basic_assembly():
1415 # Create the basic assembly
1516 assy = generate_simple_nested_boxes ()
1617
17- # Create a mesh that has all the faces tagged as physical groups
18- assy .assemblyToGmsh (mesh_path = "tagged_mesh.msh" )
18+ # Create a gmsh object that has all the faces tagged as physical groups
19+ gmsh = assy .assemblyToGmsh ()
20+
21+ # perform a simple mesh on the returned gmsh object
22+ gmsh .model .mesh .field .setAsBackgroundMesh (2 )
23+ gmsh .model .mesh .generate (3 )
24+ gmsh .write ("tagged_mesh.msh" )
25+ assert Path ("tagged_mesh.msh" ).exists ()
26+ assert len (gmsh .model .getEntities (2 )) == 16
27+ gmsh .finalize ()
1928
2029
2130def test_basic_cross_section ():
@@ -27,7 +36,14 @@ def test_basic_cross_section():
2736 assy = generate_test_cross_section ()
2837
2938 # Create a mesh that has all the faces in the correct physical groups
30- assy .assemblyToGmsh (mesh_path = "tagged_cross_section.msh" )
39+ gmsh = assy .assemblyToGmsh ()
40+
41+ # perform a simple mesh on the returned gmsh object
42+ gmsh .model .mesh .field .setAsBackgroundMesh (2 )
43+ gmsh .model .mesh .generate (3 )
44+ gmsh .write ("tagged_cross_section.msh" )
45+ assert Path ("tagged_cross_section.msh" ).exists ()
46+ gmsh .finalize ()
3147
3248
3349def test_planar_coil ():
@@ -39,4 +55,11 @@ def test_planar_coil():
3955 assy = generate_assembly ()
4056
4157 # Create a mesh that has all the faces in the correct physical groups
42- assy .assemblyToGmsh (mesh_path = "tagged_planar_coil.msh" )
58+ gmsh = assy .assemblyToGmsh ()
59+
60+ # perform a simple mesh on the returned gmsh object
61+ gmsh .model .mesh .field .setAsBackgroundMesh (2 )
62+ gmsh .model .mesh .generate (3 )
63+ gmsh .write ("tagged_cross_section.msh" )
64+ assert Path ("tagged_cross_section.msh" ).exists ()
65+ gmsh .finalize ()
0 commit comments