NeoFOAM
WIP Prototype of a modern OpenFOAM core
Loading...
Searching...
No Matches
Namespaces | Classes | Functions | Variables
NeoFOAM::sundials Namespace Reference

Namespaces

namespace  detail
 

Classes

class  SKVector
 Unified interface for SUNDIALS Kokkos vector management. More...
 
class  SKVectorDefault
 Default executor SUNDIALS Kokkos vector wrapper. More...
 
class  SKVectorHostDefault
 Host default executor SUNDIALS Kokkos vector wrapper. More...
 
class  SKVectorSerial
 Serial executor SUNDIALS Kokkos vector wrapper. More...
 

Functions

ARKODE_ERKTableID stringToERKTable (const std::string &key)
 Maps dictionary keywords to SUNDIALS RKButcher tableau identifiers.
 
template<typename SKVectorType , typename ValueType >
void fieldToSunNVectorImpl (const NeoFOAM::Field< ValueType > &field, N_Vector &vector)
 Converts NeoFOAM Field data to SUNDIALS N_Vector format.
 
template<typename ValueType >
void fieldToSunNVector (const NeoFOAM::Field< ValueType > &field, N_Vector &vector)
 Dispatcher for field to N_Vector conversion based on executor type.
 
template<typename SKVectorType , typename ValueType >
void sunNVectorToFieldImpl (const N_Vector &vector, NeoFOAM::Field< ValueType > &field)
 Converts SUNDIALS N_Vector data back to NeoFOAM Field format.
 
template<typename ValueType >
void sunNVectorToField (const N_Vector &vector, NeoFOAM::Field< ValueType > &field)
 Dispatcher for N_Vector to field conversion based on executor type.
 
template<typename SolutionFieldType >
int explicitRKSolve (sunrealtype t, N_Vector y, N_Vector ydot, void *userData)
 Performs a single explicit Runge-Kutta stage evaluation.
 

Variables

auto SUN_CONTEXT_DELETER
 Custom deleter for SUNContext shared pointers.
 
auto SUN_ARK_DELETER
 Custom deleter for explicit type RK solvers (ERK, ARK, etc) for the unique pointers.
 

Function Documentation

◆ explicitRKSolve()

template<typename SolutionFieldType >
int NeoFOAM::sundials::explicitRKSolve ( sunrealtype  t,
N_Vector  y,
N_Vector  ydot,
void *  userData 
)

Performs a single explicit Runge-Kutta stage evaluation.

Parameters
tCurrent time value
yCurrent solution vector
ydotOutput RHS vector
userDataPointer to Expression object
Returns
0 on success, non-zero on error

This is our implementation of the RHS of explicit spacial integration, to be integrated in time. In our case user_data is a unique_ptr to an expression. In this function a 'working source' vector is created and parsed to the explicitOperation, which should contain the field variable at the start of the time step. Currently 'multi-stage RK' is not supported until y can be copied to this field.

Definition at line 191 of file sundials.hpp.

◆ fieldToSunNVector()

template<typename ValueType >
void NeoFOAM::sundials::fieldToSunNVector ( const NeoFOAM::Field< ValueType > &  field,
N_Vector &  vector 
)

Dispatcher for field to N_Vector conversion based on executor type.

Template Parameters
ValueTypeThe field data type
Parameters
fieldSource NeoFOAM field
vectorTarget SUNDIALS N_Vector
Exceptions
Runtimeerror for unsupported executors

Definition at line 102 of file sundials.hpp.

◆ fieldToSunNVectorImpl()

template<typename SKVectorType , typename ValueType >
void NeoFOAM::sundials::fieldToSunNVectorImpl ( const NeoFOAM::Field< ValueType > &  field,
N_Vector &  vector 
)

Converts NeoFOAM Field data to SUNDIALS N_Vector format.

Template Parameters
SKVectorTypeThe SUNDIALS Kokkos vector type
ValueTypeThe field data type
Parameters
fieldSource NeoFOAM field
vectorTarget SUNDIALS N_Vector
Warning
Assumes matching initialization and size between field and vector

Definition at line 86 of file sundials.hpp.

◆ stringToERKTable()

ARKODE_ERKTableID NeoFOAM::sundials::stringToERKTable ( const std::string &  key)

Maps dictionary keywords to SUNDIALS RKButcher tableau identifiers.

Parameters
keyThe name of the explicit Runge-Kutta method.
Returns
ARKODE_ERKTableID for the corresponding Butcher tableau.
Exceptions
Runtimeerror for unsupported methods.

Definition at line 57 of file sundials.hpp.

◆ sunNVectorToField()

template<typename ValueType >
void NeoFOAM::sundials::sunNVectorToField ( const N_Vector &  vector,
NeoFOAM::Field< ValueType > &  field 
)

Dispatcher for N_Vector to field conversion based on executor type.

Template Parameters
ValueTypeThe field data type
Parameters
vectorSource SUNDIALS N_Vector
fieldTarget NeoFOAM field

Definition at line 152 of file sundials.hpp.

◆ sunNVectorToFieldImpl()

template<typename SKVectorType , typename ValueType >
void NeoFOAM::sundials::sunNVectorToFieldImpl ( const N_Vector &  vector,
NeoFOAM::Field< ValueType > &  field 
)

Converts SUNDIALS N_Vector data back to NeoFOAM Field format.

Template Parameters
SKVectorTypeThe SUNDIALS Kokkos vector type
ValueTypeThe field data type
Parameters
vectorSource SUNDIALS N_Vector
fieldTarget NeoFOAM field
Warning
Assumes matching initialization and size between vector and field

Definition at line 136 of file sundials.hpp.

Variable Documentation

◆ SUN_ARK_DELETER

auto NeoFOAM::sundials::SUN_ARK_DELETER
Initial value:
= [](char* ark)
{
if (ark != nullptr)
{
void* arkodMem = reinterpret_cast<void*>(ark);
ARKodeFree(&arkodMem);
}
}

Custom deleter for explicit type RK solvers (ERK, ARK, etc) for the unique pointers.

Parameters
arkPointer to the ark memory to be freed, can be nullptr.

Safely frees the ark memory.

Definition at line 42 of file sundials.hpp.

◆ SUN_CONTEXT_DELETER

auto NeoFOAM::sundials::SUN_CONTEXT_DELETER
Initial value:
= [](SUNContext* ctx)
{
if (ctx != nullptr)
{
SUNContext_Free(ctx);
}
}

Custom deleter for SUNContext shared pointers.

Parameters
ctxPointer to the SUNContext to be freed, can be nullptr.

Safely frees the context if it's the last reference.

Definition at line 29 of file sundials.hpp.