shapefunc Derived Type

type, public :: shapefunc

Shape functions and derivatives of one element type and order at the points of a cubature.

Create with the constructor, s = shapefunc(q, 2), or in place with call s%set(q, 2), where q is a cubature. Optional arguments flag infinite directions (infin), choose serendipity elements (family) and set the node ordering (nodes).


Components

Type Visibility Attributes Name Initial
integer, public :: elm = 0

Element type, CUB_*

integer, public :: dim = 0

Spatial dimension

integer, public :: order = 0

Polynomial order

integer, public :: family = SHP_LAGRANGE

SHP_LAGRANGE or SHP_SERENDIPITY

integer, public :: nnodes = 0

Number of nodes

integer, public :: npoints = 0

Number of cubature points

integer, public :: infin(3) = SHP_FIN

Infinitude per direction, SHP_*

integer, public, allocatable :: lattice(:,:)

Lattice indices, shape [nfactors, nnodes], see module documentation

real(kind=rk), public, allocatable :: coords(:,:)

Nodal coordinates, shape [dim, nnodes]

real(kind=rk), public, allocatable :: func(:,:)

Values , shape [nnodes, npoints]

real(kind=rk), public, allocatable :: derv(:,:,:)

First derivatives , shape [dim, nnodes, npoints]

real(kind=rk), public, allocatable :: curv(:,:,:,:)

Second derivatives , shape [dim, dim, nnodes, npoints]


Constructor

public interface shapefunc

Construct shape functions, e.g. shapefunc(q, 2), shapefunc(q, 1, [SHP_FIN, SHP_INF]) or shapefunc(q, 2, family=SHP_SERENDIPITY, nodes=perm)

  • private pure function new_shapefunc(q, order, infin, family, nodes) result(self)

    Construct shape functions of order order at the points of q; see set

    Arguments

    Type IntentOptional Attributes Name
    type(cubature), intent(in) :: q

    Cubature on the reference element

    integer, intent(in) :: order

    Polynomial order

    integer, intent(in), optional :: infin(:)

    Infinitude, SHP_FIN, SHP_INF or SHP_CHP, size 1 or q%dim

    integer, intent(in), optional :: family

    SHP_LAGRANGE (default) or SHP_SERENDIPITY

    integer, intent(in), optional :: nodes(:)

    Node ordering: nodes(k) is the default number of node k

    Return Value type(shapefunc)


Type-Bound Procedures

procedure, public :: set

Build the shape functions in place

  • private pure subroutine set(self, q, order, infin, family, nodes)

    Build shape functions of order order at the points of q.

    infin has size 1 (same in every direction) or q%dim, and defaults to SHP_FIN. SHP_INF and SHP_CHP are allowed along the directions of lines, quadrilaterals and hexahedra, and along the axial direction 3 of wedges, with order .

    family SHP_SERENDIPITY selects the serendipity quadrilaterals and hexahedra of orders 1 to 3 (4, 8, 12 and 8, 20, 32 nodes), which must be finite.

    nodes is a permutation of 1:nnodes: the caller's node k is node nodes(k) of the default numbering. All outputs then follow the caller's numbering.

    Stops on invalid input.

    Arguments

    Type IntentOptional Attributes Name
    class(shapefunc), intent(inout) :: self
    type(cubature), intent(in) :: q

    Cubature on the reference element

    integer, intent(in) :: order

    Polynomial order

    integer, intent(in), optional :: infin(:)

    Infinitude, SHP_FIN, SHP_INF or SHP_CHP, size 1 or q%dim

    integer, intent(in), optional :: family

    SHP_LAGRANGE (default) or SHP_SERENDIPITY

    integer, intent(in), optional :: nodes(:)

    Node ordering: nodes(k) is the default number of node k

procedure, public :: eval

Evaluate at any point of the reference element

  • private pure subroutine eval(self, xi, func, derv, curv)

    Evaluate the shape functions and their derivatives at any point xi of the reference element. The element must be set. Infinite directions are singular at .

    Arguments

    Type IntentOptional Attributes Name
    class(shapefunc), intent(in) :: self
    real(kind=rk), intent(in) :: xi(:)

    Point, size dim

    real(kind=rk), intent(out) :: func(self%nnodes)

    Values

    real(kind=rk), intent(out) :: derv(self%dim,self%nnodes)

    real(kind=rk), intent(out) :: curv(self%dim,self%dim,self%nnodes)

