GeneralMatrixTerm Derived Type

type, public, extends(MatrixTerm) :: GeneralMatrixTerm

General matrix term with the capability to take in various stencils, time and spaticoordinate profiles, and evaluate other term groups in the host model. Required row and column variables passed through the VarData object are raised to corresponding powers.


Components

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

True only if user explicitly sets it to true

type(VarData), private :: vData

Common variable data

type(CoordProfiles), private :: coordProfile

Optional multiplicative constants giving x-dependence if size 1 or x,h,v dependence if size 3

type(TimeSignalData), private, allocatable :: tData

Optional time signal data

real(kind=rk), private :: timeSignalMult

Multiplier containing tSignal result. Defaults to 1

integer(kind=ik), private, allocatable :: targetTermGroup

Term group to evaluate and use as a row function

real(kind=rk), private, allocatable, dimension(:) :: evalBuffer

Buffer for evaluating target term group

class(JaggedArrayGenerator), private, allocatable :: stencilGen

Optional stencil value generator used to update this term's multConst

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

Current values of stencil variables, used as this term's multConst

type(SparseRowData), private :: copyTermVals

Matrix values of the optional copy term

character(len=:), private, allocatable :: copyTermName

Name of the term whose values should be copied and multiplied with this term's stencil

real(kind=rk), private, allocatable, dimension(:) :: modelboundRowVarBuffer

Buffer holding the product of modelbound row variables raised to their corresponding powers

real(kind=rk), private, allocatable, dimension(:) :: modelboundColVarBuffer

Buffer holding the product of modelbound col variables raised to their corresponding powers

logical, private :: xPeriodic

True if term treats x grid as periodic

logical, private :: isActive
logical, private :: kineticRow

True if row variable is a distribution

logical, private :: kineticCol

True if col variable is a distribution

logical, private, allocatable, dimension(:) :: reqRowVarIsDist

True for all required row variables that are distributions

logical, private, allocatable, dimension(:) :: reqColVarIsDist

True for all required column variables that are distributions

integer(kind=ik), private :: locNumX

Local number of spatial cells - used when handling modelbound data

integer(kind=ik), private :: numH

Local number of spatial cells - used when handling modelbound data

integer(kind=ik), private :: numV

Local number of spatial cells - used when handling modelbound data

integer(kind=ik), private, allocatable, dimension(:) :: rowCoordsX
integer(kind=ik), private, allocatable, dimension(:) :: rowCoordsH
integer(kind=ik), private, allocatable, dimension(:) :: rowCoordsV

Type-Bound Procedures

procedure, public :: isDefined => isDefinedObject

  • interface

    private pure module function isDefinedObject(this) result(defined)

    Getter for userDefined

    Arguments

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

    Return Value logical

procedure, public :: makeDefined => makeDefinedObject

  • interface

    private pure module subroutine makeDefinedObject(this)

    Set userDefined to .true.

    Arguments

    Type IntentOptional Attributes Name
    class(Object), intent(inout) :: this

procedure, public :: makeUndefined => makeUndefinedObject

  • interface

    private pure module subroutine makeUndefinedObject(this)

    Set userDefined to .false.

    Arguments

    Type IntentOptional Attributes Name
    class(Object), intent(inout) :: this

procedure, public :: calculateValues

  • 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

procedure, public :: setNormalizationConst

  • 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

procedure, public :: getNormalizationConst

  • 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)

procedure, public :: setReqVars

  • 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

procedure, public :: setEvolvedAndImplicitVar

  • 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

procedure, public :: initRowData

  • 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

procedure, public :: evaluate => evaluateMatTerm

  • 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(:)

procedure, public :: getMultConst

  • 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(:)

procedure, public :: setMultConst

  • 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

procedure, public :: getIndexingData

procedure, public :: setFixedMatrix

  • 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

procedure, public :: setNontrivialRowFun => setNonTrivialRowFun

  • 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

procedure, public :: setNontrivialColFun => setNonTrivialColFun

  • 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

procedure, public :: addRowDataToPreallocationData

  • 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

procedure, public :: addRowDataPatternToController

  • 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

procedure, public :: addRowValuesToPETScMatrix

  • 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

procedure, public :: getVarName => getRowVarName

  • 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

procedure, public :: getRowData

  • 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)

procedure, public :: update => matTermUpdate

  • 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

procedure, public :: matrixTermUpdate => updateGeneralTerm

  • interface

    private module subroutine updateGeneralTerm(this, varCont, indexingData, modelData, hostModel)

    Update general term if using any modelbound data, updating stencil values, evaluating other terms, or if there is any explicit time dependence

    Arguments

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

    Variable container - used to update stencil values and signal

    type(MatrixTermIndexingData), intent(in) :: indexingData
    class(ModelboundData), intent(in), optional :: modelData

    Model data used to retrieve modelbound variable

    class(ModelSurrogate), intent(in), optional :: hostModel

    Host model - used to evaluate term group

procedure, public :: calculateRows => generalRow

  • interface

    private pure module subroutine generalRow(this, varCont, rowVals, indexingData)

    Multiplies all required variables and raises them to their corresponding power,using modelbound row variable buffer if allocated, and adding spatial and time profiles

    Arguments

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

procedure, public :: calculateCols => generalCol

  • interface

    private pure module subroutine generalCol(this, varCont, colVals, indexingData)

    Multiplies all required variables and raises them to their corresponding power,using modelbound row variable buffer if allocated

    Arguments

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

procedure, public :: init => initGeneralTerm

  • interface

    private module subroutine initGeneralTerm(this, gridObj, partitionObj, indexingObj, procRank, evolvedVar, implicitVar, varCont, sTemplate, vData, normConst, coordProfile, tData, evalTermGroup, mbData, copyTermName)

    General matrix term initialization routine

    Arguments

    Type IntentOptional Attributes Name
    class(GeneralMatrixTerm), intent(inout) :: this
    type(Grid), intent(in) :: gridObj

    Grid object used to initialize stencil

    type(Partition), intent(in) :: partitionObj

    Parition object used to determine local number of DoF

    type(Indexing), intent(in) :: indexingObj

    Indexing object used to initialize matrix row data

    integer(kind=ik), intent(in) :: procRank

    Current processor rank

    character(len=*), intent(in) :: evolvedVar

    Name of evolved variable

    character(len=*), intent(in) :: implicitVar

    Name of implicit variable

    type(VariableContainer), intent(in) :: varCont

    Reference variable container

    type(StencilTemplate), intent(inout) :: sTemplate

    StencilTemplate used

    type(VarData), intent(in), optional :: vData

    Required variable names and powers

    real(kind=rk), intent(in), optional :: normConst

    Normalization constant

    type(CoordProfiles), intent(in), optional :: coordProfile

    Multiplicative coordinate profiles (globally indexed)

    type(TimeSignalData), intent(in), optional :: tData

    Explicit time dependence

    integer(kind=ik), intent(in), optional :: evalTermGroup

    Optional term group of host model to evaluate and use as additional row variable

    class(ModelboundData), intent(in), optional :: mbData

    Optional modelbound data object used when initializing fixed stancil generators which might require it

    character(len=*), intent(in), optional :: copyTermName

    Name of the term whose values should be copied and multiplied with this term's stencil