cubature Derived Type

type, public :: cubature

Abscissae and weights of an integration rule on a reference element.

Create with the constructor, q = cubature(CUB_HEX, 3), or in place with call q%set(CUB_HEX, 3). Integrate with sum(q%weights * f(q%abscissae)) or a loop over q%npoints.


Components

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

Element type, CUB_*

integer, public :: dim = 0

Spatial dimension

integer, public :: degree(3) = 0

Degree of exactness, see module documentation

integer, public :: npoints = 0

Number of points

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

Abscissae, shape [dim, npoints]

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

Weights, shape [npoints]


Constructor

public interface cubature

Construct a rule, e.g. cubature(CUB_TRI, 4) or cubature(CUB_HEX, [3, 3, 1])

  • private pure function new_iso(elm, degree) result(self)

    Construct a rule of degree degree in every direction

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in) :: elm

    Element type, CUB_*

    integer, intent(in) :: degree

    Degree of exactness

    Return Value type(cubature)

  • private pure function new_aniso(elm, degree) result(self)

    Construct a rule with per-direction degrees

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in) :: elm

    Element type, CUB_*

    integer, intent(in) :: degree(:)

    Degrees of exactness, size 1 or number of directions

    Return Value type(cubature)


Type-Bound Procedures

generic, public :: set => set_iso, set_aniso

Build the rule in place

  • private pure subroutine set_iso(self, elm, degree)

    Build a rule of degree degree in every direction

    Arguments

    Type IntentOptional Attributes Name
    class(cubature), intent(inout) :: self
    integer, intent(in) :: elm

    Element type, CUB_*

    integer, intent(in) :: degree

    Degree of exactness

  • private pure subroutine set_aniso(self, elm, degree)

    Build a rule with per-direction degrees.

    degree has size 1 (same degree in every direction) or ndegrees(elm): 1 for CUB_LIN, CUB_TRI, CUB_TET; 2 for CUB_QUA, CUB_WED (triangle, axial); 3 for CUB_HEX. Stops on invalid input.

    Arguments

    Type IntentOptional Attributes Name
    class(cubature), intent(inout) :: self
    integer, intent(in) :: elm

    Element type, CUB_*

    integer, intent(in) :: degree(:)

    Degrees of exactness

procedure, public :: is_valid

True if the rule is set and consistent

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

    True if the rule is set and its arrays are consistent

    Arguments

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

    Return Value logical

procedure, public :: summary

Write element, dimension, degrees, points

  • private subroutine summary(self, unit)

    Write element type, dimension, degrees and number of points

    Arguments

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

    Output unit, default output_unit

procedure, public :: show

Write the summary, points and weights

  • private subroutine show(self, unit)

    Write the summary, every abscissa and weight, and the weight sum

    Arguments

    Type IntentOptional Attributes Name
    class(cubature), 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(cubature), intent(inout) :: self

Source Code

  type :: cubature
    !! Abscissae and weights of an integration rule on a reference element.
    !!
    !! Create with the constructor, `q = cubature(CUB_HEX, 3)`, or in place
    !! with `call q%set(CUB_HEX, 3)`. Integrate with
    !! `sum(q%weights * f(q%abscissae))` or a loop over `q%npoints`.

    integer :: elm = 0                        !! Element type, `CUB_*`
    integer :: dim = 0                        !! Spatial dimension
    integer :: degree(3) = 0                  !! Degree of exactness, see module documentation
    integer :: npoints = 0                    !! Number of points
    real(rk), allocatable :: abscissae(:,:)   !! Abscissae, shape `[dim, npoints]`
    real(rk), allocatable :: weights(:)       !! Weights, shape `[npoints]`

  contains

    generic :: set => set_iso, set_aniso      !! Build the rule in place
    procedure, private :: set_iso
    procedure, private :: set_aniso
    procedure :: is_valid                     !! True if the rule is set and consistent
    procedure :: summary                      !! Write element, dimension, degrees, points
    procedure :: show                         !! Write the summary, points and weights
    procedure :: destroy                      !! Deallocate and reset

  end type cubature