Neko 1.99.11
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
ax_helm_svv_factorized_cpu.f90
Go to the documentation of this file.
1! Copyright (c) 2025-2026, The Neko Authors
2! All rights reserved.
3!
4! Redistribution and use in source and binary forms, with or without
5! modification, are permitted provided that the following conditions
6! are met:
7!
8! * Redistributions of source code must retain the above copyright
9! notice, this list of conditions and the following disclaimer.
10!
11! * Redistributions in binary form must reproduce the above
12! copyright notice, this list of conditions and the following
13! disclaimer in the documentation and/or other materials provided
14! with the distribution.
15!
16! * Neither the name of the authors nor the names of its
17! contributors may be used to endorse or promote products derived
18! from this software without specific prior written permission.
19!
20! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31! POSSIBILITY OF SUCH DAMAGE.
32!
33!> CPU implementation of the factorized SVV Helmholtz operator.
35 use ax_helm_svv, only : ax_helm_svv_t
36 use num_types, only : rp
37 use coefs, only : coef_t
38 use space, only : space_t
39 use mesh, only : mesh_t
40 use math, only : addcol4
41 implicit none
42 private
43
44 !> CPU matrix-vector product for a factorized SVV Helmholtz problem.
46 contains
47 !> Compute the product.
48 procedure, pass(this) :: compute => ax_helm_svv_factorized_compute
50
51contains
52
53 !> Compute the product.
54 !! @param w Vector of size @a (lx,ly,lz,nelv).
55 !! @param u Vector of size @a (lx,ly,lz,nelv).
56 !! @param coef Coefficients.
57 !! @param msh Mesh.
58 !! @param Xh Function space \f$ X_h \f$.
59 subroutine ax_helm_svv_factorized_compute(this, w, u, coef, msh, Xh)
60 class(ax_helm_svv_factorized_cpu_t), intent(in) :: this
61 type(mesh_t), intent(in) :: msh
62 type(space_t), intent(in) :: Xh
63 type(coef_t), intent(in) :: coef
64 real(kind=rp), intent(inout) :: w(xh%lx, xh%ly, xh%lz, msh%nelv)
65 real(kind=rp), intent(in) :: u(xh%lx, xh%ly, xh%lz, msh%nelv)
66
67 call ax_helm_svv_factorized_lx(w, u, xh%dx, xh%dy, xh%dz, &
68 xh%dxt, xh%dyt, xh%dzt, &
69 this%svv%Br, this%svv%Bs, this%svv%Bt, coef%h1, this%svv%h1, &
70 coef%G11, coef%G22, coef%G33, coef%G12, coef%G13, coef%G23, &
71 msh%nelv, xh%lx)
72
73 if (coef%ifh2) call addcol4 (w,coef%h2,coef%B,u,coef%dof%size())
74
75
77
78 !> Generic CPU kernel for the Helmholz matrix-vector product.
79 !! @param w Result.
80 !! @param u Velocity field.
81 !! @param Dx Derivative operator in first dimension.
82 !! @param Dy Derivative operator in second dimension.
83 !! @param Dz Derivative operator in third dimension.
84 !! @param Dxt Derivative operator transpose in first dimension.
85 !! @param Dyt Derivative operator transpose in second dimension.
86 !! @param Dzt Derivative operator transpose in third dimension.
87 !! @param Br Complementary derivative operator in first dimension.
88 !! @param Bs Complementary derivative operator in second dimension.
89 !! @param Bt Complementary derivative operator in third dimension.
90 !! @param h1 Ordinary viscosity coefficient.
91 !! @param svv_h1 SVV viscosity coefficient.
92 !! @param G11 Geometric factor \f$G_{11}\f$.
93 !! @param G22 Geometric factor \f$G_{22}\f$.
94 !! @param G33 Geometric factor \f$G_{33}\f$.
95 !! @param G12 Geometric factor \f$G_{12}\f$.
96 !! @param G13 Geometric factor \f$G_{13}\f$.
97 !! @param G23 Geometric factor \f$G_{23}\f$.
98 !! @param n Number of elements.
99 !! @param lx Polynomial order.
100 subroutine ax_helm_svv_factorized_lx(w, u, Dx, Dy, Dz, Dxt, Dyt, Dzt, &
101 Br, Bs, Bt, h1, svv_h1, G11, G22, G33, G12, G13, G23, n, lx)
102 integer, intent(in) :: n, lx
103 real(kind=rp), intent(inout) :: w(lx, lx, lx, n)
104 real(kind=rp), intent(in) :: u(lx, lx, lx, n)
105 real(kind=rp), intent(in) :: h1(lx, lx, lx, n)
106 real(kind=rp), intent(in) :: svv_h1(lx, lx, lx, n)
107 real(kind=rp), intent(in) :: g11(lx, lx, lx, n)
108 real(kind=rp), intent(in) :: g22(lx, lx, lx, n)
109 real(kind=rp), intent(in) :: g33(lx, lx, lx, n)
110 real(kind=rp), intent(in) :: g12(lx, lx, lx, n)
111 real(kind=rp), intent(in) :: g13(lx, lx, lx, n)
112 real(kind=rp), intent(in) :: g23(lx, lx, lx, n)
113 real(kind=rp), intent(in) :: dx(lx, lx), dy(lx, lx), dz(lx, lx)
114 real(kind=rp), intent(in) :: dxt(lx, lx), dyt(lx, lx), dzt(lx, lx)
115 real(kind=rp), intent(in) :: br(lx, lx), bs(lx, lx), bt(lx, lx)
116 real(kind=rp) :: ur_h
117 real(kind=rp) :: us_h
118 real(kind=rp) :: ut_h
119 real(kind=rp) :: u1_svv(lx, lx, lx)
120 real(kind=rp) :: u2_svv(lx, lx, lx)
121 real(kind=rp) :: u3_svv(lx, lx, lx)
122 real(kind=rp) :: wur(lx, lx, lx)
123 real(kind=rp) :: wus(lx, lx, lx)
124 real(kind=rp) :: wut(lx, lx, lx)
125 real(kind=rp) :: tmp, tmp_svv
126 integer :: e, i, j, k, l
127
128 do e = 1, n
129 ! Ordinary and complementary reference-space derivatives, D u and B u.
130 do j = 1, lx * lx
131 do i = 1, lx
132 tmp = 0.0_rp
133 tmp_svv = 0.0_rp
134 do k = 1, lx
135 tmp = tmp + dx(i,k) * u(k,j,1,e)
136 tmp_svv = tmp_svv + br(i,k) * u(k,j,1,e)
137 end do
138 wur(i,j,1) = tmp
139 u1_svv(i,j,1) = tmp_svv
140 end do
141 end do
142
143 do k = 1, lx
144 do j = 1, lx
145 do i = 1, lx
146 tmp = 0.0_rp
147 tmp_svv = 0.0_rp
148 do l = 1, lx
149 tmp = tmp + dy(j,l) * u(i,l,k,e)
150 tmp_svv = tmp_svv + bs(j,l) * u(i,l,k,e)
151 end do
152 wus(i,j,k) = tmp
153 u2_svv(i,j,k) = tmp_svv
154 end do
155 end do
156 end do
157
158 do k = 1, lx
159 do i = 1, lx*lx
160 tmp = 0.0_rp
161 tmp_svv = 0.0_rp
162 do l = 1, lx
163 tmp = tmp + dz(k,l) * u(i,1,l,e)
164 tmp_svv = tmp_svv + bt(k,l) * u(i,1,l,e)
165 end do
166 wut(i,1,k) = tmp
167 u3_svv(i,1,k) = tmp_svv
168 end do
169 end do
170
171 ! Construct the ordinary and SVV reference-space fluxes.
172 do i = 1, lx*lx*lx
173 ur_h = h1(i,1,1,e) * (g11(i,1,1,e) * wur(i,1,1) &
174 + g12(i,1,1,e) * wus(i,1,1) &
175 + g13(i,1,1,e) * wut(i,1,1))
176 us_h = h1(i,1,1,e) * (g12(i,1,1,e) * wur(i,1,1) &
177 + g22(i,1,1,e) * wus(i,1,1) &
178 + g23(i,1,1,e) * wut(i,1,1))
179 ut_h = h1(i,1,1,e) * (g13(i,1,1,e) * wur(i,1,1) &
180 + g23(i,1,1,e) * wus(i,1,1) &
181 + g33(i,1,1,e) * wut(i,1,1))
182 wur(i,1,1) = ur_h
183 wus(i,1,1) = us_h
184 wut(i,1,1) = ut_h
185
186 ur_h = svv_h1(i,1,1,e) * (g11(i,1,1,e) * u1_svv(i,1,1) &
187 + g12(i,1,1,e) * u2_svv(i,1,1) &
188 + g13(i,1,1,e) * u3_svv(i,1,1))
189 us_h = svv_h1(i,1,1,e) * (g12(i,1,1,e) * u1_svv(i,1,1) &
190 + g22(i,1,1,e) * u2_svv(i,1,1) &
191 + g23(i,1,1,e) * u3_svv(i,1,1))
192 ut_h = svv_h1(i,1,1,e) * (g13(i,1,1,e) * u1_svv(i,1,1) &
193 + g23(i,1,1,e) * u2_svv(i,1,1) &
194 + g33(i,1,1,e) * u3_svv(i,1,1))
195 u1_svv(i,1,1) = ur_h
196 u2_svv(i,1,1) = us_h
197 u3_svv(i,1,1) = ut_h
198 end do
199
200 do j = 1, lx*lx
201 do i = 1, lx
202 tmp = 0.0_rp
203 do k = 1, lx
204 tmp = tmp + dxt(i,k) * wur(k,j,1) &
205 + br(k,i) * u1_svv(k,j,1)
206 end do
207 w(i,j,1,e) = tmp
208 end do
209 end do
210
211 do k = 1, lx
212 do j = 1, lx
213 do i = 1, lx
214 tmp = 0.0_rp
215 do l = 1, lx
216 tmp = tmp + dyt(j,l) * wus(i,l,k) &
217 + bs(l,j) * u2_svv(i,l,k)
218 end do
219 w(i,j,k,e) = w(i,j,k,e) + tmp
220 end do
221 end do
222 end do
223
224 do k = 1, lx
225 do i = 1, lx*lx
226 tmp = 0.0_rp
227 do l = 1, lx
228 tmp = tmp + dzt(k,l) * wut(i,1,l) &
229 + bt(l,k) * u3_svv(i,1,l)
230 end do
231 w(i,1,k,e) = w(i,1,k,e) + tmp
232 end do
233 end do
234
235 end do
236 end subroutine ax_helm_svv_factorized_lx
237
CPU implementation of the factorized SVV Helmholtz operator.
subroutine ax_helm_svv_factorized_compute(this, w, u, coef, msh, xh)
Compute the product.
subroutine ax_helm_svv_factorized_lx(w, u, dx, dy, dz, dxt, dyt, dzt, br, bs, bt, h1, svv_h1, g11, g22, g33, g12, g13, g23, n, lx)
Generic CPU kernel for the Helmholz matrix-vector product.
Base type for an SVV Helmholtz operator.
Coefficients.
Definition coef.f90:34
Definition math.F90:60
subroutine, public addcol4(a, b, c, d, n)
Returns .
Definition math.F90:1229
Defines a mesh.
Definition mesh.f90:34
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:14
Defines a function space.
Definition space.f90:34
Helmholtz operator carrying a non-owning SVV object.
CPU matrix-vector product for a factorized SVV Helmholtz problem.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:136
The function space for the SEM solution fields.
Definition space.f90:64