56 type(
mesh_t),
intent(inout),
target :: msh
58 type(
stack_nh_t),
allocatable :: new_mesh_dist(:)
59 type(
stack_nz_t),
allocatable :: new_zone_dist(:)
60 type(
stack_nc_t),
allocatable :: new_curve_dist(:)
63 type(
nmsh_hex_t),
allocatable :: recv_buf_msh(:)
69 integer,
allocatable :: recv_buf_idx(:), send_buf_idx(:)
70 type(mpi_status) :: status
71 integer :: i, j, k, ierr, max_recv_idx, label
72 integer :: src, dst, recv_size, gdim, tmp, new_el_idx, new_pel_idx
73 integer :: max_recv(3)
82 call msh%reset_periodic_ids()
88 allocate(new_zone_dist(0:
pe_size - 1))
90 call new_zone_dist(i)%init()
93 call redist_zone(msh, msh%wall, 1, parts, new_zone_dist)
94 call redist_zone(msh, msh%inlet, 2, parts, new_zone_dist)
95 call redist_zone(msh, msh%outlet, 3, parts, new_zone_dist)
96 call redist_zone(msh, msh%sympln, 4, parts, new_zone_dist)
97 call redist_zone(msh, msh%periodic, 5, parts, new_zone_dist)
101 call redist_zone(msh, msh%labeled_zones(j), 7, parts, &
102 new_zone_dist, label)
108 allocate(new_curve_dist(0:
pe_size - 1))
110 call new_curve_dist(i)%init()
113 call redist_curve(msh, msh%curve, parts, new_curve_dist)
119 allocate(new_mesh_dist(0:(
pe_size - 1)))
121 call new_mesh_dist(i)%init()
125 ep => msh%elements(i)%e
128 el%v(j)%v_idx = ep%pts(j)%p%id()
129 el%v(j)%v_xyz = ep%pts(j)%p%x
131 call new_mesh_dist(parts%data(i))%push(el)
140 max_recv(1) =
max(max_recv(1), new_mesh_dist(i)%size())
141 max_recv(2) =
max(max_recv(2), new_zone_dist(i)%size())
142 max_recv(3) =
max(max_recv(3), new_curve_dist(i)%size())
145 call mpi_allreduce(mpi_in_place, max_recv, 3, mpi_integer, &
147 allocate(recv_buf_msh(max_recv(1)))
148 allocate(recv_buf_zone(max_recv(2)))
149 allocate(recv_buf_curve(max_recv(3)))
158 select type (nmd_array => new_mesh_dist(dst)%data)
160 call mpi_sendrecv(nmd_array, &
161 new_mesh_dist(dst)%size(),
mpi_nmsh_hex, dst, 0, recv_buf_msh, &
164 call mpi_get_count(status,
mpi_nmsh_hex, recv_size, ierr)
167 call new_mesh_dist(
pe_rank)%push(recv_buf_msh(j))
173 select type (nzd_array => new_zone_dist(dst)%data)
175 call mpi_sendrecv(nzd_array, &
176 new_zone_dist(dst)%size(),
mpi_nmsh_zone, dst, 1, recv_buf_zone,&
182 call new_zone_dist(
pe_rank)%push(recv_buf_zone(j))
185 call mpi_sendrecv(new_curve_dist(dst)%array(), &
186 new_curve_dist(dst)%size(),
mpi_nmsh_curve, dst, 2, recv_buf_curve,&
191 call new_curve_dist(
pe_rank)%push(recv_buf_curve(j))
195 deallocate(recv_buf_msh)
196 deallocate(recv_buf_zone)
197 deallocate(recv_buf_curve)
201 call new_mesh_dist(i)%free
202 call new_zone_dist(i)%free
203 call new_curve_dist(i)%free
210 call msh%init(gdim, new_mesh_dist(
pe_rank)%size())
212 call el_map%init(new_mesh_dist(
pe_rank)%size())
213 call glb_map%init(new_mesh_dist(
pe_rank)%size())
218 select type (np => new_mesh_dist(
pe_rank)%data)
220 do i = 1, new_mesh_dist(
pe_rank)%size()
222 p(j) =
point_t(np(i)%v(j)%v_xyz, np(i)%v(j)%v_idx)
224 call msh%add_element(i, &
225 p(1), p(2), p(3), p(4), p(5), p(6), p(7), p(8))
227 if (el_map%get(np(i)%el_idx, tmp) .gt. 0)
then
230 call el_map%set(np(i)%el_idx, tmp)
233 tmp = msh%elements(i)%e%id()
234 call glb_map%set(np(i)%el_idx, tmp)
236 call neko_error(
'Global element id already defined')
240 call new_mesh_dist(
pe_rank)%free()
251 select type(zp => new_zone_dist(
pe_rank)%data)
253 do i = 1, new_zone_dist(
pe_rank)%size()
254 if (zp(i)%type .eq. 5)
then
255 call pe_lst%push(zp(i)%p_e)
260 max_recv_idx = 2 * pe_lst%size()
261 call mpi_allreduce(mpi_in_place, max_recv_idx, 1, mpi_integer, &
263 allocate(recv_buf_idx(max_recv_idx))
264 allocate(send_buf_idx(max_recv_idx))
273 select type (pe_lst_array => pe_lst%data)
275 call mpi_sendrecv(pe_lst_array, &
276 pe_lst%size(), mpi_integer, dst, 0, recv_buf_idx, &
277 max_recv_idx, mpi_integer, src, 0,
neko_comm, status, ierr)
279 call mpi_get_count(status, mpi_integer, recv_size, ierr)
283 if (glb_map%get(recv_buf_idx(j), tmp) .eq. 0)
then
285 send_buf_idx(k) = recv_buf_idx(j)
287 send_buf_idx(k) = tmp
291 call mpi_sendrecv(send_buf_idx, k, mpi_integer, src, 1, &
292 recv_buf_idx, max_recv_idx, mpi_integer, dst, 1, &
294 call mpi_get_count(status, mpi_integer, recv_size, ierr)
296 do j = 1, recv_size, 2
297 call glb_map%set(recv_buf_idx(j), recv_buf_idx(j+1))
300 deallocate(recv_buf_idx)
301 deallocate(send_buf_idx)
307 zp => new_zone_dist(
pe_rank)%array()
308 do i = 1, new_zone_dist(
pe_rank)%size()
309 if (el_map%get(zp(i)%e, new_el_idx) .gt. 0)
then
310 call neko_error(
'Missing element after redistribution')
312 select case(zp(i)%type)
314 call msh%mark_wall_facet(zp(i)%f, new_el_idx)
316 call msh%mark_inlet_facet(zp(i)%f, new_el_idx)
318 call msh%mark_outlet_facet(zp(i)%f, new_el_idx)
320 call msh%mark_sympln_facet(zp(i)%f, new_el_idx)
322 if (glb_map%get(zp(i)%p_e, new_pel_idx) .gt. 0)
then
323 call neko_error(
'Missing periodic element after redistribution')
326 call msh%mark_periodic_facet(zp(i)%f, new_el_idx, &
327 zp(i)%p_f, new_pel_idx, zp(i)%glb_pt_ids)
329 call msh%mark_labeled_facet(zp(i)%f, new_el_idx, zp(i)%p_f)
332 do i = 1, new_zone_dist(
pe_rank)%size()
333 if (el_map%get(zp(i)%e, new_el_idx) .gt. 0)
then
334 call neko_error(
'Missing element after redistribution')
336 select case(zp(i)%type)
338 if (glb_map%get(zp(i)%p_e, new_pel_idx) .gt. 0)
then
339 call neko_error(
'Missing periodic element after redistribution')
342 call msh%apply_periodic_facet(zp(i)%f, new_el_idx, &
343 zp(i)%p_f, new_pel_idx, zp(i)%glb_pt_ids)
347 call new_zone_dist(
pe_rank)%free()
352 cp => new_curve_dist(
pe_rank)%array()
353 do i = 1, new_curve_dist(
pe_rank)%size()
354 if (el_map%get(cp(i)%e, new_el_idx) .gt. 0)
then
355 call neko_error(
'Missing element after redistribution')
357 call msh%mark_curve_element(new_el_idx, cp(i)%curve_data, cp(i)%type)
359 call new_curve_dist(
pe_rank)%free()
367 type(
mesh_t),
intent(inout) :: msh
369 integer,
intent(in) :: type
371 type(
stack_nz_t),
intent(inout),
allocatable :: new_dist(:)
372 integer,
intent(in),
optional :: label
374 integer :: i, j, zone_el, lbl
376 if (
present(label))
then
385 zone_el = zp%facet_el(i)%x(2)
386 nmsh_zone%e = zp%facet_el(i)%x(2) + msh%offset_el
387 nmsh_zone%f = zp%facet_el(i)%x(1)
388 nmsh_zone%p_e = zp%p_facet_el(i)%x(2)
389 nmsh_zone%p_f = zp%p_facet_el(i)%x(1)
390 nmsh_zone%glb_pt_ids = zp%p_ids(i)%x
391 nmsh_zone%type =
type
392 call new_dist(parts%data(zone_el))%push(nmsh_zone)
396 zone_el = zp%facet_el(i)%x(2)
397 nmsh_zone%e = zp%facet_el(i)%x(2) + msh%offset_el
398 nmsh_zone%f = zp%facet_el(i)%x(1)
400 nmsh_zone%type =
type
401 call new_dist(parts%data(zone_el))%push(nmsh_zone)
408 type(
mesh_t),
intent(inout) :: msh
411 type(
stack_nc_t),
intent(inout),
allocatable :: new_dist(:)
413 integer :: i, j, curve_el
416 curve_el = c%curve_el(i)%el_idx
417 nmsh_curve%e = curve_el + msh%offset_el
418 nmsh_curve%curve_data = c%curve_el(i)%curve_data
419 nmsh_curve%type = c%curve_el(i)%curve_type
420 call new_dist(parts%data(curve_el))%push(nmsh_curve)
type(mpi_comm) neko_comm
MPI communicator.
integer pe_size
MPI size of communicator.
Defines a domain as a subset of facets in a mesh.
Defines a zone as a subset of facets in a mesh.
Implements a hash table ADT.
subroutine, public mesh_field_free(fld)
subroutine, public mesh_field_init(fld, msh, fld_name)
integer, parameter, public neko_msh_max_zlbls
Max num. zone labels.
type(mpi_datatype), public mpi_nmsh_hex
MPI derived type for 3D Neko nmsh data.
type(mpi_datatype), public mpi_nmsh_curve
MPI derived type for Neko nmsh curved elements.
type(mpi_datatype), public mpi_nmsh_zone
MPI derived type for Neko nmsh zone data.
subroutine, public redist_mesh(msh, parts)
Redistribute a mesh msh according to new partitions.
subroutine redist_zone(msh, z, type, parts, new_dist, label)
Fill redistribution list for zone data.
subroutine redist_curve(msh, c, parts, new_dist)
Fill redistribution list for zone data.
Implements a dynamic stack ADT.
Base type for an element.
Integer based hash table.
A point in with coordinates .
Neko curve info based stack.
Neko hex element based stack.