148    type(json_file), 
target, 
intent(inout) :: params
 
  149    type(
dofmap_t), 
target, 
intent(in) :: dofmap
 
  150    type(
coef_t), 
target, 
intent(in) :: coef
 
  151    real(kind=
rp), 
intent(in) :: a, b
 
  153    integer :: i, j, k, l
 
  154    real(kind=
rp), 
allocatable :: zg(:) 
 
  155    real(kind=
rp) :: normal(3)
 
  163    if (this%p .gt. 1) 
then 
  164       this%tau = -a * (this%p + 1) ** (-b)
 
  170    this%n = this%lx ** 3 * this%coef%msh%nelv
 
  171    this%n_large = (this%lx + 2) ** 3 * this%coef%msh%nelv
 
  173    allocate(this%n_facet(this%coef%msh%nelv))
 
  174    do i = 1, this%coef%msh%nelv
 
  175       select type (ep  => this%coef%msh%elements(i)%e)
 
  180                           &supported now for gradient jump penalty")
 
  183    this%n_facet_max = maxval(this%n_facet)
 
  185    allocate(this%h2(this%lx + 2, this%lx + 2, &
 
  186                        this%lx + 2, this%coef%msh%nelv))
 
  188    do i = 1, this%coef%msh%nelv
 
  189       select type (ep => this%coef%msh%elements(i)%e)
 
  191          call eval_h2_hex(this%h2(:, :, :, i), this%lx, i, this%dm, this%coef)
 
  193          call neko_error(
"Gradient jump penalty error: mesh size & 
  194                            &evaluation is not supported for quad_t")
 
  198    allocate(zg(this%lx))
 
  199    allocate(this%dphidxi(this%lx, this%lx))
 
  204          this%dphidxi(j,i) = this%coef%Xh%dx(j,i)
 
  208    allocate(this%penalty(this%lx, this%lx, this%lx, this%coef%msh%nelv))
 
  209    allocate(this%grad1(this%lx, this%lx, this%lx, this%coef%msh%nelv))
 
  210    allocate(this%grad2(this%lx, this%lx, this%lx, this%coef%msh%nelv))
 
  211    allocate(this%grad3(this%lx, this%lx, this%lx, this%coef%msh%nelv))
 
  213    allocate(this%penalty_facet(this%lx + 2, this%lx + 2, &
 
  214                    this%lx + 2, this%coef%msh%nelv))
 
  215    allocate(this%G(this%lx + 2, this%lx + 2, &
 
  216                    this%lx + 2, this%coef%msh%nelv))
 
  217    allocate(this%flux1(this%lx + 2, this%lx + 2, &
 
  218                        this%lx + 2, this%coef%msh%nelv))
 
  219    allocate(this%flux2(this%lx + 2, this%lx + 2, &
 
  220                        this%lx + 2, this%coef%msh%nelv))
 
  221    allocate(this%flux3(this%lx + 2, this%lx + 2, &
 
  222                        this%lx + 2, this%coef%msh%nelv))
 
  223    allocate(this%volflux1(this%lx + 2, this%lx + 2, &
 
  224                        this%lx + 2, this%coef%msh%nelv))
 
  225    allocate(this%volflux2(this%lx + 2, this%lx + 2, &
 
  226                        this%lx + 2, this%coef%msh%nelv))
 
  227    allocate(this%volflux3(this%lx + 2, this%lx + 2, &
 
  228                        this%lx + 2, this%coef%msh%nelv))
 
  229    allocate(this%absvolflux(this%lx + 2, this%lx + 2, &
 
  230                        this%lx + 2, this%coef%msh%nelv))
 
  231    allocate(this%n1(this%lx + 2, this%lx + 2, &
 
  232                        this%lx + 2, this%coef%msh%nelv))
 
  233    allocate(this%n2(this%lx + 2, this%lx + 2, &
 
  234                        this%lx + 2, this%coef%msh%nelv))
 
  235    allocate(this%n3(this%lx + 2, this%lx + 2, &
 
  236                        this%lx + 2, this%coef%msh%nelv))
 
  239    do i = 1, this%coef%msh%nelv
 
  245                   normal = this%coef%get_normal(1, l, k, i, j)
 
  246                   this%n1(1, l + 1, k + 1, i) = normal(1)
 
  247                   this%n2(1, l + 1, k + 1, i) = normal(2)
 
  248                   this%n3(1, l + 1, k + 1, i) = normal(3)
 
  250                   normal = this%coef%get_normal(1, l, k, i, j)
 
  251                   this%n1(this%lx + 2, l + 1, k + 1, i) = normal(1)
 
  252                   this%n2(this%lx + 2, l + 1, k + 1, i) = normal(2)
 
  253                   this%n3(this%lx + 2, l + 1, k + 1, i) = normal(3)
 
  255                   normal = this%coef%get_normal(l, 1, k, i, j)
 
  256                   this%n1(l + 1, 1, k + 1, i) = normal(1)
 
  257                   this%n2(l + 1, 1, k + 1, i) = normal(2)
 
  258                   this%n3(l + 1, 1, k + 1, i) = normal(3)
 
  260                   normal = this%coef%get_normal(l, 1, k, i, j)
 
  261                   this%n1(l + 1, this%lx + 2, k + 1, i) = normal(1)
 
  262                   this%n2(l + 1, this%lx + 2, k + 1, i) = normal(2)
 
  263                   this%n3(l + 1, this%lx + 2, k + 1, i) = normal(3)
 
  265                   normal = this%coef%get_normal(l, k, 1, i, j)
 
  266                   this%n1(l + 1, k + 1, 1, i) = normal(1)
 
  267                   this%n2(l + 1, k + 1, 1, i) = normal(2)
 
  268                   this%n3(l + 1, k + 1, 1, i) = normal(3)
 
  270                   normal = this%coef%get_normal(l, k, 1, i, j)
 
  271                   this%n1(l + 1, k + 1, this%lx + 2, i) = normal(1)
 
  272                   this%n2(l + 1, k + 1, this%lx + 2, i) = normal(2)
 
  273                   this%n3(l + 1, k + 1, this%lx + 2, i) = normal(3)
 
  275                   call neko_error(
"The face index is not correct")
 
  286    call this%Xh_GJP%init(
gll, this%lx+2, this%lx+2, this%lx+2)
 
  287    call this%dm_GJP%init(this%coef%msh, this%Xh_GJP)
 
  288    call this%gs_GJP%init(this%dm_GJP)
 
  292       call device_map(this%dphidxi, this%dphidxi_d, &
 
  294       call device_map(this%penalty, this%penalty_d, this%n)
 
  295       call device_map(this%grad1, this%grad1_d, this%n)
 
  296       call device_map(this%grad2, this%grad2_d, this%n)
 
  297       call device_map(this%grad3, this%grad3_d, this%n)
 
  299       call device_map(this%penalty_facet, this%penalty_facet_d, this%n_large)
 
  300       call device_map(this%G, this%G_d, this%n_large)
 
  301       call device_map(this%flux1, this%flux1_d, this%n_large)
 
  302       call device_map(this%flux2, this%flux2_d, this%n_large)
 
  303       call device_map(this%flux3, this%flux3_d, this%n_large)
 
  305       call device_map(this%volflux1, this%volflux1_d, this%n_large)
 
  306       call device_map(this%volflux2, this%volflux2_d, this%n_large)
 
  307       call device_map(this%volflux3, this%volflux3_d, this%n_large)
 
  308       call device_map(this%absvolflux, this%absvolflux_d, this%n_large)
 
  310       call device_map(this%n1, this%n1_d, this%n_large)
 
  311       call device_map(this%n2, this%n2_d, this%n_large)
 
  312       call device_map(this%n3, this%n3_d, this%n_large)
 
  313       call device_map(this%facet_factor, this%facet_factor_d, this%n_large)
 
  324       call device_memcpy(this%facet_factor, this%facet_factor_d, this%n_large,&
 
 
  376    integer, 
intent(in) :: l, k, j, i, n
 
  377    type(
dofmap_t), 
pointer, 
intent(in) :: dm
 
  378    type(
coef_t), 
pointer, 
intent(in) :: coef
 
  379    real(kind=
rp) :: dist2, dist_1, dist_2
 
  381    real(kind=
rp) :: x1, y1, z1, x2, y2, z2
 
  382    real(kind=
rp) :: normal1(3), normal2(3)
 
  383    real(kind=
rp) :: n11, n12, n13, n21, n22, n23
 
  384    real(kind=
rp) :: v1, v2, v3
 
  389       normal1 = coef%get_normal(1, l, k, i, 1)
 
  393       x1 = dm%x(1, l, k, i)
 
  394       y1 = dm%y(1, l, k, i)
 
  395       z1 = dm%z(1, l, k, i)
 
  396       normal2 = coef%get_normal(1, l, k, i, 2)
 
  400       x2 = dm%x(n, l, k, i)
 
  401       y2 = dm%y(n, l, k, i)
 
  402       z2 = dm%z(n, l, k, i)
 
  406       normal1 = coef%get_normal(1, l, k, i, 2)
 
  410       x1 = dm%x(n, l, k, i)
 
  411       y1 = dm%y(n, l, k, i)
 
  412       z1 = dm%z(n, l, k, i)
 
  413       normal2 = coef%get_normal(1, l, k, i, 1)
 
  417       x2 = dm%x(1, l, k, i)
 
  418       y2 = dm%y(1, l, k, i)
 
  419       z2 = dm%z(1, l, k, i)
 
  421       normal1 = coef%get_normal(1, l, k, i, 3)
 
  425       x1 = dm%x(l, 1, k, i)
 
  426       y1 = dm%y(l, 1, k, i)
 
  427       z1 = dm%z(l, 1, k, i)
 
  428       normal2 = coef%get_normal(1, l, k, i, 4)
 
  432       x2 = dm%x(l, n, k, i)
 
  433       y2 = dm%y(l, n, k, i)
 
  434       z2 = dm%z(l, n, k, i)
 
  436       normal1 = coef%get_normal(1, l, k, i, 4)
 
  440       x1 = dm%x(l, n, k, i)
 
  441       y1 = dm%y(l, n, k, i)
 
  442       z1 = dm%z(l, n, k, i)
 
  443       normal2 = coef%get_normal(1, l, k, i, 3)
 
  447       x2 = dm%x(l, 1, k, i)
 
  448       y2 = dm%y(l, 1, k, i)
 
  449       z2 = dm%z(l, 1, k, i)
 
  451       normal1 = coef%get_normal(1, l, k, i, 5)
 
  455       x1 = dm%x(l, k, 1, i)
 
  456       y1 = dm%y(l, k, 1, i)
 
  457       z1 = dm%z(l, k, 1, i)
 
  458       normal2 = coef%get_normal(1, l, k, i, 6)
 
  462       x2 = dm%x(l, k, n, i)
 
  463       y2 = dm%y(l, k, n, i)
 
  464       z2 = dm%z(l, k, n, i)
 
  466       normal1 = coef%get_normal(1, l, k, i, 6)
 
  470       x1 = dm%x(l, k, n, i)
 
  471       y1 = dm%y(l, k, n, i)
 
  472       z1 = dm%z(l, k, n, i)
 
  473       normal2 = coef%get_normal(1, l, k, i, 5)
 
  477       x2 = dm%x(l, k, 1, i)
 
  478       y2 = dm%y(l, k, 1, i)
 
  479       z2 = dm%z(l, k, 1, i)
 
  481       call neko_error(
"The face index is not correct")
 
  489    dist_1 = v1*n11 + v2*n12 + v3*n13
 
  490    dist_2 = - (v1*n21 + v2*n22 + v3*n23)
 
  492    dist2 = ((dist_1 + dist_2)/2.0_rp)*((dist_1 + dist_2)/2.0_rp)
 
 
  499    integer :: i, j, k, l
 
  500    real(kind=
rp) :: area_tmp
 
  502    allocate(this%facet_factor(this%lx + 2, this%lx + 2, &
 
  503                               this%lx + 2, this%coef%msh%nelv))
 
  505    associate(facet_factor => this%facet_factor, &
 
  508              nelv => this%coef%msh%nelv, &
 
  509              jacinv => this%coef%jacinv, h2 => this%h2, &
 
  510              tau => this%tau, n1 => this%n1, &
 
  511              n2 => this%n2, n3 => this%n3)
 
  519                   area_tmp = coef%get_area(1, l, k, i, j)
 
  520                   facet_factor(1, l + 1, k + 1, i) = area_tmp * tau * &
 
  521                           h2(1, l + 1, k + 1, i) * &
 
  522                           (n1(1, l + 1, k + 1, i) * coef%drdx(1, l, k, i) + &
 
  523                            n2(1, l + 1, k + 1, i) * coef%drdy(1, l, k, i) + &
 
  524                            n3(1, l + 1, k + 1, i) * coef%drdz(1, l, k, i) ) &
 
  527                   area_tmp = coef%get_area(1, l, k, i, j)
 
  528                   facet_factor(lx + 2, l + 1, k + 1, i) = area_tmp * tau * &
 
  529                           h2(lx + 2, l + 1, k + 1, i) * &
 
  530                           (n1(lx + 2, l + 1, k + 1, i) * &
 
  531                            coef%drdx(lx, l, k, i) + &
 
  532                            n2(lx + 2, l + 1, k + 1, i) * &
 
  533                            coef%drdy(lx, l, k, i) + &
 
  534                            n3(lx + 2, l + 1, k + 1, i) * &
 
  535                            coef%drdz(lx, l, k, i) ) &
 
  536                           * jacinv(lx, l, k, i)
 
  538                   area_tmp = coef%get_area(l, 1, k, i, j)
 
  539                   facet_factor(l + 1, 1, k + 1, i) = area_tmp * tau * &
 
  540                           h2(l + 1, 1, k + 1, i) * &
 
  541                           (n1(l + 1, 1, k + 1, i) * coef%dsdx(l, 1, k, i) + &
 
  542                            n2(l + 1, 1, k + 1, i) * coef%dsdy(l, 1, k, i) + &
 
  543                            n3(l + 1, 1, k + 1, i) * coef%dsdz(l, 1, k, i) ) &
 
  546                   area_tmp = coef%get_area(l, 1, k, i, j)
 
  547                   facet_factor(l + 1, lx + 2, k + 1, i) = area_tmp * tau * &
 
  548                           h2(l + 1, lx + 2, k + 1, i) * &
 
  549                           (n1(l + 1, lx + 2, k + 1, i) * &
 
  550                            coef%dsdx(l, lx, k, i) + &
 
  551                            n2(l + 1, lx + 2, k + 1, i) * &
 
  552                            coef%dsdy(l, lx, k, i) + &
 
  553                            n3(l + 1, lx + 2, k + 1, i) * &
 
  554                            coef%dsdz(l, lx, k, i) ) &
 
  555                           * jacinv(l, lx, k, i)
 
  557                   area_tmp = coef%get_area(l, k, 1, i, j)
 
  558                   facet_factor(l + 1, k + 1, 1, i) = area_tmp * tau * &
 
  559                           h2(l + 1, k + 1, 1, i) * &
 
  560                           (n1(l + 1, k + 1, 1, i) * coef%dtdx(l, k, 1, i) + &
 
  561                            n2(l + 1, k + 1, 1, i) * coef%dtdy(l, k, 1, i) + &
 
  562                            n3(l + 1, k + 1, 1, i) * coef%dtdz(l, k, 1, i) ) &
 
  565                   area_tmp = coef%get_area(l, k, 1, i, j)
 
  566                   facet_factor(l + 1, k + 1, lx + 2, i) = area_tmp * tau * &
 
  567                           h2(l + 1, k + 1, lx + 2, i) * &
 
  568                           (n1(l + 1, k + 1, lx + 2, i) * coef%dtdx(l, k, lx, i) + &
 
  569                            n2(l + 1, k + 1, lx + 2, i) * coef%dtdy(l, k, lx, i) + &
 
  570                            n3(l + 1, k + 1, lx + 2, i) * coef%dtdz(l, k, lx, i) ) &
 
  571                           * jacinv(l, k, lx, i)
 
  573                   call neko_error(
"The face index is not correct")
 
 
  819    type(field_t), 
intent(in) :: s
 
  821    call dudxyz(this%grad1, s%x, this%coef%drdx, &
 
  822                this%coef%dsdx, this%coef%dtdx, this%coef)
 
  823    call dudxyz(this%grad2, s%x, this%coef%drdy, &
 
  824                this%coef%dsdy, this%coef%dtdy, this%coef)
 
  825    call dudxyz(this%grad3, s%x, this%coef%drdz, &
 
  826                this%coef%dsdz, this%coef%dtdz, this%coef)
 
  828    if (neko_bcknd_device .eq. 1) 
then 
  829       call device_pick_facet_value_hex(this%flux1_d, this%grad1_d, &
 
  830                                 this%lx, this%coef%msh%nelv)
 
  831       call device_pick_facet_value_hex(this%flux2_d, this%grad2_d, &
 
  832                                 this%lx, this%coef%msh%nelv)
 
  833       call device_pick_facet_value_hex(this%flux3_d, this%grad3_d, &
 
  834                                 this%lx, this%coef%msh%nelv)
 
  835       call device_col2(this%flux1_d, this%n1_d, this%n_large)
 
  836       call device_col2(this%flux2_d, this%n2_d, this%n_large)
 
  837       call device_col2(this%flux3_d, this%n3_d, this%n_large)
 
  838       call device_add3s2(this%G_d, this%flux1_d, this%flux2_d, &
 
  839                          1.0_rp, 1.0_rp, this%n_large)
 
  840       call device_add2(this%G_d, this%flux3_d, this%n_large)
 
  843                                 this%lx, this%coef%msh%nelv)
 
  845                                 this%lx, this%coef%msh%nelv)
 
  847                                 this%lx, this%coef%msh%nelv)
 
  848       call col2(this%flux1, this%n1, this%n_large)
 
  849       call col2(this%flux2, this%n2, this%n_large)
 
  850       call col2(this%flux3, this%n3, this%n_large)
 
  851       call add3(this%G, this%flux1, this%flux2, this%n_large)
 
  852       call add2(this%G, this%flux3, this%n_large)
 
  855    call this%gs_GJP%op(this%G, this%n_large, gs_op_add)
 
 
  865    type(field_t), 
