Neko 1.99.1
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
63 use speclib
64 use math, only : rzero
65 implicit none
66 private
67
69
70contains
71
104 subroutine fd_weights_full(xi, x, n, m, c)
105 integer, intent(in) :: n
106 integer, intent(in) :: m
107 real(kind=rp), intent(in) :: x(0:n)
108 real(kind=rp), intent(out) :: c(0:n,0:m)
109 real(kind=rp), intent(in) :: xi
110 real(kind=xp) :: cx(0:n,0:m)
111 real(kind=xp) :: c1, c2, c3, c4, c5
112 integer :: i, j, k, mn
113
114 c1 = 1d0
115 c4 = x(0) - xi
116
117 do k = 0, m
118 do j = 0, n
119 cx(j,k) = 0.0_xp
120 end do
121 end do
122
123 cx(0,0) = 1d0
124
125 do i = 1, n
126 mn = min(i,m)
127 c2 = 1d0
128 c5 = c4
129 c4 = x(i) - xi
130 do j = 0, i - 1
131 c3 = x(i) - x(j)
132 c2 = c2 * c3
133 do k = mn, 1, -1
134 cx(i,k) = c1 * (k * cx(i-1,k-1) - c5 * cx(i-1,k)) / c2
135 end do
136 cx(i,0) = -c1 * c5 * cx(i-1,0) / c2
137 do k = mn, 1, -1
138 cx(j,k) = (c4 * cx(j,k) - k * cx(j,k-1)) / c3
139 end do
140 cx(j,0) = c4 * cx(j,0) / c3
141 end do
142 c1 = c2
143 end do
144 c = real(cx, kind=rp)
145 end subroutine fd_weights_full
146
147
168 subroutine semhat(a, b, c, d, z, dgll, jgll, bgl, zgl, dgl, jgl, n, w)
169 integer, intent(in) :: n
170 real(kind=rp), intent(inout) :: a(0:n,0:n)
171 real(kind=rp), intent(inout) :: b(0:n)
172 real(kind=rp), intent(inout) :: c(0:n,0:n)
173 real(kind=rp), intent(inout) :: d(0:n,0:n)
174 real(kind=rp), intent(inout) :: z(0:n)
175 real(kind=rp), intent(inout) :: dgll(0:n,1:n-1),jgll(0:n,1:n-1)
176 real(kind=rp), intent(inout) :: bgl(1:n-1)
177 real(kind=rp), intent(inout) :: zgl(1:n-1)
178 real(kind=rp), intent(inout) :: dgl(1:n-1,0:n)
179 real(kind=rp), intent(inout) :: jgl(1:n-1,0:n)
180 real(kind=rp), intent(inout) :: w(0:2*n+1)
181 integer :: np, nm, n2, i, j, k
182 np = n+1
183 nm = n-1
184 n2 = n-2
185 call zwgll(z, b, np)
186 do i = 0,n
187 call fd_weights_full(z(i), z, n, 1, w)
188 do j = 0,n
189 d(i,j) = w(j+np) ! Derivative matrix
190 end do
191 end do
192
193 if (n.eq.1) return ! No interpolation for n=1
194
195 do i = 0,n
196 call fd_weights_full(z(i), z(1), n2, 1, w(1))
197 do j = 1,nm
198 jgll(i,j) = w(j) ! Interpolation matrix
199 dgll(i,j) = w(j + nm) ! Derivative matrix
200 end do
201 end do
202 call rzero(a, np*np)
203 do j = 0,n
204 do i = 0,n
205 do k = 0,n
206 a(i,j) = a(i,j) + d(k,i)*b(k)*d(k,j)
207 end do
208 c(i,j) = b(i)*d(i,j)
209 end do
210 end do
211 call zwgl(zgl, bgl, nm)
212 do i = 1,n-1
213 call fd_weights_full(zgl(i), z, n, 1, w)
214 do j = 0,n
215 jgl(i,j) = w(j ) ! Interpolation matrix
216 dgl(i,j) = w(j+np) ! Derivative matrix
217 end do
218 end do
219 end subroutine semhat
220
243 subroutine setup_intp(jh, jht, z_to, z_from, n_to, n_from, derivative)
244 implicit none
245 integer, intent(in) :: n_to, n_from, derivative
246 real(kind=rp), intent(inout) :: jh(n_to, n_from), jht(n_from, n_to)
247 real(kind=rp), intent(in) :: z_to(n_to), z_from(n_from)
248 real(kind=rp) :: w(n_from, 0:derivative)
249 integer :: i, j
250 do i = 1, n_to
251 ! This will assign w the weights for interpolating to point
252 ! zf(i) values at points zc
253 call fd_weights_full(z_to(i), z_from, n_from-1, derivative, w)
254
255 ! store each of the weights in the corresponding row/column
256 do j = 1, n_from
257 jh(i,j) = w(j, derivative)
258 jht(j,i) = w(j, derivative)
259 end do
260 end do
261 end subroutine setup_intp
262end 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:169
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:105
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:244
Definition math.f90:60
subroutine, public rzero(a, n)
Zero a real vector.
Definition math.f90:205
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:148
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:880
subroutine zwgll(z, w, np)
Generate NP Gauss-Lobatto Legendre points (Z) and weights (W) associated with Jacobi polynomial P(N)(...
Definition speclib.f90:179
subroutine zwgl(z, w, np)
Generate NP Gauss Legendre points Z and weights W associated with Jacobi polynomial ....
Definition speclib.f90:164