cvode_integrator_class Module

Contains an Sundials CVODE integrator class


Used by


Interfaces

interface

  • private module subroutine integrateCVODE(this, manipulatedModeller, outputVars, inputVars)

    Implementation of abstract manipulate routine for the case of Runge-Kutta integrator

    Arguments

    Type IntentOptional Attributes Name
    class(CVODEIntegrator), intent(inout) :: this
    class(ModellerSurrogate), intent(inout) :: manipulatedModeller

    Modeller to be used in callbacks during integration

    class(VariableContainer), intent(inout) :: outputVars

    VariableContainer object to store the integration output

    class(VariableContainer), intent(in) :: inputVars

    VariableContainer object housing input data for the integration routine

interface

  • private module subroutine initCVODEIntegrator(this, mpiCont, options, modelList, termGroups, evolvesTimeVar, dtController, initialTimestep, integratorName)

    Arguments

    Type IntentOptional Attributes Name
    class(CVODEIntegrator), intent(inout) :: this
    type(MPIController), intent(in) :: mpiCont

    MPI Controller used to initialise the sundials context

    type(CVODEOptions), intent(in) :: options

    Options object containing CVODE options

    integer(kind=ik), intent(in), optional, dimension(:) :: modelList

    List of models this integrator will be responsible for

    type(IntArray), intent(in), optional, dimension(:) :: termGroups

    Term groups this integrator is responsible for - should conform with modelList

    logical, intent(in), optional :: evolvesTimeVar

    Set to true if this integrator is allowed to change the "time" varible (if present in passed variable container)

    class(TimestepController), intent(in), optional :: dtController

    User-supplied timestep controller object

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

    Default timestep

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

    Name of integrator used in printing

interface

  • private impure elemental module subroutine finalizeCVODEIntegrator(this)

    Arguments

    Type IntentOptional Attributes Name
    type(CVODEIntegrator), intent(inout) :: this

Derived Types

type, public ::  CVODEOptions

Components

Type Visibility Attributes Name Initial
integer(kind=ik), public :: bbdmukeep

BBD preconditioner size of kept upper diagonal band

integer(kind=ik), public :: bbdmlkeep

BBD preconditioner size of kept lower diagonal band

integer(kind=ik), public :: bbdmldq

BBD preconditioner size of lower differentiation stencil band

integer(kind=ik), public :: bbdmudq

BBD preconditioner size of upper differentitation stencil band

real(kind=rk), public :: reltol

Linear solver relative tolerance

real(kind=rk), public :: abstol

Linear solver absolute tolerance

integer(kind=ik), public :: maxRestarts

Maximum number of GMRES restarts

logical, public :: amMethod = .false.

True if using Adams Moulton (default is BDF)

integer(kind=ik), public :: maxOrder

Maximum order of method

logical, public :: stabLimitDet = .false.

True if using stability limit detection

integer(kind=ik), public :: maxInternalSteps = 500

Maximum number of internal steps

real(kind=rk), public :: maxTimestep = 0.d0

Maximum timestep size

real(kind=rk), public :: minTimestep = 0.d0

Minimum timestep size

real(kind=rk), public :: startingTimestep = 0.0d0

Starting timestep (if <0 then chosen by CVODE)

type, public, extends(Integrator) ::  CVODEIntegrator

Components

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

True only if user explicitly sets it to true

logical, public :: communicationNeeded

True if this Integrator requires MPI communication during evolution

type(CommunicationData), public :: commData

Communication data object for this Integrator

logical, public :: nonTrivialUpdate

True if this integrator should perform non-trivial updates of terms

logical, public :: nonTrivialModelDataUpdate

True if this integrator should perform non-trivial updates of model data

type(c_ptr), private :: sunctx

Sundials context

type(SUNLinearSolver), private, pointer :: sunls

Sundials linear solver pointer

type(N_Vector), private, pointer :: sunVecY

Solution and RHS sundials vector objects

type(N_Vector), private, pointer :: sunVecYDot

Solution and RHS sundials vector objects

type(c_ptr), private :: cvode

CVODE solver context

type(SUNMatrix), private, pointer :: sunmat

Sundials matrix (will be nulled)

real(kind=c_double), private, pointer, dimension(:) :: rhsVec

Pointers used for accessing the underlying N_Vectors

real(kind=c_double), private, pointer, dimension(:) :: yVec

Pointers used for accessing the underlying N_Vectors

type(VariableContainer), private, allocatable :: bufferRHS

ReMKiT1D variable containers corresponding to the RHS and solutions - enable derivation and communication calls

type(VariableContainer), private, allocatable :: bufferY

ReMKiT1D variable containers corresponding to the RHS and solutions - enable derivation and communication calls

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

Buffer for moving data between the C pointers and the ReMKiT1D variable containers

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

List of variables evolved by this solver

type(MPI_Comm), private :: mpiComm

MPI communicator object needed by some CVODE routines

integer(kind=ik), private :: numProcs

Number of processes needed for initialising the number of variables/equations in CVODE

type(CVODEOptions), private :: options
character(len=:), private, allocatable :: integratorName

Integrator named used in printing

Finalizations Procedures

final :: finalizeCVODEIntegrator

Type-Bound Procedures

procedure, public :: isDefined => isDefinedObject
procedure, public :: makeDefined => makeDefinedObject
procedure, public :: makeUndefined => makeUndefinedObject
procedure, public :: setTimestep
procedure, public :: getTimestep
procedure, public :: setTermGroups
procedure, public :: getTermGroups
procedure, public :: setModelIndices
procedure, public :: getModelIndices
procedure, public :: setTimeEvolving
procedure, public :: isTimeEvolving
procedure, public :: setTimestepController
procedure, public :: hasTimestepController
procedure, public :: getTimestepFromController
procedure, public :: isCommunicationNeeded
procedure, public :: setCommunicationNeeded
procedure, public :: getCommunicationData
procedure, public :: setCommunicationData
procedure, public :: getUpdateRules
procedure, public :: setUpdateRules
procedure, public :: getModelDataUpdateRules
procedure, public :: setModelDataUpdateRules
procedure, public :: hasNonTrivialUpdate
procedure, public :: setNonTrivialUpdate
procedure, public :: hasNonTrivialModelDataUpdate
procedure, public :: setNonTrivialModelDataUpdate
procedure, public :: affect => integrateCVODE
procedure, public :: init => initCVODEIntegrator