intent(in) :: u, v, w
 
  869    if (neko_bcknd_device .eq. 1) 
then 
  870       call device_pick_facet_value_hex(this%volflux1_d, u%x_d, this%lx, &
 
  872       call device_pick_facet_value_hex(this%volflux2_d, v%x_d, this%lx, &
 
  874       call device_pick_facet_value_hex(this%volflux3_d, w%x_d, this%lx, &
 
  876       call device_col2(this%volflux1_d, this%n1_d, this%n_large)
 
  877       call device_col2(this%volflux2_d, this%n2_d, this%n_large)
 
  878       call device_col2(this%volflux3_d, this%n3_d, this%n_large)
 
  879       call device_add3s2(this%absvolflux_d, this%volflux1_d, &
 
  880                          this%volflux2_d, 1.0_rp, 1.0_rp, this%n_large)
 
  881       call device_add2(this%absvolflux_d, this%volflux3_d, this%n_large)
 
  882       call device_absval(this%absvolflux_d, this%n_large)
 
  885                                 this%lx, this%coef%msh%nelv)
 
  887                                 this%lx, this%coef%msh%nelv)
 
  889                                 this%lx, this%coef%msh%nelv)
 
  890       call col2(this%volflux1, this%n1, this%n_large)
 
  891       call col2(this%volflux2, this%n2, this%n_large)
 
  892       call col2(this%volflux3, this%n3, this%n_large)
 
  893       call add3(this%absvolflux, this%volflux1, this%volflux2, this%n_large)
 
  894       call add2(this%absvolflux, this%volflux3, this%n_large)
 
  895       call absval(this%absvolflux, this%n_large)
 
 
  906    integer, 
