model_class Module

Houses general model class responsible for storing, directly evaluating and manipulating terms


Used by


Interfaces

interface

  • private pure module function isAssembled(this) result(assembled)

    Check if model is assembled and ready to use

    Arguments

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

    Return Value logical

interface

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

    Evaluate a term group, returning the sum of all explicit results from the term group - if groupIndex > size(implicitGroup) it is taken to be in the general group

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(in) :: this
    integer(kind=ik), intent(in) :: groupIndex

    Group index to evaluate

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

    Variable container used to evaluate this group

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

interface

  • private pure module function isGroupMixed(this, groupIndex) result(mixed)

    Return true if group with given index is mixed

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(in) :: this
    integer(kind=ik), intent(in) :: groupIndex

    Return Value logical

interface

  • private pure module function getGroupVarName(this, groupIndex) result(name)

    Return evolved variable name for given group index - works only for groups that are not mixed

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(in) :: this
    integer(kind=ik), intent(in) :: groupIndex

    Return Value character(len=:), allocatable

interface

  • private pure module function getImplicitTermRowData(this, termIndex) result(rowData)

    Return row data of implicit term with given term index

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(in) :: this
    integer(kind=ik), intent(in) :: termIndex

    Return Value type(SparseRowData)

interface

  • private pure module function getImplicitTermIndexingData(this, termIndex) result(indexingData)

    Return indexing data of implicit term with given term index

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(in) :: this
    integer(kind=ik), intent(in) :: termIndex

    Return Value type(MatrixTermIndexingData)

interface

  • private pure module function isTermNameRegistered(this, name) result(reg)

    Check whether term with given name is registered

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(in) :: this
    character(len=*), intent(in) :: name

    Return Value logical

interface

  • private pure module function isTermNameImplicit(this, name) result(reg)

    Check whether term with given name is implicit

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(in) :: this
    character(len=*), intent(in) :: name

    Return Value logical

interface

  • private pure module function getImplicitTermIndex(this, name) result(ind)

    Get index of implicit term with given name

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(in) :: this
    character(len=*), intent(in) :: name

    Return Value integer(kind=ik)

interface

  • private pure module function getGeneralTermIndex(this, name) result(ind)

    Get index of general term with given name

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(in) :: this
    character(len=*), intent(in) :: name

    Return Value integer(kind=ik)

interface

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

    Evaluate a term by name

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(in) :: this
    character(len=*), intent(in) :: name
    type(VariableContainer), intent(in) :: varCont

    Variable container used to evaluate this term

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

interface

  • private pure module subroutine initModel(this, numImplicitTerms, numGeneralTerms, numImplicitGroups, numGeneralGroups)

    Model initialization routine

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(inout) :: this
    integer(kind=ik), intent(in), optional :: numImplicitTerms

    Number of MatrixTerm objects this model expects to be added

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

    Number of general Term objects this model expects to be added

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

    Number of implicit/matrix term groups registered with this model

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

    Number of general term groups registered with this model

interface

  • private pure module subroutine setNumImplicitTerms(this, numImplicitTerms)

    Set number of implicit terms and perform allocation

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(inout) :: this
    integer(kind=ik), intent(in) :: numImplicitTerms

    Number of MatrixTerm objects this model expects to be added

interface

  • private pure module subroutine setNumGeneralTerms(this, numGeneralTerms)

    Set number of general terms and perform allocation

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(inout) :: this
    integer(kind=ik), intent(in) :: numGeneralTerms

    Number of general Term objects this model expects to be added

interface

  • private pure module subroutine setNumImplicitGroups(this, numImplicitGroups)

    Set number of implicit groups and perform allocation

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(inout) :: this
    integer(kind=ik), intent(in) :: numImplicitGroups

    Number of implicit/matrix term groups registered with this model

interface

  • private pure module subroutine setNumGeneralGroups(this, numGeneralGroups)

    Set number of general groups and perform allocation

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(inout) :: this
    integer(kind=ik), intent(in) :: numGeneralGroups

    Number of general term groups registered with this model

interface

  • private pure module subroutine addImplicitTerm(this, impTerm, implicitGroups, generalGroups, termName, skipPattern)

    Add a MatrixTerm object to the model (deallocating the source!), and specify which implicit and general groups it belongs to

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(inout) :: this
    class(MatrixTerm), intent(inout), allocatable :: impTerm

    MatrixTerm object to be reallocated to this model

    integer(kind=ik), intent(in), dimension(:) :: implicitGroups

    Implicit groups the added term should belong to

    integer(kind=ik), intent(in), dimension(:) :: generalGroups

    General groups the added term should belong to

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

    Name of added term for indexing purposes

    logical, intent(in), optional :: skipPattern

    True if the matrix term pattern should not be added to PETSc preallocation

interface

  • private pure module subroutine addGeneralTerm(this, genTerm, generalGroups, termName)

    Add a Term object to the model (deallocating the source!), and specify which general groups it belongs to

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(inout) :: this
    class(Term), intent(inout), allocatable :: genTerm

    General Term object to be reallocated to this model

    integer(kind=ik), intent(in), dimension(:) :: generalGroups

    General groups the added term should belong to

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

    Name of added term for indexing purposes

interface

  • private module subroutine updateTermGroup(this, groupIndex, varCont)

    Update a term group - if groupIndex > size(implicitGroup) it is taken to be in the general group

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(inout) :: this
    integer(kind=ik), intent(in) :: groupIndex

    Group index to be updated

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

    Variable container used to update this group

