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
184 integer :: metrics_version = 0
196 generic :: init => init_empty, init_all
249 class(
coef_t),
intent(inout),
target :: this
250 type(
gs_t),
intent(inout),
target :: gs_h
251 integer :: n, m, ncyc
254 this%msh => gs_h%dofmap%msh
255 this%Xh => gs_h%dofmap%Xh
256 this%dof => gs_h%dofmap
263 allocate(this%G11(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
264 allocate(this%G22(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
265 allocate(this%G33(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
266 allocate(this%G12(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
267 allocate(this%G13(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
268 allocate(this%G23(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
270 allocate(this%dxdr(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
271 allocate(this%dxds(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
272 allocate(this%dxdt(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
274 allocate(this%dydr(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
275 allocate(this%dyds(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
276 allocate(this%dydt(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
278 allocate(this%dzdr(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
279 allocate(this%dzds(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
280 allocate(this%dzdt(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
282 allocate(this%drdx(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
283 allocate(this%dsdx(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
284 allocate(this%dtdx(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
286 allocate(this%drdy(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
287 allocate(this%dsdy(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
288 allocate(this%dtdy(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
290 allocate(this%drdz(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
291 allocate(this%dsdz(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
292 allocate(this%dtdz(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
294 allocate(this%jac(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
295 allocate(this%jacinv(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
297 allocate(this%area(this%Xh%lx, this%Xh%ly, 6, this%msh%nelv))
298 allocate(this%nx(this%Xh%lx, this%Xh%ly, 6, this%msh%nelv))
299 allocate(this%ny(this%Xh%lx, this%Xh%ly, 6, this%msh%nelv))
300 allocate(this%nz(this%Xh%lx, this%Xh%ly, 6, this%msh%nelv))
302 allocate(this%B(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
303 allocate(this%Binv(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
307 this%Blaglag => this%B
309 allocate(this%h1(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
310 allocate(this%h2(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
312 allocate(this%mult(this%Xh%lx, this%Xh%ly, this%Xh%lz, this%msh%nelv))
319 n = this%Xh%lx * this%Xh%ly * this%Xh%lz * this%msh%nelv
357 call device_map(this%jacinv, this%jacinv_d, n)
361 this%Blag_d = this%B_d
362 this%Blaglag_d = this%B_d
364 m = this%Xh%lx * this%Xh%ly * 6 * this%msh%nelv
383 this%coef_metrics_initialized = .true.
408 call rone(this%mult, n)
421 ncyc = this%msh%periodic%size * this%Xh%lx * this%Xh%lx
422 allocate(this%cyc_msk(0:ncyc))
423 this%cyc_msk(0) = ncyc + 1
424 if (ncyc .gt. 0)
then
425 allocate(this%R11(ncyc))
426 allocate(this%R12(ncyc))
429 call rone(this%R11, ncyc)
430 call rzero(this%R12, ncyc)
433 call device_map(this%cyc_msk, this%cyc_msk_d, ncyc+1)
715 type(
coef_t),
intent(inout) :: c
716 integer :: e, i, lxy, lyz, ntot
718 lxy = c%Xh%lx*c%Xh%ly
719 lyz = c%Xh%ly*c%Xh%lz
722 associate(drdx => c%drdx, drdy => c%drdy, drdz => c%drdz, &
723 dsdx => c%dsdx, dsdy => c%dsdy, dsdz => c%dsdz, &
724 dtdx => c%dtdx, dtdy => c%dtdy, dtdz => c%dtdz, &
725 dxdr => c%dxdr, dydr => c%dydr, dzdr => c%dzdr, &
726 dxds => c%dxds, dyds => c%dyds, dzds => c%dzds, &
727 dxdt => c%dxdt, dydt => c%dydt, dzdt => c%dzdt, &
728 dx => c%Xh%dx, dy => c%Xh%dy, dz => c%Xh%dz, &
729 x => c%dof%x, y => c%dof%y, z => c%dof%z, &
730 lx => c%Xh%lx, ly => c%Xh%ly, lz => c%Xh%lz, &
731 dyt => c%Xh%dyt, dzt => c%Xh%dzt, &
732 jacinv => c%jacinv, jac => c%jac)
737 c%dsdx_d, c%dsdy_d, c%dsdz_d, c%dtdx_d, c%dtdy_d, c%dtdz_d, &
738 c%dxdr_d, c%dydr_d, c%dzdr_d, c%dxds_d, c%dyds_d, c%dzds_d, &
739 c%dxdt_d, c%dydt_d, c%dzdt_d, c%Xh%dx_d, c%Xh%dy_d, c%Xh%dz_d, &
740 c%dof%x_d, c%dof%y_d, c%dof%z_d, c%jacinv_d, c%jac_d, &
744 if (.not. c%coef_metrics_initialized)
then
790 call mxm(dx, lx, x(1,1,1,e), lx, dxdr(1,1,1,e), lyz)
791 call mxm(dx, lx, y(1,1,1,e), lx, dydr(1,1,1,e), lyz)
792 call mxm(dx, lx, z(1,1,1,e), lx, dzdr(1,1,1,e), lyz)
795 call mxm(x(1,1,i,e), lx, dyt, ly, dxds(1,1,i,e), ly)
796 call mxm(y(1,1,i,e), lx, dyt, ly, dyds(1,1,i,e), ly)
797 call mxm(z(1,1,i,e), lx, dyt, ly, dzds(1,1,i,e), ly)
801 if (c%msh%gdim .eq. 3)
then
802 call mxm(x(1,1,1,e), lxy, dzt, lz, dxdt(1,1,1,e), lz)
803 call mxm(y(1,1,1,e), lxy, dzt, lz, dydt(1,1,1,e), lz)
804 call mxm(z(1,1,1,e), lxy, dzt, lz, dzdt(1,1,1,e), lz)
806 call rzero(dxdt(1,1,1,e), lxy)
807 call rzero(dydt(1,1,1,e), lxy)
808 call rone(dzdt(1,1,1,e), lxy)
813 if (c%msh%gdim .eq. 2)
then
814 call rzero (jac, ntot)
815 call addcol3 (jac, dxdr, dyds, ntot)
816 call subcol3 (jac, dxds, dydr, ntot)
817 call copy (drdx, dyds, ntot)
818 call copy (drdy, dxds, ntot)
820 call copy (dsdx, dydr, ntot)
822 call copy (dsdy, dxdr, ntot)
823 call rzero (drdz, ntot)
824 call rzero (dsdz, ntot)
825 call rone (dtdz, ntot)
830 c%jac(i, 1, 1, 1) = 0.0_rp
835 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) + ( c%dxdr(i, 1, 1, 1) &
836 * c%dyds(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1) )
838 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) + ( c%dxdt(i, 1, 1, 1) &
839 * c%dydr(i, 1, 1, 1) * c%dzds(i, 1, 1, 1) )
841 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) + ( c%dxds(i, 1, 1, 1) &
842 * c%dydt(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1) )
847 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) - ( c%dxdr(i, 1, 1, 1) &
848 * c%dydt(i, 1, 1, 1) * c%dzds(i, 1, 1, 1) )
850 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) - ( c%dxds(i, 1, 1, 1) &
851 * c%dydr(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1) )
853 c%jac(i, 1, 1, 1) = c%jac(i, 1, 1, 1) - ( c%dxdt(i, 1, 1, 1) &
854 * c%dyds(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1) )
859 c%drdx(i, 1, 1, 1) = c%dyds(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1) &
860 - c%dydt(i, 1, 1, 1) * c%dzds(i, 1, 1, 1)
862 c%drdy(i, 1, 1, 1) = c%dxdt(i, 1, 1, 1) * c%dzds(i, 1, 1, 1) &
863 - c%dxds(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1)
865 c%drdz(i, 1, 1, 1) = c%dxds(i, 1, 1, 1) * c%dydt(i, 1, 1, 1) &
866 - c%dxdt(i, 1, 1, 1) * c%dyds(i, 1, 1, 1)
871 c%dsdx(i, 1, 1, 1) = c%dydt(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1) &
872 - c%dydr(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1)
874 c%dsdy(i, 1, 1, 1) = c%dxdr(i, 1, 1, 1) * c%dzdt(i, 1, 1, 1) &
875 - c%dxdt(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1)
877 c%dsdz(i, 1, 1, 1) = c%dxdt(i, 1, 1, 1) * c%dydr(i, 1, 1, 1) &
878 - c%dxdr(i, 1, 1, 1) * c%dydt(i, 1, 1, 1)
883 c%dtdx(i, 1, 1, 1) = c%dydr(i, 1, 1, 1) * c%dzds(i, 1, 1, 1) &
884 - c%dyds(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1)
886 c%dtdy(i, 1, 1, 1) = c%dxds(i, 1, 1, 1) * c%dzdr(i, 1, 1, 1) &
887 - c%dxdr(i, 1, 1, 1) * c%dzds(i, 1, 1, 1)
889 c%dtdz(i, 1, 1, 1) = c%dxdr(i, 1, 1, 1) * c%dyds(i, 1, 1, 1) &
890 - c%dxds(i, 1, 1, 1) * c%dydr(i, 1, 1, 1)
895 call invers2(jacinv, jac, ntot)
904 type(
coef_t),
intent(inout) :: c
905 integer :: e, i, lxyz, ntot
907 lxyz = c%Xh%lx * c%Xh%ly * c%Xh%lz
910 if (neko_bcknd_device .eq. 1)
then
912 call device_coef_generate_geo(c%G11_d, c%G12_d, c%G13_d, &
913 c%G22_d, c%G23_d, c%G33_d, &
914 c%drdx_d, c%drdy_d, c%drdz_d, &
915 c%dsdx_d, c%dsdy_d, c%dsdz_d, &
916 c%dtdx_d, c%dtdy_d, c%dtdz_d, &
917 c%jacinv_d, c%Xh%w3_d, c%msh%nelv, &
921 if (.not. c%coef_metrics_initialized)
then
922 call device_memcpy(c%G11, c%G11_d, ntot, device_to_host, &
924 call device_memcpy(c%G22, c%G22_d, ntot, device_to_host, &
926 call device_memcpy(c%G33, c%G33_d, ntot, device_to_host, &
928 call device_memcpy(c%G12, c%G12_d, ntot, device_to_host, &
930 call device_memcpy(c%G13, c%G13_d, ntot, device_to_host, &
932 call device_memcpy(c%G23, c%G23_d, ntot, device_to_host, &
937 if (c%msh%gdim .eq. 2)
then
940 c%G11(i, 1, 1, 1) = c%drdx(i, 1, 1, 1) * c%drdx(i, 1, 1, 1) &
941 + c%drdy(i, 1, 1, 1) * c%drdy(i, 1, 1, 1)
943 c%G22(i, 1, 1, 1) = c%dsdx(i, 1, 1, 1) * c%dsdx(i, 1, 1, 1) &
944 + c%dsdy(i, 1, 1, 1) * c%dsdy(i, 1, 1, 1)
946 c%G12(i, 1, 1, 1) = c%drdx(i, 1, 1, 1) * c%dsdx(i, 1, 1, 1) &
947 + c%drdy(i, 1, 1, 1) * c%dsdy(i, 1, 1, 1)
951 c%G11(i, 1, 1, 1) = c%G11(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
952 c%G22(i, 1, 1, 1) = c%G22(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
953 c%G12(i, 1, 1, 1) = c%G12(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
954 c%G33(i, 1, 1, 1) = 0.0_rp
955 c%G13(i, 1, 1, 1) = 0.0_rp
956 c%G23(i, 1, 1, 1) = 0.0_rp
959 do concurrent(e = 1:c%msh%nelv)
960 do concurrent(i = 1:lxyz)
961 c%G11(i,1,1,e) = c%G11(i,1,1,e) * c%Xh%w3(i,1,1)
962 c%G22(i,1,1,e) = c%G22(i,1,1,e) * c%Xh%w3(i,1,1)
963 c%G12(i,1,1,e) = c%G12(i,1,1,e) * c%Xh%w3(i,1,1)
971 c%G11(i, 1, 1, 1) = c%drdx(i, 1, 1, 1) * c%drdx(i, 1, 1, 1) &
972 + c%drdy(i, 1, 1, 1) * c%drdy(i, 1, 1, 1) &
973 + c%drdz(i, 1, 1, 1) * c%drdz(i, 1, 1, 1)
975 c%G22(i, 1, 1, 1) = c%dsdx(i, 1, 1, 1) * c%dsdx(i, 1, 1, 1) &
976 + c%dsdy(i, 1, 1, 1) * c%dsdy(i, 1, 1, 1) &
977 + c%dsdz(i, 1, 1, 1) * c%dsdz(i, 1, 1, 1)
979 c%G33(i, 1, 1, 1) = c%dtdx(i, 1, 1, 1) * c%dtdx(i, 1, 1, 1) &
980 + c%dtdy(i, 1, 1, 1) * c%dtdy(i, 1, 1, 1) &
981 + c%dtdz(i, 1, 1, 1) * c%dtdz(i, 1, 1, 1)
986 c%G11(i, 1, 1, 1) = c%G11(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
987 c%G22(i, 1, 1, 1) = c%G22(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
988 c%G33(i, 1, 1, 1) = c%G33(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
993 c%G12(i, 1, 1, 1) = c%drdx(i, 1, 1, 1) * c%dsdx(i, 1, 1, 1) &
994 + c%drdy(i, 1, 1, 1) * c%dsdy(i, 1, 1, 1) &
995 + c%drdz(i, 1, 1, 1) * c%dsdz(i, 1, 1, 1)
997 c%G13(i, 1, 1, 1) = c%drdx(i, 1, 1, 1) * c%dtdx(i, 1, 1, 1) &
998 + c%drdy(i, 1, 1, 1) * c%dtdy(i, 1, 1, 1) &
999 + c%drdz(i, 1, 1, 1) * c%dtdz(i, 1, 1, 1)
1001 c%G23(i, 1, 1, 1) = c%dsdx(i, 1, 1, 1) * c%dtdx(i, 1, 1, 1) &
1002 + c%dsdy(i, 1, 1, 1) * c%dtdy(i, 1, 1, 1) &
1003 + c%dsdz(i, 1, 1, 1) * c%dtdz(i, 1, 1, 1)
1008 c%G12(i, 1, 1, 1) = c%G12(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
1009 c%G13(i, 1, 1, 1) = c%G13(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
1010 c%G23(i, 1, 1, 1) = c%G23(i, 1, 1, 1) * c%jacinv(i, 1, 1, 1)
1014 do e = 1, c%msh%nelv
1015 do concurrent(i = 1:lxyz)
1016 c%G11(i,1,1,e) = c%G11(i,1,1,e) * c%Xh%w3(i,1,1)
1017 c%G22(i,1,1,e) = c%G22(i,1,1,e) * c%Xh%w3(i,1,1)
1018 c%G12(i,1,1,e) = c%G12(i,1,1,e) * c%Xh%w3(i,1,1)
1020 c%G33(i,1,1,e) = c%G33(i,1,1,e) * c%Xh%w3(i,1,1)
1021 c%G13(i,1,1,e) = c%G13(i,1,1,e) * c%Xh%w3(i,1,1)
1022 c%G23(i,1,1,e) = c%G23(i,1,1,e) * c%Xh%w3(i,1,1)
1035 type(
coef_t),
intent(inout) :: c
1036 integer :: e, m, i, lxyz, m_max
1037 integer,
allocatable :: c_inds_rev(:)
1038 real(kind=rp) :: ctol = 1.0e-7_rp
1039 real(kind=rp) :: diff = 0.0_rp
1042 allocate(c%compression_inds(c%msh%nelv))
1043 allocate(c_inds_rev(c%msh%nelv))
1048 c%compression_inds(1) = 1
1053 lxyz = c%Xh%lx * c%Xh%ly * c%Xh%lz
1054 do e = 2, c%msh%nelv
1061 diff = diff + abs(c%G11(i,1,1,e) - c%G11(i,1,1,c_inds_rev(m))) &
1062 + 2.0*abs(c%G12(i,1,1,e) - c%G12(i,1,1,c_inds_rev(m))) &
1063 + 2.0*abs(c%G13(i,1,1,e) - c%G13(i,1,1,c_inds_rev(m))) &
1064 + abs(c%G22(i,1,1,e) - c%G22(i,1,1,c_inds_rev(m))) &
1065 + 2.0*abs(c%G23(i,1,1,e) - c%G23(i,1,1,c_inds_rev(m))) &
1066 + abs(c%G33(i,1,1,e) - c%G33(i,1,1,c_inds_rev(m)))
1070 if ( diff .le. ctol )
then
1071 c%compression_inds(e) = m
1077 if ( diff .gt. ctol )
then
1079 c%compression_inds(e) = m_max
1080 c_inds_rev(m_max) = e
1085 write(*,*)
'------Mapping Compression-----'
1086 write(*,*)
'Compressed from ', c%msh%nelv,
' to ', m_max
1089 allocate(c%G11_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1090 allocate(c%G22_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1091 allocate(c%G33_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1092 allocate(c%G12_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1093 allocate(c%G13_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1094 allocate(c%G23_compressed(c%Xh%lx, c%Xh%ly, c%Xh%lz, m_max))
1097 c%G11_compressed(i,1,1,m) = c%G11(i,1,1,c_inds_rev(m))
1098 c%G22_compressed(i,1,1,m) = c%G22(i,1,1,c_inds_rev(m))
1099 c%G33_compressed(i,1,1,m) = c%G33(i,1,1,c_inds_rev(m))
1100 c%G12_compressed(i,1,1,m) = c%G12(i,1,1,c_inds_rev(m))
1101 c%G13_compressed(i,1,1,m) = c%G13(i,1,1,c_inds_rev(m))
1102 c%G23_compressed(i,1,1,m) = c%G23(i,1,1,c_inds_rev(m))
1106 deallocate(c_inds_rev)
1197 type(
coef_t),
intent(inout) :: coef
1198 real(kind=rp),
allocatable :: a(:,:,:,:)
1199 real(kind=rp),
allocatable :: b(:,:,:,:)
1200 real(kind=rp),
allocatable :: c(:,:,:,:)
1201 real(kind=rp),
allocatable :: dot(:,:,:,:)
1202 integer :: n, m, e, i, j, k, lx
1203 real(kind=rp) :: weight, len
1207 if (neko_bcknd_device .eq. 1)
then
1209 call device_coef_generate_area_and_normal( &
1210 coef%area_d, coef%nx_d, coef%ny_d, coef%nz_d, &
1211 coef%dxdr_d, coef%dydr_d, coef%dzdr_d, &
1212 coef%dxds_d, coef%dyds_d, coef%dzds_d, &
1213 coef%dxdt_d, coef%dydt_d, coef%dzdt_d, &
1214 coef%Xh%wx_d, coef%Xh%wy_d, coef%Xh%wz_d, &
1215 lx, coef%msh%nelv, neko_eps)
1219 call device_memcpy(coef%area, coef%area_d, m, &
1220 device_to_host, sync = .false.)
1221 call device_memcpy(coef%nx, coef%nx_d, m, &
1222 device_to_host, sync = .false.)
1223 call device_memcpy(coef%ny, coef%ny_d, m, &
1224 device_to_host, sync = .false.)
1225 call device_memcpy(coef%nz, coef%nz_d, &
1226 m, device_to_host, sync = .true.)
1230 allocate(a(coef%Xh%lx, coef%Xh%lx, coef%Xh%lx, coef%msh%nelv))
1231 allocate(b(coef%Xh%lx, coef%Xh%lx, coef%Xh%lx, coef%msh%nelv))
1232 allocate(c(coef%Xh%lx, coef%Xh%lx, coef%Xh%lx, coef%msh%nelv))
1233 allocate(dot(coef%Xh%lx, coef%Xh%lx, coef%Xh%lx, coef%msh%nelv))
1240 a(i, 1, 1, 1) = coef%dyds(i, 1, 1, 1) * coef%dzdt(i, 1, 1, 1) &
1241 - coef%dzds(i, 1, 1, 1) * coef%dydt(i, 1, 1, 1)
1243 b(i, 1, 1, 1) = coef%dzds(i, 1, 1, 1) * coef%dxdt(i, 1, 1, 1) &
1244 - coef%dxds(i, 1, 1, 1) * coef%dzdt(i, 1, 1, 1)
1246 c(i, 1, 1, 1) = coef%dxds(i, 1, 1, 1) * coef%dydt(i, 1, 1, 1) &
1247 - coef%dyds(i, 1, 1, 1) * coef%dxdt(i, 1, 1, 1)
1252 dot(i, 1, 1, 1) = a(i, 1, 1, 1) * a(i, 1, 1, 1) &
1253 + b(i, 1, 1, 1) * b(i, 1, 1, 1) &
1254 + c(i, 1, 1, 1) * c(i, 1, 1, 1)
1258 do e = 1, coef%msh%nelv
1259 do concurrent(k = 1:coef%Xh%lx)
1260 do concurrent(j = 1:coef%Xh%lx)
1261 weight = coef%Xh%wy(j) * coef%Xh%wz(k)
1262 coef%area(j, k, 2, e) = sqrt(dot(lx, j, k, e)) * weight
1263 coef%area(j, k, 1, e) = sqrt(dot(1, j, k, e)) * weight
1264 coef%nx(j,k, 1, e) = -a(1, j, k, e)
1265 coef%nx(j,k, 2, e) = a(lx, j, k, e)
1266 coef%ny(j,k, 1, e) = -b(1, j, k, e)
1267 coef%ny(j,k, 2, e) = b(lx, j, k, e)
1268 coef%nz(j,k, 1, e) = -c(1, j, k, e)
1269 coef%nz(j,k, 2, e) = c(lx, j, k, e)
1278 a(i, 1, 1, 1) = coef%dydr(i, 1, 1, 1) * coef%dzdt(i, 1, 1, 1) &
1279 - coef%dzdr(i, 1, 1, 1) * coef%dydt(i, 1, 1, 1)
1281 b(i, 1, 1, 1) = coef%dzdr(i, 1, 1, 1) * coef%dxdt(i, 1, 1, 1) &
1282 - coef%dxdr(i, 1, 1, 1) * coef%dzdt(i, 1, 1, 1)
1284 c(i, 1, 1, 1) = coef%dxdr(i, 1, 1, 1) * coef%dydt(i, 1, 1, 1) &
1285 - coef%dydr(i, 1, 1, 1) * coef%dxdt(i, 1, 1, 1)
1290 dot(i, 1, 1, 1) = a(i, 1, 1, 1) * a(i, 1, 1, 1) &
1291 + b(i, 1, 1, 1) * b(i, 1, 1, 1) &
1292 + c(i, 1, 1, 1) * c(i, 1, 1, 1)
1296 do e = 1, coef%msh%nelv
1297 do concurrent(k = 1:coef%Xh%lx)
1298 do concurrent(j = 1:coef%Xh%lx)
1299 weight = coef%Xh%wx(j) * coef%Xh%wz(k)
1300 coef%area(j, k, 3, e) = sqrt(dot(j, 1, k, e)) * weight
1301 coef%area(j, k, 4, e) = sqrt(dot(j, lx, k, e)) * weight
1302 coef%nx(j,k, 3, e) = a(j, 1, k, e)
1303 coef%nx(j,k, 4, e) = -a(j, lx, k, e)
1304 coef%ny(j,k, 3, e) = b(j, 1, k, e)
1305 coef%ny(j,k, 4, e) = -b(j, lx, k, e)
1306 coef%nz(j,k, 3, e) = c(j, 1, k, e)
1307 coef%nz(j,k, 4, e) = -c(j, lx, k, e)
1315 a(i, 1, 1, 1) = coef%dydr(i, 1, 1, 1) * coef%dzds(i, 1, 1, 1) &
1316 - coef%dzdr(i, 1, 1, 1) * coef%dyds(i, 1, 1, 1)
1318 b(i, 1, 1, 1) = coef%dzdr(i, 1, 1, 1) * coef%dxds(i, 1, 1, 1) &
1319 - coef%dxdr(i, 1, 1, 1) * coef%dzds(i, 1, 1, 1)
1321 c(i, 1, 1, 1) = coef%dxdr(i, 1, 1, 1) * coef%dyds(i, 1, 1, 1) &
1322 - coef%dydr(i, 1, 1, 1) * coef%dxds(i, 1, 1, 1)
1327 dot(i, 1, 1, 1) = a(i, 1, 1, 1) * a(i, 1, 1, 1) &
1328 + b(i, 1, 1, 1) * b(i, 1, 1, 1) &
1329 + c(i, 1, 1, 1) * c(i, 1, 1, 1)
1333 do e = 1, coef%msh%nelv
1334 do concurrent(k = 1:coef%Xh%lx)
1335 do concurrent(j = 1:coef%Xh%lx)
1336 weight = coef%Xh%wx(j) * coef%Xh%wy(k)
1337 coef%area(j, k, 5, e) = sqrt(dot(j, k, 1, e)) * weight
1338 coef%area(j, k, 6, e) = sqrt(dot(j, k, lx, e)) * weight
1339 coef%nx(j,k, 5, e) = -a(j, k, 1, e)
1340 coef%nx(j,k, 6, e) = a(j, k, lx, e)
1341 coef%ny(j,k, 5, e) = -b(j, k, 1, e)
1342 coef%ny(j,k, 6, e) = b(j, k, lx, e)
1343 coef%nz(j,k, 5, e) = -c(j, k, 1, e)
1344 coef%nz(j,k, 6, e) = c(j, k, lx, e)
1351 do j = 1,
size(coef%nz)
1352 len = sqrt(coef%nx(j,1,1,1)**2 + &
1353 coef%ny(j,1,1,1)**2 + coef%nz(j,1,1,1)**2)
1354 if (len .gt. neko_eps)
then
1355 coef%nx(j,1,1,1) = coef%nx(j,1,1,1) / len
1356 coef%ny(j,1,1,1) = coef%ny(j,1,1,1) / len
1357 coef%nz(j,1,1,1) = coef%nz(j,1,1,1) / len