Advanced Multi-Physics (AMP)
On-Line Documentation
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
AMP::LinearAlgebra::SundialsVector Class Referenceabstract

SundialsVector is a bridge between AMP::LinearAlgebra::Vector and the Sundials N_Vector data structure. More...

#include <SundialsVector.h>

Inheritance diagram for AMP::LinearAlgebra::SundialsVector:
Inheritance graph
[legend]

Public Member Functions

virtual std::shared_ptr< const VectorgetManagedVec () const =0
 
virtual std::shared_ptr< VectorgetManagedVec ()=0
 
N_Vector & getNativeVec ()
 
const N_Vector & getNativeVec () const
 
N_Vector & getNVector ()
 Obtain a Sundials N_Vector for use in Sundials routines.
 
const N_Vector & getNVector () const
 Obtain a Sundials N_Vector for use in Sundials routines.
 

Static Public Member Functions

static std::shared_ptr< const SundialsVectorconstView (Vector::const_shared_ptr AmpVector)
 If needed, create a Sundials wrapper for AmpVector. Otherwise, return AmpVector.
 
static std::shared_ptr< SundialsVectorview (Vector::shared_ptr AmpVector)
 If needed, create a Sundials wrapper for AmpVector. Otherwise, return AmpVector.
 

Protected Member Functions

 SundialsVector ()
 Construct a SundialsVector.
 

Protected Attributes

N_Vector d_n_vector
 Sundials NVector wrapping the data in the Vector.
 

Detailed Description

SundialsVector is a bridge between AMP::LinearAlgebra::Vector and the Sundials N_Vector data structure.

A SundialsVector has a N_Vector data structure. Given an AMP::LinearAlgebra::Vector, this class can create a Sundials view without copying the data. As such, this class serves three purposes:

  1. Provides a Sundials N_Vector for derived classes to use, fill, manage, etc.
  2. Provides an interface for accessing this Sundials N_Vector independent of derived classes
  3. Provides a static method for creating a Sundials view of an AMP Vector.

Definition at line 36 of file SundialsVector.h.

Constructor & Destructor Documentation

◆ SundialsVector()

AMP::LinearAlgebra::SundialsVector::SundialsVector ( )
protected

Construct a SundialsVector.

This can only be called by a derived class or the static function below. There is no need to create this vector directly since it is virtual.

Member Function Documentation

◆ constView()

static std::shared_ptr< const SundialsVector > AMP::LinearAlgebra::SundialsVector::constView ( Vector::const_shared_ptr  AmpVector)
static

If needed, create a Sundials wrapper for AmpVector. Otherwise, return AmpVector.

The function attempts to return a view with the least amount of work. It will never copy data. If the vector cannot be wrapped it wll return an error.

Parameters
AmpVectora shared pointer to a Vector

◆ getManagedVec() [1/2]

virtual std::shared_ptr< const Vector > AMP::LinearAlgebra::SundialsVector::getManagedVec ( ) const
pure virtual

◆ getManagedVec() [2/2]

virtual std::shared_ptr< Vector > AMP::LinearAlgebra::SundialsVector::getManagedVec ( )
pure virtual

◆ getNativeVec() [1/2]

N_Vector & AMP::LinearAlgebra::SundialsVector::getNativeVec ( )
inline

Definition at line 113 of file SundialsVector.h.

References getNVector().

◆ getNativeVec() [2/2]

const N_Vector & AMP::LinearAlgebra::SundialsVector::getNativeVec ( ) const
inline

Definition at line 114 of file SundialsVector.h.

References getNVector().

◆ getNVector() [1/2]

N_Vector & AMP::LinearAlgebra::SundialsVector::getNVector ( )

Obtain a Sundials N_Vector for use in Sundials routines.

This function is used to get a Sundials vector. The following idiom should be used since it fails gracefully. In this function, a view may be created before the NVector is extracted.

double DoSundialsMin( Vector::shared_ptr &in )
{
// Create a Sundials N_Vector if necessary
Vector::shared_ptr in_sundials_view = SundialsVector::view( in );
// Extract the N_Vector
N_Vector in_nvector =
std::dynamic_pointer_cast<SundialsVector>(in_sundials_view)->getNVector(); return N_VMin(
in_nvector );
}
static std::shared_ptr< SundialsVector > view(Vector::shared_ptr AmpVector)
If needed, create a Sundials wrapper for AmpVector. Otherwise, return AmpVector.
std::shared_ptr< Vector > shared_ptr
Shorthand for shared pointer to Vector.
Definition Vector.h:60

Referenced by getNativeVec(), and getNativeVec().

◆ getNVector() [2/2]

const N_Vector & AMP::LinearAlgebra::SundialsVector::getNVector ( ) const

Obtain a Sundials N_Vector for use in Sundials routines.

This function is used to get a Sundials vector. The following idiom should be used since it fails gracefully. In this function, a view may be created before the NVector is extracted.

double DoSundialsMin( Vector::shared_ptr &in )
{
// Create a Sundials N_Vector if necessary
Vector::shared_ptr in_sundials_view = SundialsVector::view( in );
// Extract the N_Vector
N_Vector in_nvector =
std::dynamic_pointer_cast<SundialsVector>(in_sundials_view)->getNVector(); return N_VMin(
in_nvector );
}

◆ view()

static std::shared_ptr< SundialsVector > AMP::LinearAlgebra::SundialsVector::view ( Vector::shared_ptr  AmpVector)
static

If needed, create a Sundials wrapper for AmpVector. Otherwise, return AmpVector.

The function attempts to return a view with the least amount of work. It will never copy data. If the vector cannot be wrapped it wll return an error.

Parameters
AmpVectora shared pointer to a Vector

Member Data Documentation

◆ d_n_vector

N_Vector AMP::LinearAlgebra::SundialsVector::d_n_vector
protected

Sundials NVector wrapping the data in the Vector.

However this is created, the N_Vector holds a pointer to the data used in the Vector in such a manner that is consistent with Sundials.

Definition at line 45 of file SundialsVector.h.


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



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:43.
Comments on this page