Skip to content

Commit

Permalink
Updates in AbstractMesh_Class (#438)
Browse files Browse the repository at this point in the history
- Bringing most of the code from Mesh to AbstractMesh_Class
  • Loading branch information
vickysharma0812 authored Feb 1, 2024
2 parents 61a48d6 + d08a7d4 commit 6ed414c
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 255 deletions.
8 changes: 5 additions & 3 deletions src/modules/AbstractMesh/src/ElemData_Class.F90
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ MODULE ElemData_Class
PUBLIC :: ElemData_lt
PUBLIC :: ElemData_eq
PUBLIC :: ElemData_SetID
PUBLIC :: ElemData_Copy

INTEGER(I4B), PARAMETER, PUBLIC :: INTERNAL_ELEMENT = 1
INTEGER(I4B), PARAMETER, PUBLIC :: BOUNDARY_ELEMENT = -1
Expand Down Expand Up @@ -126,12 +127,13 @@ SUBROUTINE ElemData_Copy(obj1, obj2)

obj1%globalElemNum = obj2%globalElemNum
obj1%localElemNum = obj2%localElemNum
obj1%nodeType = obj2%nodeType
obj1%elementType = obj2%elementType
obj1%name = obj2%name
IF (ALLOCATED(obj2%globalNodes)) obj1%globalNodes = obj2%globalNodes
IF (ALLOCATED(obj2%globalElements)) obj1%globalElements &
& = obj2%globalElements
IF (ALLOCATED(obj2%extraGlobalNodes)) obj1%extraGlobalNodes &
& = obj2%extraGlobalNodes
IF (ALLOCATED(obj2%boundaryData)) obj1%boundaryData&
& = obj2%boundaryData

END SUBROUTINE ElemData_Copy

Expand Down
125 changes: 5 additions & 120 deletions src/modules/Mesh/src/Mesh_Class.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,18 @@

MODULE Mesh_Class
USE GlobalData
USE BaSetype
USE Basetype
USE String_Class, ONLY: String
USE ExceptionHandler_Class, ONLY: e
USE FPL, ONLY: ParameterList_
USE HDF5File_Class
USE VTKFile_Class
USE NodeData_Class, ONLY: NodeData_, INTERNAL_NODE, BOUNDARY_NODE, &
& DOMAIN_BOUNDARY_NODE, GHOST_NODE, TypeNode, NodeData_Display
& DOMAIN_BOUNDARY_NODE, GHOST_NODE, TypeNode
USE ElemData_Class, ONLY: ElemData_, INTERNAL_ELEMENT, BOUNDARY_ELEMENT, &
& DOMAIN_BOUNDARY_ELEMENT, GHOST_ELEMENT, TypeElem, &
& ElemData_Display => Display
USE FacetData_Class, ONLY: InternalFacetData_, BoundaryFacetData_, &
& InternalFacetData_Display, BoundaryFacetData_Display
USE AbstractMesh_Class, ONLY: AbstractMesh_, AbstractMeshDeallocate, &
& DOMAIN_BOUNDARY_ELEMENT, GHOST_ELEMENT, TypeElem
USE FacetData_Class, ONLY: InternalFacetData_, BoundaryFacetData_
USE AbstractMesh_Class, ONLY: AbstractMesh_, AbstractMeshDeallocate, &
& AbstractMeshDisplay, AbstractMeshGetQuery, AbstractMeshImport

IMPLICIT NONE
Expand Down Expand Up @@ -95,27 +93,11 @@ MODULE Mesh_Class
!! Export mesh to a VTKfile
PROCEDURE, PUBLIC, PASS(obj) :: Display => obj_display
!! Display the mesh
PROCEDURE, PUBLIC, PASS(obj) :: DisplayNodeData => &
& obj_DisplayNodeData
!! Display node data
PROCEDURE, PUBLIC, PASS(obj) :: DisplayElementData => &
& obj_DisplayElementData
!! Display element data
PROCEDURE, PUBLIC, PASS(obj) :: DisplayInternalFacetData => &
& obj_DisplayInternalFacetData
!! Display internal facet data
PROCEDURE, PUBLIC, PASS(obj) :: DisplayBoundaryFacetData => &
& obj_DisplayBoundaryFacetData
!! Display mesh facet data
!! Display facet element shape data
PROCEDURE, PUBLIC, PASS(obj) :: DisplayFacetElements => &
& obj_DisplayFacetElements

! SET:
! @NodeDataMethods
PROCEDURE, PUBLIC, PASS(obj) :: InitiateNodeToElements => &
& obj_InitiateNodeToElements
!! Initiate node to node data
PROCEDURE, PUBLIC, PASS(obj) :: InitiateNodeToNodes => &
& obj_InitiateNodetoNodes
!! Initiate Node to nodes mapping
Expand Down Expand Up @@ -442,70 +424,6 @@ MODULE SUBROUTINE obj_Display(obj, msg, unitno)
END SUBROUTINE obj_Display
END INTERFACE MeshDisplay

!----------------------------------------------------------------------------
! DisplayNodeData@IOMethods
!----------------------------------------------------------------------------

!> authors: Vikas Sharma, Ph. D.
! date: 13 April 2022
! summary: Displays the Node data

INTERFACE
MODULE SUBROUTINE obj_DisplayNodeData(obj, msg, unitno)
CLASS(Mesh_), INTENT(INOUT) :: obj
CHARACTER(*), INTENT(IN) :: msg
INTEGER(I4B), OPTIONAL, INTENT(IN) :: unitno
END SUBROUTINE obj_DisplayNodeData
END INTERFACE

!----------------------------------------------------------------------------
! DisplayElementData@IOMethods
!----------------------------------------------------------------------------

!> authors: Vikas Sharma, Ph. D.
! date: 13 April 2022
! summary: Displays the element data

INTERFACE
MODULE SUBROUTINE obj_DisplayElementData(obj, msg, unitno)
CLASS(Mesh_), INTENT(INOUT) :: obj
CHARACTER(*), INTENT(IN) :: msg
INTEGER(I4B), OPTIONAL, INTENT(IN) :: unitno
END SUBROUTINE obj_DisplayElementData
END INTERFACE

!----------------------------------------------------------------------------
! DisplayFacetData@IOMethods
!----------------------------------------------------------------------------

!> authors: Vikas Sharma, Ph. D.
! date: 13 April 2022
! summary: Displays the element data

INTERFACE
MODULE SUBROUTINE obj_DisplayInternalFacetData(obj, msg, unitno)
CLASS(Mesh_), INTENT(INOUT) :: obj
CHARACTER(*), INTENT(IN) :: msg
INTEGER(I4B), OPTIONAL, INTENT(IN) :: unitno
END SUBROUTINE obj_DisplayInternalFacetData
END INTERFACE

!----------------------------------------------------------------------------
! DisplayBoundaryFacetData@IOMethods
!----------------------------------------------------------------------------

!> authors: Vikas Sharma, Ph. D.
! date: 13 April 2022
! summary: Displays the element data

INTERFACE
MODULE SUBROUTINE obj_DisplayBoundaryFacetData(obj, msg, unitno)
CLASS(Mesh_), INTENT(INOUT) :: obj
CHARACTER(*), INTENT(IN) :: msg
INTEGER(I4B), OPTIONAL, INTENT(IN) :: unitno
END SUBROUTINE obj_DisplayBoundaryFacetData
END INTERFACE

!----------------------------------------------------------------------------
! DisplayFacetElements@IOMethods
!----------------------------------------------------------------------------
Expand Down Expand Up @@ -1188,39 +1106,6 @@ MODULE SUBROUTINE obj_GetQuery(obj, &
END SUBROUTINE obj_GetQuery
END INTERFACE

!----------------------------------------------------------------------------
! InitiateNodeToElements@NodeDataMethods
!----------------------------------------------------------------------------

!> authors: Vikas Sharma, Ph. D.
! date: 15 June 2021
! summary: generate Elements surrounding a node mapping
!
!# Introduction
!
! - This subroutine generates elements surrounding a node mapping, in other
! words it generates node to element
! - Element numbers returned by this routine are global element number.
! - This mapping is stored inside `obj%nodeData` array
! - For a local node number `ii`, `obj%nodeData(ii)%globalElements(:)`
! contains the global element numbers.
!
!@note
! Always use method called `GetNodeToElements()` to access this information.
! This methods requires global Node number
!@endnote
!
!@warning
! Always use the mapping between global node number and local node number to
! avoid segmentation fault
!@endwarning

INTERFACE
MODULE SUBROUTINE obj_InitiateNodeToElements(obj)
CLASS(Mesh_), INTENT(INOUT) :: obj
END SUBROUTINE obj_InitiateNodeToElements
END INTERFACE

!----------------------------------------------------------------------------
! InitiateNodeToNode@NodeDataMethods
!----------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
!

SUBMODULE(AbstractMesh_Class) ConstructorMethods
USE Display_Method
USE GlobalData, ONLY: stdout
IMPLICIT NONE
CONTAINS

Expand Down Expand Up @@ -115,10 +117,11 @@
!----------------------------------------------------------------------------

MODULE PROCEDURE obj_InitiateDynamicDataStructure
CHARACTER(*), PARAMETER :: myName = "obj_Import()"
CHARACTER(*), PARAMETER :: myName = "obj_InitiateDynamicDataStructure()"
INTEGER(I4B) :: ii
TYPE(ElemData_), POINTER :: elemdata_ptr
TYPE(NodeData_), POINTER :: nodedata_ptr
TYPE(CPUTime_) :: TypeCPUTime

#ifdef DEBUG_VER
CALL e%RaiseInformation(modName//'::'//myName//' - '// &
Expand All @@ -138,20 +141,44 @@
CALL obj%nodeDataList%Initiate()
CALL obj%nodeDataBinaryTree%Initiate()

IF (obj%showTime) THEN
CALL Display("Showing Time States of InitiateDynamicDataStructure", &
& unitno=stdout)
CALL EqualLine(unitno=stdout)
CALL TypeCPUTime%SetStartTime()
END IF

DO ii = 1, obj%tElements
elemdata_ptr => ElemData_Pointer()
CALL ElemData_Copy(elemdata_ptr, obj%elementData(ii))
CALL obj%elementDataList%Add(elemdata_ptr)
CALL obj%elementDataBinaryTree%Insert(elemdata_ptr)
END DO

IF (obj%showTime) THEN
CALL TypeCPUTime%SetEndTime()
CALL Display(modName//" : "//myName// &
& " : time for making elementDataList: "// &
& tostring(TypeCPUTime%GetTime()), unitno=stdout)
END IF

IF (obj%showTime) CALL TypeCPUTime%SetStartTime()

DO ii = 1, obj%tNodes
nodedata_ptr => NodeData_Pointer()
CALL NodeData_Copy(nodedata_ptr, obj%nodeData(ii))
CALL obj%nodeDataList%Add(nodedata_ptr)
CALL obj%nodeDataBinaryTree%Insert(nodedata_ptr)
END DO

IF (obj%showTime) THEN
CALL TypeCPUTime%SetEndTime()
CALL Display(modName//" : "//myName// &
& " : time for making nodeDataList: "// &
& tostring(TypeCPUTime%GetTime()), unitno=stdout)
CALL EqualLine(unitno=stdout)
END IF

elemdata_ptr => NULL()
nodedata_ptr => NULL()

Expand Down
65 changes: 53 additions & 12 deletions src/submodules/AbstractMesh/src/AbstractMesh_Class@IOMethods.F90
Original file line number Diff line number Diff line change
Expand Up @@ -473,39 +473,80 @@
!----------------------------------------------------------------------------

MODULE PROCEDURE obj_DisplayElementData
CHARACTER(*), PARAMETER :: myName = "obj_DisplayElementData()"
CALL e%RaiseError(modName//'::'//myName//' - '// &
& '[WIP ERROR] :: This routine is under development')
INTEGER(I4B) :: ii, telements

CALL Display(msg, unitno=unitno)
telements = obj%GetTotalElements()

DO ii = 1, telements
CALL elemData_Display(obj=obj%elementData(ii), &
& msg="elementData("//tostring(ii)//"): ", unitno=unitno)
CALL BlankLines(nol=1, unitno=unitno)
END DO
END PROCEDURE obj_DisplayElementData

!----------------------------------------------------------------------------
! DisplayNodeData
!----------------------------------------------------------------------------

MODULE PROCEDURE obj_DisplayNodeData
CHARACTER(*), PARAMETER :: myName = "obj_DisplayNodeData()"
CALL e%RaiseError(modName//'::'//myName//' - '// &
& '[WIP ERROR] :: This routine is under development')
INTEGER(I4B) :: ii, tNodes
tNodes = obj%GetTotalNodes()
CALL Display(msg, unitno=unitno)
DO ii = 1, tNodes
CALL nodeData_Display(obj%nodeData(ii), &
& msg="nodeData("//tostring(ii)//"): ", unitno=unitno)
CALL BlankLines(nol=1, unitno=unitno)
END DO
END PROCEDURE obj_DisplayNodeData

!----------------------------------------------------------------------------
! DisplayInternalFacetData
!----------------------------------------------------------------------------

MODULE PROCEDURE obj_DisplayInternalFacetData
CHARACTER(*), PARAMETER :: myName = "obj_DisplayInternalFacetData()"
CALL e%RaiseError(modName//'::'//myName//' - '// &
& '[WIP ERROR] :: This routine is under development')
INTEGER(I4B) :: ii, n
LOGICAL(LGT) :: abool

CALL Display(msg, unitno=unitno)

abool = ALLOCATED(obj%internalFacetData)
IF (abool) THEN; n = SIZE(obj%internalFacetData); ELSE; n = 0; END IF

CALL Display(abool, "internalFacetData ALLOCATED: ", unitno=unitno)

DO ii = 1, n

CALL InternalFacetData_Display(obj=obj%internalFacetData(ii), &
& msg="internalFacetData("//tostring(ii)//"): ", unitno=unitno)

CALL BlankLines(nol=1, unitno=unitno)

END DO
END PROCEDURE obj_DisplayInternalFacetData

!----------------------------------------------------------------------------
! DisplayBoundaryFacetData
!----------------------------------------------------------------------------

MODULE PROCEDURE obj_DisplayBoundaryFacetData
CHARACTER(*), PARAMETER :: myName = "obj_DisplayBoundaryFacetData()"
CALL e%RaiseError(modName//'::'//myName//' - '// &
& '[WIP ERROR] :: This routine is under development')
INTEGER(I4B) :: ii, n
LOGICAL(LGT) :: abool

abool = ALLOCATED(obj%boundaryFacetData)
IF (abool) THEN; n = SIZE(obj%boundaryFacetData); ELSE; n = 0; END IF

CALL Display(msg, unitno=unitno)
CALL Display(abool, "boundaryFacetData ALLOCATED: ", unitno=unitno)

DO ii = 1, n

CALL BoundaryFacetData_Display(obj=obj%boundaryFacetData(ii), &
& msg="boundaryFacetData("//tostring(ii)//"): ", unitno=unitno)

CALL BlankLines(nol=1, unitno=unitno)

END DO
END PROCEDURE obj_DisplayBoundaryFacetData

!----------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 6ed414c

Please sign in to comment.