GetElementToElements
This method is inherited from the AbstractMesh class.
GetElementToElements
Retrieves information about elements that are connected to a specified element.
Interface
MODULE PURE FUNCTION getElementToElements(obj, globalElement, &
onlyElements) RESULT(ans)
CLASS(Mesh_), INTENT(IN) :: obj
!! mesh data
INTEGER(I4B), INTENT(IN) :: globalElement
!! Global element number
LOGICAL(LGT), OPTIONAL, INTENT(IN) :: onlyElements
!! If onlyElements is absent or it is FALSE then full information
!! about the elements connected to element iel is given
!! If onlyElements is present and it is TRUE then only the
!! information about the elements connected to element iel is given
INTEGER(I4B), ALLOCATABLE :: ans(:, :)
!! list of elements surrounding elements
END FUNCTION getElementToElements
Arguments
obj
(AbstractMesh_, input): The mesh object.globalElement
(INTEGER, input): The global (or local) element number.onlyElements
(LOGICAL, optional, input): If present and true, only the element numbers are returned. If absent or false, full connection information is returned.islocal
(LOGICAL, optional, input): If present and true,globalElement
is treated as local. Default is false.
Returns
ans
(INTEGER array): A 2D array containing element connection information.- If
onlyElements
is true,ans
is an Nx1 array where each row contains a connected element number. - If
onlyElements
is false,ans
is an Nx3 array where:- Column 1: Global element number of the neighbor
- Column 2: Local face number of the specified element
- Column 3: Local face number of the neighbor element
- If
Description
This function returns information about elements that share a face with the specified element. It can return either just the element numbers or detailed face connection information.
Example
! Get only element numbers connected to element 10
INTEGER(I4B), ALLOCATABLE :: connectedElems(:, :)
connectedElems = mesh%GetElementToElements(10, onlyElements=.TRUE.)
! Get full connection information for element 10
connectedElems = mesh%GetElementToElements(10)
! connectedElems(i,1) = connected element number
! connectedElems(i,2) = local face number in element 10
! connectedElems(i,3) = local face number in connected element
Examples
Example 1
This example shows how to get the element to element connectivity data in the mesh.
PROGRAM main
USE easifemBase
USE easifemClasses
IMPLICIT NONE
TYPE( FEMesh_ ) :: obj
TYPE( HDF5File_ ) :: meshfile
INTEGER( I4B ), ALLOCATABLE :: nptrs( :, : )
CHARACTER(*), PARAMETER :: filename="../../Mesh/examples/meshdata/small_mesh.h5"
! Initiate and open the mesh file which is in [[HDF5File_]] format. Then, create an instance of mesh.
CALL meshfile%Initiate(filename, "READ" )
CALL meshfile%Open()
CALL obj%Initiate(hdf5=meshfile, group="/surfaceEntities_1" )
Now we get the full information about the element connected to the given global element numbers.
In this case we set onlyElements=.FALSE.
,
or you can ignore this argument as it is optional, with default value of .FALSE.
.
nptrs = obj%GetElementToElements( globalElement=23, onlyElements=.FALSE. )
CALL Display( nptrs, "Element connected to iel=23")
We get the following output.
Element connected to iel=23
---------------------------
22 1 2
26 2 3
25 3 1
- The first column is the global element number of neighbour.
- The second column is the local facet number of the parent (iel=23)
- The third column is the local facet number of neighbour
If you only want the global element numbers of the neighbours, then you can set onlyElements=.TRUE.
nptrs = obj%GetElementToElements( globalElement=23, onlyElements=.TRUE. )
CALL Display( nptrs, "Element connected to iel=23")
Now we get the full information about the element connected to the given global element numbers.
Element connected to iel=23
---------------------------
22
26
25
CALL obj%Deallocate()
CALL meshfile%Close()
CALL meshfile%Deallocate()
END PROGRAM main