@@ -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