52 real(kind=
rp),
allocatable :: v(:,:)
54 real(kind=
rp),
allocatable :: vt(:,:)
55 real(kind=
rp),
allocatable :: vinv(:,:)
56 real(kind=
rp),
allocatable :: vinvt(:,:)
58 real(kind=
rp),
allocatable :: w(:,:)
60 real(kind=
rp),
allocatable :: fldhat(:,:,:,:)
64 type(
mesh_t),
pointer :: msh => null()
80 type(
field_t),
intent(in),
target :: u
111 if(
allocated(
cpr%v))
then
115 if(
allocated(
cpr%vt))
then
119 if(
allocated(
cpr%vinv))
then
123 if(
allocated(
cpr%vinvt))
then
124 deallocate(
cpr%vinvt)
127 if(
allocated(
cpr%w))
then
131 if(
allocated(
cpr%fldhat))
then
132 deallocate(
cpr%fldhat)
146 type(
cpr_t),
intent(inout) :: cpr
147 real(kind=
rp) :: l(0:
cpr%Xh%lx-1)
148 real(kind=
rp) :: delta(
cpr%Xh%lx)
149 integer :: i, kj, j, j2, kk
151 associate(xh =>
cpr%Xh, v=>
cpr%v, vt =>
cpr%vt, &
152 vinv =>
cpr%vinv, vinvt =>
cpr%vinvt, w =>
cpr%w)
160 l(j2) = ( (2*j2-1) * xh%zg(j,1) * l(j2-1) &
161 - (j2-1) * l(j2-2) ) / j2
174 delta(i) = 2.0_rp / (2*(i-1)+1)
177 delta(xh%lx) = 2.0_rp / (xh%lx-1)
181 delta(i) = sqrt(1.0_rp / delta(i))
186 v(i,j) = v(i,j) * delta(j)
191 call copy(vt, v, xh%lx * xh%lx)
192 call trsp1(vt, xh%lx)
208 call mxm(vt, xh%lx, w, xh%lx, vinv, xh%lx)
211 call copy(vinvt, vinv, xh%lx * xh%lx)
212 call trsp1(vinvt, xh%lx)
221 type(
cpr_t),
intent(inout) :: cpr
222 real(kind=rp) :: w2(
cpr%Xh%lx,
cpr%Xh%lx,
cpr%Xh%lx)
223 real(kind=rp) :: w1(
cpr%Xh%lx,
cpr%Xh%lx,
cpr%Xh%lx)
224 real(kind=rp) :: specmat(
cpr%Xh%lx,
cpr%Xh%lx)
225 real(kind=rp) :: specmatt(
cpr%Xh%lx,
cpr%Xh%lx)
226 integer :: k, e, nxyz, nelv
227 character(len=4) :: space
234 if (
space .eq.
'spec')
then
235 call copy(specmat,
cpr%vinv,
cpr%Xh%lx*
cpr%Xh%lx)
236 call copy(specmatt,
cpr%vinvt,
cpr%Xh%lx*
cpr%Xh%lx)
238 if (
space .eq.
'phys')
then
239 call copy(specmat,
cpr%v,
cpr%Xh%lx*
cpr%Xh%lx)
240 call copy(specmatt,
cpr%vt,
cpr%Xh%lx*
cpr%Xh%lx)
245 if (
space .eq.
'spec')
then
246 call copy(w2,
cpr%fld%x(1,1,1,e), nxyz)
248 call copy(w2,
cpr%fldhat(1,1,1,e), nxyz)
251 call mxm(specmat,
cpr%Xh%lx, w2,
cpr%Xh%lx, w1,
cpr%Xh%lx*
cpr%Xh%lx)
254 call mxm(w1(1,1,k),
cpr%Xh%lx,specmatt,
cpr%Xh%lx,w2(1,1,k),
cpr%Xh%lx)
257 call mxm (w2,
cpr%Xh%lx*
cpr%Xh%lx, specmatt,
cpr%Xh%lx,&
258 cpr%fldhat(1,1,1,e),
cpr%Xh%lx)
265 type(
cpr_t),
intent(inout) :: cpr
266 type(coef_t),
intent(inout) :: coef
267 real(kind=rp) :: w2(
cpr%Xh%lx,
cpr%Xh%lx,
cpr%Xh%lx)
268 real(kind=rp) :: w1(
cpr%Xh%lx,
cpr%Xh%lx,
cpr%Xh%lx)
269 real(kind=rp) :: vsort(
cpr%Xh%lx *
cpr%Xh%lx *
cpr%Xh%lx)
270 real(kind=rp) :: vtrunc(
cpr%Xh%lx,
cpr%Xh%lx,
cpr%Xh%lx)
271 real(kind=rp) :: vtemp(
cpr%Xh%lx *
cpr%Xh%lx *
cpr%Xh%lx)
272 real(kind=rp) :: errvec(
cpr%Xh%lx,
cpr%Xh%lx,
cpr%Xh%lx)
273 real(kind=rp) :: fx(
cpr%Xh%lx,
cpr%Xh%lx)
274 real(kind=rp) :: fy(
cpr%Xh%lx,
cpr%Xh%lx)
275 real(kind=rp) :: fz(
cpr%Xh%lx,
cpr%Xh%lx)
276 real(kind=rp) :: l2norm, oldl2norm, targeterr
277 integer :: isort(cpr%Xh%lx * cpr%Xh%lx * cpr%Xh%lx)
278 integer :: i, j, k, e, nxyz, nelv
279 integer :: kut, kutx, kuty, kutz, nx
280 character(len=LOG_SIZE) :: log_buf
291 call copy(vtemp,
cpr%fldhat(1,1,1,e), nxyz)
292 call copy(vtrunc,
cpr%fldhat(1,1,1,e), nxyz)
299 do while (l2norm .le. targeterr .and. kut .le. (
cpr%Xh%lx-1)*3)
301 call copy(vtrunc, vtemp, nxyz)
311 call copy(w2, vsort, nxyz)
313 call mxm(fx, nx, w2, nx, w1, nx*nx)
316 call mxm(w1(1,1,k), nx, fy, nx, w2(1,1,k), nx)
319 call mxm (w2, nx*nx, fz, nx, vtemp, nx)
323 call reord(vtemp, isort, nxyz)
326 call sub3(errvec,
cpr%fldhat(1,1,1,e), vtemp, nxyz)
334 call copy(
cpr%fldhat(1,1,1,e), vtrunc, nxyz)
341 write(log_buf,
'(A)') &
342 'Debugging info for e=50. Do not forget to delete'
343 call neko_log%message(log_buf)
345 call reord(vsort,isort,nxyz)
347 write(log_buf,
'(A)') &
349 call neko_log%message(log_buf)
351 write(log_buf,
'(A,E15.7)') &
353 call neko_log%message(log_buf)
354 write(log_buf,
'(A)') &
356 call neko_log%message(log_buf)
358 write(log_buf,
'(A,I5)') &
360 call neko_log%message(log_buf)
361 write(log_buf,
'(A)') &
362 'spectral coefficients'
363 call neko_log%message(log_buf)
365 write(log_buf,
'(A,E15.7,A,E15.7)') &
366 'org coeff:', vsort(i),
' truncated coeff', &
368 call neko_log%message(log_buf)
378 integer,
intent(in) :: nxyz
379 real(kind=rp),
intent(inout) :: vsort(nxyz)
380 real(kind=rp),
intent(inout) :: v(nxyz)
381 integer,
intent(inout) :: isort(nxyz)
392 call sort(vsort, isort, nxyz)
395 call flipv(vsort, isort, nxyz)
398 call copy(vsort, v, nxyz)
399 call swap(vsort, isort, nxyz)
405 integer,
intent(in) :: lx
406 integer,
intent(in) :: kut
407 real(kind=rp),
intent(inout) :: fx(lx,lx)
408 real(kind=rp),
intent(inout) :: fy(lx,lx)
409 real(kind=rp),
intent(inout) :: fz(lx,lx)
410 integer :: i, j, k, k0, kk, kutx, kuty, kutz
418 if (kut .gt. 0 .and. kut .le. (lx-1))
then
423 if (kut .gt. (lx-1) .and. kut .le. (lx-1)*2)
then
428 if (kut .gt. (lx-1)*2 .and. kut .le. (lx-1)*3)
then
470 type(coef_t),
intent(in) :: coef
471 real(kind=rp) :: elemdata(coef%Xh%lx, coef%Xh%lx, coef%Xh%lx)
472 real(kind=rp) :: vole, suma, l2e
474 character(len=4) ::
space
477 nxyz = coef%Xh%lx*coef%Xh%lx*coef%Xh%lx
480 vole = vole+coef%B(i,1,1,e)
485 if (
space .eq.
'spec')
then
487 suma = suma+elemdata(i,1,1)*elemdata(i,1,1)*coef%jac(i,1,1,e)
490 if (
space .eq.
'phys')
then
492 suma = suma+elemdata(i,1,1)*elemdata(i,1,1)*coef%B(i,1,1,e)
496 l2e = sqrt(suma)/sqrt(vole)
subroutine build_filter_tf(fx, fy, fz, kut, lx)
create filter transfer function
real(kind=rp) function get_elem_l2norm(elemdata, coef, space, e)
subroutine cpr_truncate_wn(cpr, coef)
Truncate the frequencies.
subroutine cpr_init_all(cpr, u)
Initialize cpr.
subroutine sortcoeff(vsort, v, isort, nxyz)
Sort the spectral coefficient in descending order array vsort. The original indices are stored in the...
subroutine cpr_goto_space(cpr, space)
Tranform to spectral space (using tensor product)
subroutine cpr_generate_specmat(cpr)
Generate spectral tranform matrices.
subroutine, public cpr_free(cpr)
Deallocate coefficients.
Defines a mapping of the degrees of freedom.
subroutine, public copy(a, b, n)
Copy a vector .
Wrapper for all matrix-matrix product implementations.
subroutine, public mxm(a, n1, b, n2, c, n3)
Compute matrix-matrix product for contiguously packed matrices A,B, and C.
integer, parameter, public rp
Global precision used in computations.
Defines a function space.
subroutine, public trsp1(a, n)
In-place transpose of a square tensor.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
include information needed for compressing fields
The function space for the SEM solution fields.