This serves as an simple grid generation for performance or scaling analysis without being obliged to use Seeder. You have to specify the generic grid parameters in the lua file insted of the mesh folder
mesh = { predefined='cube',
origin = {0.,0.,0.},
length = 10.,
refinementLevel = 6 }
You have to specify the shape 'cube', a bounding box origin, its length and also the refinement level, which results in different amount elements in the grid. The result of this routine is mainly the treeID list with the additional lists for saving the properties. They are all set to zero here, however. As we only have a simple cube which includes all the elements on this level, the treeID list just contains contiguously increasing integers
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(treelmesh_type), | intent(out) | :: | me |
Mesh to generate |
||
real(kind=rk), | intent(in) | :: | origin(3) |
Corner of the cube |
||
real(kind=rk), | intent(in) | :: | length |
Length of cube |
||
integer, | intent(in) | :: | level |
Resolution level |
||
integer, | intent(in) | :: | myPart |
Partition of the caller (starts with 0) |
||
integer, | intent(in) | :: | nParts |
Number of partitions |
||
integer, | intent(in) | :: | comm |
communicator to be used |
subroutine generate_treelm_cube( me, origin, length, level, myPart, nParts, & & comm ) ! -------------------------------------------------------------------- ! !> Mesh to generate type(treelmesh_type), intent(out) :: me !> Corner of the cube real(kind=rk), intent(in) :: origin(3) !> Length of cube real(kind=rk), intent(in) :: length !> Resolution level integer, intent(in) :: level !> Partition of the caller (starts with 0) integer, intent(in) :: myPart !> Number of partitions integer, intent(in) :: nParts !> communicator to be used integer, intent(in) :: comm ! -------------------------------------------------------------------- ! integer(kind=long_k) :: firstID, lastID integer(kind=long_k) :: share integer :: remainder integer :: iPart, iElem ! -------------------------------------------------------------------- ! me%global%nParts = nParts me%global%myPart = myPart me%global%comm = comm me%global%origin = origin me%global%BoundingCubeLength = length me%global%minLevel = level me%global%maxLevel = level me%global%label = 'Generic_Cube' me%global%predefined = 'cube' write(me%global%comment,'(a15,i7,a16,i2,a1)') & & 'Generated with ', nParts, ' Parts on Level ', level, '.' me%global%dirname = './' ! No properties in this mesh me%global%nProperties = 0 if (associated(me%global%Property)) deallocate(me%global%Property) allocate(me%global%Property(me%global%nProperties)) allocate(me%Part_First(nParts)) allocate(me%Part_Last(nParts)) ! Compute the treeIDs of the mesh: firstID = tem_firstIdAtLevel(level) lastID = tem_lastIdAtLevel(level) ! Total number of elements in this mesh me%global%nElems = lastID - firstID + 1_long_k share = me%global%nElems / int(nParts, kind=long_k) remainder = int(mod(me%global%nElems, int(nParts, kind=long_k))) ! The first partition starts always with the firstID me%Part_First(1) = firstID ! Up to remainder partitions have share + 1 elements do iPart=2,remainder+1 me%Part_Last(iPart-1) = me%Part_First(iPart-1) + share me%Part_First(iPart) = me%Part_Last(iPart-1) + 1 end do ! The remaining elements get exactly the share elements: do iPart=remainder+2,nParts me%Part_Last(iPart-1) = me%Part_First(iPart-1) + share - 1 me%Part_First(iPart) = me%Part_Last(iPart-1) + 1 end do ! The last partition ends always with the lastID me%Part_Last(nParts) = lastID ! Local data: me%nElems = int(me%Part_Last(myPart+1) - me%Part_First(myPart+1)) + 1 me%elemOffset = me%Part_first(myPart+1) - firstID allocate(me%treeID(me%nElems)) allocate(me%ElemPropertyBits(me%nElems)) if (associated(me%property)) deallocate(me%property) allocate(me%Property(me%global%nProperties)) ! No Properties: me%ElemPropertyBits = 0_long_k ! Filling the treeIDs: do iElem=1,me%nElems me%treeID(iElem) = me%Part_First(myPart+1) + int(iElem - 1, kind=long_k) end do end subroutine generate_treelm_cube