Initialize the forest with one root per base-mesh element (all leaves at level 0). The base geometry (node coordinates) is copied so leaf geometry can be regenerated after any amount of refinement without holding a reference to the mesh. Requires a single-rank mesh (a decomposed mesh only stores its local elements); a rank-replicated forest over a decomposed base is built by gathering the global tables and calling InitGlobal.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(OctreeMesh3D), | intent(out) | :: | this | |||
| type(Mesh3D), | intent(in) | :: | mesh |
subroutine Init_OctreeMesh3D(this,mesh)
!! Initialize the forest with one root per base-mesh element (all leaves at level 0).
!! The base geometry (node coordinates) is copied so leaf geometry can be regenerated
!! after any amount of refinement without holding a reference to the mesh. Requires a
!! single-rank mesh (a decomposed mesh only stores its local elements); a
!! rank-replicated forest over a decomposed base is built by gathering the global
!! tables and calling InitGlobal.
implicit none
class(OctreeMesh3D),intent(out) :: this
type(Mesh3D),intent(in) :: mesh
! Local
integer :: r,s
integer,allocatable :: nbr(:,:),nbrSide(:,:),flip(:,:),bc(:,:),mat(:)
if(mesh%decomp%nRanks > 1) then
print*,__FILE__,':',__LINE__, &
' : Error : OctreeMesh3D%Init requires a single-rank mesh; gather the global base'// &
' tables and call InitGlobal for a decomposed base mesh.'
stop 1
endif
allocate(nbr(1:6,1:mesh%nElem),nbrSide(1:6,1:mesh%nElem))
allocate(flip(1:6,1:mesh%nElem),bc(1:6,1:mesh%nElem))
allocate(mat(1:mesh%nElem))
do r = 1,mesh%nElem
do s = 1,6
nbr(s,r) = mesh%sideInfo(3,s,r)
nbrSide(s,r) = mesh%sideInfo(4,s,r)/10
flip(s,r) = mod(mesh%sideInfo(4,s,r),10)
bc(s,r) = mesh%sideInfo(5,s,r)
enddo
mat(r) = mesh%elemMaterial(r)
enddo
call this%InitGlobal(mesh%nElem,mesh%nGeo,mesh%quadrature, &
mesh%nodeCoords,nbr,nbrSide,flip,bc,mat)
deallocate(nbr,nbrSide,flip,bc,mat)
endsubroutine Init_OctreeMesh3D