Skip to content

Commit 24593fa

Browse files
authored
Merge pull request #1274 from mnagaso/fix/gmsh-cpml-pml-instability
Fix PML instability in Gmsh CPML MPI example
2 parents bb9cd02 + 7f650ea commit 24593fa

10 files changed

Lines changed: 259190 additions & 289713 deletions

File tree

EXAMPLES/applications/meshing/Gmsh_example_CPML_MPI/DATA/STATIONS

Lines changed: 182 additions & 182 deletions
Large diffs are not rendered by default.

EXAMPLES/applications/meshing/Gmsh_example_CPML_MPI/MESH/EltPML_test

Lines changed: 2777 additions & 4687 deletions
Large diffs are not rendered by default.

EXAMPLES/applications/meshing/Gmsh_example_CPML_MPI/MESH/Material_test

Lines changed: 19040 additions & 23627 deletions
Large diffs are not rendered by default.

EXAMPLES/applications/meshing/Gmsh_example_CPML_MPI/MESH/Mesh_test

Lines changed: 47491 additions & 52078 deletions
Large diffs are not rendered by default.

EXAMPLES/applications/meshing/Gmsh_example_CPML_MPI/MESH/Nodes_test

Lines changed: 188398 additions & 207838 deletions
Large diffs are not rendered by default.

EXAMPLES/applications/meshing/Gmsh_example_CPML_MPI/MESH/Surf_abs_test

Lines changed: 1277 additions & 629 deletions
Large diffs are not rendered by default.

EXAMPLES/applications/meshing/Gmsh_example_CPML_MPI/MESH/Surf_free_test

Lines changed: 1 addition & 667 deletions
Large diffs are not rendered by default.

EXAMPLES/applications/meshing/Gmsh_example_CPML_MPI/create_geom_with_pygmsh.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def add_pml_layers(self, geom, w_pml, lc_pml, top_pml=False):
9090

9191
# add top tag if top_pml is False
9292
if not top_pml:
93-
self.list_rects[irect_top].bound_tag = "Top"
93+
self.list_rects[irect_top].bound_tag = "TopFree"
9494

9595
# side of the main rectangles
9696
tmp_list_rects = self.list_rects.copy()
@@ -313,6 +313,11 @@ def build_points_edges(self, geom, debug=False):
313313
elif rect.bound_tag == "Top":
314314
list_l_top.append(rect.list_lines[2])
315315
list_l_top_inner.append(rect.list_lines[0])
316+
elif rect.bound_tag == "TopFree":
317+
# Top boundary of the domain when top_pml is False.
318+
# Only add outer edge to Top group; do NOT create _Top inner
319+
# boundary since there is no top PML layer.
320+
list_l_top.append(rect.list_lines[2])
316321
elif rect.bound_tag == "Bottom":
317322
list_l_bottom.append(rect.list_lines[0])
318323
list_l_bottom_inner.append(rect.list_lines[2])

EXAMPLES/applications/meshing/Gmsh_example_CPML_MPI/create_mesh_topo.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@
422422
},
423423
{
424424
"cell_type": "code",
425-
"execution_count": 3,
425+
"execution_count": null,
426426
"metadata": {},
427427
"outputs": [
428428
{
@@ -447,7 +447,7 @@
447447
"from meshio2spec2d import *\n",
448448
"\n",
449449
"mio2spec = Meshio2Specfem2D(mesh)\n",
450-
"mio2spec.write(\"test\", pml_transition_layer=True)"
450+
"mio2spec.write(\"test\", pml_transition_layer=False)"
451451
]
452452
},
453453
{

EXAMPLES/applications/meshing/Gmsh_example_CPML_MPI/meshio2spec2d.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,13 @@ def __init__(self, mesh, top_abs=False, bot_abs=True, left_abs=True, right_abs=T
208208
# check if PML_X is included in the physical groups
209209
if "PML_X" in self.mesh.cell_sets_dict:
210210
self.use_cpml = True
211+
# When CPML is used, all outer PML boundaries need absorbing edges
212+
# for Dirichlet boundary conditions (see pml_init.F90:
213+
# determine_boundary_abs_points_PML). Auto-set all abs flags to True.
214+
self.top_abs = True
215+
self.bot_abs = True
216+
self.left_abs = True
217+
self.right_abs = True
211218

212219
# check if second order elements are included in the mesh
213220
if "quad9" in self.mesh.cells_dict:
@@ -255,7 +262,14 @@ def write_material(self):
255262
arr_mflag = np.ones(self.n_cells, dtype=int) * -1
256263

257264
# id offset for quad (subtract the number of lines)
258-
self.cell_id_offset = int(np.min(self.mesh.cell_sets_dict["M1"][self.key_quad]))
265+
# find the minimum cell id across all materials (not just M1,
266+
# since M1 does not necessarily have the smallest cell id)
267+
min_cell_id = int(np.min(self.mesh.cell_sets_dict[M_keys[0]][self.key_quad]))
268+
for key in M_keys[1:]:
269+
c = int(np.min(self.mesh.cell_sets_dict[key][self.key_quad]))
270+
if c < min_cell_id:
271+
min_cell_id = c
272+
self.cell_id_offset = min_cell_id
259273

260274
print("cell_id_offset: ", self.cell_id_offset)
261275

@@ -407,7 +421,7 @@ def write_cpml(self):
407421
np.savetxt(self.fname_CPML, str_lines, fmt="%s")
408422

409423

410-
def write(self, filename_out="TEST", pml_transition_layer=True):
424+
def write(self, filename_out="TEST", pml_transition_layer=False):
411425

412426
# measure time
413427
start_time = time.time()

0 commit comments

Comments
 (0)