NeoFOAM
WIP Prototype of a modern OpenFOAM core
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
NeoFOAM::timeIntegration::RungeKutta< SolutionFieldType > Class Template Reference

Integrates in time, using Sundials, a PDE expression using the Runge-Kutta method. More...

#include <rungeKutta.hpp>

Inheritance diagram for NeoFOAM::timeIntegration::RungeKutta< SolutionFieldType >:

Public Types

using ValueType = SolutionFieldType::FieldValueType
 
using Expression = NeoFOAM::dsl::Expression
 
using Base = TimeIntegratorBase< SolutionFieldType >::template Register< RungeKutta< SolutionFieldType > >
 

Public Member Functions

 RungeKutta ()=default
 Default constructor.
 
 ~RungeKutta ()=default
 Default destructor.
 
 RungeKutta (const Dictionary &dict)
 Constructor that initializes the RungeKutta solver with a dictionary configuration.
 
 RungeKutta (const RungeKutta &other)
 Copy constructor.
 
 RungeKutta (RungeKutta &&other)
 Move Constructor.
 
RungeKuttaoperator= (const RungeKutta &other)=delete
 
RungeKuttaoperator= (RungeKutta &&other)=delete
 
void solve (Expression &exp, SolutionFieldType &solutionField, scalar t, const scalar dt) override
 Solves one (explicit) time step, from n to n+1.
 
std::unique_ptr< TimeIntegratorBase< SolutionFieldType > > clone () const override
 Return a copy of this instantiated class.
 

Static Public Member Functions

static std::string name ()
 Returns the name of the class.
 
static std::string doc ()
 Returns the documentation for the class.
 
static std::string schema ()
 Returns the schema for the class.
 

Detailed Description

template<typename SolutionFieldType>
class NeoFOAM::timeIntegration::RungeKutta< SolutionFieldType >

Integrates in time, using Sundials, a PDE expression using the Runge-Kutta method.

Template Parameters
SolutionFieldTypeThe Solution field type, should be a volume or surface field.

Implements explicit Runge-Kutta time integration using the Sundials library. The class manages Sundials vectors and memory through RAII principles, handling the conversion between internal field representations and Sundials' N_Vector format. Supports various (at present explicit) Runge-Kutta methods which can be specified through the dictionary configuration. The main interface for a solve is through the solve function.

Note
Useful Sundials documentation below, currently we have implemented only an explicit Runge-Kutta interface, this simplifies things considerably as compared to some of the examples: Initialization (and order thereof): https://sundials.readthedocs.io/en/latest/arkode/Usage/Skeleton.html Sundials-Kokkos: https://sundials.readthedocs.io/en/latest/nvectors/NVector_links.html#the-nvector-kokkos-module Sundials Contexts (scroll to bottom eg, they don't like copying): https://sundials.readthedocs.io/en/latest/sundials/SUNContext_link.html#c.SUNContext_Create
Warning
For developers:
  1. This class uses Sundials-Kokkos vectors for computation, which are immediately wrapped as Sundials N_Vectors. After initialization, only interact with the N_Vector interface as per Sundials guidelines.
  2. The Sundials context is supposed to only be created and freed once in a program, making copying less desirable, see above. However we need to copy, so the context is placed in a shared_ptr to prevent early freeing. Please read the documentation about multiple, concurrent solves (you must not do them). You have been warned.

Definition at line 52 of file rungeKutta.hpp.

Member Typedef Documentation

◆ Base

template<typename SolutionFieldType >
using NeoFOAM::timeIntegration::RungeKutta< SolutionFieldType >::Base = TimeIntegratorBase<SolutionFieldType>::template Register<RungeKutta<SolutionFieldType> >

Definition at line 59 of file rungeKutta.hpp.

◆ Expression

template<typename SolutionFieldType >
using NeoFOAM::timeIntegration::RungeKutta< SolutionFieldType >::Expression = NeoFOAM::dsl::Expression

Definition at line 58 of file rungeKutta.hpp.

