model_procedures Submodule

Contains module procedures associated with the model class


Uses


Module Functions

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

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

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

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

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)

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)

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

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

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)

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)

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


Module Subroutines

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

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

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

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

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

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

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

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

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

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

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

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

module subroutine setModelData(this, modelData)

Setter for modelData

Arguments

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

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

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