procedure, public :: is_valid

True if set and consistent

  • private pure function is_valid(self) result(ok)

    True if the shape functions are set and their arrays are consistent

    Arguments

    Type IntentOptional Attributes Name
    class(shapefunc), intent(in) :: self

    Return Value logical

procedure, public :: summary

Write element, order, family, infinitude, nodes, points

  • private subroutine summary(self, unit)

    Write element type, dimension, order, infinitude and numbers of nodes and points

    Arguments

    Type IntentOptional Attributes Name
    class(shapefunc), intent(in) :: self
    integer, intent(in), optional :: unit

    Output unit, default output_unit

procedure, public :: show

Write the summary, values and first derivatives

  • private subroutine show(self, unit)

    Write the summary, then for every point and node the value and first derivatives, and per point the sums over the nodes

    Arguments

    Type IntentOptional Attributes Name
    class(shapefunc), intent(in) :: self
    integer, intent(in), optional :: unit

    Output unit, default output_unit

procedure, public :: numbering

Write the summary and the nodal coordinates

  • private subroutine numbering(self, unit)

    Write the node numbers and nodal coordinates

    Arguments

    Type IntentOptional Attributes Name
    class(shapefunc), intent(in) :: self
    integer, intent(in), optional :: unit

    Output unit, default output_unit

procedure, public :: destroy

Deallocate and reset

  • private pure subroutine destroy(self)

    Deallocate and reset to the unset state

    Arguments

    Type IntentOptional Attributes Name
    class(shapefunc), intent(inout) :: self

Source Code

  type :: shapefunc
    !! Shape functions and derivatives of one element type and order at
    !! the points of a cubature.
    !!
    !! Create with the constructor, `s = shapefunc(q, 2)`, or in place with
    !! `call s%set(q, 2)`, where `q` is a `cubature`. Optional arguments
    !! flag infinite directions (`infin`), choose serendipity elements
    !! (`family`) and set the node ordering (`nodes`).

    integer :: elm = 0                          !! Element type, `CUB_*`
    integer :: dim = 0                          !! Spatial dimension
    integer :: order = 0                        !! Polynomial order
    integer :: family = SHP_LAGRANGE            !! `SHP_LAGRANGE` or `SHP_SERENDIPITY`
    integer :: nnodes = 0                       !! Number of nodes
    integer :: npoints = 0                      !! Number of cubature points
    integer :: infin(3) = SHP_FIN               !! Infinitude per direction, `SHP_*`
    integer, allocatable :: lattice(:,:)        !! Lattice indices, shape `[nfactors, nnodes]`, see module documentation
    real(rk), allocatable :: coords(:,:)        !! Nodal coordinates, shape `[dim, nnodes]`
    real(rk), allocatable :: func(:,:)          !! Values \(N_i\), shape `[nnodes, npoints]`
    real(rk), allocatable :: derv(:,:,:)        !! First derivatives \(\partial N_i/\partial\xi_j\), shape `[dim, nnodes, npoints]`
    real(rk), allocatable :: curv(:,:,:,:)      !! Second derivatives \(\partial^2 N_i/\partial\xi_j\partial\xi_k\),
                                                !! shape `[dim, dim, nnodes, npoints]`

    integer, private :: nfactors = 0            ! Number of factor coordinates
    integer, private :: kinds(4) = 0            ! 1D function family per factor, `SHP_*` or `SIMPLEX`
    real(rk), private :: s0(4) = 0              ! Factor coordinates at \(\xi = 0\)
    real(rk), private :: dsdxi(4,3) = 0         ! Constant \(\partial s_k/\partial\xi_j\)
    integer, allocatable, private :: basis(:,:) ! Lattice of the product functions evaluated by `eval`
    real(rk), allocatable, private :: trans(:,:) ! Serendipity functions from product functions, `[nnodes, size(basis,2)]`

  contains

    procedure :: set                          !! Build the shape functions in place
    procedure :: eval                         !! Evaluate at any point of the reference element
    procedure :: is_valid                     !! True if set and consistent
    procedure :: summary                      !! Write element, order, family, infinitude, nodes, points
    procedure :: show                         !! Write the summary, values and first derivatives
    procedure :: numbering                    !! Write the summary and the nodal coordinates
    procedure :: destroy                      !! Deallocate and reset

  end type shapefunc