Modeller Derived Type

type, public, extends(ModellerSurrogate) :: Modeller

Central object responsible for storing variables and models, as well as doing integration and data manipulation


Components

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

True only if user explicitly sets it to true

type(VariableContainer), private :: vars

Main variable container

type(ModelContainer), private, allocatable, dimension(:) :: models

Array holding all models this modeller has access to

type(PETScController), private, allocatable :: petscCont

PETScController object used for solving linear systems

type(MPIController), private :: MPICont

MPIController used for all communication

type(CommunicationData), private, allocatable :: commData

Default communication data containing MPI communication instruction

type(SparseRowData), private, allocatable :: identityMat

Sparse identity matrix used for PETSc calls

class(Manipulator), private, allocatable :: integ

Main integrator object

class(CompositeManipulator), private, allocatable :: manip

Secondary manipulator object for optional data manipulation

integer(kind=ik), private :: numModelsAdded

Tracked of number of models allocated

logical(kind=ik), private :: assembled

True if modeller has been assembled and is ready for use


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 :: isAssembled

  • interface

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

    Return true if modeller is assembled and ready to evolve variables

    Arguments

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

    Return Value logical

procedure, public :: addModel

  • interface

    private pure module subroutine addModel(this, newModel)

    Add a Model to this modeller

    Arguments

    Type IntentOptional Attributes Name
    class(Modeller), intent(inout) :: this
    class(Model), intent(inout), allocatable :: newModel

procedure, public :: copyVarValuesTo

  • interface

    private pure module subroutine copyVarValuesTo(this, varCont)

    Copy values of variables to outside variable container from this modeller's container

    Arguments

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

procedure, public :: copyVarValuesFrom

  • interface

    private pure module subroutine copyVarValuesFrom(this, varCont)

    Copy values of variables from outside variable container into this modeller's container

    Arguments

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

procedure, public :: callManipulator

  • interface

    private module subroutine callManipulator(this, priority, inVars, outVars)

    Call optional CompositeManipulator manipulate routine with inVars and outVars - the default for the optional VariableContainers is the modeller's VariableContainer

    Arguments

    Type IntentOptional Attributes Name
    class(Modeller), intent(inout) :: this
    integer(kind=ik), intent(in) :: priority
    type(VariableContainer), intent(in), optional :: inVars
    type(VariableContainer), intent(inout), optional :: outVars

procedure, public :: integrate

  • interface

    private module subroutine integrate(this, inVars, outVars)

    Call ianipulator affect routine with inVars and outVars - the default for the optional VariableContainers is the modeller's VariableContainer

    Arguments

    Type IntentOptional Attributes Name
    class(Modeller), intent(inout) :: this
    type(VariableContainer), intent(in), optional :: inVars
    type(VariableContainer), intent(inout), optional :: outVars

procedure, public :: setIntegrator

  • interface

    private pure module subroutine setIntegrator(this, integ)

    Setter for integrator object

    Arguments

    Type IntentOptional Attributes Name
    class(Modeller), intent(inout) :: this
    class(Manipulator), intent(in) :: integ

procedure, public :: setManipulator

  • interface

    private pure module subroutine setManipulator(this, manip)

    Setter for manipulator object

    Arguments

    Type IntentOptional Attributes Name
    class(Modeller), intent(inout) :: this
    class(CompositeManipulator), intent(in) :: manip

procedure, public :: calculateIdentityMat

  • interface

    private module subroutine calculateIdentityMat(this, indexingObj)

    Initializes the identity matrix of this modeller based on Indexing object

    Arguments

    Type IntentOptional Attributes Name
    class(Modeller), intent(inout) :: this
    type(Indexing), intent(in) :: indexingObj

procedure, public :: updateModelTermGroup

  • interface

    private module subroutine updateModelTermGroup(this, modelIndex, groupIndex, varCont)

    Call the update routine of model with given index for the given term group - optionally use variable container other than the one stored in the modeller

    Arguments

    Type IntentOptional Attributes Name
    class(Modeller), intent(inout) :: this
    integer(kind=ik), intent(in) :: modelIndex
    integer(kind=ik), intent(in) :: groupIndex
    type(VariableContainer), intent(in), optional :: varCont

procedure, public :: updateModelData

  • interface

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

    Update modelbound data of model with given index if that data is allocated

    Arguments

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

    Model index for model whose data is to be update

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

    Variable container to be used in update

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

    Priority for this update call

procedure, public :: calculateMatGroupValsInModel

  • interface

    private pure module subroutine calculateMatGroupValsInModel(this, modelIndex, groupIndex, varCont)

    Calculate matrix value in implicit term group given by groupIndex in model given by modelIndex, and optionally using variable container other than the one stored in the modeller

    Arguments

    Type IntentOptional Attributes Name
    class(Modeller), intent(inout) :: this
    integer(kind=ik), intent(in) :: modelIndex
    integer(kind=ik), intent(in) :: groupIndex
    type(VariableContainer), intent(in), optional :: varCont

procedure, public :: addModelMatGroupToPETSc

  • interface

    private module subroutine addModelMatGroupToPETSc(this, modelIndex, groupIndex, mult, petscGroup)

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

    Arguments

    Type IntentOptional Attributes Name
    class(Modeller), intent(inout) :: this
    integer(kind=ik), intent(in) :: modelIndex
    integer(kind=ik), intent(in) :: groupIndex
    real(kind=rk), intent(in) :: mult
    integer(kind=ik), intent(in), optional :: petscGroup

