matrix_term_abstract_class Module

Houses abstract matrix term with default interface


Used by


Interfaces

interface

  • private pure module function getNormalizationConst(this) result(norm)

    Getter for normalizationConst

    Arguments

    Type IntentOptional Attributes Name
    class(MatrixTerm), intent(in) :: this

    Return Value real(kind=rk)

interface

  • private pure module function evaluateMatTerm(this, varCont) result(res)

    Get explicit value for the term by crudely dotting each sparse row with the locally stored implicit variable vector in varCont

    Arguments

    Type IntentOptional Attributes Name
    class(MatrixTerm), intent(in) :: this
    type(VariableContainer), intent(in) :: varCont

    Return Value real(kind=rk), allocatable, dimension(:)

interface

  • private pure module function getMultConst(this) result(multConst)

    Getter for multConst

    Arguments

    Type IntentOptional Attributes Name
    class(MatrixTerm), intent(in) :: this

    Return Value type(RealArray), allocatable, dimension(:)

interface

  • private pure module function getRowVarName(this) result(name)

    Get name of the evolved variable of this term

    Arguments

    Type IntentOptional Attributes Name
    class(MatrixTerm), intent(in) :: this

    Return Value character(len=:), allocatable

interface

interface

  • private pure module function getRowData(this) result(rowData)

    Getter for rowData

    Arguments

    Type IntentOptional Attributes Name
    class(MatrixTerm), intent(in) :: this

    Return Value type(SparseRowData)

interface

  • private pure module subroutine unityRow(this, varCont, rowVals, indexingData)

    Default row function. In general should use the passed variable container, row buffer, and matrix indexing data to provide values which is only a function of the row

    Arguments

    Type IntentOptional Attributes Name
    class(MatrixTerm), intent(inout) :: this
    type(VariableContainer), intent(in) :: varCont
    real(kind=rk), intent(inout), dimension(:) :: rowVals
    type(MatrixTermIndexingData), intent(in) :: indexingData

interface

  • private pure module subroutine unityCol(this, varCont, colVals, indexingData)

    Default column function. In general should provide values for each column

    Arguments

    Type IntentOptional Attributes Name
    class(MatrixTerm), intent(inout) :: this
    type(VariableContainer), intent(in) :: varCont
    type(RealArray), intent(inout), dimension(:) :: colVals
    type(MatrixTermIndexingData), intent(in) :: indexingData

interface

  • private pure module subroutine calculateValues(this, varCont)

    Default matrix entry calculation routine - loops over each row and applies rowFun and colFun to variables in provided container

    Arguments

    Type IntentOptional Attributes Name
    class(MatrixTerm), intent(inout) :: this
    type(VariableContainer), intent(in) :: varCont

interface

  • private pure module subroutine setNormalizationConst(this, norm)

    Setter for normalizationConst

    Arguments

    Type IntentOptional Attributes Name
    class(MatrixTerm), intent(inout) :: this
    real(kind=rk), intent(in) :: norm

interface

  • private pure module subroutine setReqVars(this, rowReqVars, colReqVars, varCont)

    Set variable names required by the row and column functions and find their indices in variable container

    Arguments

    Type IntentOptional Attributes Name
    class(MatrixTerm), intent(inout) :: this
    type(StringArray), intent(in), dimension(:) :: rowReqVars
    type(StringArray), intent(in), dimension(:) :: colReqVars
    type(VariableContainer), intent(in) :: varCont

interface

  • private pure module subroutine setEvolvedAndImplicitVar(this, rowVarName, colVarName, varCont)

    Set evolved (row) and implicit (column) variable names, and check if evolved variable is stationary using varCont

    Arguments

    Type IntentOptional Attributes Name
    class(MatrixTerm), intent(inout) :: this
    character(len=*), intent(in) :: rowVarName
    character(len=*), intent(in) :: colVarName
    type(VariableContainer), intent(in) :: varCont

interface

  • private module subroutine initRowData(this, rowCoords, rowToColMapping, indexingObj)

    Initialize row data objects based on a set of evolved global coordinates, the row/col var name, and a function that returns column coordinates given a row coordinate input. Requires a reference Indexing object.

    Arguments

    Type IntentOptional Attributes Name
    class(MatrixTerm), intent(inout) :: this
    integer(kind=ik), intent(in), dimension(:,:) :: rowCoords
    procedure(coordMapping) :: rowToColMapping
    type(Indexing), intent(in) :: indexingObj

interface

  • private module subroutine addRowDataToPreallocationData(this, petscPreallocData)

    Add this term's row data to a PETSc preallocation object

    Arguments

    Type IntentOptional Attributes Name
    class(MatrixTerm), intent(inout) :: this
    type(PETScPreallocationData), intent(inout) :: petscPreallocData

interface

  • private module subroutine addRowDataPatternToController(this, petscCont)

    Add this term's row data to a petsc preallocation object in PETSc controller

    Arguments

    Type IntentOptional Attributes Name
    class(MatrixTerm), intent(in) :: this
    type(PETScController), intent(inout) :: petscCont

interface

  • private module subroutine addRowValuesToPETScMatrix(this, petscCont, mult, petscGroup)

    Add this term's row values to a petsc matrix object in PETSc controller, multiplied by mult. If evolved variable is stationary mult is ignored and set to -1

    Arguments

    Type IntentOptional Attributes Name
    class(MatrixTerm), intent(in) :: this
    type(PETScController), intent(inout) :: petscCont
    real(kind=rk), intent(in) :: mult
    integer(kind=ik), intent(in), optional :: petscGroup

