NeoN
WIP Prototype of a modern OpenFOAM core
Loading...
Searching...
No Matches
Namespaces | Classes | Functions | Variables
NeoN::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 NeoN::Vector< ValueType > &field, N_Vector &vector)
 Converts NeoN Vector data to SUNDIALS N_Vector format.
 
template<typename ValueType >
void fieldToSunNVector (const NeoN::Vector< ValueType > &field, N_Vector &vector)
 Dispatcher for field to N_Vector conversion based on executor type.
 
template<typename SKVectorType , typename ValueType >
void sunNVectorToVectorImpl (const N_Vector &vector, NeoN::Vector< ValueType > &field)
 Converts SUNDIALS N_Vector data back to NeoN Vector format.
 
template<typename ValueType >
void sunNVectorToVector (const N_Vector &vector, NeoN::Vector< ValueType > &field)
 Dispatcher for N_Vector to field conversion based on executor type.
 
template<typename SolutionVectorType >
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 SolutionVectorType >
int NeoN::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 192 of file sundials.hpp.

◆ fieldToSunNVector()

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

Dispatcher for field to N_Vector conversion based on executor type.

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

Definition at line 103 of file sundials.hpp.

◆ fieldToSunNVectorImpl()

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

Converts NeoN Vector data to SUNDIALS N_Vector format.

Template Parameters
SKVectorTypeThe SUNDIALS Kokkos vector type
ValueTypeThe field data type
Parameters
fieldSource NeoN 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 NeoN::sundials::stringToERKTable ( const std::string &  key)
inline

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.

◆ sunNVectorToVector()

template<typename ValueType >
void NeoN::sundials::sunNVectorToVector ( const N_Vector &  vector,
NeoN::Vector< 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 NeoN field

Definition at line 153 of file sundials.hpp.

◆ sunNVectorToVectorImpl()

template<typename SKVectorType , typename ValueType >
void NeoN::sundials::sunNVectorToVectorImpl ( const N_Vector &  vector,
NeoN::Vector< ValueType > &  field 
)

Converts SUNDIALS N_Vector data back to NeoN Vector format.

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

Definition at line 137 of file sundials.hpp.

Variable Documentation

◆ SUN_ARK_DELETER

auto NeoN::sundials::SUN_ARK_DELETER
inline
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 NeoN::sundials::SUN_CONTEXT_DELETER
inline
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.