intent(in) :: lx, nelv
 
  907    real(kind=rp), 
intent(in) :: f_field(lx, lx, lx, nelv)
 
  908    real(kind=rp), 
intent(inout) :: f_facet(lx + 2, lx + 2, lx + 2, nelv)
 
  910    call copy(f_facet(1, 2: lx + 1, 2: lx + 1, :), &
 
  911              f_field(1, :, :, :), lx * lx * nelv)
 
  912    call copy(f_facet(lx + 2, 2: lx + 1, 2: lx + 1, :), &
 
  913              f_field(lx, :, :, :), lx * lx * nelv)
 
  914    call copy(f_facet(2: lx + 1, 1, 2: lx + 1, :), &
 
  915              f_field(:, 1, :, :), lx * lx * nelv)
 
  916    call copy(f_facet(2: lx + 1, lx + 2, 2: lx + 1, :), &
 
  917              f_field(:, lx, :, :), lx * lx * nelv)
 
  918    call copy(f_facet(2: lx + 1, 2: lx + 1, 1, :), &
 
  919              f_field(:, :, 1, :), lx * lx * nelv)
 
  920    call copy(f_facet(2: lx + 1, 2: lx + 1, lx + 2, :), &
 
  921              f_field(:, :, lx, :), lx * lx * nelv)