95 real(kind=
rp),
allocatable :: g11(:,:,:,:)
97 real(kind=
rp),
allocatable :: g22(:,:,:,:)
99 real(kind=
rp),
allocatable :: g33(:,:,:,:)
101 real(kind=
rp),
allocatable :: g12(:,:,:,:)
103 real(kind=
rp),
allocatable :: g13(:,:,:,:)
105 real(kind=
rp),
allocatable :: g23(:,:,:,:)
109 real(kind=
rp) :: metric_cond = 0.0_rp
112 integer :: metric_degenerate = 0
119 logical :: metric_sp_safe = .false.
121 real(kind=
rp),
allocatable :: g11_compressed(:,:,:,:)
123 real(kind=
rp),
allocatable :: g22_compressed(:,:,:,:)
125 real(kind=
rp),
allocatable :: g33_compressed(:,:,:,:)
127 real(kind=
rp),
allocatable :: g12_compressed(:,:,:,:)
129 real(kind=
rp),
allocatable :: g13_compressed(:,:,:,:)
131 real(kind=
rp),
allocatable :: g23_compressed(:,:,:,:)
133 integer,
allocatable :: compression_inds(:)
135 real(kind=
rp),
allocatable :: mult(:,:,:,:)
140 real(kind=
rp),
allocatable :: dxdr(:,:,:,:), dydr(:,:,:,:), dzdr(:,:,:,:)
141 real(kind=
rp),
allocatable :: dxds(:,:,:,:), dyds(:,:,:,:), dzds(:,:,:,:)
142 real(kind=
rp),
allocatable :: dxdt(:,:,:,:), dydt(:,:,:,:), dzdt(:,:,:,:)
146 real(kind=
rp),
allocatable :: drdx(:,:,:,:), drdy(:,:,:,:), drdz(:,:,:,:)
147 real(kind=
rp),
allocatable :: dsdx(:,:,:,:), dsdy(:,:,:,:), dsdz(:,:,:,:)
148 real(kind=
rp),
allocatable :: dtdx(:,:,:,:), dtdy(:,:,:,:), dtdz(:,:,:,:)
150 real(kind=
rp),
allocatable :: h1(:,:,:,:)
151 real(kind=
rp),
allocatable :: h2(:,:,:,:)
154 real(kind=
rp),
allocatable :: jac(:,:,:,:)
155 real(kind=
rp),
allocatable :: jacinv(:,:,:,:)
156 real(kind=
rp),
allocatable :: b(:,:,:,:)
157 real(kind=
rp),
allocatable :: binv(:,:,:,:)
158 real(kind=
rp),
pointer :: blag(:,:,:,:) => null()
159 real(kind=
rp),
pointer :: blaglag(:,:,:,:) => null()
160 real(kind=
rp),
allocatable :: area(:,:,:,:)
161 real(kind=
rp),
allocatable :: nx(:,:,:,:)
162 real(kind=
rp),
allocatable :: ny(:,:,:,:)
163 real(kind=
rp),
allocatable :: nz(:,:,:,:)
164 logical :: cyclic = .false.
165 integer,
allocatable :: cyc_msk(:)
166 real(kind=
rp),
allocatable :: r11(:)
167 real(kind=
rp),
allocatable :: r12(:)
170 logical,
private :: coef_metrics_initialized = .false.
178 real(kind=
rp) :: volume = 0.0_rp
183 type(
gs_t),
pointer :: gs_h=> null()
189 type(c_ptr) :: g11_d = c_null_ptr
190 type(c_ptr) :: g22_d = c_null_ptr
191 type(c_ptr) :: g33_d = c_null_ptr
192 type(c_ptr) :: g12_d = c_null_ptr
193 type(c_ptr) :: g13_d = c_null_ptr
194 type(c_ptr) :: g23_d = c_null_ptr
195 type(c_ptr) :: dxdr_d = c_null_ptr
196 type(c_ptr) :: dydr_d = c_null_ptr
197 type(c_ptr) :: dzdr_d = c_null_ptr
198 type(c_ptr) :: dxds_d = c_null_ptr
199 type(c_ptr) :: dyds_d = c_null_ptr
200 type(c_ptr) :: dzds_d = c_null_ptr
201 type(c_ptr) :: dxdt_d = c_null_ptr
202 type(c_ptr) :: dydt_d = c_null_ptr
203 type(c_ptr) :: dzdt_d = c_null_ptr
204 type(c_ptr) :: drdx_d = c_null_ptr
205 type(c_ptr) :: drdy_d = c_null_ptr
206 type(c_ptr) :: drdz_d = c_null_ptr
207 type(c_ptr) :: dsdx_d = c_null_ptr
208 type(c_ptr) :: dsdy_d = c_null_ptr
209 type(c_ptr) :: dsdz_d = c_null_ptr
210 type(c_ptr) :: dtdx_d = c_null_ptr
211 type(c_ptr) :: dtdy_d = c_null_ptr
212 type(c_ptr) :: dtdz_d = c_null_ptr
213 type(c_ptr) :: mult_d = c_null_ptr
214 type(c_ptr) :: h1_d = c_null_ptr
215 type(c_ptr) :: h2_d = c_null_ptr
216 type(c_ptr) :: jac_d = c_null_ptr
217 type(c_ptr) :: jacinv_d = c_null_ptr
218 type(c_ptr) :: b_d = c_null_ptr
219 type(c_ptr) :: blag_d = c_null_ptr
220 type(c_ptr) :: blaglag_d = c_null_ptr
221 type(c_ptr) :: binv_d = c_null_ptr
222 type(c_ptr) :: area_d = c_null_ptr
223 type(c_ptr) :: nx_d = c_null_ptr
224 type(c_ptr) :: ny_d = c_null_ptr
225 type(c_ptr) :: nz_d = c_null_ptr
226 type(c_ptr) :: cyc_msk_d = c_null_ptr
227 type(c_ptr) :: r11_d = c_null_ptr
228 type(c_ptr) :: r12_d = c_null_ptr
231 integer :: metrics_version = 0
245 generic :: init => init_empty, init_all
301 class(
coef_t),
intent(inout),
target :: this
302 type(
gs_t),
intent(inout),
target :: gs_h
303 integer,
intent(in),
optional :: scope
304 integer :: n, m, ncyc
309 if (
present(scope))
then
316 call neko_log%section(
'Coefficients')
318 this%msh => gs_h%dofmap%msh
319 this%Xh => gs_h%dofmap%Xh
320 this%dof => gs_h%dofmap
327 allocate(this%G11(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
328 allocate(this%G22(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
329 allocate(this%G33(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
330 allocate(this%G12(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
331 allocate(this%G13(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
332 allocate(this%G23(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
334 allocate(this%dxdr(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
335 allocate(this%dxds(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
336 allocate(this%dxdt(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
338 allocate(this%dydr(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
339 allocate(this%dyds(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
340 allocate(this%dydt(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
342 allocate(this%dzdr(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
343 allocate(this%dzds(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
344 allocate(this%dzdt(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
346 allocate(this%drdx(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
347 allocate(this%dsdx(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
348 allocate(this%dtdx(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
350 allocate(this%drdy(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
351 allocate(this%dsdy(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
352 allocate(this%dtdy(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
354 allocate(this%drdz(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
355 allocate(this%dsdz(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
356 allocate(this%dtdz(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
358 allocate(this%jac(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
359 allocate(this%jacinv(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
362 allocate(this%area(this%Xh%lx, this%Xh%ly, 6, this%msh%nelv))
363 allocate(this%nx(this%Xh%lx, this%Xh%ly, 6, this%msh%nelv))
364 allocate(this%ny(this%Xh%lx, this%Xh%ly, 6, this%msh%nelv))
365 allocate(this%nz(this%Xh%lx, this%Xh%ly, 6, this%msh%nelv))
368 allocate(this%B(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
369 allocate(this%Binv(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
373 this%Blaglag => this%B
375 allocate(this%h1(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
376 allocate(this%h2(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
378 allocate(this%mult(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
385 n = this%Xh%lx * this%Xh%ly * this%Xh%lz * this%msh%nelv
423 call device_map(this%jacinv, this%jacinv_d, n)
427 this%Blag_d = this%B_d
428 this%Blaglag_d = this%B_d
431 m = this%Xh%lx * this%Xh%ly * 6 * this%msh%nelv
458 this%coef_metrics_initialized = .true.
483 call rone(this%mult, n)
496 ncyc = this%msh%periodic%size * this%Xh%lx * this%Xh%lx
497 allocate(this%cyc_msk(0:ncyc))
498 this%cyc_msk(0) = ncyc + 1
499 if (ncyc .gt. 0)
then
500 allocate(this%R11(ncyc))
501 allocate(this%R12(ncyc))
504 call rone(this%R11, ncyc)
505 call rzero(this%R12, ncyc)
508 call device_map(this%cyc_msk, this%cyc_msk_d, ncyc+1)
942 type(
coef_t),
intent(inout) :: c
943 integer :: e, i, lxy, lyz, ntot
945 lxy = c%Xh%lx*c%Xh%ly
946 lyz = c%Xh%ly*c%Xh%lz
949 associate(drdx => c%drdx, drdy => c%drdy, drdz => c%drdz, &
950 dsdx => c%dsdx, dsdy => c%dsdy, dsdz => c%dsdz, &
951 dtdx => c%dtdx, dtdy => c%dtdy, dtdz => c%dtdz, &
952 dxdr => c%dxdr, dydr => c%dydr, dzdr => c%dzdr, &
953 dxds => c%dxds, dyds => c%dyds, dzds => c%dzds, &
954 dxdt => c%dxdt, dydt => c%dydt, dzdt => c%dzdt, &
955 dx => c%Xh%dx, dy => c%Xh%dy, dz => c%Xh%dz, &
956 x => c%dof%x, y => c%dof%y, z => c%dof%z, &
957 lx => c%Xh%lx, ly => c%Xh%ly, lz => c%Xh%lz, &
958 dyt => c%Xh%dyt, dzt => c%Xh%dzt, &
959 jacinv => c%jacinv, jac => c%jac)
964 c%dsdx_d, c%dsdy_d, c%dsdz_d, c%dtdx_d, c%dtdy_d, c%dtdz_d, &
965 c%dxdr_d, c%dydr_d, c%dzdr_d, c%dxds_d, c%dyds_d, c%dzds_d, &
966 c%dxdt_d, c%dydt_d, c%dzdt_d, c%Xh%dx_d, c%Xh%dy_d, c%Xh%dz_d, &
967 c%dof%x_d, c%dof%y_d, c%dof%z_d, c%jacinv_d, c%jac_d, &
971 if (.not. c%coef_metrics_initialized)
then
1016 do e = 1, c%msh%nelv
1017 call mxm(dx, lx, x(1,1,1,e), lx, dxdr(1,1,1,e), lyz)
1018 call mxm(dx, lx, y(1,1,1,e), lx, dydr(1,1,1,e), lyz)
1019 call mxm(dx, lx, z(1,1,1,e), lx, dzdr(1,1,1,e), lyz)
1022 call mxm(x(1,1,i,e), lx, dyt, ly, dxds(1,1,i,e), ly)
1023 call mxm(y(1,1,i,e), lx, dyt, ly, dyds(1,1,i,e), ly)
1024 call mxm(z(1,1,i,e), lx, dyt, ly, dzds(1,1,i,e), ly)
1028 if (c%msh%gdim .eq. 3)
then
1029 call mxm(x(1,1,1,e), lxy, dzt, lz, dxdt(1,1,1,e), lz)
1030 call mxm(y(1,1,1,e), lxy, dzt, lz, dydt(1,1,1,e), lz)
1031 call mxm(z(1,1,1,e), lxy, dzt, lz, dzdt(1,1,1,e), lz)
1033 call rzero(dxdt(1,1,1,e), lxy)
1034 call rzero(dydt(1,1,1,e), lxy)
1035 call rone(dzdt(1,1,1,e), lxy)
1040 if (c%msh%gdim .eq. 2)
then
1041 call rzero (jac, ntot)
1042 call addcol3 (jac, dxdr, dyds, ntot)
1043 call subcol3 (jac, dxds, dydr, ntot)
1044 call copy (drdx, dyds, ntot)
1045 call copy (drdy, dxds, ntot)
1047 call copy (dsdx, dydr, ntot)
1049 call copy (dsdy, dxdr, ntot)
1050 call rzero (drdz, ntot)
1051 call rzero (dsdz, ntot)
1052 call rone (dtdz, ntot)
1057 c%jac(i, 1, 1, 1) = 0.0_rp
1062 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) + ( c%dxdr(i, 1, 1, 1) &
1063 * c%dyds(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1) )
1065 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) + ( c%dxdt(i, 1, 1, 1) &
1066 * c%dydr(i, 1, 1, 1) * c%dzds(i, 1, 1, 1) )
1068 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) + ( c%dxds(i, 1, 1, 1) &
1069 * c%dydt(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1) )
1074 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) - ( c%dxdr(i, 1, 1, 1) &
1075 * c%dydt(i, 1, 1, 1) * c%dzds(i, 1, 1, 1) )
1077 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) - ( c%dxds(i, 1, 1, 1) &
1078 * c%dydr(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1) )
1080 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) - ( c%dxdt(i, 1, 1, 1) &
1081 * c%dyds(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1) )
1086 c%drdx(i, 1, 1, 1) = c%dyds(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1) &
1087 - c%dydt(i, 1, 1, 1) * c%dzds(i, 1, 1, 1)
1089 c%drdy(i, 1, 1, 1) = c%dxdt(i, 1, 1, 1) * c%dzds(i, 1, 1, 1) &
1090 - c%dxds(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1)
1092 c%drdz(i, 1, 1, 1) = c%dxds(i, 1, 1, 1) * c%dydt(i, 1, 1, 1) &
1093 - c%dxdt(i, 1, 1, 1) * c%dyds(i, 1, 1, 1)
1098 c%dsdx(i, 1, 1, 1) = c%dydt(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1) &
1099 - c%dydr(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1)
1101 c%dsdy(i, 1, 1, 1) = c%dxdr(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1) &
1102 - c%dxdt(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1)
1104 c%dsdz(i, 1, 1, 1) = c%dxdt(i, 1, 1, 1) * c%dydr(i, 1, 1, 1) &
1105 - c%dxdr(i, 1, 1, 1) * c%dydt(i, 1, 1, 1)
1110 c%dtdx(i, 1, 1, 1) = c%dydr(i, 1, 1, 1) * c%dzds(i, 1, 1, 1) &
1111 - c%dyds(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1)
1113 c%dtdy(i, 1, 1, 1) = c%dxds(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1) &
1114 - c%dxdr(i, 1, 1, 1) * c%dzds(i, 1, 1, 1)
1116 c%dtdz(i, 1, 1, 1) = c%dxdr(i, 1, 1, 1) * c%dyds(i, 1, 1, 1) &
1117 - c%dxds(i, 1, 1, 1) * c%dydr(i, 1, 1, 1)
1122 call invers2(jacinv, jac, ntot)
1131 type(
coef_t),
intent(inout) :: c
1132 integer :: e, i, lxyz, ntot
1134 lxyz = c%Xh%lx * c%Xh%ly * c%Xh%lz
1137 if (neko_bcknd_device .eq. 1)
then
1139 call device_coef_generate_geo(c%G11_d, c%G12_d, c%G13_d, &
1140 c%G22_d, c%G23_d, c%G33_d, &
1141 c%drdx_d, c%drdy_d, c%drdz_d, &
1142 c%dsdx_d, c%dsdy_d, c%dsdz_d, &
1143 c%dtdx_d, c%dtdy_d, c%dtdz_d, &
1144 c%jacinv_d, c%Xh%w3_d, c%msh%nelv, &
1145 c%Xh%lx, c%msh%gdim)
1148 if (.not. c%coef_metrics_initialized)
then
1149 call device_memcpy(c%G11, c%G11_d, ntot, device_to_host, &
1151 call device_memcpy(c%G22, c%G22_d, ntot, device_to_host, &
1153 call device_memcpy(c%G33, c%G33_d, ntot, device_to_host, &
1155 call device_memcpy(c%G12, c%G12_d, ntot, device_to_host, &
1157 call device_memcpy(c%G13, c%G13_d, ntot, device_to_host, &
1159 call device_memcpy(c%G23, c%G23_d, ntot, device_to_host, &
1164 if (c%msh%gdim .eq. 2)
then
1167 c%G11(i, 1, 1, 1) = c%drdx(i, 1, 1, 1) * c%drdx(i, 1, 1, 1) &
1168 + c%drdy(i, 1, 1, 1) * c%drdy(i, 1, 1, 1)
1170 c%G22(i, 1, 1, 1) = c%dsdx(i, 1, 1, 1) * c%dsdx(i, 1, 1, 1) &
1171 + c%dsdy(i, 1, 1, 1) * c%dsdy(i, 1, 1, 1)
1173 c%G12(i, 1, 1, 1) = c%drdx(i, 1, 1, 1) * c%dsdx(i, 1, 1, 1) &
1174 + c%drdy(i, 1, 1, 1) * c%dsdy(i, 1, 1, 1)
1178 c%G11(i, 1, 1, 1) = c%G11(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
1179 c%G22(i, 1, 1, 1) = c%G22(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
1180 c%G12(i, 1, 1, 1) = c%G12(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
1181 c%G33(i, 1, 1, 1) = 0.0_rp
1182 c%G13(i, 1, 1, 1) = 0.0_rp
1183 c%G23(i, 1, 1, 1) = 0.0_rp
1186 do concurrent(e = 1:c%msh%nelv)
1187 do concurrent(i = 1:lxyz)
1188 c%G11(i,1,1,e) = c%G11(i,1,1,e) * c%Xh%w3(i,1,1)
1189 c%G22(i,1,1,e) = c%G22(i,1,1,e) * c%Xh%w3(i,1,1)
1190 c%G12(i,1,1,e) = c%G12(i,1,1,e) * c%Xh%w3(i,1,1)
1198 c%G11(i, 1, 1, 1) = c%drdx(i, 1, 1, 1) * c%drdx(i, 1, 1, 1) &
1199 + c%drdy(i, 1, 1, 1) * c%drdy(i, 1, 1, 1) &
1200 + c%drdz(i, 1, 1, 1) * c%drdz(i, 1, 1, 1)
1202 c%G22(i, 1, 1, 1) = c%dsdx(i, 1, 1, 1) * c%dsdx(i, 1, 1, 1) &
1203 + c%dsdy(i, 1, 1, 1) * c%dsdy(i, 1, 1, 1) &
1204 + c%dsdz(i, 1, 1, 1) * c%dsdz(i, 1, 1, 1)
1206 c%G33(i, 1, 1, 1) = c%dtdx(i, 1, 1, 1) * c%dtdx(i, 1, 1, 1) &
1207 + c%dtdy(i, 1, 1, 1) * c%dtdy(i, 1, 1, 1) &
1208 + c%dtdz(i, 1, 1, 1) * c%dtdz(i, 1, 1, 1)
1213 c%G11(i, 1, 1, 1) = c%G11(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
1214 c%G22(i, 1, 1, 1) = c%G22(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
1215 c%G33(i, 1, 1, 1) = c%G33(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
1220 c%G12(i, 1, 1, 1) = c%drdx(i, 1, 1, 1) * c%dsdx(i, 1, 1, 1) &
1221 + c%drdy(i, 1, 1, 1) * c%dsdy(i, 1, 1, 1) &
1222 + c%drdz(i, 1, 1, 1) * c%dsdz(i, 1, 1, 1)
1224 c%G13(i, 1, 1, 1) = c%drdx(i, 1, 1, 1) * c%dtdx(i, 1, 1, 1) &
1225 + c%drdy(i, 1, 1, 1) * c%dtdy(i, 1, 1, 1) &
1226 + c%drdz(i, 1, 1, 1) * c%dtdz(i, 1, 1, 1)
1228 c%G23(i, 1, 1, 1) = c%dsdx(i, 1, 1, 1) * c%dtdx(i, 1, 1, 1) &
1229 + c%dsdy(i, 1, 1, 1) * c%dtdy(i, 1, 1, 1) &
1230 + c%dsdz(i, 1, 1, 1) * c%dtdz(i, 1, 1, 1)
1235 c%G12(i, 1, 1, 1) = c%G12(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
1236 c%G13(i, 1, 1, 1) = c%G13(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
1237 c%G23(i, 1, 1, 1) = c%G23(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
1241 do e = 1, c%msh%nelv
1242 do concurrent(i = 1:lxyz)
1243 c%G11(i,1,1,e) = c%G11(i,1,1,e) * c%Xh%w3(i,1,1)
1244 c%G22(i,1,1,e) = c%G22(i,1,1,e) * c%Xh%w3(i,1,1)
1245 c%G12(i,1,1,e) = c%G12(i,1,1,e) * c%Xh%w3(i,1,1)
1247 c%G33(i,1,1,e) = c%G33(i,1,1,e) * c%Xh%w3(i,1,1)
1248 c%G13(i,1,1,e) = c%G13(i,1,1,e) * c%Xh%w3(i,1,1)
1249 c%G23(i,1,1,e) = c%G23(i,1,1,e) * c%Xh%w3(i,1,1)
1289 class(
coef_t),
intent(inout) :: this
1290 real(kind=dp) :: e1, e2, e3, scal
1291 real(kind=rp) :: kmax, tmp(1)
1292 integer :: i, j, k, e, n, ndeg, ndeg_glb, ierr
1293 character(len=LOG_SIZE) :: log_buf
1298 if (neko_bcknd_device .eq. 1 .and. this%coef_metrics_initialized)
then
1299 call device_memcpy(this%G11, this%G11_d, n, device_to_host, &
1301 call device_memcpy(this%G22, this%G22_d, n, device_to_host, &
1303 call device_memcpy(this%G33, this%G33_d, n, device_to_host, &
1305 call device_memcpy(this%G12, this%G12_d, n, device_to_host, &
1307 call device_memcpy(this%G13, this%G13_d, n, device_to_host, &
1309 call device_memcpy(this%G23, this%G23_d, n, device_to_host, &
1316 do e = 1, this%msh%nelv
1317 do k = 1, this%Xh%lz
1318 do j = 1, this%Xh%ly
1319 do i = 1, this%Xh%lx
1324 scal =
max(abs(
real(this%G11(i,j,k,e), dp)), &
1325 abs(
real(this%G22(i,j,k,e), dp)))
1326 scal =
max(scal, abs(
real(this%G33(i,j,k,e), dp)))
1327 scal =
max(scal, abs(
real(this%G12(i,j,k,e), dp)))
1328 scal =
max(scal, abs(
real(this%G13(i,j,k,e), dp)))
1329 scal =
max(scal, abs(
real(this%G23(i,j,k,e), dp)))
1331 if (scal .le. 0.0_dp)
then
1336 if (this%msh%gdim .eq. 2)
then
1337 call eig_sym2(
real(this%G11(i,j,k,e), dp) / scal, &
1338 real(this%G22(i,j,k,e), dp) / scal, &
1339 real(this%G12(i,j,k,e), dp) / scal, e1, e3)
1341 call eig_sym3(
real(this%G11(i,j,k,e), dp) / scal, &
1342 real(this%G22(i,j,k,e), dp) / scal, &
1343 real(this%G33(i,j,k,e), dp) / scal, &
1344 real(this%G12(i,j,k,e), dp) / scal, &
1345 real(this%G13(i,j,k,e), dp) / scal, &
1346 real(this%G23(i,j,k,e), dp) / scal, e1, e2, e3)
1349 if (e3 .le. 0.0_dp)
then
1352 kmax =
max(kmax,
real(e1 / e3, rp))
1361 this%metric_cond = glmax(tmp, 1)
1363 call mpi_allreduce(ndeg, ndeg_glb, 1, mpi_integer, mpi_sum, &
1365 this%metric_degenerate = ndeg_glb
1367 this%metric_sp_safe = (this%metric_degenerate .eq. 0) .and. &
1370 write(log_buf,
'(A,ES12.5)')
'Metric condition : ', this%metric_cond
1371 call neko_log%message(log_buf)
1380 write(log_buf,
'(A,ES12.5)') &
1381 'Metric too ill conditioned for single precision, limit ', &
1383 call neko_log%warning(log_buf)
1384 call neko_log%message(
'Geometric factors may lose positive ' // &
1385 'definiteness, consider a double precision build')
1392 if (this%metric_degenerate .gt. 0)
then
1393 write(log_buf,
'(A,I0)') &
1394 'Non positive definite metric at points: ', this%metric_degenerate
1395 call neko_log%error(log_buf)
1403 type(
coef_t),
intent(inout) :: c
1404 integer :: e, m, i, lxyz, m_max
1405 integer,
allocatable :: c_inds_rev(:)
1406 real(kind=rp) :: ctol = 1.0e-7_rp
1407 real(kind=rp) :: diff = 0.0_rp
1410 allocate(c%compression_inds(c%msh%nelv))
1411 allocate(c_inds_rev(c%msh%nelv))
1416 c%compression_inds(1) = 1
1421 lxyz = c%Xh%lx * c%Xh%ly * c%Xh%lz
1422 do e = 2, c%msh%nelv
1429 diff = diff + abs(c%G11(i,1,1,e) - c%G11(i,1,1,c_inds_rev(m))) &
1430 + 2.0*abs(c%G12(i,1,1,e) - c%G12(i,1,1,c_inds_rev(m))) &
1431 + 2.0*abs(c%G13(i,1,1,e) - c%G13(i,1,1,c_inds_rev(m))) &
1432 + abs(c%G22(i,1,1,e) - c%G22(i,1,1,c_inds_rev(m))) &
1433 + 2.0*abs(c%G23(i,1,1,e) - c%G23(i,1,1,c_inds_rev(m))) &
1434 + abs(c%G33(i,1,1,e) - c%G33(i,1,1,c_inds_rev(m)))
1438 if ( diff .le. ctol )
then
1439 c%compression_inds(e) = m
1445 if ( diff .gt. ctol )
then
1447 c%compression_inds(e) = m_max
1448 c_inds_rev(m_max) = e
1453 write(*,*)
'------Mapping Compression-----'
1454 write(*,*)
'Compressed from ', c%msh%nelv,
' to ', m_max
1457 allocate(c%G11_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1458 allocate(c%G22_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1459 allocate(c%G33_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1460 allocate(c%G12_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1461 allocate(c%G13_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1462 allocate(c%G23_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1465 c%G11_compressed(i,1,1,m) = c%G11(i,1,1,c_inds_rev(m))
1466 c%G22_compressed(i,1,1,m) = c%G22(i,1,1,c_inds_rev(m))
1467 c%G33_compressed(i,1,1,m) = c%G33(i,1,1,c_inds_rev(m))
1468 c%G12_compressed(i,1,1,m) = c%G12(i,1,1,c_inds_rev(m))
1469 c%G13_compressed(i,1,1,m) = c%G13(i,1,1,c_inds_rev(m))
1470 c%G23_compressed(i,1,1,m) = c%G23(i,1,1,c_inds_rev(m))
1474 deallocate(c_inds_rev)
1601 type(
coef_t),
intent(inout) :: coef
1602 real(kind=rp),
allocatable :: a(:,:,:,:)
1603 real(kind=rp),
allocatable :: b(:,:,:,:)
1604 real(kind=rp),
allocatable :: c(:,:,:,:)
1605 real(kind=rp),
allocatable :: dot(:,:,:,:)
1606 integer :: n, m, e, i, j, k, lx
1607 real(kind=rp) :: weight, len
1611 if (neko_bcknd_device .eq. 1)
then
1613 call device_coef_generate_area_and_normal( &
1614 coef%area_d, coef%nx_d, coef%ny_d, coef%nz_d, &
1615 coef%dxdr_d, coef%dydr_d, coef%dzdr_d, &
1616 coef%dxds_d, coef%dyds_d, coef%dzds_d, &
1617 coef%dxdt_d, coef%dydt_d, coef%dzdt_d, &
1618 coef%Xh%wx_d, coef%Xh%wy_d, coef%Xh%wz_d, &
1619 lx, coef%msh%nelv, neko_eps)
1623 call device_memcpy(coef%area, coef%area_d, m, &
1624 device_to_host, sync = .false.)
1625 call device_memcpy(coef%nx, coef%nx_d, m, &
1626 device_to_host, sync = .false.)
1627 call device_memcpy(coef%ny, coef%ny_d, m, &
1628 device_to_host, sync = .false.)
1629 call device_memcpy(coef%nz, coef%nz_d, &
1630 m, device_to_host, sync = .true.)
1634 allocate(a(coef%Xh%lx, coef%Xh%lx, coef%Xh%lx, coef%msh%nelv))
1635 allocate(b(coef%Xh%lx, coef%Xh%lx, coef%Xh%lx, coef%msh%nelv))
1636 allocate(c(coef%Xh%lx, coef%Xh%lx, coef%Xh%lx, coef%msh%nelv))
1637 allocate(dot(coef%Xh%lx, coef%Xh%lx, coef%Xh%lx, coef%msh%nelv))
1644 a(i, 1, 1, 1) = coef%dyds(i, 1, 1, 1) * coef%dzdt(i, 1, 1, 1) &
1645 - coef%dzds(i, 1, 1, 1) * coef%dydt(i, 1, 1, 1)
1647 b(i, 1, 1, 1) = coef%dzds(i, 1, 1, 1) * coef%dxdt(i, 1, 1, 1) &
1648 - coef%dxds(i, 1, 1, 1) * coef%dzdt(i, 1, 1, 1)
1650 c(i, 1, 1, 1) = coef%dxds(i, 1, 1, 1) * coef%dydt(i, 1, 1, 1) &
1651 - coef%dyds(i, 1, 1, 1) * coef%dxdt(i, 1, 1, 1)
1656 dot(i, 1, 1, 1) = a(i, 1, 1, 1) * a(i, 1, 1, 1) &
1657 + b(i, 1, 1, 1) * b(i, 1, 1, 1) &
1658 + c(i, 1, 1, 1) * c(i, 1, 1, 1)
1662 do e = 1, coef%msh%nelv
1663 do concurrent(k = 1:coef%Xh%lx)
1664 do concurrent(j = 1:coef%Xh%lx)
1665 weight = coef%Xh%wy(j) * coef%Xh%wz(k)
1666 coef%area(j, k, 2, e) = sqrt(dot(lx, j, k, e)) * weight
1667 coef%area(j, k, 1, e) = sqrt(dot(1, j, k, e)) * weight
1668 coef%nx(j,k, 1, e) = -a(1, j, k, e)
1669 coef%nx(j,k, 2, e) = a(lx, j, k, e)
1670 coef%ny(j,k, 1, e) = -b(1, j, k, e)
1671 coef%ny(j,k, 2, e) = b(lx, j, k, e)
1672 coef%nz(j,k, 1, e) = -c(1, j, k, e)
1673 coef%nz(j,k, 2, e) = c(lx, j, k, e)
1682 a(i, 1, 1, 1) = coef%dydr(i, 1, 1, 1) * coef%dzdt(i, 1, 1, 1) &
1683 - coef%dzdr(i, 1, 1, 1) * coef%dydt(i, 1, 1, 1)
1685 b(i, 1, 1, 1) = coef%dzdr(i, 1, 1, 1) * coef%dxdt(i, 1, 1, 1) &
1686 - coef%dxdr(i, 1, 1, 1) * coef%dzdt(i, 1, 1, 1)
1688 c(i, 1, 1, 1) = coef%dxdr(i, 1, 1, 1) * coef%dydt(i, 1, 1, 1) &
1689 - coef%dydr(i, 1, 1, 1) * coef%dxdt(i, 1, 1, 1)
1694 dot(i, 1, 1, 1) = a(i, 1, 1, 1) * a(i, 1, 1, 1) &
1695 + b(i, 1, 1, 1) * b(i, 1, 1, 1) &
1696 + c(i, 1, 1, 1) * c(i, 1, 1, 1)
1700 do e = 1, coef%msh%nelv
1701 do concurrent(k = 1:coef%Xh%lx)
1702 do concurrent(j = 1:coef%Xh%lx)
1703 weight = coef%Xh%wx(j) * coef%Xh%wz(k)
1704 coef%area(j, k, 3, e) = sqrt(dot(j, 1, k, e)) * weight
1705 coef%area(j, k, 4, e) = sqrt(dot(j, lx, k, e)) * weight
1706 coef%nx(j,k, 3, e) = a(j, 1, k, e)
1707 coef%nx(j,k, 4, e) = -a(j, lx, k, e)
1708 coef%ny(j,k, 3, e) = b(j, 1, k, e)
1709 coef%ny(j,k, 4, e) = -b(j, lx, k, e)
1710 coef%nz(j,k, 3, e) = c(j, 1, k, e)
1711 coef%nz(j,k, 4, e) = -c(j, lx, k, e)
1719 a(i, 1, 1, 1) = coef%dydr(i, 1, 1, 1) * coef%dzds(i, 1, 1, 1) &
1720 - coef%dzdr(i, 1, 1, 1) * coef%dyds(i, 1, 1, 1)
1722 b(i, 1, 1, 1) = coef%dzdr(i, 1, 1, 1) * coef%dxds(i, 1, 1, 1) &
1723 - coef%dxdr(i, 1, 1, 1) * coef%dzds(i, 1, 1, 1)
1725 c(i, 1, 1, 1) = coef%dxdr(i, 1, 1, 1) * coef%dyds(i, 1, 1, 1) &
1726 - coef%dydr(i, 1, 1, 1) * coef%dxds(i, 1, 1, 1)
1731 dot(i, 1, 1, 1) = a(i, 1, 1, 1) * a(i, 1, 1, 1) &
1732 + b(i, 1, 1, 1) * b(i, 1, 1, 1) &
1733 + c(i, 1, 1, 1) * c(i, 1, 1, 1)
1737 do e = 1, coef%msh%nelv
1738 do concurrent(k = 1:coef%Xh%lx)
1739 do concurrent(j = 1:coef%Xh%lx)
1740 weight = coef%Xh%wx(j) * coef%Xh%wy(k)
1741 coef%area(j, k, 5, e) = sqrt(dot(j, k, 1, e)) * weight
1742 coef%area(j, k, 6, e) = sqrt(dot(j, k, lx, e)) * weight
1743 coef%nx(j,k, 5, e) = -a(j, k, 1, e)
1744 coef%nx(j,k, 6, e) = a(j, k, lx, e)
1745 coef%ny(j,k, 5, e) = -b(j, k, 1, e)
1746 coef%ny(j,k, 6, e) = b(j, k, lx, e)
1747 coef%nz(j,k, 5, e) = -c(j, k, 1, e)
1748 coef%nz(j,k, 6, e) = c(j, k, lx, e)
1755 do j = 1,
size(coef%nz)
1756 len = sqrt(coef%nx(j,1,1,1)**2 + &
1757 coef%ny(j,1,1,1)**2 + coef%nz(j,1,1,1)**2)
1758 if (len .gt. neko_eps)
then
1759 coef%nx(j,1,1,1) = coef%nx(j,1,1,1) / len
1760 coef%ny(j,1,1,1) = coef%ny(j,1,1,1) / len
1761 coef%nz(j,1,1,1) = coef%nz(j,1,1,1) / len