GetIndex
Get index of node number.
Calling example:
GetIndex(obj, nodenum)
Interface 1GetIndex(obj, nodenum, ivar)
Interface 2GetIndex(obj, nodenum, varname)
Interface 3GetIndex(obj, nodenum(:) )
Interface 4GetIndex(obj, nodenum(:), ivar)
Interface 5GetIndex(obj, nodenum(:), varname)
Interface 6GetIndex(obj, nodenum, ivar, idof)
Interface 7GetIndex(obj, nodenum(:), ivar, idof)
Interface 8GetIndex(obj, nodenum, ivar, spacecompo, timecompo)
Interface 9GetIndex(obj, nodenum(:), ivar, spacecompo, timecompo)
Interface 10
note
nodenum
should be lesser than the total number of nodes defined for dof number idof
.
info
idof
s are continuously numbered, so if there are two or more physical variables, then idof of the second or later physical variables does not start from 1.
What is an index
Index is a location of a nodal degree of freedom. For example, consider velocity
variable with 3 space and 2 time components. Now what is the location of velocity (space component 1, and time component 2) at node number 3. This location is called index.
Interface 1
INTERFACE
MODULE PURE FUNCTION GetIndex1(obj, nodenum) RESULT(ans)
CLASS(DOF_), INTENT(IN) :: obj
INTEGER(I4B), INTENT(IN) :: nodenum
INTEGER(I4B), ALLOCATABLE :: ans(:)
END FUNCTION GetIndex1
END INTERFACE
- This function returns indices, representing the location of all degrees of freedom define on a given node number.
- The size of these indices is equal to the total number of
DOF
in obj - In this way,
ans(ii)
represents the location ofii
dof
at node numbernodenum
- It is user's responsibility to ensure that for every physical variable the
nodenumber
is lesser than the total number of nodes defined for that physical variable. - The returned indices can be used to extract values from an instance of
RealVector
or Fortran vector.
note
The size of returned vector ans
will be the total number of degrees of freedom in the DOF
object.
Interface 2
INTERFACE
MODULE PURE FUNCTION GetIndex2(obj, nodenum, ivar) RESULT(ans)
CLASS(DOF_), INTENT(IN) :: obj
INTEGER(I4B), INTENT(IN) :: nodenum
INTEGER(I4B), INTENT(IN) :: ivar
INTEGER(I4B), ALLOCATABLE :: ans(:)
END FUNCTION GetIndex2
END INTERFACE
- This function returns indices, representing the locations of all the degrees of freedom of a given physical variable
ivar
at a given node numbernodenum
- The physical variable is defined by
ivar
- The size of these indices is equal to the total number of DOF defined for the
ivar
physical variable. - It is user's responsibility to ensure that for the selected physical var the
nodenum
is lesser than the total number of nodes defined for that physical variable.
Interface 3
INTERFACE
MODULE PURE FUNCTION GetIndex3(obj, nodenum, varname) RESULT(ans)
CLASS(DOF_), INTENT(IN) :: obj
INTEGER(I4B), INTENT(IN) :: nodenum
CHARACTER(1), INTENT(IN) :: varname
INTEGER(I4B), ALLOCATABLE :: ans(:)
END FUNCTION GetIndex3
END INTERFACE
Same as Interface 2, but physical variable is selected by it name.
Interface 4
INTERFACE
MODULE PURE FUNCTION GetIndex4(obj, nodenum) RESULT(ans)
CLASS(DOF_), INTENT(IN) :: obj
INTEGER(I4B), INTENT(IN) :: nodenum(:)
INTEGER(I4B), ALLOCATABLE :: ans(:)
END FUNCTION GetIndex4
END INTERFACE
- This function returns indices, representing the location of all the degrees of freedom defined at node numbers specified by nodenum.
- The size of these indices is equal to the total number of DOF in obj times the size of
nodenum(:)
.
Interface 5
INTERFACE
MODULE PURE FUNCTION GetIndex5(obj, nodenum, ivar) RESULT(ans)
CLASS(DOF_), INTENT(IN) :: obj
INTEGER(I4B), INTENT(IN) :: nodenum(:)
INTEGER(I4B), INTENT(IN) :: ivar
INTEGER(I4B), ALLOCATABLE :: ans(:)
END FUNCTION GetIndex5
END INTERFACE
- This function returns indices, representing the location of all the degrees of freedom of physical variable given by
ivar
, at nodes given innodenum
. - The physical variable is defined by
ivar
- The size of these indices is equal to the total number of
DOF
defined for theivar
physical variable times the size ofnodenum
.
Interface 6
INTERFACE
MODULE PURE FUNCTION GetIndex6(obj, nodenum, varname) RESULT(ans)
CLASS(DOF_), INTENT(IN) :: obj
INTEGER(I4B), INTENT(IN) :: nodenum(:)
CHARACTER(1), INTENT(IN) :: varname
INTEGER(I4B), ALLOCATABLE :: ans(:)
END FUNCTION GetIndex6
END INTERFACE
- This function returns a vector of integers (indices) for a given node number and a given physical Variable.
- The physical variable is defined by
varname
- The size of these indices is equal to the total number of DOF defined for the
varname
physical variable. - The returned indices represent the degrees of freedom of physical variable
varname
defined on each node. - It is user's responsibility to ensure that for the selected physical var the
nodenumber
is lesser than the total number of nodes defined for that physical variable. - The returned indices can be used for getting the dof (all dof) defined on the nodenum for the given physical variable.
- The returned indices can be used to extract values from an instance of RealVector or fortran vector of real numbers.
Interface 7
INTERFACE GetIndex
MODULE PROCEDURE dof_getNodeLoc5
END INTERFACE GetIndex
Interface 8
INTERFACE GetIndex
MODULE PROCEDURE dof_getNodeLoc6
END INTERFACE GetIndex
Interface 9
INTERFACE GetIndex
MODULE PROCEDURE dof_getNodeLoc7
END INTERFACE GetIndex
Interface 10
INTERFACE GetIndex
MODULE PROCEDURE dof_getNodeLoc8
END INTERFACE GetIndex
Examples
See examples
PROGRAM main
USE GlobalData
USE BaseType, ONLY: DOF_
USE DOF_Method
USE Test_Method
IMPLICIT NONE
TYPE(DOF_) :: obj
INTEGER(I4B), ALLOCATABLE :: indx(:)
! Initiate an instance of[DOF_] (DOF_.md)
CALL Initiate(obj, tNodes=[10, 10], &
names=["V", "P"], spaceCompo=[3, 1], &
timeCompo=[1, 1], storageFMT=FMT_NODES)
! GetIndex
indx = GetIndex(obj, nodeNum=1)
CALL OK(ALL(indx .EQ. [1, 2, 3, 4]), "indx .EQ. [1,2,3,4]:")
indx = GetIndex(obj, nodeNum=5)
CALL OK(ALL(indx .EQ. [17, 18, 19, 20]), "indx .EQ. [17,18,19,20]")
indx = GetIndex(obj, nodeNum=1, iVar=1)
CALL OK(ALL(indx .EQ. [1, 2, 3]), "indx .Eq. [1,2,3]")
indx = GetIndex(obj, nodeNum=1, varName="V")
CALL OK(ALL(indx .EQ. [1, 2, 3]), "indx .Eq. [1,2,3]")
indx = GetIndex(obj, nodeNum=1, iVar=2)
CALL OK(ALL(indx .EQ. [4]), "indx .Eq. [4]")
indx = GetIndex(obj, nodeNum=1, varName="P")
CALL OK(ALL(indx .EQ. [4]), "indx .Eq. [4]")
indx = GetIndex(obj, nodeNum=2, iVar=1)
CALL OK(ALL(indx .EQ. [5, 6, 7]), "indx .Eq. [5,6,7]")
indx = GetIndex(obj, nodeNum=2, iVar=2)
CALL OK(ALL(indx .EQ. [8]), "indx .Eq. [8]")
indx = GetIndex(obj, nodeNum=[1, 2], iVar=1)
CALL OK(ALL(indx .EQ. [1, 2, 3, 5, 6, 7]), "indx .Eq. [1,2,3,5,6,7]")
indx = [GetIndex(obj, nodeNum=1, iVar=1, idof=1)]
CALL OK(ALL(indx .EQ. [1]), "indx .Eq. [1]")
indx = [GetIndex(obj, nodeNum=1, iVar=1, idof=2)]
CALL OK(ALL(indx .EQ. [2]), "indx .Eq. [2]")
indx = [GetIndex(obj, nodeNum=1, iVar=1, idof=3)]
CALL OK(ALL(indx .EQ. [3]), "indx .Eq. [3]")
indx = [GetIndex(obj, nodeNum=2, iVar=1, idof=1)]
CALL OK(ALL(indx .EQ. [5]), "indx .Eq. [5]")
indx = [GetIndex(obj, nodeNum=2, iVar=1, idof=2)]
CALL OK(ALL(indx .EQ. [6]), "indx .Eq. [6]")
indx = [GetIndex(obj, nodeNum=2, iVar=1, idof=3)]
CALL OK(ALL(indx .EQ. [7]), "indx .Eq. [7]")
CALL DEALLOCATE (obj)
END PROGRAM main