149 type(json_file),
target,
intent(inout) :: params
150 type(
dofmap_t),
target,
intent(in) :: dofmap
151 type(
coef_t),
target,
intent(in) :: coef
152 real(kind=
rp),
intent(in) :: a, b
154 integer :: i, j, k, l
155 real(kind=
rp),
allocatable :: zg(:)
156 real(kind=
rp) :: normal(3)
164 if (this%p .gt. 1)
then
165 this%tau = -a * (this%p + 1) ** (-b)
171 this%n = this%lx ** 3 * this%coef%msh%nelv
172 this%n_large = (this%lx + 2) ** 3 * this%coef%msh%nelv
174 allocate(this%n_facet(this%coef%msh%nelv))
175 do i = 1, this%coef%msh%nelv
176 select type (ep => this%coef%msh%elements(i)%e)
181 &supported now for gradient jump penalty")
184 this%n_facet_max = maxval(this%n_facet)
186 allocate(this%h2(this%lx + 2, this%lx + 2, &
187 this%lx + 2, this%coef%msh%nelv))
189 do i = 1, this%coef%msh%nelv
190 select type (ep => this%coef%msh%elements(i)%e)
192 call eval_h2_hex(this%h2(:, :, :, i), this%lx, i, this%dm, this%coef)
194 call neko_error(
"Gradient jump penalty error: mesh size &
195 &evaluation is not supported for quad_t")
199 allocate(zg(this%lx))
200 allocate(this%dphidxi(this%lx, this%lx))
205 this%dphidxi(j,i) = this%coef%Xh%dx(j,i)
209 allocate(this%penalty(this%lx, this%lx, this%lx, this%coef%msh%nelv))
210 allocate(this%grad1(this%lx, this%lx, this%lx, this%coef%msh%nelv))
211 allocate(this%grad2(this%lx, this%lx, this%lx, this%coef%msh%nelv))
212 allocate(this%grad3(this%lx, this%lx, this%lx, this%coef%msh%nelv))
214 allocate(this%penalty_facet(this%lx + 2, this%lx + 2, &
215 this%lx + 2, this%coef%msh%nelv))
216 allocate(this%G(this%lx + 2, this%lx + 2, &
217 this%lx + 2, this%coef%msh%nelv))
218 allocate(this%flux1(this%lx + 2, this%lx + 2, &
219 this%lx + 2, this%coef%msh%nelv))
220 allocate(this%flux2(this%lx + 2, this%lx + 2, &
221 this%lx + 2, this%coef%msh%nelv))
222 allocate(this%flux3(this%lx + 2, this%lx + 2, &
223 this%lx + 2, this%coef%msh%nelv))
224 allocate(this%volflux1(this%lx + 2, this%lx + 2, &
225 this%lx + 2, this%coef%msh%nelv))
226 allocate(this%volflux2(this%lx + 2, this%lx + 2, &
227 this%lx + 2, this%coef%msh%nelv))
228 allocate(this%volflux3(this%lx + 2, this%lx + 2, &
229 this%lx + 2, this%coef%msh%nelv))
230 allocate(this%absvolflux(this%lx + 2, this%lx + 2, &
231 this%lx + 2, this%coef%msh%nelv))
232 allocate(this%n1(this%lx + 2, this%lx + 2, &
233 this%lx + 2, this%coef%msh%nelv))
234 allocate(this%n2(this%lx + 2, this%lx + 2, &
235 this%lx + 2, this%coef%msh%nelv))
236 allocate(this%n3(this%lx + 2, this%lx + 2, &
237 this%lx + 2, this%coef%msh%nelv))
240 do i = 1, this%coef%msh%nelv
246 normal = this%coef%get_normal(1, l, k, i, j)
247 this%n1(1, l + 1, k + 1, i) = normal(1)
248 this%n2(1, l + 1, k + 1, i) = normal(2)
249 this%n3(1, l + 1, k + 1, i) = normal(3)
251 normal = this%coef%get_normal(1, l, k, i, j)
252 this%n1(this%lx + 2, l + 1, k + 1, i) = normal(1)
253 this%n2(this%lx + 2, l + 1, k + 1, i) = normal(2)
254 this%n3(this%lx + 2, l + 1, k + 1, i) = normal(3)
256 normal = this%coef%get_normal(l, 1, k, i, j)
257 this%n1(l + 1, 1, k + 1, i) = normal(1)
258 this%n2(l + 1, 1, k + 1, i) = normal(2)
259 this%n3(l + 1, 1, k + 1, i) = normal(3)
261 normal = this%coef%get_normal(l, 1, k, i, j)
262 this%n1(l + 1, this%lx + 2, k + 1, i) = normal(1)
263 this%n2(l + 1, this%lx + 2, k + 1, i) = normal(2)
264 this%n3(l + 1, this%lx + 2, k + 1, i) = normal(3)
266 normal = this%coef%get_normal(l, k, 1, i, j)
267 this%n1(l + 1, k + 1, 1, i) = normal(1)
268 this%n2(l + 1, k + 1, 1, i) = normal(2)
269 this%n3(l + 1, k + 1, 1, i) = normal(3)
271 normal = this%coef%get_normal(l, k, 1, i, j)
272 this%n1(l + 1, k + 1, this%lx + 2, i) = normal(1)
273 this%n2(l + 1, k + 1, this%lx + 2, i) = normal(2)
274 this%n3(l + 1, k + 1, this%lx + 2, i) = normal(3)
276 call neko_error(
"The face index is not correct")
287 call this%Xh_GJP%init(
gll, this%lx+2, this%lx+2, this%lx+2)
288 call this%dm_GJP%init(this%coef%msh, this%Xh_GJP)
289 call this%gs_GJP%init(this%dm_GJP)
293 call device_map(this%dphidxi, this%dphidxi_d, &
295 call device_map(this%penalty, this%penalty_d, this%n)
296 call device_map(this%grad1, this%grad1_d, this%n)
297 call device_map(this%grad2, this%grad2_d, this%n)
298 call device_map(this%grad3, this%grad3_d, this%n)
300 call device_map(this%penalty_facet, this%penalty_facet_d, this%n_large)
301 call device_map(this%G, this%G_d, this%n_large)
302 call device_map(this%flux1, this%flux1_d, this%n_large)
303 call device_map(this%flux2, this%flux2_d, this%n_large)
304 call device_map(this%flux3, this%flux3_d, this%n_large)
306 call device_map(this%volflux1, this%volflux1_d, this%n_large)
307 call device_map(this%volflux2, this%volflux2_d, this%n_large)
308 call device_map(this%volflux3, this%volflux3_d, this%n_large)
309 call device_map(this%absvolflux, this%absvolflux_d, this%n_large)
311 call device_map(this%n1, this%n1_d, this%n_large)
312 call device_map(this%n2, this%n2_d, this%n_large)
313 call device_map(this%n3, this%n3_d, this%n_large)
314 call device_map(this%facet_factor, this%facet_factor_d, this%n_large)
325 call device_memcpy(this%facet_factor, this%facet_factor_d, this%n_large,&
377 integer,
intent(in) :: l, k, j, i, n
378 type(
dofmap_t),
pointer,
intent(in) :: dm
379 type(
coef_t),
pointer,
intent(in) :: coef
380 real(kind=
rp) :: dist2, dist_1, dist_2
382 real(kind=
rp) :: x1, y1, z1, x2, y2, z2
383 real(kind=
rp) :: normal1(3), normal2(3)
384 real(kind=
rp) :: n11, n12, n13, n21, n22, n23
385 real(kind=
rp) :: v1, v2, v3
390 normal1 = coef%get_normal(1, l, k, i, 1)
394 x1 = dm%x(1, l, k, i)
395 y1 = dm%y(1, l, k, i)
396 z1 = dm%z(1, l, k, i)
397 normal2 = coef%get_normal(1, l, k, i, 2)
401 x2 = dm%x(n, l, k, i)
402 y2 = dm%y(n, l, k, i)
403 z2 = dm%z(n, l, k, i)
407 normal1 = coef%get_normal(1, l, k, i, 2)
411 x1 = dm%x(n, l, k, i)
412 y1 = dm%y(n, l, k, i)
413 z1 = dm%z(n, l, k, i)
414 normal2 = coef%get_normal(1, l, k, i, 1)
418 x2 = dm%x(1, l, k, i)
419 y2 = dm%y(1, l, k, i)
420 z2 = dm%z(1, l, k, i)
422 normal1 = coef%get_normal(1, l, k, i, 3)
426 x1 = dm%x(l, 1, k, i)
427 y1 = dm%y(l, 1, k, i)
428 z1 = dm%z(l, 1, k, i)
429 normal2 = coef%get_normal(1, l, k, i, 4)
433 x2 = dm%x(l, n, k, i)
434 y2 = dm%y(l, n, k, i)
435 z2 = dm%z(l, n, k, i)
437 normal1 = coef%get_normal(1, l, k, i, 4)
441 x1 = dm%x(l, n, k, i)
442 y1 = dm%y(l, n, k, i)
443 z1 = dm%z(l, n, k, i)
444 normal2 = coef%get_normal(1, l, k, i, 3)
448 x2 = dm%x(l, 1, k, i)
449 y2 = dm%y(l, 1, k, i)
450 z2 = dm%z(l, 1, k, i)
452 normal1 = coef%get_normal(1, l, k, i, 5)
456 x1 = dm%x(l, k, 1, i)
457 y1 = dm%y(l, k, 1, i)
458 z1 = dm%z(l, k, 1, i)
459 normal2 = coef%get_normal(1, l, k, i, 6)
463 x2 = dm%x(l, k, n, i)
464 y2 = dm%y(l, k, n, i)
465 z2 = dm%z(l, k, n, i)
467 normal1 = coef%get_normal(1, l, k, i, 6)
471 x1 = dm%x(l, k, n, i)
472 y1 = dm%y(l, k, n, i)
473 z1 = dm%z(l, k, n, i)
474 normal2 = coef%get_normal(1, l, k, i, 5)
478 x2 = dm%x(l, k, 1, i)
479 y2 = dm%y(l, k, 1, i)
480 z2 = dm%z(l, k, 1, i)
482 call neko_error(
"The face index is not correct")
490 dist_1 = v1*n11 + v2*n12 + v3*n13
491 dist_2 = - (v1*n21 + v2*n22 + v3*n23)
493 dist2 = ((dist_1 + dist_2)/2.0_rp)*((dist_1 + dist_2)/2.0_rp)
500 integer :: i, j, k, l
501 real(kind=
rp) :: area_tmp
503 allocate(this%facet_factor(this%lx + 2, this%lx + 2, &
504 this%lx + 2, this%coef%msh%nelv))
506 associate(facet_factor => this%facet_factor, &
509 nelv => this%coef%msh%nelv, &
510 jacinv => this%coef%jacinv, h2 => this%h2, &
511 tau => this%tau, n1 => this%n1, &
512 n2 => this%n2, n3 => this%n3)
520 area_tmp = coef%get_area(1, l, k, i, j)
521 facet_factor(1, l + 1, k + 1, i) = area_tmp * tau * &
522 h2(1, l + 1, k + 1, i) * &
523 (n1(1, l + 1, k + 1, i) * coef%drdx(1, l, k, i) + &
524 n2(1, l + 1, k + 1, i) * coef%drdy(1, l, k, i) + &
525 n3(1, l + 1, k + 1, i) * coef%drdz(1, l, k, i) ) &
528 area_tmp = coef%get_area(1, l, k, i, j)
529 facet_factor(lx + 2, l + 1, k + 1, i) = area_tmp * tau * &
530 h2(lx + 2, l + 1, k + 1, i) * &
531 (n1(lx + 2, l + 1, k + 1, i) * &
532 coef%drdx(lx, l, k, i) + &
533 n2(lx + 2, l + 1, k + 1, i) * &
534 coef%drdy(lx, l, k, i) + &
535 n3(lx + 2, l + 1, k + 1, i) * &
536 coef%drdz(lx, l, k, i) ) &
537 * jacinv(lx, l, k, i)
539 area_tmp = coef%get_area(l, 1, k, i, j)
540 facet_factor(l + 1, 1, k + 1, i) = area_tmp * tau * &
541 h2(l + 1, 1, k + 1, i) * &
542 (n1(l + 1, 1, k + 1, i) * coef%dsdx(l, 1, k, i) + &
543 n2(l + 1, 1, k + 1, i) * coef%dsdy(l, 1, k, i) + &
544 n3(l + 1, 1, k + 1, i) * coef%dsdz(l, 1, k, i) ) &
547 area_tmp = coef%get_area(l, 1, k, i, j)
548 facet_factor(l + 1, lx + 2, k + 1, i) = area_tmp * tau * &
549 h2(l + 1, lx + 2, k + 1, i) * &
550 (n1(l + 1, lx + 2, k + 1, i) * &
551 coef%dsdx(l, lx, k, i) + &
552 n2(l + 1, lx + 2, k + 1, i) * &
553 coef%dsdy(l, lx, k, i) + &
554 n3(l + 1, lx + 2, k + 1, i) * &
555 coef%dsdz(l, lx, k, i) ) &
556 * jacinv(l, lx, k, i)
558 area_tmp = coef%get_area(l, k, 1, i, j)
559 facet_factor(l + 1, k + 1, 1, i) = area_tmp * tau * &
560 h2(l + 1, k + 1, 1, i) * &
561 (n1(l + 1, k + 1, 1, i) * coef%dtdx(l, k, 1, i) + &
562 n2(l + 1, k + 1, 1, i) * coef%dtdy(l, k, 1, i) + &
563 n3(l + 1, k + 1, 1, i) * coef%dtdz(l, k, 1, i) ) &
566 area_tmp = coef%get_area(l, k, 1, i, j)
567 facet_factor(l + 1, k + 1, lx + 2, i) = area_tmp * tau * &
568 h2(l + 1, k + 1, lx + 2, i) * &
569 (n1(l + 1, k + 1, lx + 2, i) * coef%dtdx(l, k, lx, i) + &
570 n2(l + 1, k + 1, lx + 2, i) * coef%dtdy(l, k, lx, i) + &
571 n3(l + 1, k + 1, lx + 2, i) * coef%dtdz(l, k, lx, i) ) &
572 * jacinv(l, k, lx, i)
574 call neko_error(
"The face index is not correct")
820 type(field_t),
intent(in) :: s
822 call dudxyz(this%grad1, s%x, this%coef%drdx, &
823 this%coef%dsdx, this%coef%dtdx, this%coef)
824 call dudxyz(this%grad2, s%x, this%coef%drdy, &
825 this%coef%dsdy, this%coef%dtdy, this%coef)
826 call dudxyz(this%grad3, s%x, this%coef%drdz, &
827 this%coef%dsdz, this%coef%dtdz, this%coef)
829 if (neko_bcknd_device .eq. 1)
then
830 call device_pick_facet_value_hex(this%flux1_d, this%grad1_d, &
831 this%lx, this%coef%msh%nelv)
832 call device_pick_facet_value_hex(this%flux2_d, this%grad2_d, &
833 this%lx, this%coef%msh%nelv)
834 call device_pick_facet_value_hex(this%flux3_d, this%grad3_d, &
835 this%lx, this%coef%msh%nelv)
836 call device_col2(this%flux1_d, this%n1_d, this%n_large)
837 call device_col2(this%flux2_d, this%n2_d, this%n_large)
838 call device_col2(this%flux3_d, this%n3_d, this%n_large)
839 call device_add3s2(this%G_d, this%flux1_d, this%flux2_d, &
840 1.0_rp, 1.0_rp, this%n_large)
841 call device_add2(this%G_d, this%flux3_d, this%n_large)
844 this%lx, this%coef%msh%nelv)
846 this%lx, this%coef%msh%nelv)
848 this%lx, this%coef%msh%nelv)
849 call col2(this%flux1, this%n1, this%n_large)
850 call col2(this%flux2, this%n2, this%n_large)
851 call col2(this%flux3, this%n3, this%n_large)
852 call add3(this%G, this%flux1, this%flux2, this%n_large)
853 call add2(this%G, this%flux3, this%n_large)
856 call this%gs_GJP%op(this%G, this%n_large, gs_op_add)
866 type(field_t),
intent(in) :: u, v, w
870 if (neko_bcknd_device .eq. 1)
then
871 call device_pick_facet_value_hex(this%volflux1_d, u%x_d, this%lx, &
873 call device_pick_facet_value_hex(this%volflux2_d, v%x_d, this%lx, &
875 call device_pick_facet_value_hex(this%volflux3_d, w%x_d, this%lx, &
877 call device_col2(this%volflux1_d, this%n1_d, this%n_large)
878 call device_col2(this%volflux2_d, this%n2_d, this%n_large)
879 call device_col2(this%volflux3_d, this%n3_d, this%n_large)
880 call device_add3s2(this%absvolflux_d, this%volflux1_d, &
881 this%volflux2_d, 1.0_rp, 1.0_rp, this%n_large)
882 call device_add2(this%absvolflux_d, this%volflux3_d, this%n_large)
883 call device_absval(this%absvolflux_d, this%n_large)
886 this%lx, this%coef%msh%nelv)
888 this%lx, this%coef%msh%nelv)
890 this%lx, this%coef%msh%nelv)
891 call col2(this%volflux1, this%n1, this%n_large)
892 call col2(this%volflux2, this%n2, this%n_large)
893 call col2(this%volflux3, this%n3, this%n_large)
894 call add3(this%absvolflux, this%volflux1, this%volflux2, this%n_large)
895 call add2(this%absvolflux, this%volflux3, this%n_large)
896 call absval(this%absvolflux, this%n_large)
907 integer,
intent(in) :: lx, nelv
908 real(kind=rp),
intent(in) :: f_field(lx, lx, lx, nelv)
909 real(kind=rp),
intent(inout) :: f_facet(lx + 2, lx + 2, lx + 2, nelv)
911 call copy(f_facet(1, 2: lx + 1, 2: lx + 1, :), &
912 f_field(1, :, :, :), lx * lx * nelv)
913 call copy(f_facet(lx + 2, 2: lx + 1, 2: lx + 1, :), &
914 f_field(lx, :, :, :), lx * lx * nelv)
915 call copy(f_facet(2: lx + 1, 1, 2: lx + 1, :), &
916 f_field(:, 1, :, :), lx * lx * nelv)
917 call copy(f_facet(2: lx + 1, lx + 2, 2: lx + 1, :), &
918 f_field(:, lx, :, :), lx * lx * nelv)
919 call copy(f_facet(2: lx + 1, 2: lx + 1, 1, :), &
920 f_field(:, :, 1, :), lx * lx * nelv)
921 call copy(f_facet(2: lx + 1, 2: lx + 1, lx + 2, :), &
922 f_field(:, :, lx, :), lx * lx * nelv)