Skip to main content

GetConnectivity

The GetConnectivity method returns the global degrees of freedom (DOFs) associated with a specified element in the mesh. This connectivity information is essential for assembling local element matrices and vectors into the global system during finite element analysis.

Interface

INTERFACE
MODULE FUNCTION GetConnectivity(obj, opt, globalElement, islocal) RESULT(ans)
CLASS(FEDOF_), INTENT(INOUT) :: obj
CHARACTER(*), INTENT(IN) :: opt
INTEGER(I4B), INTENT(IN) :: globalElement
LOGICAL(LGT), OPTIONAL, INTENT(IN) :: islocal
INTEGER(I4B), ALLOCATABLE :: ans(:)
END FUNCTION GetConnectivity
END INTERFACE

Parameters

  • obj - The FEDOF_ object containing degree of freedom information
  • opt - A string specifying which type of connectivity to retrieve:
    • "Vertex" - Only vertex DOFs
    • "Edge" - Only edge DOFs
    • "Face" - Only face DOFs
    • "Cell" - Only cell DOFs
    • "All" - All DOFs (vertices, edges, faces, and cells)
  • globalElement - The global or local element number, depending on the value of islocal
  • islocal - Optional logical flag. If present and .TRUE., globalElement is interpreted as a local element number; otherwise, it's a global element number

Return Value

  • ans - An allocatable array containing the global DOF numbers associated with the specified element, filtered according to the opt parameter

Implementation Details

The function:

  1. Determines the total number of DOFs for the element using obj%GetTotalDOF
  2. Allocates the return array with the appropriate size
  3. Calls the obj%GetConnectivity_ subroutine to populate the array with the actual connectivity data

The key steps in the implementation are:

tdof = obj%GetTotalDOF(globalElement=globalElement, isLocal=isLocal)
ALLOCATE (ans(tdof))
CALL obj%GetConnectivity_(ans=ans, tsize=tdof, opt=opt,
globalElement = globalElement, islocal = islocal)

The underlying GetConnectivity_ subroutine performs the actual work of gathering the connectivity data by:

  1. Getting the element's topological entities (vertices, edges, faces, and cells)
  2. Retrieving the DOFs for each entity using the appropriate methods (GetVertexDOF, GetEdgeDOF, etc.)
  3. Combining these DOFs into a single connectivity array

Notes

  • For Lagrangian elements (obj%isLagrange is .TRUE.), only vertex DOFs are considered, regardless of the opt parameter
  • For hierarchical elements, the connectivity includes all specified entity types (vertices, edges, faces, cells)
  • The connectivity array contains global DOF numbers that map the local element DOFs to the global system
  • The order of DOFs in the returned array follows a hierarchical pattern: vertices first, then edges, faces, and finally cell DOFs
  • This method is crucial for element assembly operations in finite element analysis

Example

!> author: Vikas Sharma, Ph. D.
! date: 2025-06-07
! summary: Testing GetConnectivity method of FEDOF class
! H1 Heirarchical Second Order Triangular Mesh

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

IMPLICIT NONE

CHARACTER(*), PARAMETER :: &
filename = "../../FEMesh/examples/meshdata/small_tri3_mesh.h5", &
baseContinuity = "H1", &
baseInterpolation = "Heirarchical", &
testname = baseContinuity // " " // baseInterpolation

TYPE(FEDOF_) :: fedof
TYPE(FEDomain_) :: dom
CLASS(AbstractMesh_), POINTER :: meshptr => NULL()
TYPE(HDF5File_) :: meshfile
INTEGER(I4B), ALLOCATABLE :: found(:), want(:)
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), ALLOCATABLE :: globalNode(:)
INTEGER(I4B) :: ent(4), tVertices

order = 1
CALL fedof%Initiate(baseContinuity=baseContinuity, &
baseInterpolation=baseInterpolation, &
order=order, mesh=meshptr)

tVertices = meshptr%GetTotalVertexNodes(globalElement=[1], islocal=.TRUE.)

ent = meshptr%GetTotalEntities(globalElement=1, islocal=.TRUE.)

! Get all connectivity for local element 1
found = fedof%GetConnectivity(opt="A", globalElement=1, islocal=.TRUE.)

globalNode = meshptr%GetConnectivity(globalElement=1, islocal=.TRUE.)

want = meshptr%GetLocalNodenumber( &
globalNode=globalNode(1:tVertices), islocal=.FALSE.)

isok = ALL(found == want)
CALL OK(isok, testname // " GetConnectivity (order= "//ToString(order)//"): ")

END SUBROUTINE test1

!----------------------------------------------------------------------------
! test2
!----------------------------------------------------------------------------

SUBROUTINE test2
INTEGER(I4B), ALLOCATABLE :: globalNode(:), temp1(:)
INTEGER(I4B) :: ent(4), a, b, tVertices

order = 2
CALL fedof%Initiate(baseContinuity=baseContinuity, &
baseInterpolation=baseInterpolation, &
order=order, mesh=meshptr)

found = fedof%GetConnectivity(opt="A", globalElement=1, islocal=.TRUE.)
globalNode = meshptr%GetConnectivity(globalElement=1, islocal=.TRUE.)
tVertices = meshptr%GetTotalVertexNodes(globalElement=[1], islocal=.TRUE.)

want = meshptr%GetLocalNodenumber(globalNode=globalNode(1:tVertices), &
islocal=.FALSE.)
a = meshptr%GetTotalVertexNodes() + 1
ent = meshptr%GetTotalEntities(globalElement=1, islocal=.TRUE.)

b = meshptr%GetTotalVertexNodes() + ent(3) * (order - 1)
temp1 = Arange(a, b)

want = want.APPEND.temp1

isok = ALL(found == want)

CALL OK(isok, testname // " GetConnectivity (order= "//ToString(order)//"): ")

END SUBROUTINE test2

!----------------------------------------------------------------------------
! test3
!----------------------------------------------------------------------------

SUBROUTINE test3
INTEGER(I4B), ALLOCATABLE :: globalNode(:), temp1(:)
INTEGER(I4B) :: ent(4), a, b, tVertices

order = 3
CALL fedof%Initiate(baseContinuity=baseContinuity, &
baseInterpolation=baseInterpolation, &
order=order, mesh=meshptr)

found = fedof%GetConnectivity(opt="A", globalElement=1, islocal=.TRUE.)

globalNode = meshptr%GetConnectivity(globalElement=1, islocal=.TRUE.)

tVertices = meshptr%GetTotalVertexNodes(globalElement=[1], islocal=.TRUE.)

want = meshptr%GetLocalNodenumber( &
globalNode=globalNode(1:tVertices), islocal=.FALSE.)

ent = meshptr%GetTotalEntities(globalElement=1, islocal=.TRUE.)

a = totalVertexNodes + 1
b = a - 1 + ent(3) * (order - 1)

temp1 = Arange(a, b)

want = want.APPEND.temp1

a = totalVertexNodes + totalFaces * (order - 1) + 1
b = a - 1 + ent(4) * (order - 2) * (order - 1) * 0.5

temp1 = Arange(a, b)
want = want.APPEND.temp1

isok = ALL(found == want)

CALL OK(isok, testname // " GetConnectivity (order= "//ToString(order)//"): ")
END SUBROUTINE test3

END PROGRAM main