Skip to content

Commit af3bc72

Browse files
committed
Fixed a bug by synchronize being called at the wrong time
1 parent 0a7759a commit af3bc72

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

assembly_mesh_plugin/plugin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,21 +204,21 @@ def get_gmsh(self, imprint=True):
204204

205205
# Step through each of the volumes and add physical groups for each
206206
for volume_id in volumes.keys():
207+
gmsh.model.occ.synchronize()
207208
ps = gmsh.model.addPhysicalGroup(3, volumes[volume_id][0])
208209
gmsh.model.setPhysicalName(3, ps, f"{volume_map[volume_id]}")
209-
gmsh.model.occ.synchronize()
210210

211211
# Handle tagged surface groups
212212
for t_name, surf_group in surface_groups.items():
213+
gmsh.model.occ.synchronize()
213214
ps = gmsh.model.addPhysicalGroup(2, surf_group)
214215
gmsh.model.setPhysicalName(2, ps, t_name)
215-
gmsh.model.occ.synchronize()
216216

217217
# Handle multi-material tags
218218
for group_name, mm_group in multi_material_groups.items():
219+
gmsh.model.occ.synchronize()
219220
ps = gmsh.model.addPhysicalGroup(2, mm_group)
220221
gmsh.model.setPhysicalName(2, ps, f"{group_name}")
221-
gmsh.model.occ.synchronize()
222222

223223
gmsh.model.occ.synchronize()
224224

tests/test_meshes.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ def _check_physical_groups():
141141
# Make sure that there are physical groups for the volumes
142142
physical_groups = gmsh.model.getPhysicalGroups(3)
143143
assert (
144-
len(physical_groups) > 0
145-
), "There should be some physical groups for volumes"
144+
len(physical_groups) == 2
145+
), "There should be two physical groups for volumes"
146146

147147
# Check the solids for the correct tags
148148
for group in physical_groups:
@@ -151,6 +151,10 @@ def _check_physical_groups():
151151

152152
assert cur_name in ["inner_sphere", "middle_sphere"]
153153

154+
# Make sure we can retrieve the physical groups
155+
inner_sphere_volume = gmsh.model.getEntitiesForPhysicalName("inner_sphere")
156+
middle_sphere_volume = gmsh.model.getEntitiesForPhysicalName("middle_sphere")
157+
154158
# Create a basic assembly
155159
assy = generate_nested_spheres()
156160

0 commit comments

Comments
 (0)