procedure, public :: linearSolvePETSc

  • interface

    private module subroutine linearSolvePETSc(this, knownVec, unknownVec, addIdentityMat, convReason, petscGroup)

    Call linearSolve routine on PETScController of this modeller. Creates PETSc objects if they've not yet been created. If addIdentityMat is true adds an identity matrix to the PETSc matrix.

    Arguments

    Type IntentOptional Attributes Name
    class(Modeller), intent(inout) :: this
    real(kind=rk), intent(in), dimension(:) :: knownVec
    real(kind=rk), intent(out), dimension(:) :: unknownVec
    logical, intent(in) :: addIdentityMat
    integer(kind=ik), intent(inout) :: convReason
    integer(kind=ik), intent(in), optional :: petscGroup

procedure, public :: evaluateModelTermGroup

  • interface

    private pure module function evaluateModelTermGroup(this, modelIndex, groupIndex, varCont) result(res)

    Call the evaluateTermGroup routine on model with given index and for given term group - optionally use variable container other than the one stored in the modeller

    Arguments

    Type IntentOptional Attributes Name
    class(Modeller), intent(in) :: this
    integer(kind=ik), intent(in) :: modelIndex
    integer(kind=ik), intent(in) :: groupIndex
    type(VariableContainer), intent(in), optional :: varCont

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

procedure, public :: evaluateModelTermByName

  • interface

    private pure module function evaluateModelTermByName(this, modelIndex, name, varCont) result(res)

    Call the evaluateTermByName routine on model with given index and for given term name - optionally use variable container other than the one stored in the modeller

    Arguments

    Type IntentOptional Attributes Name
    class(Modeller), intent(in) :: this
    integer(kind=ik), intent(in) :: modelIndex
    character(len=*), intent(in) :: name
    type(VariableContainer), intent(in), optional :: varCont

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

procedure, public :: copyDataFromModel

  • interface

    private module subroutine copyDataFromModel(this, modelIndex, varName, container)

    Copy modelbound variable data with given name from model with given index.

    Arguments

    Type IntentOptional Attributes Name
    class(Modeller), intent(in) :: this
    integer(kind=ik), intent(in) :: modelIndex
    character(len=*), intent(in) :: varName

    Name of data

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

    Container to copy into

procedure, public :: getEvolvedVarInTermGroup

  • interface

    private pure module function getEvolvedVarInTermGroup(this, groupIndex, modelIndex) result(name)

    Return variable name for given group index and model index

    Arguments

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

    Return Value character(len=:), allocatable

procedure, public :: isModelTermGroupMixed

  • interface

    private pure module function isModelTermGroupMixed(this, groupIndex, modelIndex) result(mixed)

    Return true if group with given index is mixed in model with given index

    Arguments

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

    Return Value logical

procedure, public :: getCurrentTime

  • interface

    private pure module function getCurrentTime(this) result(time)

    Return current value of the integrator time variable if the integrator object is a composite integrator or the value of the "time" variable if it isn't

    Arguments

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

    Return Value real(kind=rk)

procedure, public :: performComm

  • interface

    private module subroutine performComm(this, commData, varCont, onlyDepth)

    Perform communications using the modeller's MPI controller - optionally uses external CommunicationData instructions or exchanges data in external variable container

    Arguments

    Type IntentOptional Attributes Name
    class(Modeller), intent(inout) :: this
    type(CommunicationData), intent(in), optional :: commData

    Optional non-default communication data

    type(VariableContainer), intent(inout), optional :: varCont

    Optional variable container to perform communications on instead of the modeller's

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

    Only communicate variables at given derivation depth

procedure, public :: safeCommAndDeriv

  • interface

    private module subroutine safeCommAndDeriv(this, commData, varCont, derivPriority)

    Perform communications interlaced with derivation calls of increasing derivation depth

    Arguments

    Type IntentOptional Attributes Name
    class(Modeller), intent(inout) :: this
    type(CommunicationData), intent(in), optional :: commData

    Optional non-default communication data

    type(VariableContainer), intent(inout), optional :: varCont

    Optional variable container to perform communications on instead of the modeller's

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

    Derivation priority for interlaced calls

procedure, public :: isTrueEverywhere

  • interface

    private module function isTrueEverywhere(this, input) result(isTrue)

    Return true if input is true on every processor using the MPI controller of the modeller

    Arguments

    Type IntentOptional Attributes Name
    class(Modeller), intent(inout) :: this
    logical, intent(inout) :: input

    Return Value logical

procedure, public :: assemble

  • interface

    private module subroutine assemble(this, withIdentityMat)

    Assemble all of the matrix terms, preallocate PETScController objects and make sure modeller is ready for use. If withIdentityMat is true preallocates diagonal elements for the identity matrix.

    Arguments

    Type IntentOptional Attributes Name
    class(Modeller), intent(inout) :: this
    logical, intent(in), optional :: withIdentityMat

procedure, public :: init => initModeller

  • interface

    private module subroutine initModeller(this, numModels, initVars, mpiCont, petscCont, commData)

    Modeller initialization routine

    Arguments

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

    Number of models this modeller expects to be added

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

    Initial variable container

    type(MPIController), intent(in) :: mpiCont

    Main MPIController

    type(PETScController), intent(in), optional :: petscCont

    Optional PETSc controller - should be supplied if any integration/manipulation routine uses PETSc

    type(CommunicationData), intent(in), optional :: commData

    Default MPI communication data