64 real(kind=
rp),
allocatable :: g11(:,:,:,:)
66 real(kind=
rp),
allocatable :: g22(:,:,:,:)
68 real(kind=
rp),
allocatable :: g33(:,:,:,:)
70 real(kind=
rp),
allocatable :: g12(:,:,:,:)
72 real(kind=
rp),
allocatable :: g13(:,:,:,:)
74 real(kind=
rp),
allocatable :: g23(:,:,:,:)
77 real(kind=
rp),
allocatable :: g11_compressed(:,:,:,:)
79 real(kind=
rp),
allocatable :: g22_compressed(:,:,:,:)
81 real(kind=
rp),
allocatable :: g33_compressed(:,:,:,:)
83 real(kind=
rp),
allocatable :: g12_compressed(:,:,:,:)
85 real(kind=
rp),
allocatable :: g13_compressed(:,:,:,:)
87 real(kind=
rp),
allocatable :: g23_compressed(:,:,:,:)
89 integer,
allocatable :: compression_inds(:)
91 real(kind=
rp),
allocatable :: mult(:,:,:,:)
96 real(kind=
rp),
allocatable :: dxdr(:,:,:,:), dydr(:,:,:,:), dzdr(:,:,:,:)
97 real(kind=
rp),
allocatable :: dxds(:,:,:,:), dyds(:,:,:,:), dzds(:,:,:,:)
98 real(kind=
rp),
allocatable :: dxdt(:,:,:,:), dydt(:,:,:,:), dzdt(:,:,:,:)
102 real(kind=
rp),
allocatable :: drdx(:,:,:,:), drdy(:,:,:,:), drdz(:,:,:,:)
103 real(kind=
rp),
allocatable :: dsdx(:,:,:,:), dsdy(:,:,:,:), dsdz(:,:,:,:)
104 real(kind=
rp),
allocatable :: dtdx(:,:,:,:), dtdy(:,:,:,:), dtdz(:,:,:,:)
106 real(kind=
rp),
allocatable :: h1(:,:,:,:)
107 real(kind=
rp),
allocatable :: h2(:,:,:,:)
110 real(kind=
rp),
allocatable :: jac(:,:,:,:)
111 real(kind=
rp),
allocatable :: jacinv(:,:,:,:)
112 real(kind=
rp),
allocatable :: b(:,:,:,:)
113 real(kind=
rp),
allocatable :: binv(:,:,:,:)
114 real(kind=
rp),
pointer :: blag(:,:,:,:) => null()
115 real(kind=
rp),
pointer :: blaglag(:,:,:,:) => null()
116 real(kind=
rp),
allocatable :: area(:,:,:,:)
117 real(kind=
rp),
allocatable :: nx(:,:,:,:)
118 real(kind=
rp),
allocatable :: ny(:,:,:,:)
119 real(kind=
rp),
allocatable :: nz(:,:,:,:)
120 logical :: cyclic = .false.
121 integer,
allocatable :: cyc_msk(:)
122 real(kind=
rp),
allocatable :: r11(:)
123 real(kind=
rp),
allocatable :: r12(:)
126 logical,
private :: coef_metrics_initialized = .false.
130 real(kind=
rp) :: volume
135 type(
gs_t),
pointer :: gs_h=> null()
141 type(c_ptr) :: g11_d = c_null_ptr
142 type(c_ptr) :: g22_d = c_null_ptr
143 type(c_ptr) :: g33_d = c_null_ptr
144 type(c_ptr) :: g12_d = c_null_ptr
145 type(c_ptr) :: g13_d = c_null_ptr
146 type(c_ptr) :: g23_d = c_null_ptr
147 type(c_ptr) :: dxdr_d = c_null_ptr
148 type(c_ptr) :: dydr_d = c_null_ptr
149 type(c_ptr) :: dzdr_d = c_null_ptr
150 type(c_ptr) :: dxds_d = c_null_ptr
151 type(c_ptr) :: dyds_d = c_null_ptr
152 type(c_ptr) :: dzds_d = c_null_ptr
153 type(c_ptr) :: dxdt_d = c_null_ptr
154 type(c_ptr) :: dydt_d = c_null_ptr
155 type(c_ptr) :: dzdt_d = c_null_ptr
156 type(c_ptr) :: drdx_d = c_null_ptr
157 type(c_ptr) :: drdy_d = c_null_ptr
158 type(c_ptr) :: drdz_d = c_null_ptr
159 type(c_ptr) :: dsdx_d = c_null_ptr
160 type(c_ptr) :: dsdy_d = c_null_ptr
161 type(c_ptr) :: dsdz_d = c_null_ptr
162 type(c_ptr) :: dtdx_d = c_null_ptr
163 type(c_ptr) :: dtdy_d = c_null_ptr
164 type(c_ptr) :: dtdz_d = c_null_ptr
165 type(c_ptr) :: mult_d = c_null_ptr
166 type(c_ptr) :: h1_d = c_null_ptr
167 type(c_ptr) :: h2_d = c_null_ptr
168 type(c_ptr) :: jac_d = c_null_ptr
169 type(c_ptr) :: jacinv_d = c_null_ptr
170 type(c_ptr) :: b_d = c_null_ptr
171 type(c_ptr) :: blag_d = c_null_ptr
172 type(c_ptr) :: blaglag_d = c_null_ptr
173 type(c_ptr) :: binv_d = c_null_ptr
174 type(c_ptr) :: area_d = c_null_ptr
175 type(c_ptr) :: nx_d = c_null_ptr
176 type(c_ptr) :: ny_d = c_null_ptr
177 type(c_ptr) :: nz_d = c_null_ptr
178 type(c_ptr) :: cyc_msk_d = c_null_ptr
179 type(c_ptr) :: r11_d = c_null_ptr
180 type(c_ptr) :: r12_d = c_null_ptr
194 generic :: init => init_empty, init_all
247 class(
coef_t),
intent(inout),
target :: this
248 type(
gs_t),
intent(inout),
target :: gs_h
249 integer :: n, m, ncyc
252 this%msh => gs_h%dofmap%msh
253 this%Xh => gs_h%dofmap%Xh
254 this%dof => gs_h%dofmap
261 allocate(this%G11(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
262 allocate(this%G22(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
263 allocate(this%G33(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
264 allocate(this%G12(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
265 allocate(this%G13(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
266 allocate(this%G23(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
268 allocate(this%dxdr(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
269 allocate(this%dxds(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
270 allocate(this%dxdt(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
272 allocate(this%dydr(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
273 allocate(this%dyds(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
274 allocate(this%dydt(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
276 allocate(this%dzdr(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
277 allocate(this%dzds(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
278 allocate(this%dzdt(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
280 allocate(this%drdx(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
281 allocate(this%dsdx(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
282 allocate(this%dtdx(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
284 allocate(this%drdy(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
285 allocate(this%dsdy(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
286 allocate(this%dtdy(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
288 allocate(this%drdz(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
289 allocate(this%dsdz(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
290 allocate(this%dtdz(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
292 allocate(this%jac(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
293 allocate(this%jacinv(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
295 allocate(this%area(this%Xh%lx, this%Xh%ly, 6, this%msh%nelv))
296 allocate(this%nx(this%Xh%lx, this%Xh%ly, 6, this%msh%nelv))
297 allocate(this%ny(this%Xh%lx, this%Xh%ly, 6, this%msh%nelv))
298 allocate(this%nz(this%Xh%lx, this%Xh%ly, 6, this%msh%nelv))
300 allocate(this%B(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
301 allocate(this%Binv(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
305 this%Blaglag => this%B
307 allocate(this%h1(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
308 allocate(this%h2(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
310 allocate(this%mult(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
317 n = this%Xh%lx * this%Xh%ly * this%Xh%lz * this%msh%nelv
355 call device_map(this%jacinv, this%jacinv_d, n)
359 this%Blag_d = this%B_d
360 this%Blaglag_d = this%B_d
362 m = this%Xh%lx * this%Xh%ly * 6 * this%msh%nelv
381 this%coef_metrics_initialized = .true.
406 call rone(this%mult, n)
419 ncyc = this%msh%periodic%size * this%Xh%lx * this%Xh%lx
420 allocate(this%cyc_msk(0:ncyc))
421 this%cyc_msk(0) = ncyc + 1
422 if (ncyc .gt. 0)
then
423 allocate(this%R11(ncyc))
424 allocate(this%R12(ncyc))
427 call rone(this%R11, ncyc)
428 call rzero(this%R12, ncyc)
431 call device_map(this%cyc_msk, this%cyc_msk_d, ncyc+1)
713 type(
coef_t),
intent(inout) :: c
714 integer :: e, i, lxy, lyz, ntot
716 lxy = c%Xh%lx*c%Xh%ly
717 lyz = c%Xh%ly*c%Xh%lz
720 associate(drdx => c%drdx, drdy => c%drdy, drdz => c%drdz, &
721 dsdx => c%dsdx, dsdy => c%dsdy, dsdz => c%dsdz, &
722 dtdx => c%dtdx, dtdy => c%dtdy, dtdz => c%dtdz, &
723 dxdr => c%dxdr, dydr => c%dydr, dzdr => c%dzdr, &
724 dxds => c%dxds, dyds => c%dyds, dzds => c%dzds, &
725 dxdt => c%dxdt, dydt => c%dydt, dzdt => c%dzdt, &
726 dx => c%Xh%dx, dy => c%Xh%dy, dz => c%Xh%dz, &
727 x => c%dof%x, y => c%dof%y, z => c%dof%z, &
728 lx => c%Xh%lx, ly => c%Xh%ly, lz => c%Xh%lz, &
729 dyt => c%Xh%dyt, dzt => c%Xh%dzt, &
730 jacinv => c%jacinv, jac => c%jac)
735 c%dsdx_d, c%dsdy_d, c%dsdz_d, c%dtdx_d, c%dtdy_d, c%dtdz_d, &
736 c%dxdr_d, c%dydr_d, c%dzdr_d, c%dxds_d, c%dyds_d, c%dzds_d, &
737 c%dxdt_d, c%dydt_d, c%dzdt_d, c%Xh%dx_d, c%Xh%dy_d, c%Xh%dz_d, &
738 c%dof%x_d, c%dof%y_d, c%dof%z_d, c%jacinv_d, c%jac_d, &
742 if (.not. c%coef_metrics_initialized)
then
788 call mxm(dx, lx, x(1,1,1,e), lx, dxdr(1,1,1,e), lyz)
789 call mxm(dx, lx, y(1,1,1,e), lx, dydr(1,1,1,e), lyz)
790 call mxm(dx, lx, z(1,1,1,e), lx, dzdr(1,1,1,e), lyz)
793 call mxm(x(1,1,i,e), lx, dyt, ly, dxds(1,1,i,e), ly)
794 call mxm(y(1,1,i,e), lx, dyt, ly, dyds(1,1,i,e), ly)
795 call mxm(z(1,1,i,e), lx, dyt, ly, dzds(1,1,i,e), ly)
799 if (c%msh%gdim .eq. 3)
then
800 call mxm(x(1,1,1,e), lxy, dzt, lz, dxdt(1,1,1,e), lz)
801 call mxm(y(1,1,1,e), lxy, dzt, lz, dydt(1,1,1,e), lz)
802 call mxm(z(1,1,1,e), lxy, dzt, lz, dzdt(1,1,1,e), lz)
804 call rzero(dxdt(1,1,1,e), lxy)
805 call rzero(dydt(1,1,1,e), lxy)
806 call rone(dzdt(1,1,1,e), lxy)
811 if (c%msh%gdim .eq. 2)
then
812 call rzero (jac, ntot)
813 call addcol3 (jac, dxdr, dyds, ntot)
814 call subcol3 (jac, dxds, dydr, ntot)
815 call copy (drdx, dyds, ntot)
816 call copy (drdy, dxds, ntot)
818 call copy (dsdx, dydr, ntot)
820 call copy (dsdy, dxdr, ntot)
821 call rzero (drdz, ntot)
822 call rzero (dsdz, ntot)
823 call rone (dtdz, ntot)
828 c%jac(i, 1, 1, 1) = 0.0_rp
833 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) + ( c%dxdr(i, 1, 1, 1) &
834 * c%dyds(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1) )
836 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) + ( c%dxdt(i, 1, 1, 1) &
837 * c%dydr(i, 1, 1, 1) * c%dzds(i, 1, 1, 1) )
839 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) + ( c%dxds(i, 1, 1, 1) &
840 * c%dydt(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1) )
845 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) - ( c%dxdr(i, 1, 1, 1) &
846 * c%dydt(i, 1, 1, 1) * c%dzds(i, 1, 1, 1) )
848 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) - ( c%dxds(i, 1, 1, 1) &
849 * c%dydr(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1) )
851 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) - ( c%dxdt(i, 1, 1, 1) &
852 * c%dyds(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1) )
857 c%drdx(i, 1, 1, 1) = c%dyds(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1) &
858 - c%dydt(i, 1, 1, 1) * c%dzds(i, 1, 1, 1)
860 c%drdy(i, 1, 1, 1) = c%dxdt(i, 1, 1, 1) * c%dzds(i, 1, 1, 1) &
861 - c%dxds(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1)
863 c%drdz(i, 1, 1, 1) = c%dxds(i, 1, 1, 1) * c%dydt(i, 1, 1, 1) &
864 - c%dxdt(i, 1, 1, 1) * c%dyds(i, 1, 1, 1)
869 c%dsdx(i, 1, 1, 1) = c%dydt(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1) &
870 - c%dydr(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1)
872 c%dsdy(i, 1, 1, 1) = c%dxdr(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1) &
873 - c%dxdt(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1)
875 c%dsdz(i, 1, 1, 1) = c%dxdt(i, 1, 1, 1) * c%dydr(i, 1, 1, 1) &
876 - c%dxdr(i, 1, 1, 1) * c%dydt(i, 1, 1, 1)
881 c%dtdx(i, 1, 1, 1) = c%dydr(i, 1, 1, 1) * c%dzds(i, 1, 1, 1) &
882 - c%dyds(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1)
884 c%dtdy(i, 1, 1, 1) = c%dxds(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1) &
885 - c%dxdr(i, 1, 1, 1) * c%dzds(i, 1, 1, 1)
887 c%dtdz(i, 1, 1, 1) = c%dxdr(i, 1, 1, 1) * c%dyds(i, 1, 1, 1) &
888 - c%dxds(i, 1, 1, 1) * c%dydr(i, 1, 1, 1)
893 call invers2(jacinv, jac, ntot)
902 type(
coef_t),
intent(inout) :: c
903 integer :: e, i, lxyz, ntot
905 lxyz = c%Xh%lx * c%Xh%ly * c%Xh%lz
908 if (neko_bcknd_device .eq. 1)
then
910 call device_coef_generate_geo(c%G11_d, c%G12_d, c%G13_d, &
911 c%G22_d, c%G23_d, c%G33_d, &
912 c%drdx_d, c%drdy_d, c%drdz_d, &
913 c%dsdx_d, c%dsdy_d, c%dsdz_d, &
914 c%dtdx_d, c%dtdy_d, c%dtdz_d, &
915 c%jacinv_d, c%Xh%w3_d, c%msh%nelv, &
919 if (.not. c%coef_metrics_initialized)
then
920 call device_memcpy(c%G11, c%G11_d, ntot, device_to_host, &
922 call device_memcpy(c%G22, c%G22_d, ntot, device_to_host, &
924 call device_memcpy(c%G33, c%G33_d, ntot, device_to_host, &
926 call device_memcpy(c%G12, c%G12_d, ntot, device_to_host, &
928 call device_memcpy(c%G13, c%G13_d, ntot, device_to_host, &
930 call device_memcpy(c%G23, c%G23_d, ntot, device_to_host, &
935 if (c%msh%gdim .eq. 2)
then
938 c%G11(i, 1, 1, 1) = c%drdx(i, 1, 1, 1) * c%drdx(i, 1, 1, 1) &
939 + c%drdy(i, 1, 1, 1) * c%drdy(i, 1, 1, 1)
941 c%G22(i, 1, 1, 1) = c%dsdx(i, 1, 1, 1) * c%dsdx(i, 1, 1, 1) &
942 + c%dsdy(i, 1, 1, 1) * c%dsdy(i, 1, 1, 1)
944 c%G12(i, 1, 1, 1) = c%drdx(i, 1, 1, 1) * c%dsdx(i, 1, 1, 1) &
945 + c%drdy(i, 1, 1, 1) * c%dsdy(i, 1, 1, 1)
949 c%G11(i, 1, 1, 1) = c%G11(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
950 c%G22(i, 1, 1, 1) = c%G22(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
951 c%G12(i, 1, 1, 1) = c%G12(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
952 c%G33(i, 1, 1, 1) = 0.0_rp
953 c%G13(i, 1, 1, 1) = 0.0_rp
954 c%G23(i, 1, 1, 1) = 0.0_rp
957 do concurrent(e = 1:c%msh%nelv)
958 do concurrent(i = 1:lxyz)
959 c%G11(i,1,1,e) = c%G11(i,1,1,e) * c%Xh%w3(i,1,1)
960 c%G22(i,1,1,e) = c%G22(i,1,1,e) * c%Xh%w3(i,1,1)
961 c%G12(i,1,1,e) = c%G12(i,1,1,e) * c%Xh%w3(i,1,1)
969 c%G11(i, 1, 1, 1) = c%drdx(i, 1, 1, 1) * c%drdx(i, 1, 1, 1) &
970 + c%drdy(i, 1, 1, 1) * c%drdy(i, 1, 1, 1) &
971 + c%drdz(i, 1, 1, 1) * c%drdz(i, 1, 1, 1)
973 c%G22(i, 1, 1, 1) = c%dsdx(i, 1, 1, 1) * c%dsdx(i, 1, 1, 1) &
974 + c%dsdy(i, 1, 1, 1) * c%dsdy(i, 1, 1, 1) &
975 + c%dsdz(i, 1, 1, 1) * c%dsdz(i, 1, 1, 1)
977 c%G33(i, 1, 1, 1) = c%dtdx(i, 1, 1, 1) * c%dtdx(i, 1, 1, 1) &
978 + c%dtdy(i, 1, 1, 1) * c%dtdy(i, 1, 1, 1) &
979 + c%dtdz(i, 1, 1, 1) * c%dtdz(i, 1, 1, 1)
984 c%G11(i, 1, 1, 1) = c%G11(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
985 c%G22(i, 1, 1, 1) = c%G22(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
986 c%G33(i, 1, 1, 1) = c%G33(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
991 c%G12(i, 1, 1, 1) = c%drdx(i, 1, 1, 1) * c%dsdx(i, 1, 1, 1) &
992 + c%drdy(i, 1, 1, 1) * c%dsdy(i, 1, 1, 1) &
993 + c%drdz(i, 1, 1, 1) * c%dsdz(i, 1, 1, 1)
995 c%G13(i, 1, 1, 1) = c%drdx(i, 1, 1, 1) * c%dtdx(i, 1, 1, 1) &
996 + c%drdy(i, 1, 1, 1) * c%dtdy(i, 1, 1, 1) &
997 + c%drdz(i, 1, 1, 1) * c%dtdz(i, 1, 1, 1)
999 c%G23(i, 1, 1, 1) = c%dsdx(i, 1, 1, 1) * c%dtdx(i, 1, 1, 1) &
1000 + c%dsdy(i, 1, 1, 1) * c%dtdy(i, 1, 1, 1) &
1001 + c%dsdz(i, 1, 1, 1) * c%dtdz(i, 1, 1, 1)
1006 c%G12(i, 1, 1, 1) = c%G12(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
1007 c%G13(i, 1, 1, 1) = c%G13(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
1008 c%G23(i, 1, 1, 1) = c%G23(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
1012 do e = 1, c%msh%nelv
1013 do concurrent(i = 1:lxyz)
1014 c%G11(i,1,1,e) = c%G11(i,1,1,e) * c%Xh%w3(i,1,1)
1015 c%G22(i,1,1,e) = c%G22(i,1,1,e) * c%Xh%w3(i,1,1)
1016 c%G12(i,1,1,e) = c%G12(i,1,1,e) * c%Xh%w3(i,1,1)
1018 c%G33(i,1,1,e) = c%G33(i,1,1,e) * c%Xh%w3(i,1,1)
1019 c%G13(i,1,1,e) = c%G13(i,1,1,e) * c%Xh%w3(i,1,1)
1020 c%G23(i,1,1,e) = c%G23(i,1,1,e) * c%Xh%w3(i,1,1)
1033 type(
coef_t),
intent(inout) :: c
1034 integer :: e, m, i, lxyz, m_max
1035 integer,
allocatable :: c_inds_rev(:)
1036 real(kind=rp) :: ctol = 1.0e-7_rp
1037 real(kind=rp) :: diff = 0.0_rp
1040 allocate(c%compression_inds(c%msh%nelv))
1041 allocate(c_inds_rev(c%msh%nelv))
1046 c%compression_inds(1) = 1
1051 lxyz = c%Xh%lx * c%Xh%ly * c%Xh%lz
1052 do e = 2, c%msh%nelv
1059 diff = diff + abs(c%G11(i,1,1,e) - c%G11(i,1,1,c_inds_rev(m))) &
1060 + 2.0*abs(c%G12(i,1,1,e) - c%G12(i,1,1,c_inds_rev(m))) &
1061 + 2.0*abs(c%G13(i,1,1,e) - c%G13(i,1,1,c_inds_rev(m))) &
1062 + abs(c%G22(i,1,1,e) - c%G22(i,1,1,c_inds_rev(m))) &
1063 + 2.0*abs(c%G23(i,1,1,e) - c%G23(i,1,1,c_inds_rev(m))) &
1064 + abs(c%G33(i,1,1,e) - c%G33(i,1,1,c_inds_rev(m)))
1068 if ( diff <= ctol )
then
1069 c%compression_inds(e) = m
1075 if ( diff > ctol )
then
1077 c%compression_inds(e) = m_max
1078 c_inds_rev(m_max) = e
1083 write(*,*)
'------Mapping Compression-----'
1084 write(*,*)
'Compressed from ', c%msh%nelv,
' to ', m_max
1087 allocate(c%G11_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1088 allocate(c%G22_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1089 allocate(c%G33_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1090 allocate(c%G12_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1091 allocate(c%G13_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1092 allocate(c%G23_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1095 c%G11_compressed(i,1,1,m) = c%G11(i,1,1,c_inds_rev(m))
1096 c%G22_compressed(i,1,1,m) = c%G22(i,1,1,c_inds_rev(m))
1097 c%G33_compressed(i,1,1,m) = c%G33(i,1,1,c_inds_rev(m))
1098 c%G12_compressed(i,1,1,m) = c%G12(i,1,1,c_inds_rev(m))
1099 c%G13_compressed(i,1,1,m) = c%G13(i,1,1,c_inds_rev(m))
1100 c%G23_compressed(i,1,1,m) = c%G23(i,1,1,c_inds_rev(m))
1104 deallocate(c_inds_rev)
1195 type(
coef_t),
intent(inout) :: coef
1196 real(kind=rp),
allocatable :: a(:,:,:,:)
1197 real(kind=rp),
allocatable :: b(:,:,:,:)
1198 real(kind=rp),
allocatable :: c(:,:,:,:)
1199 real(kind=rp),
allocatable :: dot(:,:,:,:)
1200 integer :: n, m, e, i, j, k, lx
1201 real(kind=rp) :: weight, len
1205 if (neko_bcknd_device .eq. 1)
then
1207 call device_coef_generate_area_and_normal( &
1208 coef%area_d, coef%nx_d, coef%ny_d, coef%nz_d, &
1209 coef%dxdr_d, coef%dydr_d, coef%dzdr_d, &
1210 coef%dxds_d, coef%dyds_d, coef%dzds_d, &
1211 coef%dxdt_d, coef%dydt_d, coef%dzdt_d, &
1212 coef%Xh%wx_d, coef%Xh%wy_d, coef%Xh%wz_d, &
1213 lx, coef%msh%nelv, neko_eps)
1217 call device_memcpy(coef%area, coef%area_d, m, &
1218 device_to_host, sync = .false.)
1219 call device_memcpy(coef%nx, coef%nx_d, m, &
1220 device_to_host, sync = .false.)
1221 call device_memcpy(coef%ny, coef%ny_d, m, &
1222 device_to_host, sync = .false.)
1223 call device_memcpy(coef%nz, coef%nz_d, &
1224 m, device_to_host, sync = .true.)
1228 allocate(a(coef%Xh%lx, coef%Xh%lx, coef%Xh%lx, coef%msh%nelv))
1229 allocate(b(coef%Xh%lx, coef%Xh%lx, coef%Xh%lx, coef%msh%nelv))
1230 allocate(c(coef%Xh%lx, coef%Xh%lx, coef%Xh%lx, coef%msh%nelv))
1231 allocate(dot(coef%Xh%lx, coef%Xh%lx, coef%Xh%lx, coef%msh%nelv))
1238 a(i, 1, 1, 1) = coef%dyds(i, 1, 1, 1) * coef%dzdt(i, 1, 1, 1) &
1239 - coef%dzds(i, 1, 1, 1) * coef%dydt(i, 1, 1, 1)
1241 b(i, 1, 1, 1) = coef%dzds(i, 1, 1, 1) * coef%dxdt(i, 1, 1, 1) &
1242 - coef%dxds(i, 1, 1, 1) * coef%dzdt(i, 1, 1, 1)
1244 c(i, 1, 1, 1) = coef%dxds(i, 1, 1, 1) * coef%dydt(i, 1, 1, 1) &
1245 - coef%dyds(i, 1, 1, 1) * coef%dxdt(i, 1, 1, 1)
1250 dot(i, 1, 1, 1) = a(i, 1, 1, 1) * a(i, 1, 1, 1) &
1251 + b(i, 1, 1, 1) * b(i, 1, 1, 1) &
1252 + c(i, 1, 1, 1) * c(i, 1, 1, 1)
1256 do e = 1, coef%msh%nelv
1257 do concurrent(k = 1:coef%Xh%lx)
1258 do concurrent(j = 1:coef%Xh%lx)
1259 weight = coef%Xh%wy(j) * coef%Xh%wz(k)
1260 coef%area(j, k, 2, e) = sqrt(dot(lx, j, k, e)) * weight
1261 coef%area(j, k, 1, e) = sqrt(dot(1, j, k, e)) * weight
1262 coef%nx(j,k, 1, e) = -a(1, j, k, e)
1263 coef%nx(j,k, 2, e) = a(lx, j, k, e)
1264 coef%ny(j,k, 1, e) = -b(1, j, k, e)
1265 coef%ny(j,k, 2, e) = b(lx, j, k, e)
1266 coef%nz(j,k, 1, e) = -c(1, j, k, e)
1267 coef%nz(j,k, 2, e) = c(lx, j, k, e)
1276 a(i, 1, 1, 1) = coef%dydr(i, 1, 1, 1) * coef%dzdt(i, 1, 1, 1) &
1277 - coef%dzdr(i, 1, 1, 1) * coef%dydt(i, 1, 1, 1)
1279 b(i, 1, 1, 1) = coef%dzdr(i, 1, 1, 1) * coef%dxdt(i, 1, 1, 1) &
1280 - coef%dxdr(i, 1, 1, 1) * coef%dzdt(i, 1, 1, 1)
1282 c(i, 1, 1, 1) = coef%dxdr(i, 1, 1, 1) * coef%dydt(i, 1, 1, 1) &
1283 - coef%dydr(i, 1, 1, 1) * coef%dxdt(i, 1, 1, 1)
1288 dot(i, 1, 1, 1) = a(i, 1, 1, 1) * a(i, 1, 1, 1) &
1289 + b(i, 1, 1, 1) * b(i, 1, 1, 1) &
1290 + c(i, 1, 1, 1) * c(i, 1, 1, 1)
1294 do e = 1, coef%msh%nelv
1295 do concurrent(k = 1:coef%Xh%lx)
1296 do concurrent(j = 1:coef%Xh%lx)
1297 weight = coef%Xh%wx(j) * coef%Xh%wz(k)
1298 coef%area(j, k, 3, e) = sqrt(dot(j, 1, k, e)) * weight
1299 coef%area(j, k, 4, e) = sqrt(dot(j, lx, k, e)) * weight
1300 coef%nx(j,k, 3, e) = a(j, 1, k, e)
1301 coef%nx(j,k, 4, e) = -a(j, lx, k, e)
1302 coef%ny(j,k, 3, e) = b(j, 1, k, e)
1303 coef%ny(j,k, 4, e) = -b(j, lx, k, e)
1304 coef%nz(j,k, 3, e) = c(j, 1, k, e)
1305 coef%nz(j,k, 4, e) = -c(j, lx, k, e)
1313 a(i, 1, 1, 1) = coef%dydr(i, 1, 1, 1) * coef%dzds(i, 1, 1, 1) &
1314 - coef%dzdr(i, 1, 1, 1) * coef%dyds(i, 1, 1, 1)
1316 b(i, 1, 1, 1) = coef%dzdr(i, 1, 1, 1) * coef%dxds(i, 1, 1, 1) &
1317 - coef%dxdr(i, 1, 1, 1) * coef%dzds(i, 1, 1, 1)
1319 c(i, 1, 1, 1) = coef%dxdr(i, 1, 1, 1) * coef%dyds(i, 1, 1, 1) &
1320 - coef%dydr(i, 1, 1, 1) * coef%dxds(i, 1, 1, 1)
1325 dot(i, 1, 1, 1) = a(i, 1, 1, 1) * a(i, 1, 1, 1) &
1326 + b(i, 1, 1, 1) * b(i, 1, 1, 1) &
1327 + c(i, 1, 1, 1) * c(i, 1, 1, 1)
1331 do e = 1, coef%msh%nelv
1332 do concurrent(k = 1:coef%Xh%lx)
1333 do concurrent(j = 1:coef%Xh%lx)
1334 weight = coef%Xh%wx(j) * coef%Xh%wy(k)
1335 coef%area(j, k, 5, e) = sqrt(dot(j, k, 1, e)) * weight
1336 coef%area(j, k, 6, e) = sqrt(dot(j, k, lx, e)) * weight
1337 coef%nx(j,k, 5, e) = -a(j, k, 1, e)
1338 coef%nx(j,k, 6, e) = a(j, k, lx, e)
1339 coef%ny(j,k, 5, e) = -b(j, k, 1, e)
1340 coef%ny(j,k, 6, e) = b(j, k, lx, e)
1341 coef%nz(j,k, 5, e) = -c(j, k, 1, e)
1342 coef%nz(j,k, 6, e) = c(j, k, lx, e)
1349 do j = 1,
size(coef%nz)
1350 len = sqrt(coef%nx(j,1,1,1)**2 + &
1351 coef%ny(j,1,1,1)**2 + coef%nz(j,1,1,1)**2)
1352 if (len .gt. neko_eps)
then
1353 coef%nx(j,1,1,1) = coef%nx(j,1,1,1) / len
1354 coef%ny(j,1,1,1) = coef%ny(j,1,1,1) / len
1355 coef%nz(j,1,1,1) = coef%nz(j,1,1,1) / len