subroutine Init_Mesh3D_t(this,nGeo,nElem,nSides,nNodes,nBCs)
implicit none
class(Mesh3D_t),intent(inout) :: this
integer,intent(in) :: nGeo
integer,intent(in) :: nElem
integer,intent(in) :: nSides
integer,intent(in) :: nNodes
integer,intent(in) :: nBCs
! Local
integer :: i,j,k,l
this%nElem = nElem
this%nGlobalElem = nElem
this%nGeo = nGeo
this%nSides = nSides
this%nNodes = nNodes
this%nCornerNodes = 0
this%nUniqueSides = 0
this%nUniqueNodes = 0
this%nBCs = nBCs
allocate(this%elemInfo(1:6,1:nElem))
allocate(this%sideInfo(1:5,1:6,1:nElem))
allocate(this%nodeCoords(1:3,1:nGeo+1,1:nGeo+1,1:nGeo+1,1:nElem))
allocate(this%globalNodeIDs(1:nGeo+1,1:nGeo+1,1:nGeo+1,1:nElem))
allocate(this%CGNSCornerMap(1:3,1:8))
allocate(this%CGNSSideMap(1:4,1:6))
allocate(this%sideMap(1:4,1:6))
allocate(this%BCType(1:4,1:nBCs))
allocate(this%BCNames(1:nBCs))
! Create lookup tables to assist with connectivity generation
this%CGNSCornerMap(1:3,1) = (/1,1,1/) ! Bottom-South-West
this%CGNSCornerMap(1:3,2) = (/nGeo+1,1,1/) ! Bottom-South-East
this%CGNSCornerMap(1:3,3) = (/nGeo+1,nGeo+1,1/) ! Bottom-North-East
this%CGNSCornerMap(1:3,4) = (/1,nGeo+1,1/) ! Bottom-North-West
this%CGNSCornerMap(1:3,5) = (/1,1,nGeo+1/) ! Top-South-West
this%CGNSCornerMap(1:3,6) = (/nGeo+1,1,nGeo+1/) ! Top-South-East
this%CGNSCornerMap(1:3,7) = (/nGeo+1,nGeo+1,nGeo+1/) ! Top-North-East
this%CGNSCornerMap(1:3,8) = (/1,nGeo+1,nGeo+1/) ! Top-North-West
! Maps from local corner node id to CGNS side
this%CGNSSideMap(1:4,1) = (/1,4,3,2/)
this%CGNSSideMap(1:4,2) = (/1,2,6,5/)
this%CGNSSideMap(1:4,3) = (/2,3,7,6/)
this%CGNSSideMap(1:4,4) = (/3,4,8,7/)
this%CGNSSideMap(1:4,5) = (/1,5,8,4/)
this%CGNSSideMap(1:4,6) = (/5,6,7,8/)
! Sidemap traverses each face so that the normal
! formed by the right hand rule is the coordinate
! positive pointing normal. For east,north,and top
! this is an outward facing normal.
! For bottom, south, and west, the normal is inward
! facing.
this%sideMap(1:4,1) = (/1,2,3,4/) ! Bottom
this%sideMap(1:4,2) = (/1,2,6,5/) ! South
this%sideMap(1:4,3) = (/2,3,7,6/) ! East
this%sideMap(1:4,4) = (/4,3,7,8/) ! North
this%sideMap(1:4,5) = (/1,4,8,5/) ! West
this%sideMap(1:4,6) = (/5,6,7,8/) ! Top
endsubroutine Init_Mesh3D_t