Skip to content

Commit 5e8a82f

Browse files
committed
adds check and suggested PML thickness info
1 parent 027ba1d commit 5e8a82f

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

src/generate_databases/pml_set_local_dampingcoeff.f90

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,13 @@ subroutine pml_set_local_dampingcoeff(xstore,ystore,zstore)
316316
write(IMAIN,*)
317317
! wavelength
318318
if (vp_max_all > 0.d0) then
319-
write(IMAIN,*) ' resulting dominant wavelength : ',sngl(vp_max_all/f0_FOR_PML),'m'
320-
write(IMAIN,*) ' ratio CPML_width_x : ',sngl(CPML_width_x / (vp_max_all/f0_FOR_PML))
321-
write(IMAIN,*) ' ratio CPML_width_y : ',sngl(CPML_width_y / (vp_max_all/f0_FOR_PML))
322-
write(IMAIN,*) ' ratio CPML_width_z : ',sngl(CPML_width_z / (vp_max_all/f0_FOR_PML))
319+
write(IMAIN,*) ' resulting dominant wavelength (L) : ',sngl(vp_max_all/f0_FOR_PML),'m'
320+
! suggested PML width ~ lambda * 0.8 for degree N==4
321+
write(IMAIN,*) ' suggested minimum PML width : ',sngl((vp_max_all/f0_FOR_PML) * 0.8d0),'m'
322+
write(IMAIN,*) ' ratio CPML_width_x/L : ',sngl(CPML_width_x / (vp_max_all/f0_FOR_PML)), &
323+
'(suggested minimum ~ 0.5-0.8)'
324+
write(IMAIN,*) ' ratio CPML_width_y/L : ',sngl(CPML_width_y / (vp_max_all/f0_FOR_PML))
325+
write(IMAIN,*) ' ratio CPML_width_z/L : ',sngl(CPML_width_z / (vp_max_all/f0_FOR_PML))
323326
write(IMAIN,*)
324327
endif
325328
call flush_IMAIN()

src/meshfem3D/create_CPML_regions.f90

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,9 +609,10 @@ subroutine add_CPML_region_as_extra_layers(nglob)
609609
! topology of faces of cube (see similar definition in check_mesh_quality.f90)
610610
integer :: faces_topo(4,6),faces_topo_midpoints(5,6)
611611
integer :: iface,face_type
612+
integer :: elem_mapping(NGNOD)
613+
logical :: is_mapped(NGNOD)
612614
! MPI Cartesian topology uses W for West (= XI_MIN), E for East (= XI_MAX), S for South (= ETA_MIN), N for North (= ETA_MAX)
613615
integer, parameter :: W = 1,E = 2,S = 3,N = 4,B = 5,T = 6 ! B==Bottom, T==Top
614-
integer :: elem_mapping(NGNOD)
615616

616617
integer :: p1,p2,p3,p4,p5,p6,p7,p8,p9,ia,iglob
617618
integer :: factor_x,factor_y,factor_z
@@ -795,6 +796,30 @@ subroutine add_CPML_region_as_extra_layers(nglob)
795796
faces_topo_midpoints(4,T) = 20
796797
faces_topo_midpoints(5,T) = 26 ! face midpoint
797798

799+
! checks face setup
800+
do iface = 1,6
801+
! element mapping
802+
call get_element_index_mapping(iface,elem_mapping)
803+
! sets node flags to check that mapping is bijective (unique)
804+
is_mapped(:) = .false.
805+
do ia = 1,NGNOD
806+
is_mapped(elem_mapping(ia)) = .true.
807+
enddo
808+
! check
809+
if (any(is_mapped .eqv. .false.)) then
810+
print *,'Error: setup for element mapping is invalid for face type:',iface
811+
print *,' elem_mapping:'
812+
do ia = 1,NGNOD
813+
print *,' ',ia,elem_mapping(ia)
814+
enddo
815+
print *,' is mapped:'
816+
do ia = 1,NGNOD
817+
print *,' ',ia,is_mapped(ia)
818+
enddo
819+
stop 'Invalid element mapping setup for PML element extension'
820+
endif
821+
enddo
822+
798823
! determine element sizes (all thicknesses given in m here)
799824
SIZE_OF_X_ELEMENT_TO_ADD = 0.d0
800825
SIZE_OF_Y_ELEMENT_TO_ADD = 0.d0

0 commit comments

Comments
 (0)