Neko  0.8.1
A portable framework for high-order spectral element flow simulations
pnpn_res_sx.f90
Go to the documentation of this file.
1 
2 module pnpn_res_sx
3  use gather_scatter, only : gs_t, gs_op_add
4  use operators
5  use field, only : field_t
6  use ax_product, only : ax_t
7  use coefs, only : coef_t
8  use facet_normal, only : facet_normal_t
11  use mesh, only : mesh_t
12  use num_types, only : rp
13  use space, only : space_t
14  implicit none
15  private
16 
17  type, public, extends(pnpn_prs_res_t) :: pnpn_prs_res_sx_t
18  contains
19  procedure, nopass :: compute => pnpn_prs_res_sx_compute
20  end type pnpn_prs_res_sx_t
21 
22  type, public, extends(pnpn_vel_res_t) :: pnpn_vel_res_sx_t
23  contains
24  procedure, nopass :: compute => pnpn_vel_res_sx_compute
25  end type pnpn_vel_res_sx_t
26 
27 contains
28 
29  subroutine pnpn_prs_res_sx_compute(p, p_res, u, v, w, u_e, v_e, w_e, f_x, &
30  f_y, f_z, c_Xh, gs_Xh, bc_prs_surface,bc_sym_surface, Ax, bd, dt, mu, rho)
31  type(field_t), intent(inout) :: p, u, v, w
32  type(field_t), intent(inout) :: u_e, v_e, w_e
33  type(field_t), intent(inout) :: p_res
34  type(field_t), intent(inout) :: f_x, f_y, f_z
35  type(coef_t), intent(inout) :: c_Xh
36  type(gs_t), intent(inout) :: gs_Xh
37  type(facet_normal_t), intent(inout) :: bc_prs_surface
38  type(facet_normal_t), intent(inout) :: bc_sym_surface
39  class(ax_t), intent(inout) :: Ax
40  real(kind=rp), intent(inout) :: bd
41  real(kind=rp), intent(in) :: dt
42  real(kind=rp), intent(in) :: mu
43  real(kind=rp), intent(in) :: rho
44  real(kind=rp) :: dtbd
45  integer :: n
46  integer :: i
47  type(field_t), pointer :: ta1, ta2, ta3, wa1, wa2, wa3, work1, work2
48  integer :: temp_indices(8)
49 
50  call neko_scratch_registry%request_field(ta1, temp_indices(1))
51  call neko_scratch_registry%request_field(ta2, temp_indices(2))
52  call neko_scratch_registry%request_field(ta3, temp_indices(3))
53  call neko_scratch_registry%request_field(wa1, temp_indices(4))
54  call neko_scratch_registry%request_field(wa2, temp_indices(5))
55  call neko_scratch_registry%request_field(wa3, temp_indices(6))
56  call neko_scratch_registry%request_field(work1, temp_indices(7))
57  call neko_scratch_registry%request_field(work2, temp_indices(8))
58 
59  n = c_xh%dof%size()
60 
61  do i = 1, n
62  c_xh%h1(i,1,1,1) = 1.0_rp / rho
63  c_xh%h2(i,1,1,1) = 0.0_rp
64  end do
65  c_xh%ifh2 = .false.
66 
67  call curl(ta1, ta2, ta3, u_e, v_e, w_e, work1, work2, c_xh)
68  call curl(wa1, wa2, wa3, ta1, ta2, ta3, work1, work2, c_xh)
69 
70  do i = 1, n
71  wa1%x(i,1,1,1) = (wa1%x(i,1,1,1) * mu / rho) * c_xh%B(i,1,1,1)
72  wa2%x(i,1,1,1) = (wa2%x(i,1,1,1) * mu / rho) * c_xh%B(i,1,1,1)
73  wa3%x(i,1,1,1) = (wa3%x(i,1,1,1) * mu / rho) * c_xh%B(i,1,1,1)
74  end do
75 
76  do i = 1, n
77  ta1%x(i,1,1,1) = f_x%x(i,1,1,1) / rho - wa1%x(i,1,1,1)
78  ta2%x(i,1,1,1) = f_y%x(i,1,1,1) / rho - wa2%x(i,1,1,1)
79  ta3%x(i,1,1,1) = f_z%x(i,1,1,1) / rho - wa3%x(i,1,1,1)
80  end do
81 
82  call gs_xh%op(ta1, gs_op_add)
83  call gs_xh%op(ta2, gs_op_add)
84  call gs_xh%op(ta3, gs_op_add)
85 
86  do i = 1, n
87  ta1%x(i,1,1,1) = ta1%x(i,1,1,1) * c_xh%Binv(i,1,1,1)
88  ta2%x(i,1,1,1) = ta2%x(i,1,1,1) * c_xh%Binv(i,1,1,1)
89  ta3%x(i,1,1,1) = ta3%x(i,1,1,1) * c_xh%Binv(i,1,1,1)
90  end do
91 
92  call ax%compute(p_res%x,p%x,c_xh,p%msh,p%Xh)
93 
94  call cdtp(wa1%x, ta1%x, c_xh%drdx, c_xh%dsdx, c_xh%dtdx, c_xh)
95  call cdtp(wa2%x, ta2%x, c_xh%drdy, c_xh%dsdy, c_xh%dtdy, c_xh)
96  call cdtp(wa3%x, ta3%x, c_xh%drdz, c_xh%dsdz, c_xh%dtdz, c_xh)
97  do i = 1, n
98  p_res%x(i,1,1,1) = (-p_res%x(i,1,1,1)) &
99  + wa1%x(i,1,1,1) + wa2%x(i,1,1,1) + wa3%x(i,1,1,1)
100  end do
101 
102  !
103  ! Surface velocity terms
104  !
105  do i = 1, n
106  wa1%x(i,1,1,1) = 0.0_rp
107  wa2%x(i,1,1,1) = 0.0_rp
108  wa3%x(i,1,1,1) = 0.0_rp
109  end do
110 
111  call bc_sym_surface%apply_surfvec(wa1%x,wa2%x,wa3%x,ta1%x, ta2%x, ta3%x, n)
112 
113  dtbd = bd / dt
114  do i = 1, n
115  ta1%x(i,1,1,1) = 0.0_rp
116  ta2%x(i,1,1,1) = 0.0_rp
117  ta3%x(i,1,1,1) = 0.0_rp
118  end do
119 
120  call bc_prs_surface%apply_surfvec(ta1%x, ta2%x, ta3%x, u%x, v%x, w%x, n)
121 
122  do i = 1, n
123  p_res%x(i,1,1,1) = p_res%x(i,1,1,1) &
124  - (dtbd * (ta1%x(i,1,1,1) + ta2%x(i,1,1,1) + ta3%x(i,1,1,1)))&
125  - (wa1%x(i,1,1,1) + wa2%x(i,1,1,1) + wa3%x(i,1,1,1))
126  end do
127 
128  call neko_scratch_registry%relinquish_field(temp_indices)
129  end subroutine pnpn_prs_res_sx_compute
130 
131  subroutine pnpn_vel_res_sx_compute(Ax, u, v, w, u_res, v_res, w_res, &
132  p, f_x, f_y, f_z, c_Xh, msh, Xh, mu, rho, bd, dt, n)
133  class(ax_t), intent(in) :: Ax
134  type(mesh_t), intent(inout) :: msh
135  type(space_t), intent(inout) :: Xh
136  type(field_t), intent(inout) :: p, u, v, w
137  type(field_t), intent(inout) :: u_res, v_res, w_res
138  type(field_t), intent(inout) :: f_x, f_y, f_z
139  type(coef_t), intent(inout) :: c_Xh
140  real(kind=rp), intent(in) :: mu
141  real(kind=rp), intent(in) :: rho
142  real(kind=rp), intent(in) :: bd
143  real(kind=rp), intent(in) :: dt
144  integer, intent(in) :: n
145  integer :: temp_indices(3)
146  type(field_t), pointer :: ta1, ta2, ta3
147  integer :: i
148 
149  do i = 1, n
150  c_xh%h1(i,1,1,1) = mu
151  c_xh%h2(i,1,1,1) = rho * (bd / dt)
152  end do
153  c_xh%ifh2 = .true.
154 
155  call ax%compute(u_res%x, u%x, c_xh, msh, xh)
156  call ax%compute(v_res%x, v%x, c_xh, msh, xh)
157  call ax%compute(w_res%x, w%x, c_xh, msh, xh)
158 
159  call neko_scratch_registry%request_field(ta1, temp_indices(1))
160  call neko_scratch_registry%request_field(ta2, temp_indices(2))
161  call neko_scratch_registry%request_field(ta3, temp_indices(3))
162 
163  call opgrad(ta1%x, ta2%x, ta3%x, p%x, c_xh)
164 
165  do i = 1, n
166  u_res%x(i,1,1,1) = (-u_res%x(i,1,1,1)) - ta1%x(i,1,1,1) + f_x%x(i,1,1,1)
167  v_res%x(i,1,1,1) = (-v_res%x(i,1,1,1)) - ta2%x(i,1,1,1) + f_y%x(i,1,1,1)
168  w_res%x(i,1,1,1) = (-w_res%x(i,1,1,1)) - ta3%x(i,1,1,1) + f_z%x(i,1,1,1)
169  end do
170 
171  call neko_scratch_registry%relinquish_field(temp_indices)
172  end subroutine pnpn_vel_res_sx_compute
173 
174 end module pnpn_res_sx
Defines a Matrix-vector product.
Definition: ax.f90:34
Coefficients.
Definition: coef.f90:34
Dirichlet condition applied in the facet normal direction.
Defines a field.
Definition: field.f90:34
Gather-scatter.
Defines a mesh.
Definition: mesh.f90:34
integer, parameter, public rp
Global precision used in computations.
Definition: num_types.f90:12
Operators.
Definition: operators.f90:34
subroutine, public cdtp(dtx, x, dr, ds, dt, coef)
Apply D^T to a scalar field, where D is the derivative matrix.
Definition: operators.f90:157
subroutine, public opgrad(ux, uy, uz, u, coef, es, ee)
Compute the gradient of a scalar field.
Definition: operators.f90:100
subroutine, public curl(w1, w2, w3, u1, u2, u3, work1, work2, coef)
Definition: operators.f90:234
Residuals in the Pn-Pn formulation (SX version)
Definition: pnpn_res_sx.f90:2
subroutine pnpn_vel_res_sx_compute(Ax, u, v, w, u_res, v_res, w_res, p, f_x, f_y, f_z, c_Xh, msh, Xh, mu, rho, bd, dt, n)
subroutine pnpn_prs_res_sx_compute(p, p_res, u, v, w, u_e, v_e, w_e, f_x, f_y, f_z, c_Xh, gs_Xh, bc_prs_surface, bc_sym_surface, Ax, bd, dt, mu, rho)
Definition: pnpn_res_sx.f90:31
Defines Pressure and velocity residuals in the Pn-Pn formulation.
Definition: pnpn_res.f90:34
Defines a registry for storing and requesting temporary fields This can be used when you have a funct...
type(scratch_registry_t), target, public neko_scratch_registry
Global scratch registry.
Defines a function space.
Definition: space.f90:34
Base type for a matrix-vector product providing .
Definition: ax.f90:43
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition: coef.f90:54
Dirichlet condition in facet normal direction.
Abstract type to compute pressure residual.
Definition: pnpn_res.f90:47
Abstract type to compute velocity residual.
Definition: pnpn_res.f90:53
The function space for the SEM solution fields.
Definition: space.f90:62