Neko 1.99.5
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
fast3d.f90
Go to the documentation of this file.
1! Copyright (c) 2008-2020, UCHICAGO ARGONNE, LLC.
2!
3! The UChicago Argonne, LLC as Operator of Argonne National
4! Laboratory holds copyright in the Software. The copyright holder
5! reserves all rights except those expressly granted to licensees,
6! and U.S. Government license rights.
7!
8! Redistribution and use in source and binary forms, with or without
9! modification, are permitted provided that the following conditions
10! are met:
11!
12! 1. Redistributions of source code must retain the above copyright
13! notice, this list of conditions and the disclaimer below.
14!
15! 2. Redistributions in binary form must reproduce the above copyright
16! notice, this list of conditions and the disclaimer (as noted below)
17! in the documentation and/or other materials provided with the
18! distribution.
19!
20! 3. Neither the name of ANL nor the names of its contributors
21! may be used to endorse or promote products derived from this software
22! without specific prior written permission.
23!
24! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
28! UCHICAGO ARGONNE, LLC, THE U.S. DEPARTMENT OF
29! ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
31! TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34! (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36!
37! Additional BSD Notice
38! ---------------------
39! 1. This notice is required to be provided under our contract with
40! the U.S. Department of Energy (DOE). This work was produced at
41! Argonne National Laboratory under Contract
42! No. DE-AC02-06CH11357 with the DOE.
43!
44! 2. Neither the United States Government nor UCHICAGO ARGONNE,
45! LLC nor any of their employees, makes any warranty,
46! express or implied, or assumes any liability or responsibility for the
47! accuracy, completeness, or usefulness of any information, apparatus,
48! product, or process disclosed, or represents that its use would not
49! infringe privately-owned rights.
50!
51! 3. Also, reference herein to any specific commercial products, process,
52! or services by trade name, trademark, manufacturer or otherwise does
53! not necessarily constitute or imply its endorsement, recommendation,
54! or favoring by the United States Government or UCHICAGO ARGONNE LLC.
55! The views and opinions of authors expressed
56! herein do not necessarily state or reflect those of the United States
57! Government or UCHICAGO ARGONNE, LLC, and shall
58! not be used for advertising or product endorsement purposes.
59!
61module fast3d
62 use num_types, only : rp, xp
63 use speclib, only : zwgll, zwgl
64 use math, only : rzero
65 implicit none
66 private
67
69
70contains
71
105 subroutine fd_weights_full(xi, x, n, m, c)
106 integer, intent(in) :: n
107 integer, intent(in) :: m
108 real(kind=rp), intent(in) :: x(0:n)
109 real(kind=rp), intent(out) :: c(0:n,0:m)
110 real(kind=rp), intent(in) :: xi
111 real(kind=xp) :: cx(0:n,0:m)
112 real(kind=xp) :: c1, c2, c3, c4, c5
113 integer :: i, j, k, mn
114
115 c1 = 1d0
116 c4 = x(0) - xi
117
118 do k = 0, m
119 do j = 0, n
120 cx(j,k) = 0.0_xp
121 end do
122 end do
123
124 cx(0,0) = 1d0
125
126 do i = 1, n
127 mn = min(i,m)
128 c2 = 1d0
129 c5 = c4
130 c4 = x(i) - xi
131 do j = 0, i - 1
132 c3 = x(i) - x(j)
133 c2 = c2 * c3
134 do k = mn, 1, -1
135 cx(i,k) = c1 * (k * cx(i-1,k-1) - c5 * cx(i-1,k)) / c2
136 end do
137 cx(i,0) = -c1 * c5 * cx(i-1,0) / c2
138 do k = mn, 1, -1
139 cx(j,k) = (c4 * cx(j,k) - k * cx(j,k-1)) / c3
140 end do
141 cx(j,0) = c4 * cx(j,0) / c3
142 end do
143 c1 = c2
144 end do
145 c = real(cx, kind=rp)
146 end subroutine fd_weights_full
147
148
169 subroutine semhat(a, b, c, d, z, dgll, jgll, bgl, zgl, dgl, jgl, n, w)
170 integer, intent(in) :: n
171 real(kind=rp), intent(inout) :: a(0:n,0:n)
172 real(kind=rp), intent(inout) :: b(0:n)
173 real(kind=rp), intent(inout) :: c(0:n,0:n)
174 real(kind=rp), intent(inout) :: d(0:n,0:n)
175 real(kind=rp), intent(inout) :: z(0:n)
176 real(kind=rp), intent(inout) :: dgll(0:n,1:n-1), jgll(0:n,1:n-1)
177 real(kind=rp), intent(inout) :: bgl(1:n-1)
178 real(kind=rp), intent(inout) :: zgl(1:n-1)
179 real(kind=rp), intent(inout) :: dgl(1:n-1,0:n)
180 real(kind=rp), intent(inout) :: jgl(1:n-1,0:n)
181 real(kind=rp), intent(inout) :: w(0:2*n+1)
182 integer :: np, nm, n2, i, j, k
183 np = n+1
184 nm = n-1
185 n2 = n-2
186 call zwgll(z, b, np)
187 do i = 0,n
188 call fd_weights_full(z(i), z, n, 1, w)
189 do j = 0,n
190 d(i,j) = w(j+np) ! Derivative matrix
191 end do
192 end do
193
194 if (n .eq. 1) return ! No interpolation for n = 1
195
196 do i = 0,n
197 call fd_weights_full(z(i), z(1), n2, 1, w(1))
198 do j = 1, nm
199 jgll(i,j) = w(j) ! Interpolation matrix
200 dgll(i,j) = w(j + nm) ! Derivative matrix
201 end do
202 end do
203 call rzero(a, np*np)
204 do j = 0,n
205 do i = 0,n
206 do k = 0,n
207 a(i,j) = a(i,j) + d(k,i)*b(k)*d(k,j)
208 end do
209 c(i,j) = b(i)*d(i,j)
210 end do
211 end do
212 call zwgl(zgl, bgl, nm)
213 do i = 1,n-1
214 call fd_weights_full(zgl(i), z, n, 1, w)
215 do j = 0,n
216 jgl(i,j) = w(j ) ! Interpolation matrix
217 dgl(i,j) = w(j+np) ! Derivative matrix
218 end do
219 end do
220 end subroutine semhat
221
245 subroutine setup_intp(jh, jht, z_to, z_from, n_to, n_from, derivative)
246 implicit none
247 integer, intent(in) :: n_to, n_from, derivative
248 real(kind=rp), intent(inout) :: jh(n_to, n_from), jht(n_from, n_to)
249 real(kind=rp), intent(in) :: z_to(n_to), z_from(n_from)
250 real(kind=rp) :: w(n_from, 0:derivative)
251 integer :: i, j
252 do i = 1, n_to
253 ! This will assign w the weights for interpolating to point
254 ! zf(i) values at points zc
255 call fd_weights_full(z_to(i), z_from, n_from-1, derivative, w)
256
257 ! store each of the weights in the corresponding row/column
258 do j = 1, n_from
259 jh(i,j) = w(j, derivative)
260 jht(j,i) = w(j, derivative)
261 end do
262 end do
263 end subroutine setup_intp
264end module fast3d
double real
Fast diagonalization methods from NEKTON.
Definition fast3d.f90:61
subroutine, public semhat(a, b, c, d, z, dgll, jgll, bgl, zgl, dgl, jgl, n, w)
Generate matrices for single element, 1D operators: a = Laplacian b = diagonal mass matrix c = convec...
Definition fast3d.f90:170
subroutine, public fd_weights_full(xi, x, n, m, c)
Compute finite-difference stencil weights for evaluating derivatives up to order at a point.
Definition fast3d.f90:106
subroutine, public setup_intp(jh, jht, z_to, z_from, n_to, n_from, derivative)
Compute interpolation weights for points z_to using values at points z_from.
Definition fast3d.f90:246
Definition math.f90:60
subroutine, public rzero(a, n)
Zero a real vector.
Definition math.f90:235
integer, parameter, public xp
Definition num_types.f90:14
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
LIBRARY ROUTINES FOR SPECTRAL METHODS.
Definition speclib.f90:149
subroutine dgll(d, dt, z, nz, nzd)
Compute the derivative matrix D and its transpose DT associated with the Nth order Lagrangian interpo...
Definition speclib.f90:881
subroutine zwgll(z, w, np)
Generate NP Gauss-Lobatto Legendre points (Z) and weights (W) associated with Jacobi polynomial P(N)(...
Definition speclib.f90:180
subroutine zwgl(z, w, np)
Generate NP Gauss Legendre points Z and weights W associated with Jacobi polynomial ....
Definition speclib.f90:165