interface

  • private pure module subroutine setMultConst(this, multConst)

    Setter for multConst

    Arguments

    Type IntentOptional Attributes Name
    class(MatrixTerm), intent(inout) :: this
    type(RealArray), intent(in), dimension(:) :: multConst

interface

  • private pure module subroutine setFixedMatrix(this, isFixed)

    Set whether the matrix is fixed -> only calculated once

    Arguments

    Type IntentOptional Attributes Name
    class(MatrixTerm), intent(inout) :: this
    logical, intent(in) :: isFixed

interface

  • private pure module subroutine setNonTrivialRowFun(this, nontriv)

    Set whether the matrix has a non-trivial row function

    Arguments

    Type IntentOptional Attributes Name
    class(MatrixTerm), intent(inout) :: this
    logical, intent(in) :: nontriv

interface

  • private pure module subroutine setNonTrivialColFun(this, nontriv)

    Set whether the matrix has a non-trivial col function

    Arguments

    Type IntentOptional Attributes Name
    class(MatrixTerm), intent(inout) :: this
    logical, intent(in) :: nontriv

interface

  • private module subroutine matTermUpdate(this, varCont, modelData, hostModel)

    Default matrix term update, call matrixTermUpdate

    Arguments

    Type IntentOptional Attributes Name
    class(MatrixTerm), intent(inout) :: this
    type(VariableContainer), intent(in) :: varCont
    class(ModelboundData), intent(in), optional :: modelData
    class(ModelSurrogate), intent(in), optional :: hostModel

interface


Derived Types

type, public ::  DataCoords

Data type used to store global coordinates of any given matrix row

Components

Type Visibility Attributes Name Initial
integer(kind=ik), public, allocatable, dimension(:) :: rowCoords

Size 1 or 3 array depending on whether the evolved variable is a distribution

integer(kind=ik), public, allocatable, dimension(:,:) :: colCoords

Size (1,:) or (3,:) depending on whether the implicit variable is a distribution - the second dimension has the size of the column vector corresponding to given row of matrix

type, public ::  MatrixTermIndexingData

Indexing data used by the matrix term

Components

Type Visibility Attributes Name Initial
type(DataCoords), public, allocatable, dimension(:) :: rowDataCoordsGlobal

Global coordinates of each row in matrix

type(DataCoords), public, allocatable, dimension(:) :: rowDataCoordsLocal

Local coordinates of each row in matrix (unflattened)

integer(kind=ik), public, allocatable, dimension(:) :: localRowIndices

Local row indices corresponding to stored evolved variable (flattened)

type(IntArray), public, allocatable, dimension(:) :: localColIndices

Local col indices corresponding to stored implicit variable (flattened)

integer(kind=ik), public, allocatable, dimension(:) :: rowReqVarIndices

Indices of variables entering the matrix as a function of the row coordinates

integer(kind=ik), public, allocatable, dimension(:) :: colReqVarIndices

Indices of variables entering the matrix as s function of the column coordinates

character(len=:), public, allocatable :: rowVarName

Name of the evolved/row variable

character(len=:), public, allocatable :: colVarName

Name of the implicit/column variable

type, public, abstract, extends(Term) ::  MatrixTerm

Abstract matrix term containing general matrix construction routines and interface with PETSc. The values of a matrix are by default constructed by evaluating row and column functions for each element, and multiplying with the corresponding multiplicative and normalization constants

Components

Type Visibility Attributes Name Initial
logical, public :: userDefined = .false.

True only if user explicitly sets it to true

type(SparseRowData), private :: rowData

Matrix object in sparse row data form

type(RealArray), private, allocatable, dimension(:) :: multConst

Multiplicative constants for each row/column corresponding to the matrix structure

real(kind=rk), private :: normalizationConst = real(1.0d0, kind=rk)

Normalization constant for this term

type(MatrixTermIndexingData), private :: indexingData

Indexing data used to determing coordinates and required variables

logical, private :: fixedMatrix = .false.

If true the matrix is constructed only once

logical, private :: fixedMatrixCalculated = .false.

True if the fixed matrix has been calculated

logical, private :: stationaryEvolvedVar = .false.

If true, this term is always sent to PETSc with multiplicative constant -1

logical, private :: hasNonTrivialRowFun = .true.

Set to false to not call row function. Defaults to true.

logical, private :: hasNonTrivialColFun = .true.

Set to false to not call col function. Defaults to true.

type(RealArray), private, allocatable, dimension(:) :: colBuffer
real(kind=rk), private, allocatable, dimension(:) :: rowBuffer

Type-Bound Procedures

procedure, public :: isDefined => isDefinedObject
procedure, public :: makeDefined => makeDefinedObject
procedure, public :: makeUndefined => makeUndefinedObject
procedure, public :: calculateValues
procedure, public :: setNormalizationConst
procedure, public :: getNormalizationConst
procedure, public :: setReqVars
procedure, public :: setEvolvedAndImplicitVar
procedure, public :: initRowData
procedure, public :: evaluate => evaluateMatTerm
procedure, public :: getMultConst
procedure, public :: setMultConst
procedure, public :: getIndexingData
procedure, public :: setFixedMatrix
procedure, public :: setNontrivialRowFun => setNonTrivialRowFun
procedure, public :: setNontrivialColFun => setNonTrivialColFun
procedure, private :: calculateRows => unityRow
procedure, private :: calculateCols => unityCol
procedure, public :: addRowDataToPreallocationData
procedure, public :: addRowDataPatternToController
procedure, public :: addRowValuesToPETScMatrix
procedure, public :: getVarName => getRowVarName
procedure, public :: getRowData
procedure, public :: update => matTermUpdate
procedure, public :: matrixTermUpdate => matrixNoUpdate