82 logical,
allocatable :: dfrmd_el(:)
90 integer,
allocatable :: facet_neigh(:,:)
99 logical,
allocatable :: neigh(:)
100 integer,
allocatable :: neigh_order(:)
102 integer(2),
allocatable :: facet_type(:,:)
108 logical :: lconn = .false.
109 logical :: ldist = .false.
110 logical :: lnumr = .false.
111 logical :: lgenc = .true.
115 procedure(
mesh_deform), pass(msh),
pointer :: apply_deform => null()
145 generic :: init => init_nelv, init_dist
147 generic :: add_element => add_quad, add_hex
150 generic :: get_local => get_local_point, get_local_edge, get_local_facet
153 generic :: get_global => get_global_edge, get_global_facet
155 generic :: is_shared => is_shared_point, is_shared_edge, is_shared_facet
163 integer,
intent(in) :: lx, ly, lz
164 real(kind=
rp),
intent(inout) :: x(lx, ly, lz, msh%nelv)
165 real(kind=
rp),
intent(inout) :: y(lx, ly, lz, msh%nelv)
166 real(kind=
rp),
intent(inout) :: z(lx, ly, lz, msh%nelv)
176 class(
mesh_t),
intent(inout) :: this
177 integer,
intent(in) :: gdim
178 integer,
intent(in) :: nelv
180 character(len=LOG_SIZE) :: log_buf
187 if (this%nelv < 1)
then
188 write(log_buf,
'(A,I0,A)')
'MPI rank ',
pe_rank,
' has zero elements'
192 call mpi_allreduce(this%nelv, this%glb_nelv, 1, &
196 call mpi_exscan(this%nelv, this%offset_el, 1, &
205 class(
mesh_t),
intent(inout) :: this
206 integer,
intent(in) :: gdim
208 character(len=LOG_SIZE) :: log_buf
212 this%nelv = dist%num_local()
213 if (this%nelv < 1)
then
214 write(log_buf,
'(A,I0,A)')
'MPI rank ',
pe_rank,
' has zero elements'
217 this%glb_nelv = dist%num_global()
218 this%offset_el = dist%start_idx()
226 type(
mesh_t),
intent(inout) :: this
232 allocate(this%elements(this%nelv))
233 allocate(this%dfrmd_el(this%nelv))
234 if (this%gdim .eq. 3)
then
236 allocate(
hex_t::this%elements(i)%e)
242 select type (fmp => this%facet_map)
244 call fmp%init(this%nelv, facet_data)
252 else if (this%gdim .eq. 2)
then
254 allocate(
quad_t::this%elements(i)%e)
259 select type (fmp => this%facet_map)
261 call fmp%init(this%nelv, facet_data)
273 allocate(this%points(this%npts*this%nelv))
278 allocate(this%point_neigh(this%gdim*this%npts*this%nelv))
279 do i = 1, this%gdim*this%npts*this%nelv
280 call this%point_neigh(i)%init()
284 allocate(this%facet_type(2 * this%gdim, this%nelv))
287 call this%htp%init(this%npts*this%nelv, i)
288 call this%htel%init(this%nelv, i)
290 call this%periodic%init(this%nelv)
294 call this%labeled_zones(i)%init(this%nelv)
297 call this%curve%init(this%nelv)
301 allocate(this%neigh(0:
pe_size-1))
312 class(
mesh_t),
intent(inout) :: this
318 call this%htel%free()
320 call this%curve%free()
322 if (
allocated(this%dfrmd_el))
then
323 deallocate(this%dfrmd_el)
326 if (
allocated(this%elements))
then
328 call this%elements(i)%e%free()
329 deallocate(this%elements(i)%e)
331 deallocate(this%elements)
334 if (
allocated(this%facet_map))
then
335 select type (fmp => this%facet_map)
341 deallocate(this%facet_map)
344 if (
allocated(this%facet_neigh))
then
345 deallocate(this%facet_neigh)
348 if (
allocated(this%point_neigh))
then
349 do i = 1, this%gdim * this%npts * this%nelv
350 call this%point_neigh(i)%free()
352 deallocate(this%point_neigh)
355 if (
allocated(this%facet_type))
then
356 deallocate(this%facet_type)
358 if (
allocated(this%labeled_zones))
then
360 call this%labeled_zones(i)%free()
362 deallocate(this%labeled_zones)
365 if (
allocated(this%neigh))
then
366 deallocate(this%neigh)
369 if (
allocated(this%neigh_order))
then
370 deallocate(this%neigh_order)
373 if (
allocated(this%points))
then
374 deallocate(this%points)
377 call this%periodic%free()
386 class(
mesh_t),
target,
intent(inout) :: this
392 call this%periodic%finalize()
394 call this%labeled_zones(i)%finalize()
396 call this%curve%finalize()
401 type(
mesh_t),
intent(inout) :: this
402 real(kind=
dp) :: u(3), v(3), w(3), temp
406 if (this%gdim .eq. 2)
then
407 this%dfrmd_el(e) = .false.
408 u = this%elements(e)%e%pts(2)%p%x - this%elements(e)%e%pts(1)%p%x
409 v = this%elements(e)%e%pts(3)%p%x - this%elements(e)%e%pts(1)%p%x
410 temp = u(1)*v(1) + u(2)*v(2)
411 if(.not.
abscmp(temp, 0d0)) this%dfrmd_el(e) = .true.
413 this%dfrmd_el(e) = .false.
414 u = this%elements(e)%e%pts(2)%p%x - this%elements(e)%e%pts(1)%p%x
415 v = this%elements(e)%e%pts(3)%p%x - this%elements(e)%e%pts(1)%p%x
416 w = this%elements(e)%e%pts(5)%p%x - this%elements(e)%e%pts(1)%p%x
417 temp = u(1)*v(1) + u(2)*v(2) + u(3)*v(3)
418 if(.not.
abscmp(temp, 0d0)) this%dfrmd_el(e) = .true.
419 temp = u(1)*w(1) + u(2)*w(2) + u(3)*w(3)
420 if(.not.
abscmp(temp, 0d0)) this%dfrmd_el(e) = .true.
421 u = this%elements(e)%e%pts(7)%p%x - this%elements(e)%e%pts(8)%p%x
422 v = this%elements(e)%e%pts(6)%p%x - this%elements(e)%e%pts(8)%p%x
423 w = this%elements(e)%e%pts(4)%p%x - this%elements(e)%e%pts(8)%p%x
424 temp = u(1)*v(1) + u(2)*v(2) + u(3)*v(3)
425 if(.not.
abscmp(temp, 0d0)) this%dfrmd_el(e) = .true.
426 temp = u(1)*w(1) + u(2)*w(2) + u(3)*w(3)
427 if(.not.
abscmp(temp, 0d0)) this%dfrmd_el(e) = .true.
434 class(
mesh_t),
intent(inout) :: this
435 this%dfrmd_el = .true.
440 class(
mesh_t),
target,
intent(inout) :: this
448 integer :: p_local_idx
450 integer :: i, j, k, ierr, el_glb_idx, n_sides, n_nodes, src, dst
452 if (this%lconn)
return
454 if (.not. this%lgenc)
return
458 ep => this%elements(el)%e
463 call this%add_point(ep%pts(i)%p, id)
464 p_local_idx = this%get_local(this%points(id))
467 call this%point_neigh(p_local_idx)%push(id)
470 call ep%facet_id(f, i)
471 call this%add_face(f)
475 call ep%edge_id(e, i)
476 call this%add_edge(e)
481 call this%add_point(ep%pts(i)%p, id)
482 p_local_idx = this%get_local(this%points(id))
485 call this%point_neigh(p_local_idx)%push(id)
489 call ep%facet_id(e, i)
490 call this%add_edge(e)
496 if (this%gdim .eq. 2)
then
505 call mpi_allreduce(this%max_pts_id, this%glb_mpts, 1, &
515 select type (fmp => this%facet_map)
519 el_glb_idx = i + this%offset_el
521 call this%elements(i)%e%facet_id(edge, j)
524 facet_data%x = [0, 0]
527 if (fmp%get(edge, facet_data) .eq. 0)
then
529 if (facet_data%x(1) .eq. el_glb_idx )
then
530 this%facet_neigh(j, i) = facet_data%x(2)
531 else if( facet_data%x(2) .eq. el_glb_idx)
then
532 this%facet_neigh(j, i) = facet_data%x(1)
534 else if(facet_data%x(1) .gt. el_glb_idx)
then
535 facet_data%x(2) = facet_data%x(1)
536 facet_data%x(1) = el_glb_idx
537 this%facet_neigh(j, i) = facet_data%x(2)
538 call fmp%set(edge, facet_data)
539 else if(facet_data%x(1) .lt. el_glb_idx)
then
540 facet_data%x(2) = el_glb_idx
541 this%facet_neigh(j, i) = facet_data%x(1)
542 call fmp%set(edge, facet_data)
545 facet_data%x(1) = el_glb_idx
546 this%facet_neigh(j, i) = facet_data%x(2)
547 call fmp%set(edge, facet_data)
556 el_glb_idx = i + this%offset_el
558 call this%elements(i)%e%facet_id(face, j)
560 facet_data%x = (/ 0, 0/)
563 if (fmp%get(face, facet_data) .eq. 0)
then
565 if (facet_data%x(1) .eq. el_glb_idx )
then
566 this%facet_neigh(j, i) = facet_data%x(2)
567 call this%elements(i)%e%facet_id(face_comp, &
568 j + (2*mod(j, 2) - 1))
569 if (face_comp .eq. face)
then
570 facet_data%x(2) = el_glb_idx
571 this%facet_neigh(j, i) = facet_data%x(1)
572 call fmp%set(face, facet_data)
574 else if( facet_data%x(2) .eq. el_glb_idx)
then
575 this%facet_neigh(j, i) = facet_data%x(1)
577 else if(facet_data%x(1) .gt. el_glb_idx)
then
578 facet_data%x(2) = facet_data%x(1)
579 facet_data%x(1) = el_glb_idx
580 this%facet_neigh(j, i) = facet_data%x(2)
581 call fmp%set(face, facet_data)
582 else if(facet_data%x(1) .lt. el_glb_idx)
then
583 facet_data%x(2) = el_glb_idx
584 this%facet_neigh(j, i) = facet_data%x(1)
585 call fmp%set(face, facet_data)
588 facet_data%x(1) = el_glb_idx
589 this%facet_neigh(j, i) = 0
590 call fmp%set(face, facet_data)
615 if (this%neigh(src) .or. this%neigh(dst))
then
617 call neigh_order%push(j)
621 allocate(this%neigh_order(neigh_order%size()))
622 select type(order => neigh_order%data)
624 do i = 1, neigh_order%size()
625 this%neigh_order(i) = order(i)
628 call neigh_order%free()
632 allocate(this%neigh_order(1))
641 if (this%gdim .eq. 3)
then
654 type(
mesh_t),
intent(inout) :: this
659 type(mpi_status) :: status
660 type(mpi_request) :: send_req, recv_req
661 integer,
allocatable :: recv_buffer(:)
662 integer :: i, j, k, el_glb_idx, n_sides, n_nodes, facet, element, l
663 integer :: max_recv, ierr, src, dst, n_recv, recv_side, neigh_el
666 if (this%gdim .eq. 2)
then
679 el_glb_idx = i + this%offset_el
682 if (this%facet_neigh(j, i) .eq. 0)
then
683 if (n_nodes .eq. 2)
then
684 call this%elements(i)%e%facet_id(edge, j)
685 call buffer%push(el_glb_idx)
686 call buffer%push(facet)
688 call buffer%push(edge%x(k))
691 call this%elements(i)%e%facet_id(face, j)
692 call buffer%push(el_glb_idx)
693 call buffer%push(facet)
695 call buffer%push(face%x(k))
703 call mpi_allreduce(buffer%size(), max_recv, 1, &
706 allocate(recv_buffer(max_recv))
708 do i = 1,
size(this%neigh_order)
712 if (this%neigh(src))
then
713 call mpi_irecv(recv_buffer, max_recv, mpi_integer, &
717 if (this%neigh(dst))
then
718 call mpi_isend(buffer%array(), buffer%size(), mpi_integer, &
722 if (this%neigh(src))
then
723 call mpi_wait(recv_req, status, ierr)
724 call mpi_get_count(status, mpi_integer, n_recv, ierr)
726 select type (fmp => this%facet_map)
728 do j = 1, n_recv, n_nodes + 2
729 neigh_el = recv_buffer(j)
730 recv_side = recv_buffer(j+1)
732 edge = (/ recv_buffer(j+2), recv_buffer(j+3) /)
734 facet_data = (/ 0, 0 /)
736 if (fmp%get(edge, facet_data) .eq. 0)
then
737 element = facet_data%x(1) - this%offset_el
740 call this%elements(
element)%e%facet_id(edge2, l)
741 if(edge2 .eq. edge)
then
746 this%facet_neigh(facet,
element) = -neigh_el
747 facet_data%x(2) = -neigh_el
750 call fmp%set(edge, facet_data)
754 if (this%hte%get(edge, facet) .eq. 0)
then
764 do j = 1, n_recv, n_nodes + 2
765 neigh_el = recv_buffer(j)
766 recv_side = recv_buffer(j+1)
768 face%x = (/ recv_buffer(j+2), recv_buffer(j+3), &
769 recv_buffer(j+4), recv_buffer(j+5) /)
772 facet_data%x = (/ 0, 0 /)
775 if (fmp%get(face, facet_data) .eq. 0)
then
777 element = facet_data%x(1) - this%offset_el
779 call this%elements(
element)%e%facet_id(face2, l)
780 if(face2 .eq. face)
then
785 this%facet_neigh(facet,
element) = -neigh_el
786 facet_data%x(2) = -neigh_el
789 call fmp%set(face, facet_data)
793 if (this%htf%get(face, facet) .eq. 0)
then
806 if (this%neigh(dst))
then
807 call mpi_wait(send_req, mpi_status_ignore, ierr)
813 deallocate(recv_buffer)
821 type(
mesh_t),
intent(inout) :: this
823 type(mpi_status) :: status
824 integer,
allocatable :: recv_buffer(:)
826 integer :: max_recv, ierr, src, dst, n_recv, neigh_el
827 integer :: pt_glb_idx, pt_loc_idx, num_neigh
828 integer,
contiguous,
pointer :: neighs(:)
831 call send_buffer%init(this%mpts * 2)
836 pt_glb_idx = this%points(i)%id()
837 num_neigh = this%point_neigh(i)%size()
838 call send_buffer%push(pt_glb_idx)
839 call send_buffer%push(num_neigh)
841 neighs => this%point_neigh(i)%array()
842 do j = 1, this%point_neigh(i)%size()
843 call send_buffer%push(neighs(j))
847 call mpi_allreduce(send_buffer%size(), max_recv, 1, &
849 allocate(recv_buffer(max_recv))
855 call mpi_sendrecv(send_buffer%array(), send_buffer%size(), &
856 mpi_integer, dst, 0, recv_buffer, max_recv, mpi_integer, src, 0, &
859 call mpi_get_count(status, mpi_integer, n_recv, ierr)
862 do while (j .le. n_recv)
863 pt_glb_idx = recv_buffer(j)
864 num_neigh = recv_buffer(j + 1)
866 pt_loc_idx = this%have_point_glb_idx(pt_glb_idx)
867 if (pt_loc_idx .gt. 0)
then
868 this%neigh(src) = .true.
870 neigh_el = -recv_buffer(j + 1 + k)
871 call this%point_neigh(pt_loc_idx)%push(neigh_el)
875 j = j + (2 + num_neigh)
880 deallocate(recv_buffer)
881 call send_buffer%free()
889 type(
mesh_t),
target,
intent(inout) :: this
892 type(
uset_i8_t),
target :: edge_idx, ghost, owner
895 type(mpi_status) :: status
896 type(mpi_request) :: send_req, recv_req
897 integer,
contiguous,
pointer :: p1(:), p2(:), ns_id(:)
898 integer :: i, j, id, ierr, num_edge_glb, edge_offset, num_edge_loc
899 integer :: k, l , shared_offset, glb_nshared, n_glb_id
900 integer(kind=i8) :: C, glb_max, glb_id
901 integer(kind=i8),
pointer :: glb_ptr
902 integer(kind=i8),
allocatable :: recv_buff(:)
903 logical :: shared_edge
905 integer :: max_recv, src, dst, n_recv
909 allocate(this%ddata%local_to_global_edge(this%meds))
911 call edge_idx%init(this%hte%num_entries())
912 call send_buff%init(this%hte%num_entries())
913 call owner%init(this%hte%num_entries())
915 call glb_to_loc%init(32, i)
923 num_edge_glb = 2* this%meds
924 call mpi_allreduce(mpi_in_place, num_edge_glb, 1, &
927 glb_max = int(num_edge_glb,
i8)
929 call non_shared_edges%init(this%hte%num_entries())
931 call it%init(this%hte)
936 k = this%have_point_glb_idx(edge%x(1))
937 l = this%have_point_glb_idx(edge%x(2))
938 p1 => this%point_neigh(k)%array()
939 p2 => this%point_neigh(l)%array()
941 shared_edge = .false.
944 do i = 1, this%point_neigh(k)%size()
945 do j = 1, this%point_neigh(l)%size()
946 if ((p1(i) .eq. p2(j)) .and. &
947 (p1(i) .lt. 0) .and. (p2(j) .lt. 0))
then
957 if (shared_edge)
then
958 glb_id = ((int(edge%x(1),
i8)) + int(edge%x(2),
i8)*c) + glb_max
959 call glb_to_loc%set(glb_id, id)
960 call edge_idx%add(glb_id)
961 call owner%add(glb_id)
962 call send_buff%push(glb_id)
964 call non_shared_edges%push(id)
970 num_edge_loc = non_shared_edges%size()
971 call mpi_exscan(num_edge_loc, edge_offset, 1, &
973 edge_offset = edge_offset + 1
976 ns_id => non_shared_edges%array()
977 do i = 1, non_shared_edges%size()
979 edge_offset = edge_offset + 1
987 call mpi_allreduce(send_buff%size(), max_recv, 1, &
990 call ghost%init(send_buff%size())
992 allocate(recv_buff(max_recv))
994 do i = 1,
size(this%neigh_order)
998 if (this%neigh(src))
then
999 call mpi_irecv(recv_buff, max_recv, mpi_integer8, &
1003 if (this%neigh(dst))
then
1007 select type(sbarray=>send_buff%data)
1008 type is (
integer(i8))
1009 call mpi_isend(sbarray, send_buff%size(), mpi_integer8, &
1014 if (this%neigh(src))
then
1015 call mpi_wait(recv_req, status, ierr)
1016 call mpi_get_count(status, mpi_integer8, n_recv, ierr)
1019 if ((edge_idx%element(recv_buff(j))) .and. (src .lt.
pe_rank))
then
1020 call ghost%add(recv_buff(j))
1021 call owner%remove(recv_buff(j))
1026 if (this%neigh(dst))
then
1027 call mpi_wait(send_req, mpi_status_ignore, ierr)
1033 glb_nshared = num_edge_loc
1034 call mpi_allreduce(mpi_in_place, glb_nshared, 1, &
1038 call mpi_exscan(owner%size(), shared_offset, 1, &
1040 shared_offset = shared_offset + glb_nshared + 1
1043 call send_buff%clear()
1044 call owner%iter_init()
1045 do while (owner%iter_next())
1046 glb_ptr => owner%iter_value()
1047 if (glb_to_loc%get(glb_ptr, id) .eq. 0)
then
1051 call send_buff%push(glb_ptr)
1052 glb_id = int(shared_offset, i8)
1053 call send_buff%push(glb_id)
1055 shared_offset = shared_offset + 1
1064 this%glb_meds = shared_offset -1
1065 call mpi_allreduce(mpi_in_place, this%glb_meds, 1, &
1072 call mpi_allreduce(send_buff%size(), max_recv, 1, &
1075 deallocate(recv_buff)
1076 allocate(recv_buff(max_recv))
1079 do i = 1,
size(this%neigh_order)
1083 if (this%neigh(src))
then
1084 call mpi_irecv(recv_buff, max_recv, mpi_integer8, &
1088 if (this%neigh(dst))
then
1092 select type(sbarray=>send_buff%data)
1093 type is (
integer(i8))
1094 call mpi_isend(sbarray, send_buff%size(), mpi_integer8, &
1099 if (this%neigh(src))
then
1100 call mpi_wait(recv_req, status, ierr)
1101 call mpi_get_count(status, mpi_integer8, n_recv, ierr)
1104 if (ghost%element(recv_buff(j)))
then
1105 if (glb_to_loc%get(recv_buff(j), id) .eq. 0)
then
1106 n_glb_id = int(recv_buff(j + 1 ), 4)
1116 if (this%neigh(dst))
then
1117 call mpi_wait(send_req, mpi_status_ignore, ierr)
1121 deallocate(recv_buff)
1122 call glb_to_loc%free()
1123 call send_buff%free()
1124 call edge_idx%free()
1125 call non_shared_edges%free()
1133 type(
mesh_t),
target,
intent(inout) :: this
1146 type(mpi_status) :: status
1147 type(mpi_request) :: send_req, recv_req
1148 integer,
allocatable :: recv_buff(:)
1149 integer :: non_shared_facets, shared_facets, facet_offset
1150 integer :: id, glb_nshared, shared_offset, owned_facets
1151 integer :: i, j, ierr, max_recv, src, dst, n_recv
1153 shared_facets = this%ddata%shared_facet%size()
1156 if (this%gdim .eq. 2)
then
1157 allocate(this%ddata%local_to_global_facet(this%meds))
1158 call edge_owner%init(this%meds)
1159 call edge_ghost%init(64, i)
1160 non_shared_facets = this%hte%num_entries() - shared_facets
1162 allocate(this%ddata%local_to_global_facet(this%mfcs))
1163 call face_owner%init(this%mfcs)
1164 call face_ghost%init(64, i)
1165 non_shared_facets = this%htf%num_entries() - shared_facets
1171 call mpi_exscan(non_shared_facets, facet_offset, 1, &
1173 facet_offset = facet_offset + 1
1176 if (this%gdim .eq. 2)
then
1177 call edge_it%init(this%hte)
1178 do while (edge_it%next())
1179 call edge_it%data(id)
1180 edge => edge_it%key()
1181 if (.not. this%ddata%shared_facet%element(id))
then
1184 facet_offset = facet_offset + 1
1186 select type(fmp => this%facet_map)
1188 if (fmp%get(edge, facet_data) .eq. 0)
then
1189 if (facet_data%x(2) .lt. 0)
then
1190 if (abs(facet_data%x(2)) .lt. (this%offset_el + 1))
then
1191 call edge_ghost%set(edge, id)
1193 call edge_owner%push(edge)
1202 owned_facets = edge_owner%size()
1204 call face_it%init(this%htf)
1205 do while (face_it%next())
1206 call face_it%data(id)
1207 face => face_it%key()
1208 if (.not. this%ddata%shared_facet%element(id))
then
1211 facet_offset = facet_offset + 1
1213 select type(fmp => this%facet_map)
1215 if (fmp%get(face, facet_data) .eq. 0)
then
1216 if (facet_data%x(2) .lt. 0)
then
1217 if (abs(facet_data%x(2)) .lt. (this%offset_el + 1))
then
1218 call face_ghost%set(face, id)
1220 call face_owner%push(face)
1229 owned_facets = face_owner%size()
1233 glb_nshared = non_shared_facets
1234 call mpi_allreduce(mpi_in_place, glb_nshared, 1, &
1238 call mpi_exscan(owned_facets, shared_offset, 1, &
1240 shared_offset = shared_offset + glb_nshared + 1
1242 if (this%gdim .eq. 2)
then
1244 if (owned_facets .gt. 32)
then
1245 call send_buff%init(owned_facets)
1247 call send_buff%init()
1250 ed => edge_owner%array()
1251 do i = 1, edge_owner%size()
1252 if (this%hte%get(ed(i), id) .eq. 0)
then
1259 call send_buff%push(ed(i)%x(j))
1261 call send_buff%push(shared_offset)
1263 shared_offset = shared_offset + 1
1269 if (owned_facets .gt. 32)
then
1270 call send_buff%init(owned_facets)
1272 call send_buff%init()
1275 fd => face_owner%array()
1276 do i = 1, face_owner%size()
1277 if (this%htf%get(fd(i), id) .eq. 0)
then
1284 call send_buff%push(fd(i)%x(j))
1286 call send_buff%push(shared_offset)
1288 shared_offset = shared_offset + 1
1297 this%glb_mfcs = shared_offset - 1
1298 call mpi_allreduce(mpi_in_place, this%glb_mfcs, 1, &
1305 call mpi_allreduce(send_buff%size(), max_recv, 1, &
1308 allocate(recv_buff(max_recv))
1311 do i = 1,
size(this%neigh_order)
1315 if (this%neigh(src))
then
1316 call mpi_irecv(recv_buff, max_recv, mpi_integer, &
1320 if (this%neigh(dst))
then
1321 call mpi_isend(send_buff%array(), send_buff%size(), mpi_integer, &
1325 if (this%neigh(src))
then
1326 call mpi_wait(recv_req, status, ierr)
1327 call mpi_get_count(status, mpi_integer, n_recv, ierr)
1329 if (this%gdim .eq. 2)
then
1332 recv_edge = (/recv_buff(j), recv_buff(j+1)/)
1335 if (edge_ghost%get(recv_edge, id) .eq. 0)
then
1343 recv_face = (/recv_buff(j), recv_buff(j+1), &
1344 recv_buff(j+2), recv_buff(j+3) /)
1347 if (face_ghost%get(recv_face, id) .eq. 0)
then
1355 if (this%neigh(dst))
then
1356 call mpi_wait(send_req, mpi_status_ignore, ierr)
1361 if (this%gdim .eq. 2)
then
1362 call edge_owner%free()
1363 call edge_ghost%free()
1365 call face_owner%free()
1366 call face_ghost%free()
1369 call send_buff%free()
1370 deallocate(recv_buff)
1377 class(
mesh_t),
target,
intent(inout) :: this
1378 integer,
value :: el, el_glb
1379 type(
point_t),
target,
intent(inout) :: p1, p2, p3, p4
1384 this%lconn = .false.
1387 this%lnumr = .false.
1389 call this%add_point(p1, p(1))
1390 call this%add_point(p2, p(2))
1391 call this%add_point(p3, p(3))
1392 call this%add_point(p4, p(4))
1394 select type (ep => this%elements(el)%e)
1396 call ep%init(el_glb, &
1397 this%points(p(1)), this%points(p(2)), &
1398 this%points(p(3)), this%points(p(4)))
1408 subroutine mesh_add_hex(this, el, el_glb, p1, p2, p3, p4, p5, p6, p7, p8)
1409 class(
mesh_t),
target,
intent(inout) :: this
1410 integer,
value :: el, el_glb
1411 type(
point_t),
target,
intent(inout) :: p1, p2, p3, p4, p5, p6, p7, p8
1417 this%lconn = .false.
1420 this%lnumr = .false.
1422 call this%add_point(p1, p(1))
1423 call this%add_point(p2, p(2))
1424 call this%add_point(p3, p(3))
1425 call this%add_point(p4, p(4))
1426 call this%add_point(p5, p(5))
1427 call this%add_point(p6, p(6))
1428 call this%add_point(p7, p(7))
1429 call this%add_point(p8, p(8))
1432 call this%htel%set(el_glb, el)
1434 select type (ep => this%elements(el)%e)
1436 call ep%init(el_glb, &
1437 this%points(p(1)), this%points(p(2)), &
1438 this%points(p(3)), this%points(p(4)), &
1439 this%points(p(5)), this%points(p(6)), &
1440 this%points(p(7)), this%points(p(8)))
1408 subroutine mesh_add_hex(this, el, el_glb, p1, p2, p3, p4, p5, p6, p7, p8)
…
1449 class(
mesh_t),
intent(inout) :: this
1450 type(
point_t),
intent(inout) :: p
1451 integer,
intent(inout) :: idx
1456 this%max_pts_id =
max(this%max_pts_id, tmp)
1458 if (tmp .le. 0)
then
1462 if (this%htp%get(tmp, idx) .gt. 0)
then
1463 this%mpts = this%mpts + 1
1464 call this%htp%set(tmp, this%mpts)
1465 this%points(this%mpts) = p
1473 class(
mesh_t),
intent(inout) :: this
1477 if (this%htf%get(f, idx) .gt. 0)
then
1478 this%mfcs = this%mfcs + 1
1479 call this%htf%set(f, this%mfcs)
1486 class(
mesh_t),
intent(inout) :: this
1490 if (this%hte%get(e, idx) .gt. 0)
then
1491 this%meds = this%meds + 1
1492 call this%hte%set(e, this%meds)
1499 class(
mesh_t),
intent(inout) :: this
1500 integer,
intent(in) :: e
1501 real(kind=
dp),
dimension(5,12),
intent(in) :: curve_data
1502 integer,
dimension(12),
intent(in) :: curve_type
1504 if (e .gt. this%nelv)
then
1507 if ((this%gdim .eq. 2 .and. sum(curve_type(5:8)) .gt. 0) )
then
1510 call this%curve%add_element(e, curve_data, curve_type)
1516 class(
mesh_t),
intent(inout) :: this
1517 integer,
intent(in) :: f
1518 integer,
intent(in) :: e
1519 integer,
intent(in) :: label
1521 if (e .gt. this%nelv)
then
1525 if ((this%gdim .eq. 2 .and. f .gt. 4) .or. &
1526 (this%gdim .eq. 3 .and. f .gt. 6))
then
1529 call this%labeled_zones(label)%add_facet(f, e)
1530 this%facet_type(f,e) = -label
1536 class(
mesh_t),
intent(inout) :: this
1537 integer,
intent(in) :: f
1538 integer,
intent(in) :: e
1539 integer,
intent(in) :: pf
1540 integer,
intent(in) :: pe
1541 integer,
intent(inout) :: pids(4)
1542 integer,
dimension(4) :: org_ids
1544 call this%get_facet_ids(f, e, org_ids)
1545 call this%periodic%add_periodic_facet(f, e, pf, pe, pids, org_ids)
1550 class(
mesh_t),
intent(inout) :: this
1551 integer,
intent(in) :: f
1552 integer,
intent(in) :: e
1553 integer,
intent(inout) :: pids(4)
1558 select type(ele => this%elements(e)%e)
1560 call ele%facet_order(t,f)
1563 call ele%facet_order(t2,f)
1573 class(
mesh_t),
intent(inout) :: this
1579 integer :: org_ids(4), pids(4)
1581 integer,
dimension(4, 6) :: face_nodes = reshape([ &
1589 integer,
dimension(2, 4) :: edge_nodes = reshape([ &
1596 do i = 1, this%periodic%size
1597 e = this%periodic%facet_el(i)%x(2)
1598 f = this%periodic%facet_el(i)%x(1)
1599 pe = this%periodic%p_facet_el(i)%x(2)
1600 pf = this%periodic%p_facet_el(i)%x(1)
1601 pids = this%periodic%p_ids(i)%x
1602 call this%get_facet_ids(f, e, pids)
1603 this%periodic%p_ids(i)%x = pids
1605 do i = 1, this%periodic%size
1606 e = this%periodic%facet_el(i)%x(2)
1607 f = this%periodic%facet_el(i)%x(1)
1608 org_ids = this%periodic%org_ids(i)%x
1609 select type(ele => this%elements(e)%e)
1612 pi => ele%pts(face_nodes(j,f))%p
1613 call pi%set_id(org_ids(j))
1617 pi => ele%pts(edge_nodes(j,f))%p
1618 call pi%set_id(org_ids(j))
1626 class(
mesh_t),
intent(inout) :: this
1627 integer,
intent(in) :: f
1628 integer,
intent(in) :: e
1629 integer,
intent(in) :: pf
1630 integer,
intent(in) :: pe
1631 type(
point_t),
pointer :: pi, pj
1632 real(kind=
dp) :: l(3)
1633 integer :: i, j, id, p_local_idx, match
1636 integer,
dimension(4, 6) :: face_nodes = reshape([&
1644 integer,
dimension(2, 4) :: edge_nodes = reshape([&
1651 select type(ele => this%elements(e)%e)
1653 select type(elp => this%elements(pe)%e)
1657 l = l + ele%pts(face_nodes(i,f))%p%x(1:3) - &
1658 elp%pts(face_nodes(i,pf))%p%x(1:3)
1662 pi => ele%pts(face_nodes(i,f))%p
1665 pj => elp%pts(face_nodes(j,pf))%p
1666 if (norm2(pi%x(1:3) - pj%x(1:3) - l) .lt. 1d-7)
then
1667 id = min(pi%id(), pj%id())
1670 p_local_idx = this%get_local(this%points(id))
1674 if ( match .gt. 1)
then
1675 call neko_error(
'Multiple matches when creating periodic ids')
1676 else if (match .eq. 0)
then
1677 call neko_error(
'Cannot find matching periodic point')
1682 select type(elp => this%elements(pe)%e)
1686 l = l + ele%pts(edge_nodes(i,f))%p%x(1:3) - &
1687 elp%pts(edge_nodes(i,pf))%p%x(1:3)
1691 pi => ele%pts(edge_nodes(i,f))%p
1693 pj => elp%pts(edge_nodes(j,pf))%p
1695 if (norm2(pi%x(1:3) - pj%x(1:3) - l) .lt. 1d-7)
then
1696 id = min(pi%id(), pj%id())
1699 p_local_idx = this%get_local(this%points(id))
1710 class(
mesh_t),
intent(inout) :: this
1711 integer,
intent(in) :: f
1712 integer,
intent(in) :: e
1713 integer,
intent(in) :: pf
1714 integer,
intent(in) :: pe
1715 integer,
intent(inout) :: pids(4)
1717 integer :: i, id, p_local_idx
1720 integer,
dimension(4, 6) :: face_nodes = reshape([&
1728 select type(ele => this%elements(e)%e)
1731 pi => ele%pts(face_nodes(i,f))%p
1732 call pi%set_id(pids(i))
1733 call this%add_point(pi, id)
1734 p_local_idx = this%get_local(this%points(id))
1742 class(
mesh_t),
intent(inout) :: this
1743 type(
point_t),
intent(inout) :: p
1750 if (this%htp%get(tmp, local_id) .gt. 0)
then
1751 call neko_error(
'Invalid global id (local point)')
1759 class(
mesh_t),
intent(inout) :: this
1763 if (this%hte%get(e, local_id) .gt. 0)
then
1764 call neko_error(
'Invalid global id (local edge)')
1771 class(
mesh_t),
intent(inout) :: this
1775 if (this%htf%get(f, local_id) .gt. 0)
then
1776 call neko_error(
'Invalid global id (local facet)')
1783 class(
mesh_t),
intent(inout) :: this
1785 integer :: global_id
1787 global_id = this%get_local(e)
1789 if (this%gdim .eq. 2)
then
1791 global_id = this%ddata%local_to_global_facet(global_id)
1795 global_id = this%ddata%local_to_global_edge(global_id)
1803 class(
mesh_t),
intent(inout) :: this
1805 integer :: global_id
1807 global_id = this%get_local_facet(f)
1810 global_id = this%ddata%local_to_global_facet(global_id)
1820 class(
mesh_t),
intent(inout) :: this
1821 integer,
intent(inout) :: index
1824 if (this%htp%get(index, local_id) .eq. 1)
then
1833 class(
mesh_t),
intent(inout) :: this
1834 type(
point_t),
intent(inout) :: p
1835 integer :: local_index
1838 local_index = this%get_local(p)
1839 shared = this%ddata%shared_point%element(local_index)
1847 class(
mesh_t),
intent(inout) :: this
1849 integer :: local_index
1851 local_index = this%get_local(e)
1852 if (this%gdim .eq. 2)
then
1853 shared = this%ddata%shared_facet%element(local_index)
1855 shared = this%ddata%shared_edge%element(local_index)
1861 class(
mesh_t),
intent(inout) :: this
1863 integer :: local_index
1866 local_index = this%get_local(f)
1867 shared = this%ddata%shared_facet%element(local_index)
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 practical data distributions.
subroutine, public distdata_set_shared_point(ddata, point)
Mark a point as shared.
subroutine, public distdata_set_shared_el_facet(ddata, element, side)
Mark an element's facet as shared.
subroutine, public distdata_set_local_to_global_facet(ddata, local, global)
Set local to global mapping (facets)
subroutine, public distdata_free(ddata)
Free a distdata type.
subroutine, public distdata_set_local_to_global_edge(ddata, local, global)
Set local to global mapping (edges)
subroutine, public distdata_init(ddata)
Initialise a distdata type.
subroutine, public distdata_set_shared_facet(ddata, facet)
Mark a facet as shared.
subroutine, public distdata_set_shared_edge(ddata, edge)
Mark an element's edge as shared.
Defines a zone as a subset of facets in a mesh.
Defines a hexahedron element.
integer, parameter, public neko_hex_npts
Number of points.
integer, parameter, public neko_hex_nfcs
Number of faces.
integer, parameter, public neko_hex_neds
Number of edges.
Implements a hash table ADT.
integer, parameter, public log_size
subroutine mesh_generate_flags(this)
subroutine mesh_generate_facet_numbering(this)
Generate a unique facet numbering.
subroutine mesh_init_dist(this, gdim, dist)
Initialise a mesh this based on a distribution dist.
logical function mesh_is_shared_point(this, p)
Check if a point is shared.
integer, parameter, public neko_msh_max_zlbls
Max num. zone labels.
subroutine mesh_add_face(this, f)
Add a unique face represented as a 4-tuple to the mesh.
integer function mesh_get_global_edge(this, e)
Return the global id of an edge e.
subroutine mesh_generate_edge_conn(this)
Generate element-element connectivity via edges both between internal and between PEs.
subroutine mesh_add_edge(this, e)
Add a unique edge represented as a 2-tuple to the mesh.
subroutine mesh_add_point(this, p, idx)
Add a unique point to the mesh.
subroutine mesh_free(this)
Deallocate a mesh this.
subroutine mesh_mark_labeled_facet(this, f, e, label)
Mark facet f in element e with label.
subroutine mesh_add_quad(this, el, el_glb, p1, p2, p3, p4)
Add a quadrilateral element to the mesh this.
integer, parameter, public neko_msh_max_zlbl_len
Max length of a zone label.
subroutine mesh_mark_periodic_facet(this, f, e, pf, pe, pids)
Mark facet f in element e as periodic with (pf, pe)
integer function mesh_get_local_edge(this, e)
Return the local id of an edge e.
subroutine mesh_all_deformed(this)
Set all elements as if they are deformed.
logical function mesh_is_shared_edge(this, e)
Check if an edge is shared.
subroutine mesh_init_common(this)
subroutine mesh_get_facet_ids(this, f, e, pids)
Get original ids of periodic points.
subroutine mesh_create_periodic_ids(this, f, e, pf, pe)
Creates common ids for matching periodic points.
subroutine mesh_reset_periodic_ids(this)
Reset ids of periodic points to their original ids.
subroutine mesh_init_nelv(this, gdim, nelv)
Initialise a mesh this with nelv elements.
logical function mesh_is_shared_facet(this, f)
Check if a facet is shared.
integer function mesh_get_global_facet(this, f)
Return the local id of a face f.
integer function mesh_have_point_glb_idx(this, index)
Check if the mesh has a point given its global index.
subroutine mesh_generate_external_point_conn(this)
Generate element-element connectivity via points between PEs.
subroutine mesh_apply_periodic_facet(this, f, e, pf, pe, pids)
Replaces the periodic point's id with a common id for matching periodic points.
subroutine mesh_finalize(this)
subroutine mesh_generate_external_facet_conn(this)
Generate element-element connectivity via facets between PEs.
subroutine mesh_mark_curve_element(this, e, curve_data, curve_type)
Mark element e as a curve element.
subroutine mesh_generate_conn(this)
Generate element-to-element connectivity.
subroutine mesh_add_hex(this, el, el_glb, p1, p2, p3, p4, p5, p6, p7, p8)
Add a hexahedral element to the mesh this.
integer function mesh_get_local_facet(this, f)
Return the local id of a face f.
integer function mesh_get_local_point(this, p)
Return the local id of a point p.
integer, parameter, public i8
integer, parameter, public dp
integer, parameter, public rp
Global precision used in computations.
Defines a quadrilateral element.
integer, parameter, public neko_quad_neds
Number of edges.
integer, parameter, public neko_quad_npts
Number of points.
Implements a dynamic stack ADT.
Implements an unordered set ADT.
subroutine, public neko_warning(warning_msg)
Reports a warning to standard output.
Load-balanced linear distribution .
Base type for an element.
Integer based hash table.
Integer 2-tuple based hash table.
Integer 4-tuple based hash table.
Integer*8 based hash table.
Iterator for an integer based 2-tuple hash table.
Iterator for an integer based 4-tuple hash table.
Base type for a hash table.
A point in with coordinates .
Integer 2-tuple based stack.
Integer 4-tuple based stack.
Integer*8 based unordered set.