Init_MultiSetModel3D_t Subroutine

public subroutine Init_MultiSetModel3D_t(this, globalMesh, interp, setOfElemLocal, nSets)

Split globalMesh into nSets element sets and build each set's sub-mesh and geometry. The set models are not created here; see the module documentation.

Collective over globalMesh%decomp%mpiComm: every rank must call it.

Input - globalMesh : the decomposed global mesh; must outlive this model - interp : the interpolant shared by every set's geometry - setOfElemLocal(1:globalMesh%nElem) : set id, in 1..nSets, of each rank-local element - nSets : number of element sets, >= 1

Arguments

TypeIntentOptionalAttributesName
class(MultiSetModel3D_t), intent(out) :: this
type(Mesh3D), intent(in), target:: globalMesh
type(Lagrange), intent(in), pointer:: interp
integer, intent(in) :: setOfElemLocal(1:globalMesh%nElem)
integer, intent(in) :: nSets

Calls

proc~~init_multisetmodel3d_t~~CallsGraph proc~init_multisetmodel3d_t Init_MultiSetModel3D_t proc~gathersetofelem GatherSetOfElem proc~init_multisetmodel3d_t->proc~gathersetofelem proc~validatesetpartition ValidateSetPartition proc~init_multisetmodel3d_t->proc~validatesetpartition proc~extractsubmesh ExtractSubMesh proc~init_multisetmodel3d_t->proc~extractsubmesh proc~buildsetnumbering BuildSetNumbering proc~init_multisetmodel3d_t->proc~buildsetnumbering mpi_comm_dup mpi_comm_dup proc~init_multisetmodel3d_t->mpi_comm_dup mpi_allgatherv mpi_allgatherv proc~gathersetofelem->mpi_allgatherv

Contents


Source Code

  subroutine Init_MultiSetModel3D_t(this,globalMesh,interp,setOfElemLocal,nSets)
    !! Split globalMesh into nSets element sets and build each set's sub-mesh and
    !! geometry. The set models are not created here; see the module documentation.
    !!
    !! Collective over globalMesh%decomp%mpiComm: every rank must call it.
    !!
    !!  Input
    !!    - globalMesh : the decomposed global mesh; must outlive this model
    !!    - interp : the interpolant shared by every set's geometry
    !!    - setOfElemLocal(1:globalMesh%nElem) : set id, in 1..nSets, of each rank-local
    !!      element
    !!    - nSets : number of element sets, >= 1
    implicit none
    class(MultiSetModel3D_t),intent(out) :: this
    type(Mesh3D),intent(in),target :: globalMesh
    type(Lagrange),pointer,intent(in) :: interp
    integer,intent(in) :: setOfElemLocal(1:globalMesh%nElem)
    integer,intent(in) :: nSets
    ! Local
    integer :: k,nGlobalElem,ierror
    integer,allocatable :: setOffsets(:,:)

    this%globalMesh => globalMesh
    this%nSets = nSets
    this%nvar = 0
    this%t = 0.0_prec
    this%dt = 0.0_prec

    nGlobalElem = globalMesh%decomp%offsetElem(globalMesh%decomp%nRanks+1)
    allocate(this%setOfElem(1:nGlobalElem),this%setGlobalId(1:nGlobalElem))

    call GatherSetOfElem(globalMesh,setOfElemLocal,this%setOfElem)
    if(.not. ValidateSetPartition(globalMesh,this%setOfElem,nSets)) then
      error stop "MultiSetModel3D : invalid element-set partition"
    endif

    allocate(setOffsets(1:globalMesh%decomp%nRanks+1,1:nSets))
    call BuildSetNumbering(globalMesh,this%setOfElem,nSets,this%setGlobalId,setOffsets)
    this%setOffsetThisRank = setOffsets(globalMesh%decomp%rankId+1,1:nSets)

    allocate(this%sets(1:nSets))
    do k = 1,nSets
      call mpi_comm_dup(globalMesh%decomp%mpiComm,this%sets(k)%comm,ierror)
      allocate(this%sets(k)%mesh)
      call ExtractSubMesh(globalMesh,k,this%setOfElem,this%setGlobalId,setOffsets, &
                          this%sets(k)%comm,this%sets(k)%mesh)

      allocate(this%sets(k)%geometry)
      call this%sets(k)%geometry%Init(interp,this%sets(k)%mesh%nElem)
      ! Element-local, and a zero-element launch is invalid on the GPU, so a set with
      ! no elements on this rank skips it.
      if(this%sets(k)%mesh%nElem > 0) then
        call this%sets(k)%geometry%GenerateFromMesh(this%sets(k)%mesh)
      endif
    enddo

    deallocate(setOffsets)

  endsubroutine Init_MultiSetModel3D_t