Neko 1.99.6
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
pnpn_res_cpu.f90
Go to the documentation of this file.
1
3 use gather_scatter, only : gs_t, gs_op_add
4 use operators, only : opgrad, curl, cdtp, rotate_cyc
5 use field, only : field_t
6 use ax_product, only : ax_t
7 use coefs, only : coef_t
11 use mesh, only : mesh_t
12 use num_types, only : rp
13 use space, only : space_t
14 use math, only : copy, cmult2, invers2, rzero
15 use, intrinsic :: iso_c_binding, only : c_ptr
16 implicit none
17 private
18
19 type, public, extends(pnpn_prs_res_t) :: pnpn_prs_res_cpu_t
20 contains
21 procedure, nopass :: compute => pnpn_prs_res_cpu_compute
22 end type pnpn_prs_res_cpu_t
23
24 type, public, extends(pnpn_vel_res_t) :: pnpn_vel_res_cpu_t
25 contains
26 procedure, nopass :: compute => pnpn_vel_res_cpu_compute
27 end type pnpn_vel_res_cpu_t
28
29contains
30
31 subroutine pnpn_prs_res_cpu_compute(p, p_res, u, v, w, u_e, v_e, w_e, f_x, &
32 f_y, f_z, c_Xh, gs_Xh, bc_prs_surface, bc_sym_surface, Ax, bd, dt, mu, &
33 rho, event)
34 type(field_t), intent(inout) :: p, u, v, w
35 type(field_t), intent(in) :: u_e, v_e, w_e
36 type(field_t), intent(inout) :: p_res
37 type(field_t), intent(in) :: f_x, f_y, f_z
38 type(coef_t), intent(inout) :: c_Xh
39 type(gs_t), intent(inout) :: gs_Xh
40 type(facet_normal_t), intent(in) :: bc_prs_surface
41 type(facet_normal_t), intent(in) :: bc_sym_surface
42 class(ax_t), intent(inout) :: Ax
43 real(kind=rp), intent(in) :: bd
44 real(kind=rp), intent(in) :: dt
45 type(field_t), intent(in) :: mu
46 type(field_t), intent(in) :: rho
47 type(c_ptr), intent(inout) :: event
48 real(kind=rp) :: dtbd, rho_val, mu_val
49 integer :: n
50 integer :: i
51 type(field_t), pointer :: ta1, ta2, ta3, wa1, wa2, wa3, work1, work2
52 integer :: temp_indices(8)
53
54 call neko_scratch_registry%request_field(ta1, temp_indices(1), .false.)
55 call neko_scratch_registry%request_field(ta2, temp_indices(2), .false.)
56 call neko_scratch_registry%request_field(ta3, temp_indices(3), .false.)
57 call neko_scratch_registry%request_field(wa1, temp_indices(4), .false.)
58 call neko_scratch_registry%request_field(wa2, temp_indices(5), .false.)
59 call neko_scratch_registry%request_field(wa3, temp_indices(6), .false.)
60 call neko_scratch_registry%request_field(work1, temp_indices(7), .false.)
61 call neko_scratch_registry%request_field(work2, temp_indices(8), .false.)
62
63 n = c_xh%dof%size()
64
65 ! We assume the material properties are constant
66 rho_val = rho%x(1,1,1,1)
67 mu_val = mu%x(1,1,1,1)
68 !OCL NORECURRENCE, NOVREC, NOALIAS
69 !DIR$ CONCURRENT
70 !DIR$ IVDEP
71 !GCC$ ivdep
72 !$omp parallel do
73 do i = 1, n
74 c_xh%h1(i,1,1,1) = 1.0_rp / rho_val
75 c_xh%h2(i,1,1,1) = 0.0_rp
76 end do
77 !$omp end parallel do
78 c_xh%ifh2 = .false.
79
80 call curl(ta1, ta2, ta3, u_e, v_e, w_e, work1, work2, c_xh)
81 call curl(wa1, wa2, wa3, ta1, ta2, ta3, work1, work2, c_xh)
82
83 ! ta = f / rho - wa * mu / rho * B
84 !OCL NORECURRENCE, NOVREC, NOALIAS
85 !DIR$ CONCURRENT
86 !DIR$ IVDEP
87 !GCC$ ivdep
88 !$omp parallel do
89 do i = 1,n
90 ta1%x(i,1,1,1) = f_x%x(i,1,1,1) / rho_val &
91 - ((wa1%x(i,1,1,1) * (mu_val / rho_val)) * c_xh%B(i,1,1,1))
92 ta2%x(i,1,1,1) = f_y%x(i,1,1,1) / rho_val &
93 - ((wa2%x(i,1,1,1) * (mu_val / rho_val)) * c_xh%B(i,1,1,1))
94 ta3%x(i,1,1,1) = f_z%x(i,1,1,1) / rho_val &
95 - ((wa3%x(i,1,1,1) * (mu_val / rho_val)) * c_xh%B(i,1,1,1))
96 end do
97 !$omp end parallel do
98
99 call rotate_cyc(ta1%x, ta2%x, ta3%x, 1, c_xh)
100 call gs_xh%op(ta1%x, ta2%x, ta3%x, n, gs_op_add)
101 call rotate_cyc(ta1%x, ta2%x, ta3%x, 0, c_xh)
102
103 !OCL NORECURRENCE, NOVREC, NOALIAS
104 !DIR$ CONCURRENT
105 !DIR$ IVDEP
106 !GCC$ ivdep
107 !$omp parallel do
108 do i = 1,n
109 ta1%x(i,1,1,1) = ta1%x(i,1,1,1) * c_xh%Binv(i,1,1,1)
110 ta2%x(i,1,1,1) = ta2%x(i,1,1,1) * c_xh%Binv(i,1,1,1)
111 ta3%x(i,1,1,1) = ta3%x(i,1,1,1) * c_xh%Binv(i,1,1,1)
112 end do
113 !$omp end parallel do
114
115 call cdtp(wa1%x, ta1%x, c_xh%drdx, c_xh%dsdx, c_xh%dtdx, c_xh)
116 call cdtp(wa2%x, ta2%x, c_xh%drdy, c_xh%dsdy, c_xh%dtdy, c_xh)
117 call cdtp(wa3%x, ta3%x, c_xh%drdz, c_xh%dsdz, c_xh%dtdz, c_xh)
118
119 call ax%compute(p_res%x, p%x, c_xh, p%msh, p%Xh)
120
121 !$omp parallel private (i)
122 !OCL NORECURRENCE, NOVREC, NOALIAS
123 !DIR$ CONCURRENT
124 !DIR$ IVDEP
125 !GCC$ ivdep
126 !$omp do
127 do i = 1,n
128 p_res%x(i,1,1,1) = (-p_res%x(i,1,1,1)) &
129 + wa1%x(i,1,1,1) + wa2%x(i,1,1,1) + wa3%x(i,1,1,1)
130 end do
131 !$omp end do
132
133 !
134 ! Surface velocity terms
135 !
136 !OCL NORECURRENCE, NOVREC, NOALIAS
137 !DIR$ CONCURRENT
138 !DIR$ IVDEP
139 !GCC$ ivdep
140 !$omp do
141 do i = 1,n
142 wa1%x(i,1,1,1) = 0.0_rp
143 wa2%x(i,1,1,1) = 0.0_rp
144 wa3%x(i,1,1,1) = 0.0_rp
145 end do
146 !$omp end do
147 !$omp end parallel
148
149 call bc_sym_surface%apply_surfvec(wa1%x, wa2%x, wa3%x, ta1%x, ta2%x, ta3%x,&
150 n)
151
152 dtbd = bd / dt
153 !OCL NORECURRENCE, NOVREC, NOALIAS
154 !DIR$ CONCURRENT
155 !DIR$ IVDEP
156 !GCC$ ivdep
157 !$omp parallel do
158 do i = 1, n
159 ta1%x(i,1,1,1) = 0.0_rp
160 ta2%x(i,1,1,1) = 0.0_rp
161 ta3%x(i,1,1,1) = 0.0_rp
162 end do
163 !$omp end parallel do
164
165 call bc_prs_surface%apply_surfvec(ta1%x, ta2%x, ta3%x, u%x, v%x, w%x, n)
166
167 !OCL NORECURRENCE, NOVREC, NOALIAS
168 !DIR$ CONCURRENT
169 !DIR$ IVDEP
170 !GCC$ ivdep
171 !$omp parallel do
172 do i = 1,n
173 p_res%x(i,1,1,1) = p_res%x(i,1,1,1) &
174 - (dtbd * (ta1%x(i,1,1,1) + ta2%x(i,1,1,1) + ta3%x(i,1,1,1)))&
175 - (wa1%x(i,1,1,1) + wa2%x(i,1,1,1) + wa3%x(i,1,1,1))
176 end do
177 !$omp end parallel do
178
179 call neko_scratch_registry%relinquish_field(temp_indices)
180
181 end subroutine pnpn_prs_res_cpu_compute
182
183 subroutine pnpn_vel_res_cpu_compute(Ax, u, v, w, u_res, v_res, w_res, &
184 p, f_x, f_y, f_z, c_Xh, msh, Xh, mu, rho, bd, dt, n)
185 class(ax_t), intent(in) :: Ax
186 type(mesh_t), intent(inout) :: msh
187 type(space_t), intent(inout) :: Xh
188 type(field_t), intent(inout) :: p, u, v, w
189 type(field_t), intent(inout) :: u_res, v_res, w_res
190 type(field_t), intent(in) :: f_x, f_y, f_z
191 type(coef_t), intent(inout) :: c_Xh
192 type(field_t), intent(in) :: mu
193 type(field_t), intent(in) :: rho
194 real(kind=rp), intent(in) :: bd
195 real(kind=rp), intent(in) :: dt
196 real(kind=rp) :: rho_val, mu_val
197 integer :: temp_indices(3)
198 type(field_t), pointer :: ta1, ta2, ta3
199 integer, intent(in) :: n
200 integer :: i
201
202 ! We assume the material properties are constant
203 rho_val = rho%x(1,1,1,1)
204 mu_val = mu%x(1,1,1,1)
205
206 !OCL NORECURRENCE, NOVREC, NOALIAS
207 !DIR$ CONCURRENT
208 !DIR$ IVDEP
209 !GCC$ ivdep
210 !$omp parallel do
211 do i = 1, n
212 c_xh%h1(i,1,1,1) = mu_val
213 c_xh%h2(i,1,1,1) = rho_val * bd / dt
214 end do
215 !$omp end parallel do
216 c_xh%ifh2 = .true.
217
218 call ax%compute(u_res%x, u%x, c_xh, msh, xh)
219 call ax%compute(v_res%x, v%x, c_xh, msh, xh)
220 call ax%compute(w_res%x, w%x, c_xh, msh, xh)
221 call neko_scratch_registry%request_field(ta1, temp_indices(1), .false.)
222 call neko_scratch_registry%request_field(ta2, temp_indices(2), .false.)
223 call neko_scratch_registry%request_field(ta3, temp_indices(3), .false.)
224
225 call opgrad(ta1%x, ta2%x, ta3%x, p%x, c_xh)
226
227 !OCL NORECURRENCE, NOVREC, NOALIAS
228 !DIR$ CONCURRENT
229 !DIR$ IVDEP
230 !GCC$ ivdep
231 !$omp parallel do
232 do i = 1, n
233 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)
234 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)
235 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)
236 end do
237 !$omp end parallel do
238
239 call neko_scratch_registry%relinquish_field(temp_indices)
240
241 end subroutine pnpn_vel_res_cpu_compute
242
243end module pnpn_res_cpu
Apply cyclic boundary condition to a vector field.
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.
Definition math.f90:60
subroutine, public cmult2(a, b, c, n)
Multiplication by constant c .
Definition math.f90:519
subroutine, public invers2(a, b, n)
Compute inverted vector .
Definition math.f90:800
subroutine, public copy(a, b, n)
Copy a vector .
Definition math.f90:291
subroutine, public rzero(a, n)
Zero a real vector.
Definition math.f90:235
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 opgrad(ux, uy, uz, u, coef, es, ee)
Compute the weak gradient of a scalar field, i.e. the gradient multiplied by the mass matrix.
subroutine, public curl(w1, w2, w3, u1, u2, u3, work1, work2, coef, event)
subroutine, public cdtp(dtx, x, dr, ds, dt, coef, es, ee)
Apply D^T to a scalar field, where D is the derivative matrix.
Residuals in the Pn-Pn formulation (CPU version)
subroutine pnpn_vel_res_cpu_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_cpu_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, event)
Defines Pressure and velocity residuals in the Pn-Pn formulation.
Definition pnpn_res.f90:34
Defines a registry for storing and requesting temporary objects This can be used when you have a func...
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:63
Dirichlet condition in facet normal direction.
Gather-scatter kernel.
Abstract type to compute pressure residual.
Definition pnpn_res.f90:48
Abstract type to compute velocity residual.
Definition pnpn_res.f90:54
The function space for the SEM solution fields.
Definition space.f90:64