65 real(kind=
rp),
allocatable :: g11(:,:,:,:)
67 real(kind=
rp),
allocatable :: g22(:,:,:,:)
69 real(kind=
rp),
allocatable :: g33(:,:,:,:)
71 real(kind=
rp),
allocatable :: g12(:,:,:,:)
73 real(kind=
rp),
allocatable :: g13(:,:,:,:)
75 real(kind=
rp),
allocatable :: g23(:,:,:,:)
78 real(kind=
rp),
allocatable :: g11_compressed(:,:,:,:)
80 real(kind=
rp),
allocatable :: g22_compressed(:,:,:,:)
82 real(kind=
rp),
allocatable :: g33_compressed(:,:,:,:)
84 real(kind=
rp),
allocatable :: g12_compressed(:,:,:,:)
86 real(kind=
rp),
allocatable :: g13_compressed(:,:,:,:)
88 real(kind=
rp),
allocatable :: g23_compressed(:,:,:,:)
90 integer,
allocatable :: compression_inds(:)
92 real(kind=
rp),
allocatable :: mult(:,:,:,:)
97 real(kind=
rp),
allocatable :: dxdr(:,:,:,:), dydr(:,:,:,:), dzdr(:,:,:,:)
98 real(kind=
rp),
allocatable :: dxds(:,:,:,:), dyds(:,:,:,:), dzds(:,:,:,:)
99 real(kind=
rp),
allocatable :: dxdt(:,:,:,:), dydt(:,:,:,:), dzdt(:,:,:,:)
103 real(kind=
rp),
allocatable :: drdx(:,:,:,:), drdy(:,:,:,:), drdz(:,:,:,:)
104 real(kind=
rp),
allocatable :: dsdx(:,:,:,:), dsdy(:,:,:,:), dsdz(:,:,:,:)
105 real(kind=
rp),
allocatable :: dtdx(:,:,:,:), dtdy(:,:,:,:), dtdz(:,:,:,:)
107 real(kind=
rp),
allocatable :: h1(:,:,:,:)
108 real(kind=
rp),
allocatable :: h2(:,:,:,:)
111 real(kind=
rp),
allocatable :: jac(:,:,:,:)
112 real(kind=
rp),
allocatable :: jacinv(:,:,:,:)
113 real(kind=
rp),
allocatable :: b(:,:,:,:)
114 real(kind=
rp),
allocatable :: binv(:,:,:,:)
115 real(kind=
rp),
pointer :: blag(:,:,:,:) => null()
116 real(kind=
rp),
pointer :: blaglag(:,:,:,:) => null()
117 real(kind=
rp),
allocatable :: area(:,:,:,:)
118 real(kind=
rp),
allocatable :: nx(:,:,:,:)
119 real(kind=
rp),
allocatable :: ny(:,:,:,:)
120 real(kind=
rp),
allocatable :: nz(:,:,:,:)
121 logical :: cyclic = .false.
122 integer,
allocatable :: cyc_msk(:)
123 real(kind=
rp),
allocatable :: r11(:)
124 real(kind=
rp),
allocatable :: r12(:)
127 logical,
private :: coef_metrics_initialized = .false.
131 real(kind=
rp) :: volume
136 type(
gs_t),
pointer :: gs_h=> null()
142 type(c_ptr) :: g11_d = c_null_ptr
143 type(c_ptr) :: g22_d = c_null_ptr
144 type(c_ptr) :: g33_d = c_null_ptr
145 type(c_ptr) :: g12_d = c_null_ptr
146 type(c_ptr) :: g13_d = c_null_ptr
147 type(c_ptr) :: g23_d = c_null_ptr
148 type(c_ptr) :: dxdr_d = c_null_ptr
149 type(c_ptr) :: dydr_d = c_null_ptr
150 type(c_ptr) :: dzdr_d = c_null_ptr
151 type(c_ptr) :: dxds_d = c_null_ptr
152 type(c_ptr) :: dyds_d = c_null_ptr
153 type(c_ptr) :: dzds_d = c_null_ptr
154 type(c_ptr) :: dxdt_d = c_null_ptr
155 type(c_ptr) :: dydt_d = c_null_ptr
156 type(c_ptr) :: dzdt_d = c_null_ptr
157 type(c_ptr) :: drdx_d = c_null_ptr
158 type(c_ptr) :: drdy_d = c_null_ptr
159 type(c_ptr) :: drdz_d = c_null_ptr
160 type(c_ptr) :: dsdx_d = c_null_ptr
161 type(c_ptr) :: dsdy_d = c_null_ptr
162 type(c_ptr) :: dsdz_d = c_null_ptr
163 type(c_ptr) :: dtdx_d = c_null_ptr
164 type(c_ptr) :: dtdy_d = c_null_ptr
165 type(c_ptr) :: dtdz_d = c_null_ptr
166 type(c_ptr) :: mult_d = c_null_ptr
167 type(c_ptr) :: h1_d = c_null_ptr
168 type(c_ptr) :: h2_d = c_null_ptr
169 type(c_ptr) :: jac_d = c_null_ptr
170 type(c_ptr) :: jacinv_d = c_null_ptr
171 type(c_ptr) :: b_d = c_null_ptr
172 type(c_ptr) :: blag_d = c_null_ptr
173 type(c_ptr) :: blaglag_d = c_null_ptr
174 type(c_ptr) :: binv_d = c_null_ptr
175 type(c_ptr) :: area_d = c_null_ptr
176 type(c_ptr) :: nx_d = c_null_ptr
177 type(c_ptr) :: ny_d = c_null_ptr
178 type(c_ptr) :: nz_d = c_null_ptr
179 type(c_ptr) :: cyc_msk_d = c_null_ptr
180 type(c_ptr) :: r11_d = c_null_ptr
181 type(c_ptr) :: r12_d = c_null_ptr
195 generic :: init => init_empty, init_all
248 class(
coef_t),
intent(inout),
target :: this
249 type(
gs_t),
intent(inout),
target :: gs_h
250 integer :: n, m, ncyc
253 this%msh => gs_h%dofmap%msh
254 this%Xh => gs_h%dofmap%Xh
255 this%dof => gs_h%dofmap
262 allocate(this%G11(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
263 allocate(this%G22(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
264 allocate(this%G33(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
265 allocate(this%G12(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
266 allocate(this%G13(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
267 allocate(this%G23(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
269 allocate(this%dxdr(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
270 allocate(this%dxds(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
271 allocate(this%dxdt(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
273 allocate(this%dydr(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
274 allocate(this%dyds(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
275 allocate(this%dydt(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
277 allocate(this%dzdr(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
278 allocate(this%dzds(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
279 allocate(this%dzdt(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
281 allocate(this%drdx(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
282 allocate(this%dsdx(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
283 allocate(this%dtdx(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
285 allocate(this%drdy(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
286 allocate(this%dsdy(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
287 allocate(this%dtdy(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
289 allocate(this%drdz(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
290 allocate(this%dsdz(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
291 allocate(this%dtdz(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
293 allocate(this%jac(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
294 allocate(this%jacinv(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
296 allocate(this%area(this%Xh%lx, this%Xh%ly, 6, this%msh%nelv))
297 allocate(this%nx(this%Xh%lx, this%Xh%ly, 6, this%msh%nelv))
298 allocate(this%ny(this%Xh%lx, this%Xh%ly, 6, this%msh%nelv))
299 allocate(this%nz(this%Xh%lx, this%Xh%ly, 6, this%msh%nelv))
301 allocate(this%B(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
302 allocate(this%Binv(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
306 this%Blaglag => this%B
308 allocate(this%h1(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
309 allocate(this%h2(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
311 allocate(this%mult(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
318 n = this%Xh%lx * this%Xh%ly * this%Xh%lz * this%msh%nelv
356 call device_map(this%jacinv, this%jacinv_d, n)
360 this%Blag_d = this%B_d
361 this%Blaglag_d = this%B_d
363 m = this%Xh%lx * this%Xh%ly * 6 * this%msh%nelv
382 this%coef_metrics_initialized = .true.
407 call rone(this%mult, n)
420 ncyc = this%msh%periodic%size * this%Xh%lx * this%Xh%lx
421 allocate(this%cyc_msk(0:ncyc))
422 this%cyc_msk(0) = ncyc + 1
423 if (ncyc .gt. 0)
then
424 allocate(this%R11(ncyc))
425 allocate(this%R12(ncyc))
428 call rone(this%R11, ncyc)
429 call rzero(this%R12, ncyc)
432 call device_map(this%cyc_msk, this%cyc_msk_d, ncyc+1)
714 type(
coef_t),
intent(inout) :: c
715 integer :: e, i, lxy, lyz, ntot
717 lxy = c%Xh%lx*c%Xh%ly
718 lyz = c%Xh%ly*c%Xh%lz
721 associate(drdx => c%drdx, drdy => c%drdy, drdz => c%drdz, &
722 dsdx => c%dsdx, dsdy => c%dsdy, dsdz => c%dsdz, &
723 dtdx => c%dtdx, dtdy => c%dtdy, dtdz => c%dtdz, &
724 dxdr => c%dxdr, dydr => c%dydr, dzdr => c%dzdr, &
725 dxds => c%dxds, dyds => c%dyds, dzds => c%dzds, &
726 dxdt => c%dxdt, dydt => c%dydt, dzdt => c%dzdt, &
727 dx => c%Xh%dx, dy => c%Xh%dy, dz => c%Xh%dz, &
728 x => c%dof%x, y => c%dof%y, z => c%dof%z, &
729 lx => c%Xh%lx, ly => c%Xh%ly, lz => c%Xh%lz, &
730 dyt => c%Xh%dyt, dzt => c%Xh%dzt, &
731 jacinv => c%jacinv, jac => c%jac)
736 c%dsdx_d, c%dsdy_d, c%dsdz_d, c%dtdx_d, c%dtdy_d, c%dtdz_d, &
737 c%dxdr_d, c%dydr_d, c%dzdr_d, c%dxds_d, c%dyds_d, c%dzds_d, &
738 c%dxdt_d, c%dydt_d, c%dzdt_d, c%Xh%dx_d, c%Xh%dy_d, c%Xh%dz_d, &
739 c%dof%x_d, c%dof%y_d, c%dof%z_d, c%jacinv_d, c%jac_d, &
743 if (.not. c%coef_metrics_initialized)
then
789 call mxm(dx, lx, x(1,1,1,e), lx, dxdr(1,1,1,e), lyz)
790 call mxm(dx, lx, y(1,1,1,e), lx, dydr(1,1,1,e), lyz)
791 call mxm(dx, lx, z(1,1,1,e), lx, dzdr(1,1,1,e), lyz)
794 call mxm(x(1,1,i,e), lx, dyt, ly, dxds(1,1,i,e), ly)
795 call mxm(y(1,1,i,e), lx, dyt, ly, dyds(1,1,i,e), ly)
796 call mxm(z(1,1,i,e), lx, dyt, ly, dzds(1,1,i,e), ly)
800 if (c%msh%gdim .eq. 3)
then
801 call mxm(x(1,1,1,e), lxy, dzt, lz, dxdt(1,1,1,e), lz)
802 call mxm(y(1,1,1,e), lxy, dzt, lz, dydt(1,1,1,e), lz)
803 call mxm(z(1,1,1,e), lxy, dzt, lz, dzdt(1,1,1,e), lz)
805 call rzero(dxdt(1,1,1,e), lxy)
806 call rzero(dydt(1,1,1,e), lxy)
807 call rone(dzdt(1,1,1,e), lxy)
812 if (c%msh%gdim .eq. 2)
then
813 call rzero (jac, ntot)
814 call addcol3 (jac, dxdr, dyds, ntot)
815 call subcol3 (jac, dxds, dydr, ntot)
816 call copy (drdx, dyds, ntot)
817 call copy (drdy, dxds, ntot)
819 call copy (dsdx, dydr, ntot)
821 call copy (dsdy, dxdr, ntot)
822 call rzero (drdz, ntot)
823 call rzero (dsdz, ntot)
824 call rone (dtdz, ntot)
829 c%jac(i, 1, 1, 1) = 0.0_rp
834 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) + ( c%dxdr(i, 1, 1, 1) &
835 * c%dyds(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1) )
837 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) + ( c%dxdt(i, 1, 1, 1) &
838 * c%dydr(i, 1, 1, 1) * c%dzds(i, 1, 1, 1) )
840 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) + ( c%dxds(i, 1, 1, 1) &
841 * c%dydt(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1) )
846 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) - ( c%dxdr(i, 1, 1, 1) &
847 * c%dydt(i, 1, 1, 1) * c%dzds(i, 1, 1, 1) )
849 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) - ( c%dxds(i, 1, 1, 1) &
850 * c%dydr(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1) )
852 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) - ( c%dxdt(i, 1, 1, 1) &
853 * c%dyds(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1) )
858 c%drdx(i, 1, 1, 1) = c%dyds(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1) &
859 - c%dydt(i, 1, 1, 1) * c%dzds(i, 1, 1, 1)
861 c%drdy(i, 1, 1, 1) = c%dxdt(i, 1, 1, 1) * c%dzds(i, 1, 1, 1) &
862 - c%dxds(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1)
864 c%drdz(i, 1, 1, 1) = c%dxds(i, 1, 1, 1) * c%dydt(i, 1, 1, 1) &
865 - c%dxdt(i, 1, 1, 1) * c%dyds(i, 1, 1, 1)
870 c%dsdx(i, 1, 1, 1) = c%dydt(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1) &
871 - c%dydr(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1)
873 c%dsdy(i, 1, 1, 1) = c%dxdr(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1) &
874 - c%dxdt(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1)
876 c%dsdz(i, 1, 1, 1) = c%dxdt(i, 1, 1, 1) * c%dydr(i, 1, 1, 1) &
877 - c%dxdr(i, 1, 1, 1) * c%dydt(i, 1, 1, 1)
882 c%dtdx(i, 1, 1, 1) = c%dydr(i, 1, 1, 1) * c%dzds(i, 1, 1, 1) &
883 - c%dyds(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1)
885 c%dtdy(i, 1, 1, 1) = c%dxds(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1) &
886 - c%dxdr(i, 1, 1, 1) * c%dzds(i, 1, 1, 1)
888 c%dtdz(i, 1, 1, 1) = c%dxdr(i, 1, 1, 1) * c%dyds(i, 1, 1, 1) &
889 - c%dxds(i, 1, 1, 1) * c%dydr(i, 1, 1, 1)
894 call invers2(jacinv, jac, ntot)
903 type(
coef_t),
intent(inout) :: c
904 integer :: e, i, lxyz, ntot
906 lxyz = c%Xh%lx * c%Xh%ly * c%Xh%lz
909 if (neko_bcknd_device .eq. 1)
then
911 call device_coef_generate_geo(c%G11_d, c%G12_d, c%G13_d, &
912 c%G22_d, c%G23_d, c%G33_d, &
913 c%drdx_d, c%drdy_d, c%drdz_d, &
914 c%dsdx_d, c%dsdy_d, c%dsdz_d, &
915 c%dtdx_d, c%dtdy_d, c%dtdz_d, &
916 c%jacinv_d, c%Xh%w3_d, c%msh%nelv, &
920 if (.not. c%coef_metrics_initialized)
then
921 call device_memcpy(c%G11, c%G11_d, ntot, device_to_host, &
923 call device_memcpy(c%G22, c%G22_d, ntot, device_to_host, &
925 call device_memcpy(c%G33, c%G33_d, ntot, device_to_host, &
927 call device_memcpy(c%G12, c%G12_d, ntot, device_to_host, &
929 call device_memcpy(c%G13, c%G13_d, ntot, device_to_host, &
931 call device_memcpy(c%G23, c%G23_d, ntot, device_to_host, &
936 if (c%msh%gdim .eq. 2)
then
939 c%G11(i, 1, 1, 1) = c%drdx(i, 1, 1, 1) * c%drdx(i, 1, 1, 1) &
940 + c%drdy(i, 1, 1, 1) * c%drdy(i, 1, 1, 1)
942 c%G22(i, 1, 1, 1) = c%dsdx(i, 1, 1, 1) * c%dsdx(i, 1, 1, 1) &
943 + c%dsdy(i, 1, 1, 1) * c%dsdy(i, 1, 1, 1)
945 c%G12(i, 1, 1, 1) = c%drdx(i, 1, 1, 1) * c%dsdx(i, 1, 1, 1) &
946 + c%drdy(i, 1, 1, 1) * c%dsdy(i, 1, 1, 1)
950 c%G11(i, 1, 1, 1) = c%G11(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
951 c%G22(i, 1, 1, 1) = c%G22(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
952 c%G12(i, 1, 1, 1) = c%G12(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
953 c%G33(i, 1, 1, 1) = 0.0_rp
954 c%G13(i, 1, 1, 1) = 0.0_rp
955 c%G23(i, 1, 1, 1) = 0.0_rp
958 do concurrent(e = 1:c%msh%nelv)
959 do concurrent(i = 1:lxyz)
960 c%G11(i,1,1,e) = c%G11(i,1,1,e) * c%Xh%w3(i,1,1)
961 c%G22(i,1,1,e) = c%G22(i,1,1,e) * c%Xh%w3(i,1,1)
962 c%G12(i,1,1,e) = c%G12(i,1,1,e) * c%Xh%w3(i,1,1)
970 c%G11(i, 1, 1, 1) = c%drdx(i, 1, 1, 1) * c%drdx(i, 1, 1, 1) &
971 + c%drdy(i, 1, 1, 1) * c%drdy(i, 1, 1, 1) &
972 + c%drdz(i, 1, 1, 1) * c%drdz(i, 1, 1, 1)
974 c%G22(i, 1, 1, 1) = c%dsdx(i, 1, 1, 1) * c%dsdx(i, 1, 1, 1) &
975 + c%dsdy(i, 1, 1, 1) * c%dsdy(i, 1, 1, 1) &
976 + c%dsdz(i, 1, 1, 1) * c%dsdz(i, 1, 1, 1)
978 c%G33(i, 1, 1, 1) = c%dtdx(i, 1, 1, 1) * c%dtdx(i, 1, 1, 1) &
979 + c%dtdy(i, 1, 1, 1) * c%dtdy(i, 1, 1, 1) &
980 + c%dtdz(i, 1, 1, 1) * c%dtdz(i, 1, 1, 1)
985 c%G11(i, 1, 1, 1) = c%G11(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
986 c%G22(i, 1, 1, 1) = c%G22(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
987 c%G33(i, 1, 1, 1) = c%G33(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
992 c%G12(i, 1, 1, 1) = c%drdx(i, 1, 1, 1) * c%dsdx(i, 1, 1, 1) &
993 + c%drdy(i, 1, 1, 1) * c%dsdy(i, 1, 1, 1) &
994 + c%drdz(i, 1, 1, 1) * c%dsdz(i, 1, 1, 1)
996 c%G13(i, 1, 1, 1) = c%drdx(i, 1, 1, 1) * c%dtdx(i, 1, 1, 1) &
997 + c%drdy(i, 1, 1, 1) * c%dtdy(i, 1, 1, 1) &
998 + c%drdz(i, 1, 1, 1) * c%dtdz(i, 1, 1, 1)
1000 c%G23(i, 1, 1, 1) = c%dsdx(i, 1, 1, 1) * c%dtdx(i, 1, 1, 1) &
1001 + c%dsdy(i, 1, 1, 1) * c%dtdy(i, 1, 1, 1) &
1002 + c%dsdz(i, 1, 1, 1) * c%dtdz(i, 1, 1, 1)
1007 c%G12(i, 1, 1, 1) = c%G12(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
1008 c%G13(i, 1, 1, 1) = c%G13(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
1009 c%G23(i, 1, 1, 1) = c%G23(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
1013 do e = 1, c%msh%nelv
1014 do concurrent(i = 1:lxyz)
1015 c%G11(i,1,1,e) = c%G11(i,1,1,e) * c%Xh%w3(i,1,1)
1016 c%G22(i,1,1,e) = c%G22(i,1,1,e) * c%Xh%w3(i,1,1)
1017 c%G12(i,1,1,e) = c%G12(i,1,1,e) * c%Xh%w3(i,1,1)
1019 c%G33(i,1,1,e) = c%G33(i,1,1,e) * c%Xh%w3(i,1,1)
1020 c%G13(i,1,1,e) = c%G13(i,1,1,e) * c%Xh%w3(i,1,1)
1021 c%G23(i,1,1,e) = c%G23(i,1,1,e) * c%Xh%w3(i,1,1)
1034 type(
coef_t),
intent(inout) :: c
1035 integer :: e, m, i, lxyz, m_max
1036 integer,
allocatable :: c_inds_rev(:)
1037 real(kind=rp) :: ctol = 1.0e-7_rp
1038 real(kind=rp) :: diff = 0.0_rp
1041 allocate(c%compression_inds(c%msh%nelv))
1042 allocate(c_inds_rev(c%msh%nelv))
1047 c%compression_inds(1) = 1
1052 lxyz = c%Xh%lx * c%Xh%ly * c%Xh%lz
1053 do e = 2, c%msh%nelv
1060 diff = diff + abs(c%G11(i,1,1,e) - c%G11(i,1,1,c_inds_rev(m))) &
1061 + 2.0*abs(c%G12(i,1,1,e) - c%G12(i,1,1,c_inds_rev(m))) &
1062 + 2.0*abs(c%G13(i,1,1,e) - c%G13(i,1,1,c_inds_rev(m))) &
1063 + abs(c%G22(i,1,1,e) - c%G22(i,1,1,c_inds_rev(m))) &
1064 + 2.0*abs(c%G23(i,1,1,e) - c%G23(i,1,1,c_inds_rev(m))) &
1065 + abs(c%G33(i,1,1,e) - c%G33(i,1,1,c_inds_rev(m)))
1069 if ( diff .le. ctol )
then
1070 c%compression_inds(e) = m
1076 if ( diff .gt. ctol )
then
1078 c%compression_inds(e) = m_max
1079 c_inds_rev(m_max) = e
1084 write(*,*)
'------Mapping Compression-----'
1085 write(*,*)
'Compressed from ', c%msh%nelv,
' to ', m_max
1088 allocate(c%G11_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1089 allocate(c%G22_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1090 allocate(c%G33_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1091 allocate(c%G12_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1092 allocate(c%G13_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1093 allocate(c%G23_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1096 c%G11_compressed(i,1,1,m) = c%G11(i,1,1,c_inds_rev(m))
1097 c%G22_compressed(i,1,1,m) = c%G22(i,1,1,c_inds_rev(m))
1098 c%G33_compressed(i,1,1,m) = c%G33(i,1,1,c_inds_rev(m))
1099 c%G12_compressed(i,1,1,m) = c%G12(i,1,1,c_inds_rev(m))
1100 c%G13_compressed(i,1,1,m) = c%G13(i,1,1,c_inds_rev(m))
1101 c%G23_compressed(i,1,1,m) = c%G23(i,1,1,c_inds_rev(m))
1105 deallocate(c_inds_rev)
1196 type(
coef_t),
intent(inout) :: coef
1197 real(kind=rp),
allocatable :: a(:,:,:,:)
1198 real(kind=rp),
allocatable :: b(:,:,:,:)
1199 real(kind=rp),
allocatable :: c(:,:,:,:)
1200 real(kind=rp),
allocatable :: dot(:,:,:,:)
1201 integer :: n, m, e, i, j, k, lx
1202 real(kind=rp) :: weight, len
1206 if (neko_bcknd_device .eq. 1)
then
1208 call device_coef_generate_area_and_normal( &
1209 coef%area_d, coef%nx_d, coef%ny_d, coef%nz_d, &
1210 coef%dxdr_d, coef%dydr_d, coef%dzdr_d, &
1211 coef%dxds_d, coef%dyds_d, coef%dzds_d, &
1212 coef%dxdt_d, coef%dydt_d, coef%dzdt_d, &
1213 coef%Xh%wx_d, coef%Xh%wy_d, coef%Xh%wz_d, &
1214 lx, coef%msh%nelv, neko_eps)
1218 call device_memcpy(coef%area, coef%area_d, m, &
1219 device_to_host, sync = .false.)
1220 call device_memcpy(coef%nx, coef%nx_d, m, &
1221 device_to_host, sync = .false.)
1222 call device_memcpy(coef%ny, coef%ny_d, m, &
1223 device_to_host, sync = .false.)
1224 call device_memcpy(coef%nz, coef%nz_d, &
1225 m, device_to_host, sync = .true.)
1229 allocate(a(coef%Xh%lx, coef%Xh%lx, coef%Xh%lx, coef%msh%nelv))
1230 allocate(b(coef%Xh%lx, coef%Xh%lx, coef%Xh%lx, coef%msh%nelv))
1231 allocate(c(coef%Xh%lx, coef%Xh%lx, coef%Xh%lx, coef%msh%nelv))
1232 allocate(dot(coef%Xh%lx, coef%Xh%lx, coef%Xh%lx, coef%msh%nelv))
1239 a(i, 1, 1, 1) = coef%dyds(i, 1, 1, 1) * coef%dzdt(i, 1, 1, 1) &
1240 - coef%dzds(i, 1, 1, 1) * coef%dydt(i, 1, 1, 1)
1242 b(i, 1, 1, 1) = coef%dzds(i, 1, 1, 1) * coef%dxdt(i, 1, 1, 1) &
1243 - coef%dxds(i, 1, 1, 1) * coef%dzdt(i, 1, 1, 1)
1245 c(i, 1, 1, 1) = coef%dxds(i, 1, 1, 1) * coef%dydt(i, 1, 1, 1) &
1246 - coef%dyds(i, 1, 1, 1) * coef%dxdt(i, 1, 1, 1)
1251 dot(i, 1, 1, 1) = a(i, 1, 1, 1) * a(i, 1, 1, 1) &
1252 + b(i, 1, 1, 1) * b(i, 1, 1, 1) &
1253 + c(i, 1, 1, 1) * c(i, 1, 1, 1)
1257 do e = 1, coef%msh%nelv
1258 do concurrent(k = 1:coef%Xh%lx)
1259 do concurrent(j = 1:coef%Xh%lx)
1260 weight = coef%Xh%wy(j) * coef%Xh%wz(k)
1261 coef%area(j, k, 2, e) = sqrt(dot(lx, j, k, e)) * weight
1262 coef%area(j, k, 1, e) = sqrt(dot(1, j, k, e)) * weight
1263 coef%nx(j,k, 1, e) = -a(1, j, k, e)
1264 coef%nx(j,k, 2, e) = a(lx, j, k, e)
1265 coef%ny(j,k, 1, e) = -b(1, j, k, e)
1266 coef%ny(j,k, 2, e) = b(lx, j, k, e)
1267 coef%nz(j,k, 1, e) = -c(1, j, k, e)
1268 coef%nz(j,k, 2, e) = c(lx, j, k, e)
1277 a(i, 1, 1, 1) = coef%dydr(i, 1, 1, 1) * coef%dzdt(i, 1, 1, 1) &
1278 - coef%dzdr(i, 1, 1, 1) * coef%dydt(i, 1, 1, 1)
1280 b(i, 1, 1, 1) = coef%dzdr(i, 1, 1, 1) * coef%dxdt(i, 1, 1, 1) &
1281 - coef%dxdr(i, 1, 1, 1) * coef%dzdt(i, 1, 1, 1)
1283 c(i, 1, 1, 1) = coef%dxdr(i, 1, 1, 1) * coef%dydt(i, 1, 1, 1) &
1284 - coef%dydr(i, 1, 1, 1) * coef%dxdt(i, 1, 1, 1)
1289 dot(i, 1, 1, 1) = a(i, 1, 1, 1) * a(i, 1, 1, 1) &
1290 + b(i, 1, 1, 1) * b(i, 1, 1, 1) &
1291 + c(i, 1, 1, 1) * c(i, 1, 1, 1)
1295 do e = 1, coef%msh%nelv
1296 do concurrent(k = 1:coef%Xh%lx)
1297 do concurrent(j = 1:coef%Xh%lx)
1298 weight = coef%Xh%wx(j) * coef%Xh%wz(k)
1299 coef%area(j, k, 3, e) = sqrt(dot(j, 1, k, e)) * weight
1300 coef%area(j, k, 4, e) = sqrt(dot(j, lx, k, e)) * weight
1301 coef%nx(j,k, 3, e) = a(j, 1, k, e)
1302 coef%nx(j,k, 4, e) = -a(j, lx, k, e)
1303 coef%ny(j,k, 3, e) = b(j, 1, k, e)
1304 coef%ny(j,k, 4, e) = -b(j, lx, k, e)
1305 coef%nz(j,k, 3, e) = c(j, 1, k, e)
1306 coef%nz(j,k, 4, e) = -c(j, lx, k, e)
1314 a(i, 1, 1, 1) = coef%dydr(i, 1, 1, 1) * coef%dzds(i, 1, 1, 1) &
1315 - coef%dzdr(i, 1, 1, 1) * coef%dyds(i, 1, 1, 1)
1317 b(i, 1, 1, 1) = coef%dzdr(i, 1, 1, 1) * coef%dxds(i, 1, 1, 1) &
1318 - coef%dxdr(i, 1, 1, 1) * coef%dzds(i, 1, 1, 1)
1320 c(i, 1, 1, 1) = coef%dxdr(i, 1, 1, 1) * coef%dyds(i, 1, 1, 1) &
1321 - coef%dydr(i, 1, 1, 1) * coef%dxds(i, 1, 1, 1)
1326 dot(i, 1, 1, 1) = a(i, 1, 1, 1) * a(i, 1, 1, 1) &
1327 + b(i, 1, 1, 1) * b(i, 1, 1, 1) &
1328 + c(i, 1, 1, 1) * c(i, 1, 1, 1)
1332 do e = 1, coef%msh%nelv
1333 do concurrent(k = 1:coef%Xh%lx)
1334 do concurrent(j = 1:coef%Xh%lx)
1335 weight = coef%Xh%wx(j) * coef%Xh%wy(k)
1336 coef%area(j, k, 5, e) = sqrt(dot(j, k, 1, e)) * weight
1337 coef%area(j, k, 6, e) = sqrt(dot(j, k, lx, e)) * weight
1338 coef%nx(j,k, 5, e) = -a(j, k, 1, e)
1339 coef%nx(j,k, 6, e) = a(j, k, lx, e)
1340 coef%ny(j,k, 5, e) = -b(j, k, 1, e)
1341 coef%ny(j,k, 6, e) = b(j, k, lx, e)
1342 coef%nz(j,k, 5, e) = -c(j, k, 1, e)
1343 coef%nz(j,k, 6, e) = c(j, k, lx, e)
1350 do j = 1,
size(coef%nz)
1351 len = sqrt(coef%nx(j,1,1,1)**2 + &
1352 coef%ny(j,1,1,1)**2 + coef%nz(j,1,1,1)**2)
1353 if (len .gt. neko_eps)
then
1354 coef%nx(j,1,1,1) = coef%nx(j,1,1,1) / len
1355 coef%ny(j,1,1,1) = coef%ny(j,1,1,1) / len
1356 coef%nz(j,1,1,1) = coef%nz(j,1,1,1) / len