@@ -43,7 +43,18 @@ __global__ void compute_coupling_acoustic_el_kernel(realw* displ,
4343 realw* coupling_ac_el_jacobian1Dw,
4444 int * d_ibool,
4545 int simulation_type,
46- int backward_simulation) {
46+ int backward_simulation,
47+ const int PML ,
48+ const int * d_spec_to_pml,
49+ const int NSPEC_PML_X ,
50+ const int NSPEC_PML_Z ,
51+ const realw deltat,
52+ realw_const_p d_displ_elastic_old,
53+ realw* d_rmemory_fsb_displ_elastic,
54+ realw_const_p alphax_store,
55+ realw_const_p alphaz_store,
56+ realw_const_p betax_store,
57+ realw_const_p betaz_store) {
4758
4859 int igll = threadIdx .x ;
4960 int iface = blockIdx .x + gridDim .x *blockIdx .y ;
@@ -54,11 +65,6 @@ __global__ void compute_coupling_acoustic_el_kernel(realw* displ,
5465 realw jacobianw;
5566
5667 if (iface < num_coupling_ac_el_faces){
57-
58- // don't compute points outside NGLLSQUARE==NGLL2==25
59- // way 2: no further check needed since blocksize = 25
60- // if (igll<NGLL2) {
61-
6268 // "-1" from index values to convert from Fortran-> C indexing
6369 ispec = coupling_ac_el_ispec[iface] - 1 ;
6470
@@ -79,13 +85,120 @@ __global__ void compute_coupling_acoustic_el_kernel(realw* displ,
7985 displ_z = - displ_z;
8086 }
8187
88+ // PML
89+ if (PML ) {
90+ // PML element index
91+ int ispec_pml = d_spec_to_pml[ispec] - 1 ;
92+ // checks if element is inside the PML
93+ if (ispec_pml >= 0 ) {
94+ realw alpha1,beta1;
95+ realw coef0_1,coef1_1,coef2_1;
96+ realw A9 ;
97+
98+ // to match offset for local (i,j) index to thread index (tx == i + j * NGLLX from I = (tx-J*NGLLX))
99+ int tx = i + j * NGLLX ;
100+
101+ // local PML array index
102+ int offset_pml = ispec_pml * NGLL2 + tx; // ispec_pml elements in range [0,NSPEC_PML-1]
103+
104+ // coefficients
105+ if (ispec_pml < NSPEC_PML_X ){
106+ // in CPML_X_ONLY
107+ // alpha1 == alpha_x
108+ // alpha_z == 0
109+ //
110+ // beta1 == beta_x == alpha_x + d_x / K_x
111+ // beta_z == 0
112+ //
113+ alpha1 = alphax_store[offset_pml];
114+ beta1 = betax_store[offset_pml];
115+ } else if (ispec_pml < (NSPEC_PML_X + NSPEC_PML_Z )){
116+ // in CPML_Z_ONLY region
117+ // alpha1 == alpha_z
118+ // alpha_x == 0
119+ //
120+ // beta1 == beta_z == alpha_z + d_z / K_z
121+ // beta_x == 0
122+ alpha1 = alphaz_store[offset_pml];
123+ beta1 = betaz_store[offset_pml];
124+ } else {
125+ // not used, there should be no coupling interface in the CPML_XZ regions at the corners
126+ alpha1 = 0 .f ;
127+ beta1 = 0 .f ;
128+ }
129+
130+ // for all PML regions
131+ realw c1 = __expf (-0 .5f * deltat * alpha1);
132+
133+ coef0_1 = c1 * c1;
134+ if (abs (alpha1) > 0 .00001f ){
135+ // coef1_zx_1 == (1 - c1)/alpha1
136+ // coef2_zx_1 == coef1 * c1
137+ coef1_1 = (1 .f - c1) / alpha1;
138+ coef2_1 = coef1_1 * c1;
139+ } else {
140+ // coef1_zx_1 == 1/2 dt
141+ // coef2_zx_1 == coef1_zx_1
142+ coef1_1 = 0 .5f * deltat;
143+ coef2_1 = coef1_1;
144+ }
145+
146+ // memory variables update
147+ // see compute_coupling_acoustic_el.f90 (line ~142):
148+ // ! Newmark
149+ // rmemory_fsb_displ_elastic(1,1,i,j,inum) = coef0_xz_1 * rmemory_fsb_displ_elastic(1,1,i,j,inum) + &
150+ // coef1_xz_1 * displ_elastic(1,iglob) + coef2_xz_1 * displ_elastic_old(1,iglob)
151+ // rmemory_fsb_displ_elastic(1,2,i,j,inum) = coef0_xz_1 * rmemory_fsb_displ_elastic(1,2,i,j,inum) + &
152+ // coef1_xz_1 * displ_elastic(2,iglob) + coef2_xz_1 * displ_elastic_old(2,iglob)
153+ //
154+ // x-comp
155+ realw r_x = coef0_1 * d_rmemory_fsb_displ_elastic[INDEX3 (NDIM ,NGLLX ,0 ,igll,iface)] + coef1_1 * displ_x + coef2_1 * d_displ_elastic_old[offset_pml*2 ];
156+ // z-comp
157+ realw r_z = coef0_1 * d_rmemory_fsb_displ_elastic[INDEX3 (NDIM ,NGLLX ,1 ,igll,iface)] + coef1_1 * displ_z + coef2_1 * d_displ_elastic_old[offset_pml*2 +1 ];
158+
159+ d_rmemory_fsb_displ_elastic[INDEX3 (NDIM ,NGLLX ,0 ,igll,iface)] = r_x; // (1,igll,iface)
160+ d_rmemory_fsb_displ_elastic[INDEX3 (NDIM ,NGLLX ,1 ,igll,iface)] = r_z; // (2,igll,iface)
161+
162+ // displacement update
163+ // see compute_coupling_acoustic_el.f90 (line ~166):
164+ // displ_x = A8 * displ_elastic(1,iglob) + A9 * rmemory_fsb_displ_elastic(1,1,i,j,inum)
165+ // displ_z = A8 * displ_elastic(2,iglob) + A9 * rmemory_fsb_displ_elastic(1,2,i,j,inum)
166+ //
167+ // with coefficients A8, A9 from routine lik_parameter_computation(..),
168+ // note that we require K_x == K_z == 1:
169+ // for CPML_X_ONLY_TEMP
170+ // A8 == A_0 == kappa_x == 1
171+ // A9 == - A_0 * (alpha_x - beta_x) == beta_x - alpha_x
172+ // for CPML_Z_ONLY_TEMP
173+ // A8 == A_0 == 1 / kappa_z == 1
174+ // A9 == - A_0 * (beta_z - alpha_z) == alpha_z - beta_z
175+ if (ispec_pml < NSPEC_PML_X ){
176+ // in CPML_X_ONLY region
177+ // A8 = 1.0f;
178+ A9 = beta1 - alpha1;
179+ } else if (ispec_pml < (NSPEC_PML_X + NSPEC_PML_Z )) {
180+ // in CPML_Z_ONLY region
181+ // A8 = 1.0f;
182+ A9 = alpha1 - beta1;
183+ } else {
184+ // in CPML_XZ region
185+ // should not occur
186+ // A8 = 1.0f; // keeps displ_x and displ_z as is
187+ A9 = 0 .f ;
188+ }
189+ // overwrites displ_x and displ_z
190+ displ_x += A9 * r_x;
191+ displ_z += A9 * r_z;
192+ }
193+ } // PML
194+
82195 // gets associated normal on GLL point
83196 nx = coupling_ac_el_normal[INDEX3 (NDIM ,NGLLX ,0 ,igll,iface)]; // (1,igll,iface)
84197 nz = coupling_ac_el_normal[INDEX3 (NDIM ,NGLLX ,1 ,igll,iface)]; // (2,igll,iface)
85198
86199 // calculates displacement component along normal
87200 // (normal points outwards of acoustic element)
88- displ_n = displ_x* nx + displ_z* nz;
201+ displ_n = displ_x * nx + displ_z * nz;
89202
90203 // gets associated, weighted jacobian
91204 jacobianw = coupling_ac_el_jacobian1Dw[INDEX2 (NGLLX ,igll,iface)];
@@ -99,9 +212,7 @@ __global__ void compute_coupling_acoustic_el_kernel(realw* displ,
99212 // (see e.g. Chaljub & Vilotte, Nissen-Meyer thesis...)
100213 // it also means you have to calculate and update this here first before
101214 // calculating the coupling on the elastic side for the acceleration...
102- atomicAdd (&potential_dot_dot_acoustic[iglob],+ jacobianw*displ_n);
103-
104- // }
215+ atomicAdd (&potential_dot_dot_acoustic[iglob],jacobianw * displ_n);
105216 }
106217}
107218
0 commit comments