GetTotalNodes
Inheritence
This method is inherited from the AbstractMesh class.
GetTotalNodes
The GetTotalNodes
method returns the total number of nodes in the mesh, with options to count nodes for specific mesh IDs or element selections.
Interface
INTERFACE
MODULE FUNCTION GetTotalNodes1(obj) RESULT(ans)
CLASS(AbstractMesh_), INTENT(IN) :: obj
INTEGER(I4B) :: ans
END FUNCTION GetTotalNodes1
END INTERFACE
INTERFACE
MODULE FUNCTION GetTotalNodes2(obj, meshid) RESULT(ans)
CLASS(AbstractMesh_), INTENT(IN) :: obj
INTEGER(I4B), INTENT(IN) :: meshid
INTEGER(I4B) :: ans
END FUNCTION GetTotalNodes2
END INTERFACE
INTERFACE
MODULE FUNCTION GetTotalNodes3(obj, globalElement, islocal) RESULT(ans)
CLASS(AbstractMesh_), INTENT(IN) :: obj
!! abstrract mesh
INTEGER(I4B), INTENT(IN) :: globalElement(:)
!! global or local element number
LOGICAL(LGT), OPTIONAL, INTENT(IN) :: islocal
!! if true then global element is local element
INTEGER(I4B) :: ans
END FUNCTION GetTotalNodes3
END INTERFACE
Syntax
! Get total nodes in the mesh
totalNodes = mesh%GetTotalNodes()
! Get total nodes for a specific mesh ID
subdomainNodes = mesh%GetTotalNodes(meshid)
! Get total unique nodes in specified elements
elementNodes = mesh%GetTotalNodes(globalElement, [islocal])
Parameters
Parameter | Type | Intent | Description |
---|---|---|---|
obj | CLASS(AbstractMesh_) | IN | The mesh object |
meshid | INTEGER(I4B) | IN | Mesh ID to filter nodes by |
globalElement | INTEGER(I4B)(:) | IN | Global or local element numbers to count nodes from |
islocal | LOGICAL(LGT) | IN (optional) | If true, globalElement contains local element numbers |
Return Value
Type | Description |
---|---|
INTEGER(I4B) | Total number of nodes matching the criteria |
Description
GetTotalNodes
returns the total number of nodes in the mesh, with options to count nodes for specific contexts:
- Return the total number of all nodes in the mesh
- Return the total number of nodes in elements with a specific mesh ID
- Return the total number of unique nodes in a list of specified elements
This information is essential for array sizing, iteration limits, and mesh statistics.
Example Usage
TYPE(Mesh_) :: mesh
INTEGER(I4B) :: totalNodes, subdomain1Nodes, elemNodes
INTEGER(I4B) :: selectedElems(3)
! Initialize mesh...
selectedElems = [10, 15, 20] ! Example element numbers
! Get total nodes in the mesh
totalNodes = mesh%GetTotalNodes()
! Get total nodes in subdomain 1
subdomain1Nodes = mesh%GetTotalNodes(meshid=1)
! Get total unique nodes in selected elements
elemNodes = mesh%GetTotalNodes(selectedElems)
PRINT*, "Total nodes in mesh:", totalNodes
PRINT*, "Nodes in subdomain 1:", subdomain1Nodes
PRINT*, "Unique nodes in selected elements:", elemNodes
Example 1
!> author: Vikas Sharma, Ph. D.
! date: 2025-06-05
! summary: Test for `GetTotalNodes` method of `FEMesh_` class.
PROGRAM main
USE FEMesh_Class, ONLY: FEMesh_
USE HDF5File_Class, ONLY: HDF5File_
USE GlobalData, ONLY: I4B, LGT, Quadrangle
USE ReallocateUtility, ONLY: Reallocate
USE Display_Method, ONLY: Display
USE Test_Method
IMPLICIT NONE
TYPE(FEMesh_) :: obj
TYPE(HDF5File_) :: meshfile
CHARACTER(LEN=*), PARAMETER :: filename = "./meshdata/very_small_quad4_mesh.h5"
INTEGER(I4B), PARAMETER :: nsd = 2
INTEGER(I4B) :: found(8), want(8)
LOGICAL(LGT) :: isok
CHARACTER(*), PARAMETER :: testname = "GetTotalNodes"
! Initiate and open the mesh file which is in `HDF5File_` format.
CALL meshfile%Initiate(FileName=filename, MODE="READ")
! Open the mesh file
CALL meshfile%OPEN()
! Initiate an instance of `Mesh_`
CALL obj%Initiate(hdf5=meshfile, dim=nsd)
CALL obj%DisplayMeshInfo("Mesh Info")
CALL meshfile%DEALLOCATE()
found(1) = obj%GetTotalNodes()
found(2) = obj%GetTotalNodes(meshid=1)
want(1) = 9
want(2) = 9
isok = found(1) .EQ. want(1)
CALL ok(isok, testname)
isok = found(2) .EQ. want(2)
CALL ok(isok, testname)
CALL obj%DEALLOCATE()
END PROGRAM main
! Mesh Info
! ==============================
! total nodes: 9
! total elements: 4
! tEdges: 0
! tFaces: 12
! ==============================
Example 2
!> author: Vikas Sharma, Ph. D.
! date: 2025-06-05
! summary: Test for `GetTotalNodes` method of `FEMesh_` class.
PROGRAM main
USE FEMesh_Class, ONLY: FEMesh_
USE HDF5File_Class, ONLY: HDF5File_
USE GlobalData, ONLY: I4B, LGT, Quadrangle
USE ReallocateUtility, ONLY: Reallocate
USE Display_Method, ONLY: Display
USE Test_Method
IMPLICIT NONE
TYPE(FEMesh_) :: obj
TYPE(HDF5File_) :: meshfile
CHARACTER(LEN=*), PARAMETER :: filename = "./meshdata/small_tri3_mesh.h5"
INTEGER(I4B), PARAMETER :: nsd = 2
INTEGER(I4B) :: found(8), want(8)
LOGICAL(LGT) :: isok
CHARACTER(*), PARAMETER :: testname = "GetTotalNodes"
! Initiate and open the mesh file which is in `HDF5File_` format.
CALL meshfile%Initiate(FileName=filename, MODE="READ")
! Open the mesh file
CALL meshfile%OPEN()
! Initiate an instance of `Mesh_`
CALL obj%Initiate(hdf5=meshfile, dim=nsd)
CALL obj%DisplayMeshInfo("Mesh Info")
CALL meshfile%DEALLOCATE()
found(1) = obj%GetTotalNodes()
found(2) = obj%GetTotalNodes(meshid=1)
want(1) = 12
want(2) = 12
isok = found(1) .EQ. want(1)
CALL ok(isok, testname)
isok = found(2) .EQ. want(2)
CALL ok(isok, testname)
CALL obj%DEALLOCATE()
END PROGRAM main
! Mesh Info
! ==============================
! total nodes: 12
! total elements: 14
! tEdges: 0
! tFaces: 25
! ==============================
Example 3
!> author: Vikas Sharma, Ph. D.
! date: 2025-06-05
! summary: Test for `GetTotalNodes` method of `FEMesh_` class.
PROGRAM main
USE FEMesh_Class, ONLY: FEMesh_
USE HDF5File_Class, ONLY: HDF5File_
USE GlobalData, ONLY: I4B, LGT, Quadrangle
USE ReallocateUtility, ONLY: Reallocate
USE Display_Method, ONLY: Display
USE Test_Method
IMPLICIT NONE
TYPE(FEMesh_) :: obj
TYPE(HDF5File_) :: meshfile
CHARACTER(LEN=*), PARAMETER :: filename = "./meshdata/small_tri6_mesh.h5"
INTEGER(I4B), PARAMETER :: nsd = 2
INTEGER(I4B) :: found(8), want(8)
LOGICAL(LGT) :: isok
CHARACTER(*), PARAMETER :: testname = "GetTotalNodes"
! Initiate and open the mesh file which is in `HDF5File_` format.
CALL meshfile%Initiate(FileName=filename, MODE="READ")
! Open the mesh file
CALL meshfile%OPEN()
! Initiate an instance of `Mesh_`
CALL obj%Initiate(hdf5=meshfile, dim=nsd)
CALL obj%DisplayMeshInfo("Mesh Info")
CALL meshfile%DEALLOCATE()
found(1) = obj%GetTotalNodes()
found(2) = obj%GetTotalNodes(meshid=1)
want(1) = 37
want(2) = 37
isok = found(1) .EQ. want(1)
CALL ok(isok, testname)
isok = found(2) .EQ. want(2)
CALL ok(isok, testname)
CALL obj%DEALLOCATE()
END PROGRAM main
! Mesh Info
! ==============================
! total nodes: 37
! total elements: 14
! tEdges: 0
! tFaces: 25
! ==============================