49 use,
intrinsic :: iso_c_binding
53 use mpi_f08,
only : mpi_allreduce, mpi_integer, mpi_sum, mpi_exscan
59 integer :: nelv_2d = 0
60 integer :: glb_nelv_2d = 0
61 integer :: offset_el_2d = 0
64 integer,
allocatable :: idx_2d(:)
65 integer,
allocatable :: el_idx_2d(:)
69 type(
coef_t),
pointer :: coef => null()
75 real(kind=
rp) :: domain_height
80 generic :: init => init_int, init_char
83 generic :: average => average_list, average_file
89 class(
map_2d_t),
intent(inout) :: this
90 type(
coef_t),
intent(inout),
target :: coef
91 integer,
intent(in) :: dir
92 real(kind=
rp),
intent(in) :: tol
93 real(kind=
rp) :: el_dim(3,3), el_h
94 integer :: i, e, j, ierr, k, lx, lxy, n
95 call this%map_1d%init(coef,dir,tol)
100 call this%u%init(this%dof)
101 call this%old_u%init(this%dof)
102 call this%avg_u%init(this%dof)
103 call this%el_heights%init(this%dof)
108 lxy = this%dof%Xh%lxy
110 do i = 1, this%msh%nelv
111 if (this%map_1d%el_lvl(i) .eq. 1)
then
112 this%nelv_2d = this%nelv_2d + 1
116 call mpi_allreduce(this%nelv_2d, this%glb_nelv_2d, 1, &
119 this%offset_el_2d = 0
120 call mpi_exscan(this%nelv_2d, this%offset_el_2d, 1, &
122 allocate(this%el_idx_2d(this%nelv_2d))
123 do i = 1, this%nelv_2d
124 this%el_idx_2d(i) = this%offset_el_2d + i
126 this%n_2d = this%nelv_2d*lxy
127 allocate(this%idx_2d(this%n_2d))
130 do e = 1, this%msh%nelv
131 if (this%map_1d%el_lvl(e) .eq. 1)
then
132 if (this%map_1d%dir_el(e) .eq. 1)
then
137 if (this%map_1d%dir_el(e) .eq. 2)
then
140 this%idx_2d(j * lxy + k + lx * (i - 1)) = &
145 if (this%map_1d%dir_el(e) .eq. 3)
then
153 do i = 1, this%msh%nelv
158 el_dim(1,:) = abs(this%msh%elements(i)%e%pts(1)%p%x-&
159 this%msh%elements(i)%e%pts(2)%p%x)
160 el_dim(2,:) = abs(this%msh%elements(i)%e%pts(1)%p%x-&
161 this%msh%elements(i)%e%pts(3)%p%x)
162 el_dim(3,:) = abs(this%msh%elements(i)%e%pts(1)%p%x-&
163 this%msh%elements(i)%e%pts(5)%p%x)
165 el_h = el_dim(this%map_1d%dir_el(i),dir)
166 this%el_heights%x(:,:,:,i) = el_h
171 call copy(this%u%x,this%el_heights%x,n)
172 call copy(this%old_u%x,this%el_heights%x,n)
173 call copy(this%avg_u%x,this%el_heights%x,n)
175 this%map_1d%n_el_lvls, &
176 this%map_1d%dir_el,this%coef%gs_h, this%coef%mult, this%msh%nelv, lx)
177 this%domain_height = this%u%x(1,1,1,1)
183 type(
coef_t),
intent(inout),
target :: coef
184 character(len=*),
intent(in) :: dir
185 real(kind=
rp),
intent(in) :: tol
188 if (trim(dir) .eq.
'x')
then
190 else if (trim(dir) .eq.
'y')
then
192 else if (trim(dir) .eq.
'z')
then
195 call neko_error(
'Direction not supported, map_2d')
198 call this%init(coef,idir,tol)
203 class(
map_2d_t),
intent(inout) :: this
205 if (
allocated(this%idx_2d))
then
206 deallocate(this%idx_2d)
209 if (
allocated(this%el_idx_2d))
then
210 deallocate(this%el_idx_2d)
214 call this%old_u%free()
215 call this%avg_u%free()
216 call this%el_heights%free()
217 call this%map_1d%free()
230 class(
map_2d_t),
intent(inout) :: this
233 real(kind=
rp),
pointer,
contiguous,
dimension(:,:,:,:) :: x_ptr, y_ptr
237 integer :: i, j, lx, lxy
239 call fld_data2d%init(this%nelv_2d, this%offset_el_2d)
241 fld_data2d%lx = this%dof%Xh%lx
242 fld_data2d%ly = this%dof%Xh%ly
245 fld_data2d%glb_nelv = this%glb_nelv_2d
246 lxy = fld_data2d%lx*fld_data2d%ly
247 n_2d = lxy*this%nelv_2d
249 call fld_data2d%x%init(n_2d)
250 call fld_data2d%y%init(n_2d)
251 allocate(fld_data2d%idx(this%nelv_2d))
253 if (this%dir .eq. 1)
then
254 x_ptr => this%dof%z%x
255 y_ptr => this%dof%y%x
257 if (this%dir .eq. 2)
then
258 x_ptr => this%dof%x%x
259 y_ptr => this%dof%z%x
261 if (this%dir .eq. 3)
then
262 x_ptr => this%dof%x%x
263 y_ptr => this%dof%y%x
265 do j = 1, this%nelv_2d
266 fld_data2d%idx(j) = this%el_idx_2d(j)
269 fld_data2d%x%x(j) = x_ptr(this%idx_2d(j),1,1,1)
270 fld_data2d%y%x(j) = y_ptr(this%idx_2d(j),1,1,1)
272 allocate(fields2d(fld_data3d%size()))
274 call fld_data2d%init_n_fields(fld_data3d%size(), n_2d)
278 do i = 1, fld_data3d%size()
279 call copy(this%old_u%x, fld_data3d%items(i)%ptr%x, n)
281 this%el_heights, this%domain_height, &
282 this%map_1d%dir_el, this%coef, this%msh%nelv, lx)
283 call copy(this%old_u%x, this%u%x, n)
284 call copy(this%avg_u%x, this%u%x, n)
286 this%old_u, this%map_1d%n_el_lvls, &
287 this%map_1d%dir_el,this%coef%gs_h, this%coef%mult, &
289 call copy(fld_data3d%items(i)%ptr%x, this%u%x, n)
291 call fld_data2d%get_list(fields2d, fld_data2d%size())
292 do i = 1, fld_data3d%size()
294 fields2d(i)%ptr%x(j) = fld_data3d%items(i)%ptr%x(this%idx_2d(j),1,1,1)
306 class(
map_2d_t),
intent(inout) :: this
309 real(kind=
rp),
pointer,
dimension(:,:,:,:) :: x_ptr, y_ptr
311 type(
vector_ptr_t),
allocatable :: fields3d(:), fields2d(:)
313 integer :: i, j, lx, lxy
315 call fld_data2d%init(this%nelv_2d, this%offset_el_2d)
317 fld_data2d%lx = this%dof%Xh%lx
318 fld_data2d%ly = this%dof%Xh%ly
321 fld_data2d%glb_nelv = this%glb_nelv_2d
322 lxy = fld_data2d%lx*fld_data2d%ly
323 n_2d = lxy*this%nelv_2d
325 call fld_data2d%x%init(n_2d)
326 call fld_data2d%y%init(n_2d)
327 allocate(fld_data2d%idx(n_2d))
329 if (this%dir .eq. 1)
then
330 x_ptr => this%dof%z%x
331 y_ptr => this%dof%y%x
333 if (this%dir .eq. 2)
then
334 x_ptr => this%dof%x%x
335 y_ptr => this%dof%z%x
337 if (this%dir .eq. 3)
then
338 x_ptr => this%dof%x%x
339 y_ptr => this%dof%y%x
342 fld_data2d%idx(j) = this%idx_2d(j)
343 fld_data2d%x%x(j) = x_ptr(this%idx_2d(j),1,1,1)
344 fld_data2d%y%x(j) = y_ptr(this%idx_2d(j),1,1,1)
346 allocate(fields3d(fld_data3d%size()))
347 allocate(fields2d(fld_data3d%size()))
349 call fld_data2d%init_n_fields(fld_data3d%size(), n_2d)
350 call fld_data3d%get_list(fields3d,fld_data3d%size())
355 do i = 1, fld_data3d%size()
356 call copy(this%old_u%x, fields3d(i)%ptr%x, n)
358 this%el_heights, this%domain_height, &
359 this%map_1d%dir_el, this%coef, this%msh%nelv, lx)
360 call copy(this%old_u%x, this%u%x,n)
361 call copy(this%avg_u%x, this%u%x,n)
363 this%old_u, this%map_1d%n_el_lvls, &
364 this%map_1d%dir_el, this%coef%gs_h,&
365 this%coef%mult, this%msh%nelv, lx)
366 call copy(fields3d(i)%ptr%x, this%u%x, n)
368 call fld_data2d%get_list(fields2d, fld_data2d%size())
369 do i = 1, fld_data3d%size()
371 fields2d(i)%ptr%x(j) = fields3d(i)%ptr%x(this%idx_2d(j))
377 hom_dir_el, gs_h, mult, nelv, lx)
378 type(
field_t),
intent(inout) :: u, avg_u, old_u
379 type(
gs_t),
intent(inout) :: gs_h
380 integer,
intent(in) :: n_levels, nelv, lx
381 integer,
intent(in) :: hom_dir_el(nelv)
382 real(kind=
rp),
intent(in) :: mult(nelv*lx**3)
383 real(kind=
rp) :: temp_el(lx,lx,lx)
384 integer :: n, i, j, e
393 call gs_h%op(u,gs_op_add)
396 call col2(u%x,mult,n)
399 temp_el = 2.0*u%x(:,:,:,e)-old_u%x(:,:,:,e)
400 if (hom_dir_el(e) .eq. 1)
then
401 u%x(1,:,:,e) = temp_el(lx,:,:)
402 avg_u%x(1,:,:,e) = avg_u%x(1,:,:,e)+temp_el(1,:,:)
403 u%x(lx,:,:,e) = temp_el(1,:,:)
404 else if (hom_dir_el(e) .eq. 2)
then
405 u%x(:,1,:,e) = temp_el(:,lx,:)
406 avg_u%x(:,1,:,e) = avg_u%x(:,1,:,e)+temp_el(:,1,:)
407 u%x(:,lx,:,e) = temp_el(:,1,:)
408 else if (hom_dir_el(e) .eq. 3)
then
409 u%x(:,:,1,e) = temp_el(:,:,lx)
410 avg_u%x(:,:,1,e) = avg_u%x(:,:,1,e)+temp_el(:,:,1)
411 u%x(:,:,lx,e) = temp_el(:,:,1)
413 old_u%x(:,:,:,e) = u%x(:,:,:,e)
419 if (hom_dir_el(e) .eq. 1)
then
420 u%x(:,i,j,e) = avg_u%x(1,i,j,e)
421 else if (hom_dir_el(e) .eq. 2)
then
422 u%x(i,:,j,e) = avg_u%x(i,1,j,e)
423 else if (hom_dir_el(e) .eq. 3)
then
424 u%x(i,j,:,e) = avg_u%x(i,j,1,e)
432 hom_dir_el, coef, nelv, lx)
433 type(
field_t),
intent(inout) :: u, u_out, el_heights
434 type(
coef_t),
intent(inout) :: coef
435 integer,
intent(in) :: nelv, lx
436 integer,
intent(in) :: hom_dir_el(nelv)
437 real(kind=
rp),
intent(in) :: domain_height
439 integer :: n, i, j, e, k
443 call col2(u%x,el_heights%x,n)
444 call cmult(u%x, 1.0_rp/(2.0*domain_height),n)
445 call rzero(u_out%x,n)
453 if (hom_dir_el(e) .eq. 1)
then
454 u_out%x(1,i,j,e) = u_out%x(1,i,j,e)+wt*u%x(k,i,j,e)
455 else if (hom_dir_el(e) .eq. 2)
then
456 u_out%x(i,1,j,e) = u_out%x(i,1,j,e)+wt*u%x(i,k,j,e)
457 else if (hom_dir_el(e) .eq. 3)
then
458 u_out%x(i,j,1,e) = u_out%x(i,j,1,e)+wt*u%x(i,j,k,e)
468 if (hom_dir_el(e) .eq. 1)
then
469 u_out%x(:,i,j,e) = u_out%x(1,i,j,e)
470 else if (hom_dir_el(e) .eq. 2)
then
471 u_out%x(i,:,j,e) = u_out%x(i,1,j,e)
472 else if (hom_dir_el(e) .eq. 3)
then
473 u_out%x(i,j,:,e) = u_out%x(i,j,1,e)
Copy data between host and device (or device and device)
type(mpi_comm), public neko_comm
MPI communicator.
Device abstraction, common interface for various accelerators.
integer, parameter, public host_to_device
integer, parameter, public device_to_host
Defines a mapping of the degrees of freedom.
Simple module to handle fld file series. Provides an interface to the different fields sotred in a fl...
Creates a 1d GLL point map along a specified direction based on the connectivity in the mesh.
Maps a 3D dofmap to a 2D spectral element grid.
subroutine map_2d_free(this)
subroutine perform_local_summation(u_out, u, el_heights, domain_height, hom_dir_el, coef, nelv, lx)
subroutine perform_global_summation(u, avg_u, old_u, n_levels, hom_dir_el, gs_h, mult, nelv, lx)
subroutine map_2d_init(this, coef, dir, tol)
subroutine map_2d_init_char(this, coef, dir, tol)
subroutine map_2d_average_field_list(this, fld_data2d, fld_data3d)
Computes average if field list in one direction and outputs 2D field with averaged values.
subroutine map_2d_average(this, fld_data2d, fld_data3d)
Computes average if field list in one direction and outputs 2D field with averaged values.
subroutine, public cmult(a, c, n)
Multiplication by constant c .
subroutine, public col2(a, b, n)
Vector multiplication .
subroutine, public copy(a, b, n)
Copy a vector .
subroutine, public rzero(a, n)
Zero a real vector.
integer, parameter neko_bcknd_device
integer, parameter, public rp
Global precision used in computations.
pure integer function, public linear_index(i, j, k, l, lx, ly, lz)
Compute the address of a (i,j,k,l) array with sizes (1:lx, 1:ly, 1:lz, :)
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
field_list_t, To be able to group fields together
Map every GLL point in the mesh to a level in one physical direction. Can be used to average across t...