interface

  • private pure module subroutine calculateMatGroupValues(this, groupIndex, varCont)

    Calculate matrix value in implicit term group given by groupIndex

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(inout) :: this
    integer(kind=ik), intent(in) :: groupIndex

    Group index of terms whose matrices should be calculated

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

    Variable container used for the calculation

interface

  • private module subroutine addMatGroupValsToPETSc(this, groupIndex, petscCont, mult, petscGroup)

    Send off matrix values of given term group to the PETSc controller, multiplied by mult

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(in) :: this
    integer(kind=ik), intent(in) :: groupIndex

    Group index of terms whose matrices should be sent to PETSc

    type(PETScController), intent(inout) :: petscCont

    PETScController object housing PETSc matrices

    real(kind=rk), intent(in) :: mult

    Multiplier used when adding matrices to PETSc - usually -dt

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

interface

  • private module subroutine assemble(this, petscCont)

    Assemble all of the matrix terms, preallocate PETScController objects and make sure model is ready for use

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(inout) :: this
    type(PETScController), intent(inout), optional :: petscCont

    Optional PETScController - should be present if the model has any implicitly evaluated terms

interface

  • private module subroutine updateModelData(this, varCont, updatePriority)

    Update this model's modelbound data if allocated

    Arguments

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

    Variable container used in the update

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

    Priority for this update call

interface

  • private module subroutine setModelData(this, modelData)

    Setter for modelData

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(inout) :: this
    class(ModelboundData), intent(in) :: modelData

interface

  • private module subroutine copyModelData(this, modelData)

    Copy model data from this model into modelData

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(in) :: this
    class(ModelboundData), intent(inout), allocatable :: modelData

interface

  • private module subroutine copyModelboundDataEntry(this, varName, container)

    Copy modelbound variable data with given name. Will throw error if no modelbound data is found

    Arguments

    Type IntentOptional Attributes Name
    class(Model), intent(in) :: this
    character(len=*), intent(in) :: varName

    Name of data

    real(kind=rk), intent(inout), allocatable, dimension(..) :: container

    Container to copy into


Derived Types

type, public ::  MatTermContainer

Container allowing for heterogeneous matrix term arrays

Components

Type Visibility Attributes Name Initial
class(MatrixTerm), public, allocatable :: entry

type, public ::  TermContainer

Container allowing for heterogeneous general term arrays

Components

Type Visibility Attributes Name Initial
class(Term), public, allocatable :: entry

type, public, extends(ModelSurrogate) ::  Model

Object storing, evaluating, and manipulating various term objects, with terms categorized as either implicit (MatrixTerm objects) or general (Term objects).

Components

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

True only if user explicitly sets it to true

integer(kind=ik), private :: numAddedMatrixTerms

Tracker for number of allocated matrix terms

integer(kind=ik), private :: numAddedGeneralTerms

Tracker for number of allocated general terms

type(IntArray), private, allocatable, dimension(:) :: implicitTermGroup

Groups of matrix terms used to identify terms for evaluation/manipulation

type(IntArray), private, allocatable, dimension(:) :: generalTermGroup

Groups of general terms used to identify terms for evaluation/manipulation

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

True for each implicit group that is either empty or contains terms that evolve/evaluate more than one variable - used to forbid explicit evaluation of such terms

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

True for each general group that that is either empty or contains terms that evolve/evaluate more than one variable - used to forbid explicit evaluation of such terms

type(MatTermContainer), private, allocatable, dimension(:) :: implicitTerms

Container for MatrixTerm objects living in this model

type(TermContainer), private, allocatable, dimension(:) :: generalTerms

Container for general Term objects living in this model

logical, private :: assembled

True if the model is assembled and ready for use

logical, private, dimension(4) :: setupCounter

All true if the model is ready to accept terms

class(ModelboundData), private, allocatable :: modelData

Optional model data that can be used by contained terms

type(StringArray), private, allocatable, dimension(:) :: implicitTermNames

Names of implicit terms

type(StringArray), private, allocatable, dimension(:) :: generalTermNames

Names of general terms

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

Flag to skip pattern of particular implicit term when adding (for performance on startup)

Type-Bound Procedures

procedure, public :: isDefined => isDefinedObject
procedure, public :: makeDefined => makeDefinedObject
procedure, public :: makeUndefined => makeUndefinedObject
procedure, public :: isAssembled
procedure, public :: addImplicitTerm
procedure, public :: addGeneralTerm
procedure, public :: updateTermGroup
procedure, public :: evaluateTermGroup
procedure, public :: evaluateTermByName
procedure, public :: calculateMatGroupValues
procedure, public :: addMatGroupValsToPETSc
procedure, public :: assemble
procedure, public :: isGroupMixed
procedure, public :: getGroupVarName
procedure, public :: setModelData
procedure, public :: copyModelData
procedure, public :: updateModelData
procedure, public :: copyModelboundDataEntry
procedure, public :: setNumImplicitTerms
procedure, public :: setNumGeneralTerms
procedure, public :: setNumImplicitGroups
procedure, public :: setNumGeneralGroups
procedure, public :: init => initModel
procedure, public :: getImplicitTermRowData
procedure, public :: getImplicitTermIndexingData
procedure, public :: isTermNameRegistered
procedure, public :: isTermNameImplicit
procedure, public :: getImplicitTermIndex
procedure, public :: getGeneralTermIndex