GetTotalDOF
These methods provide a comprehensive interface for querying degree of freedom information at different levels of granularity, from global system-wide counts to element-specific and entity-specific counts.
Method | Purpose |
---|---|
GetTotalDOF1 | Returns the total number of degrees of freedom in the entire domain |
GetTotalDOF2 | Returns the total number of DOFs for a specific element |
GetTotalDOF3 | Returns filtered DOFs for a specific element based on entity type |
Interface 1
MODULE FUNCTION obj_GetTotalDOF1(obj) RESULT(ans)
CLASS(FEDOF_), INTENT(IN) :: obj
INTEGER(I4B) :: ans
END FUNCTION obj_GetTotalDOF1
Parameters
obj
: The FEDOF_ objectans
: Integer result containing the total number of degrees of freedom
Functionality
This method returns the total number of degrees of freedom in the entire FEDOF object. It simply returns the tdof
field of the object, which represents the global count of all degrees of freedom across the domain.
Interface 2
MODULE FUNCTION obj_GetTotalDOF2(obj, globalElement, islocal) RESULT(ans)
CLASS(FEDOF_), INTENT(IN) :: obj
INTEGER(I4B), INTENT(IN) :: globalElement
LOGICAL(LGT), OPTIONAL, INTENT(IN) :: islocal
INTEGER(I4B) :: ans
END FUNCTION obj_GetTotalDOF2
Parameters
obj
: The FEDOF_ objectglobalElement
: Global element number to retrieve the total DOFs forislocal
: Optional logical flag - if true, globalElement is treated as a local element numberans
: Integer result containing the total number of degrees of freedom for the specified element
Functionality
This method returns the total number of degrees of freedom associated with a specific element. It:
- Gets the element data pointer for the specified element
- Retrieves the total entities (points, edges, faces, cells) for the element
- Counts vertex node DOFs
- Adds the DOFs from all edges of the element
- Adds the DOFs from all faces of the element
- Adds the DOFs from the cell itself
- Returns the total sum as the result
Interface 3
MODULE FUNCTION obj_GetTotalDOF3(obj, globalElement, opt, islocal) RESULT(ans)
CLASS(FEDOF_), INTENT(IN) :: obj
INTEGER(I4B), INTENT(IN) :: globalElement
!! global or local element number
CHARACTER(*), INTENT(IN) :: opt
!! opt for Vertex, Edge, Face, Cell, and All
!! opt = Vertex
!! opt = Edge
!! opt = Face
!! opt = Cell
!! opt = All
LOGICAL(LGT), OPTIONAL, INTENT(IN) :: islocal
!! if islocal true then globalElement is local element number
INTEGER(I4B) :: ans
!! Total number of dof in the FEDOF with opt filter
END FUNCTION obj_GetTotalDOF3
Parameters
obj
: The FEDOF_ objectglobalElement
: Global element number to retrieve the total DOFs foropt
: Filter option specifying which type of DOFs to count- "Vertex" or "V" - Only count vertex DOFs
- "Edge" or "E" - Only count edge DOFs
- "Face" or "F" - Only count face DOFs
- "Cell" or "C" - Only count cell DOFs
- Any other value - Count all DOFs (same as GetTotalDOF2)
islocal
: Optional logical flag - if true, globalElement is treated as a local element numberans
: Integer result containing the filtered total of degrees of freedom
Functionality
This method is similar to GetTotalDOF2 but allows filtering the DOF count by entity type. It:
- Gets the element data pointer for the specified element
- Checks the first character of the opt parameter to determine which entity types to include
- Calls the appropriate internal subroutine(s) to count DOFs for the selected entity types:
- onlyVertex: Counts vertex DOFs
- onlyEdge: Counts edge DOFs
- onlyFace: Counts face DOFs
- onlyCell: Counts cell DOFs
- Returns the total sum as the result
Usage
The generic GetTotalDOF
method is fundamental in finite element analysis for:
- Allocating memory for element matrices and vectors
- Determining the size of local element contributions
- Computing the total size of the global system
- Estimating computational requirements
- Filtering DOFs by entity type for specialized operations
This flexible interface allows for both global analysis (total DOFs in the system), local element-wise operations (DOFs per element), and entity-specific queries (e.g., only edge DOFs), providing comprehensive flexibility in how degree of freedom information is accessed throughout the finite element code.
Example 1
!> author: Vikas Sharma, Ph. D.
! date: 2025-06-08
! summary: Testing GetTotalDOF method of FEDOF class
PROGRAM main
USE FEDOF_Class
USE FEDomain_Class
USE AbstractMesh_Class
USE HDF5File_Class
USE Display_Method
USE GlobalData
USE Test_Method
USE ExceptionHandler_Class, ONLY: e, EXCEPTION_INFORMATION
USE AppendUtility
USE ArangeUtility
USE ReallocateUtility
IMPLICIT NONE
CHARACTER(*), PARAMETER :: &
filename = "../../FEMesh/examples/meshdata/small_tri3_mesh.h5", &
baseContinuity = "H1", &
baseInterpolation = "Heirarchical", &
testname = baseContinuity//" "//baseInterpolation//" GetTotalDOF"
TYPE(FEDOF_) :: fedof
TYPE(FEDomain_) :: dom
CLASS(AbstractMesh_), POINTER :: meshptr => NULL()
TYPE(HDF5File_) :: meshfile
INTEGER(I4B) :: order, totalVertexNodes, totalFaces
LOGICAL(LGT) :: isok
CALL e%SetQuietMode(EXCEPTION_INFORMATION, .TRUE.)
CALL meshfile%Initiate(filename, mode="READ")
CALL meshfile%OPEN()
CALL dom%Initiate(meshfile, '')
meshptr => dom%GetMeshPointer()
totalVertexNodes = meshptr%GetTotalVertexNodes()
totalFaces = meshptr%GetTotalFaces()
CALL test1
CALL test2
CALL test3
CALL dom%DEALLOCATE()
CALL meshfile%DEALLOCATE()
CONTAINS
!----------------------------------------------------------------------------
! test1
!----------------------------------------------------------------------------
SUBROUTINE test1
INTEGER(I4B) :: tsize, found, want
order = 1
CALL fedof%Initiate(baseContinuity=baseContinuity, &
baseInterpolation=baseInterpolation, &
order=order, mesh=meshptr)
found = fedof%GetTotalDOF()
want = meshptr%GetTotalVertexNodes()
CALL IS(found, want, testname//" interface 1 (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE.)
want = meshptr%GetTotalVertexNodes(globalElement=1, islocal=.TRUE.)
CALL IS(found, want, testname//" interface 2 (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="A")
want = meshptr%GetTotalVertexNodes(globalElement=1, islocal=.TRUE.)
CALL IS(found, want, testname//" interface 3 a (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="E")
want = 0
CALL IS(found, want, testname//" interface 3 e (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="F")
want = 0
CALL IS(found, want, testname//" interface 3 f (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="c")
want = 0
CALL IS(found, want, testname//" interface 3 c (order= "// &
ToString(order)//"): ")
END SUBROUTINE test1
!----------------------------------------------------------------------------
! test2
!----------------------------------------------------------------------------
SUBROUTINE test2
INTEGER(I4B) :: tsize, found, want
order = 2
CALL fedof%Initiate(baseContinuity=baseContinuity, &
baseInterpolation=baseInterpolation, &
order=order, mesh=meshptr)
found = fedof%GetTotalDOF()
want = meshptr%GetTotalVertexNodes() + meshptr%GetTotalFaces() * (order - 1)
CALL IS(found, want, testname//" interface 1 (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE.)
want = 6
CALL IS(found, want, testname//" interface 2 (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="A")
want = 6
CALL IS(found, want, testname//" interface 3 a (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="E")
want = 0
CALL IS(found, want, testname//" interface 3 e (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="F")
want = 3
CALL IS(found, want, testname//" interface 3 f (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="c")
want = 0
CALL IS(found, want, testname//" interface 3 c (order= "// &
ToString(order)//"): ")
END SUBROUTINE test2
!----------------------------------------------------------------------------
! test3
!----------------------------------------------------------------------------
SUBROUTINE test3
INTEGER(I4B) :: tsize, found, want
order = 3
CALL fedof%Initiate(baseContinuity=baseContinuity, &
baseInterpolation=baseInterpolation, &
order=order, mesh=meshptr)
found = fedof%GetTotalDOF()
want = meshptr%GetTotalVertexNodes() + meshptr%GetTotalFaces() * (order - 1) &
+ meshptr%GetTotalCells() * (order - 2) * (order - 1) * 0.5
CALL IS(found, want, testname//" interface 1 (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE.)
want = 10
CALL IS(found, want, testname//" interface 2 (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="A")
want = 10
CALL IS(found, want, testname//" interface 3 a (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="E")
want = 0
CALL IS(found, want, testname//" interface 3 e (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="F")
want = 6
CALL IS(found, want, testname//" interface 3 f (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="c")
want = 1
CALL IS(found, want, testname//" interface 3 c (order= "// &
ToString(order)//"): ")
END SUBROUTINE test3
!----------------------------------------------------------------------------
!
!----------------------------------------------------------------------------
END PROGRAM main
Example 2
!> author: Vikas Sharma, Ph. D.
! date: 2025-06-08
! summary: Testing GetTotalDOF method of FEDOF class
PROGRAM main
USE FEDOF_Class
USE FEDomain_Class
USE AbstractMesh_Class
USE HDF5File_Class
USE Display_Method
USE GlobalData
USE Test_Method
USE ExceptionHandler_Class, ONLY: e, EXCEPTION_INFORMATION
USE AppendUtility
USE ArangeUtility
USE ReallocateUtility
IMPLICIT NONE
CHARACTER(*), PARAMETER :: &
filename = "../../FEMesh/examples/meshdata/small_tri6_mesh.h5", &
baseContinuity = "H1", &
baseInterpolation = "Heirarchical", &
testname = baseContinuity//" "//baseInterpolation//" GetTotalDOF"
TYPE(FEDOF_) :: fedof
TYPE(FEDomain_) :: dom
CLASS(AbstractMesh_), POINTER :: meshptr => NULL()
TYPE(HDF5File_) :: meshfile
INTEGER(I4B) :: order, totalVertexNodes, totalFaces
LOGICAL(LGT) :: isok
CALL e%SetQuietMode(EXCEPTION_INFORMATION, .TRUE.)
CALL meshfile%Initiate(filename, mode="READ")
CALL meshfile%OPEN()
CALL dom%Initiate(meshfile, '')
meshptr => dom%GetMeshPointer()
totalVertexNodes = meshptr%GetTotalVertexNodes()
totalFaces = meshptr%GetTotalFaces()
CALL test1
CALL test2
CALL test3
CALL dom%DEALLOCATE()
CALL meshfile%DEALLOCATE()
CONTAINS
!----------------------------------------------------------------------------
! test1
!----------------------------------------------------------------------------
SUBROUTINE test1
INTEGER(I4B) :: tsize, found, want
order = 1
CALL fedof%Initiate(baseContinuity=baseContinuity, &
baseInterpolation=baseInterpolation, &
order=order, mesh=meshptr)
found = fedof%GetTotalDOF()
want = meshptr%GetTotalVertexNodes()
CALL IS(found, want, testname//" interface 1 (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE.)
want = meshptr%GetTotalVertexNodes(globalElement=1, islocal=.TRUE.)
CALL IS(found, want, testname//" interface 2 (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="A")
want = meshptr%GetTotalVertexNodes(globalElement=1, islocal=.TRUE.)
CALL IS(found, want, testname//" interface 3 a (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="E")
want = 0
CALL IS(found, want, testname//" interface 3 e (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="F")
want = 0
CALL IS(found, want, testname//" interface 3 f (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="c")
want = 0
CALL IS(found, want, testname//" interface 3 c (order= "// &
ToString(order)//"): ")
END SUBROUTINE test1
!----------------------------------------------------------------------------
! test2
!----------------------------------------------------------------------------
SUBROUTINE test2
INTEGER(I4B) :: tsize, found, want
order = 2
CALL fedof%Initiate(baseContinuity=baseContinuity, &
baseInterpolation=baseInterpolation, &
order=order, mesh=meshptr)
found = fedof%GetTotalDOF()
want = meshptr%GetTotalVertexNodes() + meshptr%GetTotalFaces() * (order - 1)
CALL IS(found, want, testname//" interface 1 (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE.)
want = 6
CALL IS(found, want, testname//" interface 2 (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="A")
want = 6
CALL IS(found, want, testname//" interface 3 a (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="E")
want = 0
CALL IS(found, want, testname//" interface 3 e (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="F")
want = 3
CALL IS(found, want, testname//" interface 3 f (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="c")
want = 0
CALL IS(found, want, testname//" interface 3 c (order= "// &
ToString(order)//"): ")
END SUBROUTINE test2
!----------------------------------------------------------------------------
! test3
!----------------------------------------------------------------------------
SUBROUTINE test3
INTEGER(I4B) :: tsize, found, want
order = 3
CALL fedof%Initiate(baseContinuity=baseContinuity, &
baseInterpolation=baseInterpolation, &
order=order, mesh=meshptr)
found = fedof%GetTotalDOF()
want = meshptr%GetTotalVertexNodes() + meshptr%GetTotalFaces() * (order - 1) &
+ meshptr%GetTotalCells() * (order - 2) * (order - 1) * 0.5
CALL IS(found, want, testname//" interface 1 (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE.)
want = 10
CALL IS(found, want, testname//" interface 2 (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="A")
want = 10
CALL IS(found, want, testname//" interface 3 a (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="E")
want = 0
CALL IS(found, want, testname//" interface 3 e (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="F")
want = 6
CALL IS(found, want, testname//" interface 3 f (order= "// &
ToString(order)//"): ")
found = fedof%GetTotalDOF(globalElement=1, islocal=.TRUE., opt="c")
want = 1
CALL IS(found, want, testname//" interface 3 c (order= "// &
ToString(order)//"): ")
END SUBROUTINE test3
!----------------------------------------------------------------------------
!
!----------------------------------------------------------------------------
END PROGRAM main