◆ ValueType

template<typename SolutionFieldType >
using NeoFOAM::timeIntegration::RungeKutta< SolutionFieldType >::ValueType = SolutionFieldType::FieldValueType

Definition at line 57 of file rungeKutta.hpp.

Constructor & Destructor Documentation

◆ RungeKutta() [1/4]

template<typename SolutionFieldType >
NeoFOAM::timeIntegration::RungeKutta< SolutionFieldType >::RungeKutta ( )
default

Default constructor.

◆ ~RungeKutta()

template<typename SolutionFieldType >
NeoFOAM::timeIntegration::RungeKutta< SolutionFieldType >::~RungeKutta ( )
default

Default destructor.

◆ RungeKutta() [2/4]

template<typename SolutionFieldType >
NeoFOAM::timeIntegration::RungeKutta< SolutionFieldType >::RungeKutta ( const Dictionary dict)
inline

Constructor that initializes the RungeKutta solver with a dictionary configuration.

Parameters
dictThe dictionary containing configuration parameters.

Definition at line 77 of file rungeKutta.hpp.

◆ RungeKutta() [3/4]

template<typename SolutionFieldType >
NeoFOAM::timeIntegration::RungeKutta< SolutionFieldType >::RungeKutta ( const RungeKutta< SolutionFieldType > &  other)

Copy constructor.

Parameters
otherThe RungeKutta instance to copy from.
Note
Sundials Kokkos vectors have copy constructors, N_Vectors should be constructed from the Kokkos vectors.

◆ RungeKutta() [4/4]

template<typename SolutionFieldType >
NeoFOAM::timeIntegration::RungeKutta< SolutionFieldType >::RungeKutta ( RungeKutta< SolutionFieldType > &&  other)

Move Constructor.

Parameters
otherThe RungeKutta instance to move from.

Member Function Documentation

◆ clone()

template<typename SolutionFieldType >
std::unique_ptr< TimeIntegratorBase< SolutionFieldType > > NeoFOAM::timeIntegration::RungeKutta< SolutionFieldType >::clone ( ) const
override

Return a copy of this instantiated class.

Returns
std::unique_ptr to the new copy.

◆ doc()

template<typename SolutionFieldType >
static std::string NeoFOAM::timeIntegration::RungeKutta< SolutionFieldType >::doc ( )
inlinestatic

Returns the documentation for the class.

Returns
std::string containing class documentation.

Definition at line 109 of file rungeKutta.hpp.

◆ name()

template<typename SolutionFieldType >
static std::string NeoFOAM::timeIntegration::RungeKutta< SolutionFieldType >::name ( )
inlinestatic

Returns the name of the class.

Returns
std::string("Runge-Kutta").

Definition at line 103 of file rungeKutta.hpp.

◆ operator=() [1/2]

template<typename SolutionFieldType >
RungeKutta & NeoFOAM::timeIntegration::RungeKutta< SolutionFieldType >::operator= ( const RungeKutta< SolutionFieldType > &  other)
delete

◆ operator=() [2/2]

template<typename SolutionFieldType >
RungeKutta & NeoFOAM::timeIntegration::RungeKutta< SolutionFieldType >::operator= ( RungeKutta< SolutionFieldType > &&  other)
delete

◆ schema()

template<typename SolutionFieldType >
static std::string NeoFOAM::timeIntegration::RungeKutta< SolutionFieldType >::schema ( )
inlinestatic

Returns the schema for the class.

Returns
std::string containing the schema definition.

Definition at line 115 of file rungeKutta.hpp.

◆ solve()

template<typename SolutionFieldType >
void NeoFOAM::timeIntegration::RungeKutta< SolutionFieldType >::solve ( Expression exp,
SolutionFieldType &  solutionField,
scalar  t,
const scalar  dt 
)
override

Solves one (explicit) time step, from n to n+1.

Parameters
expThe expression to be solved
solutionFieldThe field containing the solution.
tThe current time
dtThe time step size

The documentation for this class was generated from the following file: