Skip to content

Commit ae82191

Browse files
committed
Added material names via a different physical group
1 parent 95bf9d7 commit ae82191

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@ jobs:
4040
- name: Install dependencies
4141
run: |
4242
python -m pip install .[dev]
43+
python -m pip install --upgrade git+https://github.com/CadQuery/cadquery.git
4344
- name: Run tests
4445
run: python -m pytest -v

assembly_mesh_plugin/plugin.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,14 @@ def get_gmsh(self, imprint=True):
221221
for volume_id in volumes.keys():
222222
gmsh.model.occ.synchronize()
223223

224-
# Include the material name, if present
224+
# Attach the name to the volume
225225
ps = gmsh.model.addPhysicalGroup(3, volumes[volume_id][0])
226+
gmsh.model.setPhysicalName(3, ps, f"{volume_map[volume_id]}")
226227

227-
# See if we need to include the material name as part of the physical volume name
228-
volume_name = f"{volume_map[volume_id]}"
228+
# Attach the material to the volume, if the material is present
229229
if len(solid_materials) >= volume_id:
230-
volume_name = f"{volume_map[volume_id]}~{solid_materials[volume_id - 1]}"
231-
gmsh.model.setPhysicalName(3, ps, volume_name)
230+
ps1 = gmsh.model.addPhysicalGroup(3, volumes[volume_id][0])
231+
gmsh.model.setPhysicalName(3, ps1, f"mat:{solid_materials[volume_id - 1]}")
232232

233233
# Handle tagged surface groups
234234
for t_name, surf_group in surface_groups.items():

tests/test_meshes.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,13 @@ def test_mesh_materials():
196196

197197
# Make sure we got the correct names
198198
name = gmsh.model.getPhysicalName(3, 1)
199-
assert name == "cube_1~copper"
199+
assert name == "cube_1"
200200
name = gmsh.model.getPhysicalName(3, 2)
201-
assert name == "cube_2~steel"
201+
assert name == "mat:copper"
202+
name = gmsh.model.getPhysicalName(3, 3)
203+
assert name == "cube_2"
204+
name = gmsh.model.getPhysicalName(3, 4)
205+
assert name == "mat:steel"
202206

203207
#
204208
# Non-imprinted assembly
@@ -210,6 +214,10 @@ def test_mesh_materials():
210214

211215
# Make sure we got the correct names
212216
name = gmsh.model.getPhysicalName(3, 1)
213-
assert name == "cube_1~copper"
217+
assert name == "cube_1"
214218
name = gmsh.model.getPhysicalName(3, 2)
215-
assert name == "cube_2~steel"
219+
assert name == "mat:copper"
220+
name = gmsh.model.getPhysicalName(3, 3)
221+
assert name == "cube_2"
222+
name = gmsh.model.getPhysicalName(3, 4)
223+
assert name == "mat:steel"

0 commit comments

Comments
 (0)