125 integer,
intent(in) :: ne
126 integer,
intent(in) :: nfaces
127 integer,
intent(out) :: etoe(ne, nfaces)
128 integer,
intent(out) :: etof(ne, nfaces)
129 integer,
intent(in) :: etov(ne,8)
131 integer :: nodes(ne*nfaces,4)
132 integer(kind=8) :: face_ids(ne*nfaces)
139 integer :: nnodes_row
140 integer :: matchl(2,3), matchr(2,3)
142 real(rp) :: etoe_1d(ne*nfaces)
143 real(rp) :: etof_1d(ne*nfaces)
145 integer :: spnodetonode(3,ne*nfaces)
146 integer :: spnodetonoderowtmp(3,ne*nfaces)
147 integer :: sort_indx(ne*nfaces)
148 integer(kind=8) :: sorted_faceid(ne*nfaces)
154 nnodes = maxval( etov )
155 nnodes_row =
size(nodes,1)
159 nodes(ke ,:) = etov(ke,(/ 1, 2, 6, 5 /))
160 nodes(ke+ne ,:) = etov(ke,(/ 2, 4, 8, 6 /))
161 nodes(ke+2*ne,:) = etov(ke,(/ 4, 3, 7, 8 /))
162 nodes(ke+3*ne,:) = etov(ke,(/ 3, 1, 5, 7 /))
163 nodes(ke+4*ne,:) = etov(ke,(/ 1, 3, 4, 2 /))
164 nodes(ke+5*ne,:) = etov(ke,(/ 5, 6, 8, 7 /))
170 call bubblesort( vtmp )
179 etof(ke,:) = (/ 1, 2, 3, 4, 5, 6 /)
182 face_ids(:) = nodes(:,1)*nnodes**3 + nodes(:,2)*nnodes**2 &
183 + nodes(:,3)*nnodes + nodes(:,4) + 1
188 spnodetonode(:,n) = (/ n, etoe(ke,f), etof(ke,f) /)
189 sorted_faceid(n) = face_ids(n)
197 spnodetonoderowtmp(:,:) = spnodetonode(:,:)
200 spnodetonode(:,n) = spnodetonoderowtmp(:,sort_indx(n))
207 if ( sorted_faceid(n) - sorted_faceid(n+1) == 0 )
then
208 matchl(:,:) = transpose( spnodetonode(:,(/ n, n+1 /)) )
209 matchr(:,:) = transpose( spnodetonode(:,(/ n+1, n /)) )
211 etoe_1d(matchl(:,1)) = matchr(:,2)
212 etof_1d(matchl(:,1)) = matchr(:,3)
219 if ( etoe_1d(n) /= -1 )
then
220 etoe(ke,f) = etoe_1d(n)
221 etof(ke,f) = etof_1d(n)
265 pos_en, pos_ev, EtoE, EtoF, EtoV, Fmask_h, Fmask_v, &
266 Ne, Nv, Np, Nfp_h, Nfp_v, NfpTot, Nfaces_h, Nfaces_v, Nfaces)
270 integer,
intent(in) :: ne
271 integer,
intent(in) :: nv
272 integer,
intent(in) :: np
273 integer,
intent(in) :: nfp_h
274 integer,
intent(in) :: nfp_v
275 integer,
intent(in) :: nfptot
276 integer,
intent(in) :: nfaces_h
277 integer,
intent(in) :: nfaces_v
278 integer,
intent(in) :: nfaces
280 integer,
intent(out) :: vmapm(nfptot,ne)
281 integer,
intent(out) :: vmapp(nfptot,ne)
282 integer,
intent(out) :: mapm(nfptot,ne)
283 integer,
intent(out) :: mapp(nfptot,ne)
285 real(rp),
intent(in) :: pos_en(np,ne,3)
286 real(rp),
intent(in) :: pos_ev(nv,3)
287 integer,
intent(in) :: etoe(ne,nfaces)
288 integer,
intent(in) :: etof(ne,nfaces)
289 integer,
intent(in) :: etov(ne,nv)
290 integer,
intent(in) :: fmask_h(nfp_h,nfaces_h)
291 integer,
intent(in) :: fmask_v(nfp_v,nfaces_v)
293 integer :: ke, ke1, ke2
300 integer :: nodeids(np,ne)
301 real(rp) :: r_h(nfp_h,nfp_h,3,2)
302 real(rp) :: r_v(nfp_v,nfp_v,3,2)
303 real(rp) :: dist_h(nfp_h,nfp_h)
304 real(rp) :: dist_v(nfp_v,nfp_v)
305 real(rp) :: x(np*ne), y(np*ne), z(np*ne)
307 integer :: vmapm_h(nfp_h,nfaces_h,ne)
308 integer :: vmapp_h(nfp_h,nfaces_h,ne)
309 integer :: vmapm_v(nfp_v,nfaces_v,ne)
310 integer :: vmapp_v(nfp_v,nfaces_v,ne)
311 integer :: mapm_h(nfp_h,nfaces_h,ne)
312 integer :: mapp_h(nfp_h,nfaces_h,ne)
313 integer :: mapm_v(nfp_v,nfaces_v,ne)
314 integer :: mapp_v(nfp_v,nfaces_v,ne)
316 integer :: mindist_indx(1)
326 x(n) = pos_en(p,ke,1)
327 y(n) = pos_en(p,ke,2)
328 z(n) = pos_en(p,ke,3)
337 n = p + (f-1)*nfp_h + (ke-1)*nfptot
340 vmapm_h(p,f,ke) = nodeids(fmask_h(p,f),ke)
345 n = p + nfaces_h*nfp_h + (f-1)*nfp_v + (ke-1)*nfptot
348 vmapm_v(p,f,ke) = nodeids(fmask_v(p,f),ke)
367 ke2 = etoe(ke1,f1); f2 = etof(ke1,f1)
369 v1 = etov(ke1,f1); v2 = etov(ke1,1+mod(f1,nfaces_h))
371 r_h(:,:,1,1) = spread( x(vmapm_h(:,f1,ke1)), 2, nfp_h )
372 r_h(:,:,1,2) = spread( x(vmapm_h(:,f2,ke2)), 1, nfp_h )
373 r_h(:,:,2,1) = spread( y(vmapm_h(:,f1,ke1)), 2, nfp_h )
374 r_h(:,:,2,2) = spread( y(vmapm_h(:,f2,ke2)), 1, nfp_h )
375 r_h(:,:,3,1) = spread( z(vmapm_h(:,f1,ke1)), 2, nfp_h )
376 r_h(:,:,3,2) = spread( z(vmapm_h(:,f2,ke2)), 1, nfp_h )
378 dist_h(:,:) = (r_h(:,:,1,1) - r_h(:,:,1,2))**2 &
379 + (r_h(:,:,2,1) - r_h(:,:,2,2))**2 &
380 + (r_h(:,:,3,1) - r_h(:,:,3,2))**2
382 mindist_indx(:) = minloc(dist_h(idm,:))
383 idp = mindist_indx(1)
384 vmapp_h(idm,f1,ke1) = vmapm_h(idp,f2,ke2)
385 mapp_h(idm,f1,ke1) = idp + (f2-1)*nfp_h + (ke2-1)*nfptot
394 ke2 = etoe(ke1,nfaces_h+f1); f2 = etof(ke1,nfaces_h+f1) - nfaces_h
396 v1 = etov(ke1,1); v2 = etov(ke1,nfaces_h+1)
398 r_v(:,:,1,1) = spread( x(vmapm_v(:,f1,ke1)), 2, nfp_v )
399 r_v(:,:,1,2) = spread( x(vmapm_v(:,f2,ke2)), 1, nfp_v )
400 r_v(:,:,2,1) = spread( y(vmapm_v(:,f1,ke1)), 2, nfp_v )
401 r_v(:,:,2,2) = spread( y(vmapm_v(:,f2,ke2)), 1, nfp_v )
402 r_v(:,:,3,1) = spread( z(vmapm_v(:,f1,ke1)), 2, nfp_v )
403 r_v(:,:,3,2) = spread( z(vmapm_v(:,f2,ke2)), 1, nfp_v )
405 dist_v(:,:) = (r_v(:,:,1,1) - r_v(:,:,1,2))**2 &
406 + (r_v(:,:,2,1) - r_v(:,:,2,2))**2 &
407 + (r_v(:,:,3,1) - r_v(:,:,3,2))**2
409 mindist_indx(:) = minloc(dist_v(idm,:))
410 idp = mindist_indx(1)
411 vmapp_v(idm,f1,ke1) = vmapm_v(idp,f2,ke2)
412 mapp_v(idm,f1,ke1) = idp + nfaces_h*nfp_h + (f2-1)*nfp_v + (ke2-1)*nfptot
424 vmapm(i,ke) = vmapm_h(n,f,ke)
425 mapm(i,ke) = mapm_h(n,f,ke)
426 vmapp(i,ke) = vmapp_h(n,f,ke)
427 mapp(i,ke) = mapp_h(n,f,ke)
432 i = n + nfaces_h*nfp_h + (f-1)*nfp_v
433 vmapm(i,ke) = vmapm_v(n,f,ke)
434 mapm(i,ke) = mapm_v(n,f,ke)
435 vmapp(i,ke) = vmapp_v(n,f,ke)
436 mapp(i,ke) = mapp_v(n,f,ke)
479 pos_en, xmin, xmax, ymin, ymax, zmin, zmax, &
480 Fmask_h, Fmask_v, Ne, Nv, Np, Nfp_h, Nfp_v, NfpTot, Nfaces_h, Nfaces_v, Nfaces )
484 integer,
intent(in) :: ne
485 integer,
intent(in) :: nv
486 integer,
intent(in) :: np
487 integer,
intent(in) :: nfp_h
488 integer,
intent(in) :: nfp_v
489 integer,
intent(in) :: nfptot
490 integer,
intent(in) :: nfaces_h
491 integer,
intent(in) :: nfaces_v
492 integer,
intent(in) :: nfaces
494 integer,
intent(inout),
allocatable :: vmapb(:)
495 integer,
intent(inout),
allocatable :: mapb(:)
496 integer,
intent(inout) :: vmapp(nfptot,ne)
498 real(rp),
intent(in) :: pos_en(np,ne,3)
499 real(rp),
intent(in) :: xmin, xmax
500 real(rp),
intent(in) :: ymin, ymax
501 real(rp),
intent(in) :: zmin, zmax
502 integer,
intent(in) :: fmask_h(nfp_h,nfaces_h)
503 integer,
intent(in) :: fmask_v(nfp_v,nfaces_v)
511 real(rp),
parameter :: node_tol = 1.0e-12_rp
513 integer :: elemids_h(nfp_h*ne,nfaces_h)
514 real(rp) :: ordinfo_h(nfp_h*ne,nfaces_h)
515 integer :: faceids_h(nfp_h*ne,nfaces_h)
516 integer :: counterb_h(nfaces_h)
518 integer :: elemids_v(nfp_v*ne,nfaces_v)
519 real(rp) :: ordinfo_v(nfp_v*ne,nfaces_v)
520 integer :: faceids_v(nfp_v*ne,nfaces_v)
521 integer :: counterb_v(nfaces_v)
523 integer :: mapb_counter
524 real(rp) :: rdomx, rdomy, rdomz
530 rdomx = 1.0_rp/(xmax - xmin)
531 rdomy = 1.0_rp/(ymax - ymin)
532 rdomz = 1.0_rp/abs(zmax - zmin)
536 x = sum(pos_en(fmask_h(:,f),ke,1)) / dble(nfp_h)
537 y = sum(pos_en(fmask_h(:,f),ke,2)) / dble(nfp_h)
539 call eval_domain_boundary( &
540 elemids_h, ordinfo_h, faceids_h, counterb_h, &
541 1, y, ymin, x, ke, f, rdomy )
542 call eval_domain_boundary( &
543 elemids_h, ordinfo_h, faceids_h, counterb_h, &
544 2, x, xmax, y, ke, f, rdomx )
545 call eval_domain_boundary( &
546 elemids_h, ordinfo_h, faceids_h, counterb_h, &
547 3, y, ymax, x, ke, f, rdomy )
548 call eval_domain_boundary( &
549 elemids_h, ordinfo_h, faceids_h, counterb_h, &
550 4, x, xmin, y, ke, f, rdomx )
553 x = sum(pos_en(fmask_v(:,f),ke,1)) / dble(nfp_v)
554 z = sum(pos_en(fmask_v(:,f),ke,3)) / dble(nfp_v)
556 call eval_domain_boundary( &
557 elemids_v, ordinfo_v, faceids_v, counterb_v, &
558 1, z, zmin, x, ke, f, rdomz )
559 call eval_domain_boundary( &
560 elemids_v, ordinfo_v, faceids_v, counterb_v, &
561 2, z, zmax, x, ke, f, rdomz )
566 allocate( mapb(sum(counterb_h(:)*nfp_h)+sum(counterb_v(:)*nfp_v)) )
567 allocate( vmapb(
size(mapb)) )
577 do i=1, counterb_h(b)
578 ke = elemids_h(i,b); f = faceids_h(i,b)
581 vmapp(n,ke) = np*ne + mapb_counter
582 vmapb(mapb_counter) = fmask_h(j,f) + (ke-1)*np
583 mapb_counter = mapb_counter + 1
589 do i=1, counterb_v(b)
590 ke = elemids_v(i,b); f = faceids_v(i,b)
592 n = j + nfp_h*nfaces_h + nfp_v*(f-1)
593 vmapp(n,ke) = np*ne + mapb_counter
594 vmapb(mapb_counter) = fmask_v(j,f) + (ke-1)*np
595 mapb_counter = mapb_counter + 1
615 subroutine eval_domain_boundary( &
616 elemIDs, ordInfo, faceIDs, counterB, &
617 domb_id, r, rbc, ord_info, k_, f_, normalized_fac )
620 integer,
intent(inout) :: elemids(:,:)
621 real(rp),
intent(inout) :: ordinfo(:,:)
622 integer,
intent(inout) :: counterb(:)
623 integer,
intent(inout) :: faceids(:,:)
624 integer,
intent(in) :: domb_id
625 real(rp),
intent(in) :: r
626 real(rp),
intent(in) :: rbc
627 real(rp),
intent(in) :: ord_info
628 integer,
intent(in) :: k_, f_
629 real(rp),
intent(in) :: normalized_fac
632 if ( abs(r - rbc)*normalized_fac < node_tol )
then
633 counterb(domb_id) = counterb(domb_id) + 1
634 ordinfo(counterb(domb_id),domb_id) = ord_info
635 elemids(counterb(domb_id),domb_id) = k_
636 faceids(counterb(domb_id),domb_id) = f_
640 end subroutine eval_domain_boundary
645 panelID_table, pi_table, pj_table, pk_table, &
646 tileID_map, tileFaceID_map, tilePanelID_map, &
647 Ntile, NtileFace, NtileVertex, &
648 isPeriodicX, isPeriodicY, isPeriodicZ, &
654 integer,
intent(in) :: ntile
655 integer,
intent(in) :: ntileface
656 integer,
intent(in) :: ntilevertex
657 integer,
intent(out) :: panelid_table(ntile)
658 integer,
intent(out) :: pi_table(ntile)
659 integer,
intent(out) :: pj_table(ntile)
660 integer,
intent(out) :: pk_table(ntile)
661 integer,
intent(out) :: tileid_map(ntileface,ntile)
662 integer,
intent(out) :: tilefaceid_map(ntileface,ntile)
663 integer,
intent(out) :: tilepanelid_map(ntileface,ntile)
664 logical,
intent(in) :: isperiodicx
665 logical,
intent(in) :: isperiodicy
666 logical,
intent(in) :: isperiodicz
667 integer,
intent(in) :: ne_x
668 integer,
intent(in) :: ne_y
669 integer,
intent(in) :: ne_z
671 integer :: ntileperpanel
672 integer :: nv_x, nv_y, nv_z
673 integer,
allocatable :: nodesid_3d(:,:,:)
674 integer,
allocatable :: etov(:,:)
675 integer,
allocatable :: etoe(:,:)
676 integer,
allocatable :: etof(:,:)
677 integer :: i, j, k, f
678 integer :: tileid, tileid_r
683 ntileperpanel = ntile/1
689 allocate( nodesid_3d(nv_x,nv_y,nv_z) )
690 allocate( etov(ntile,ntilevertex), etoe(ntile,ntileface), etof(ntile,ntileface) )
696 counter = counter + 1
697 nodesid_3d(i,j,k) = counter
710 panelid_table(tileid) = 1
711 pi_table(tileid) = i; pj_table(tileid) = j; pk_table(tileid) = k
712 etov(tileid,:) = (/ nodesid_3d(i,j ,k ), nodesid_3d(i+1,j ,k ), &
713 nodesid_3d(i,j+1,k ), nodesid_3d(i+1,j+1,k ), &
714 nodesid_3d(i,j ,k+1), nodesid_3d(i+1,j ,k+1), &
715 nodesid_3d(i,j+1,k+1), nodesid_3d(i+1,j+1,k+1) /)
721 etov, ntile, ntileface )
722 tileid_map(:,:) = transpose(etoe)
723 tilefaceid_map(:,:) = transpose(etof)
727 tileid_r = tileid_map(f,tileid)
728 tilepanelid_map(f,tileid) = panelid_table(tileid_r)
732 if (isperiodicx)
then
734 if (pi_table(tileid) == 1 .and. tilefaceid_map(4,tileid) == 4)
then
735 tileid_map(4,tileid) = ne_x + (pj_table(tileid) - 1)*ne_x + (pk_table(tileid) - 1)*ne_x*ne_y
736 tilefaceid_map(4,tileid) = 2
738 if (pi_table(tileid) == ne_x .and. tilefaceid_map(2,tileid) == 2)
then
739 tileid_map(2,tileid) = 1 + (pj_table(tileid) - 1)*ne_x + (pk_table(tileid) - 1)*ne_x*ne_y
740 tilefaceid_map(2,tileid) = 4
745 if (isperiodicy)
then
747 if (pj_table(tileid) == 1 .and. tilefaceid_map(1,tileid) == 1)
then
748 tileid_map(1,tileid) = pi_table(tileid) + (ne_y - 1)*ne_x + (pk_table(tileid) - 1)*ne_x*ne_y
749 tilefaceid_map(1,tileid) = 3
751 if (pj_table(tileid) == ne_y .and. tilefaceid_map(3,tileid) == 3)
then
752 tileid_map(3,tileid) = pi_table(tileid) + (pk_table(tileid) - 1)*ne_x*ne_y
753 tilefaceid_map(3,tileid) = 1
758 if (isperiodicz)
then
760 if (pk_table(tileid) == 1 .and. tilefaceid_map(5,tileid) == 5)
then
761 tileid_map(5,tileid) = pi_table(tileid) + (pj_table(tileid) - 1)*ne_x + (ne_z - 1)*ne_x*ne_y
762 tilefaceid_map(5,tileid) = 6
764 if (pk_table(tileid) == ne_z .and. tilefaceid_map(6,tileid) == 6)
then
765 tileid_map(6,tileid) = pi_table(tileid) + (pj_table(tileid) - 1)*ne_x
766 tilefaceid_map(6,tileid) = 5