Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
amrex::sundials Namespace Reference

Classes

class  MemoryHelper
 A SUNDIALS SUNMemoryHelper interface to the amrex::Arena. More...
 
struct  N_VectorContent_MultiFab_notptr
 

Typedefs

using N_VectorContent_MultiFab = N_VectorContent_MultiFab_notptr *
 

Functions

N_Vector N_VNewEmpty_MultiFab (sunindextype vec_length, ::sundials::Context *sunctx=The_Sundials_Context())
 Create an empty MultiFab N_Vector shell of length vec_length.
 
N_Vector N_VNew_MultiFab (sunindextype vec_length, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm, sunindextype nComp, sunindextype nGhost, ::sundials::Context *sunctx=The_Sundials_Context())
 Allocate a MultiFab-backed N_Vector of length vec_length.
 
N_Vector N_VMake_MultiFab (sunindextype vec_length, amrex::MultiFab *mf, ::sundials::Context *sunctx=The_Sundials_Context())
 Wrap an existing MultiFab mf as an N_Vector without copying.
 
sunindextype N_VGetLength_MultiFab (N_Vector v)
 Return the logical length of N_Vector v.
 
int N_VGetOwnMF_MultiFab (N_Vector v)
 Query whether v owns its MultiFab storage.
 
void N_VSetOwnMF_MultiFab (N_Vector v, int own_mf)
 Set the ownership flag on v's MultiFab.
 
N_Vector N_VCloneEmpty_MultiFab (N_Vector w)
 Create an empty clone of w that owns no data.
 
N_Vector N_VClone_MultiFab (N_Vector w)
 Create a deep clone of w including its MultiFab data.
 
void N_VDestroy_MultiFab (N_Vector v)
 Destroy v and free its resources (MultiFab if owned).
 
void N_VSpace_MultiFab (N_Vector v, sunindextype *lrw, sunindextype *liw)
 Return workspace requirements for v.
 
N_VectorContent_MultiFab N_VGetContent_MultiFab (N_Vector v)
 Access the implementation-specific content stored in v.
 
amrex::MultiFab *& getMFptr (N_Vector v)
 Access the MultiFab pointer stored inside v (non-const).
 
amrex::MultiFabN_VGetVectorPointer_MultiFab (N_Vector v)
 Return the wrapped MultiFab pointer from v.
 
amrex::MultiFab N_VGetVectorAlias_MultiFab (N_Vector v)
 Return a shallow alias of the MultiFab stored in v.
 
void N_VLinearSum_MultiFab (amrex::Real a, N_Vector x, amrex::Real b, N_Vector y, N_Vector z)
 Compute z = a x + b y.
 
void N_VConst_MultiFab (amrex::Real c, N_Vector z)
 Fill z with the constant c.
 
void N_VProd_MultiFab (N_Vector x, N_Vector y, N_Vector z)
 Compute the element-wise product z = x * y.
 
void N_VDiv_MultiFab (N_Vector x, N_Vector y, N_Vector z)
 Compute the element-wise quotient z = x / y.
 
void N_VScale_MultiFab (amrex::Real c, N_Vector x, N_Vector z)
 Compute the scalar product z = c * x.
 
void N_VAbs_MultiFab (N_Vector x, N_Vector z)
 Compute the element-wise absolute value z = |x|.
 
void N_VInv_MultiFab (N_Vector x, N_Vector z)
 Compute the element-wise inverse z = 1 / x.
 
void N_VAddConst_MultiFab (N_Vector x, amrex::Real b, N_Vector z)
 Compute z = x + b.
 
amrex::Real N_VDotProd_MultiFab (N_Vector x, N_Vector y)
 Return the dot product x · y.
 
amrex::Real N_VMaxNorm_MultiFab (N_Vector x)
 Return the infinity norm of x.
 
amrex::Real N_VWrmsNorm_MultiFab (N_Vector x, N_Vector w)
 Return the weighted RMS norm of x using weights w.
 
amrex::Real N_VWrmsNormMask_MultiFab (N_Vector x, N_Vector w, N_Vector id)
 Return the weighted RMS norm restricted by mask id.
 
amrex::Real N_VMin_MultiFab (N_Vector x)
 Return the minimum entry of x.
 
amrex::Real NormHelper_NVector_MultiFab (N_Vector x, N_Vector w, N_Vector id, int use_id, bool rms)
 Helper that computes weighted norms or RMS values.
 
amrex::Real N_VWL2Norm_MultiFab (N_Vector x, N_Vector w)
 Return the weighted L2 norm of x using weights w.
 
amrex::Real N_VL1Norm_MultiFab (N_Vector x)
 Return the L1 norm (sum of absolute values) of x.
 
void N_VCompare_MultiFab (amrex::Real a, N_Vector x, N_Vector z)
 Build a mask z where entries of x exceed a.
 
int N_VInvTest_MultiFab (N_Vector x, N_Vector z)
 Compute the element-wise inverse test z = 1 / x, returning failure if zero encountered.
 
int N_VConstrMask_MultiFab (N_Vector a_a, N_Vector x, N_Vector m)
 Apply constraint masking from a_a to produce mask m.
 
amrex::Real N_VMinQuotient_MultiFab (N_Vector num, N_Vector denom)
 Return the minimum element-wise quotient num / denom.
 
void Initialize (int nthreads)
 Initialize the AMReX-SUNDIALS interface.
 
void Finalize ()
 Cleanup everything allocated for the AMReX-SUNDIALS interface.
 
::sundials::Context * The_Sundials_Context (int i=amrex::OpenMP::get_thread_num())
 Get the i-th SUNDIALS context instance.
 
MemoryHelperThe_SUNMemory_Helper (int i=amrex::OpenMP::get_thread_num())
 Get the OpenMP-thread-local SUNMemoryHelper instance.
 
amrex::ArenagetArena (SUNMemoryType type)
 Return the AMReX arena used to satisfy allocations of type.
 

Typedef Documentation

◆ N_VectorContent_MultiFab

Function Documentation

◆ Finalize()

void amrex::sundials::Finalize ( )

Cleanup everything allocated for the AMReX-SUNDIALS interface.

Called by amrex::Finalize.

◆ getArena()

amrex::Arena * amrex::sundials::getArena ( SUNMemoryType  type)

Return the AMReX arena used to satisfy allocations of type.

Parameters
[in]typeSUNDIALS memory type requested (host, pinned, device, etc.).
Returns
Corresponding amrex::Arena pointer.

◆ getMFptr()

MultiFab *& amrex::sundials::getMFptr ( N_Vector  v)

Access the MultiFab pointer stored inside v (non-const).

Parameters
vVector whose pointer is returned.
Returns
Reference to the MultiFab pointer for direct manipulation.

◆ Initialize()

void amrex::sundials::Initialize ( int  nthreads)

Initialize the AMReX-SUNDIALS interface.

Parameters
[in]nthreadsThe number of threads that will be used with SUNDIALS.

This will create the nthreads SUNDIALS context objects that are needed by the SUNDIALS solver and vector objects. Called by amrex::Initialize.

◆ N_VAbs_MultiFab()

void amrex::sundials::N_VAbs_MultiFab ( N_Vector  x,
N_Vector  z 
)

Compute the element-wise absolute value z = |x|.

Parameters
xInput vector.
zOutput vector receiving the magnitudes.

◆ N_VAddConst_MultiFab()

void amrex::sundials::N_VAddConst_MultiFab ( N_Vector  x,
amrex::Real  b,
N_Vector  z 
)

Compute z = x + b.

Parameters
xInput vector.
bScalar shift applied to every entry.
zOutput vector.

◆ N_VClone_MultiFab()

N_Vector amrex::sundials::N_VClone_MultiFab ( N_Vector  w)

Create a deep clone of w including its MultiFab data.

Parameters
wTemplate vector to clone.
Returns
New vector with copied storage.

◆ N_VCloneEmpty_MultiFab()

N_Vector amrex::sundials::N_VCloneEmpty_MultiFab ( N_Vector  w)

Create an empty clone of w that owns no data.

Parameters
wTemplate vector describing the layout.
Returns
Empty clone matching w.

◆ N_VCompare_MultiFab()

void amrex::sundials::N_VCompare_MultiFab ( amrex::Real  a,
N_Vector  x,
N_Vector  z 
)

Build a mask z where entries of x exceed a.

Parameters
aThreshold value.
xInput vector.
zOutput mask (1 where |x| >= a, 0 otherwise).

◆ N_VConst_MultiFab()

void amrex::sundials::N_VConst_MultiFab ( amrex::Real  c,
N_Vector  z 
)

Fill z with the constant c.

Parameters
cValue assigned to every entry.
zDestination vector.

◆ N_VConstrMask_MultiFab()

int amrex::sundials::N_VConstrMask_MultiFab ( N_Vector  a_a,
N_Vector  x,
N_Vector  m 
)

Apply constraint masking from a_a to produce mask m.

Parameters
a_aConstraint vector (per SUNDIALS conventions).
xSolution vector tested against constraints.
mOutput mask updated in place.
Returns
Non-zero if all constraints satisfied, zero otherwise.

◆ N_VDestroy_MultiFab()

void amrex::sundials::N_VDestroy_MultiFab ( N_Vector  v)

Destroy v and free its resources (MultiFab if owned).

Parameters
vVector to destroy.

◆ N_VDiv_MultiFab()

void amrex::sundials::N_VDiv_MultiFab ( N_Vector  x,
N_Vector  y,
N_Vector  z 
)

Compute the element-wise quotient z = x / y.

Parameters
xNumerator vector.
yDenominator vector.
zOutput vector receiving the quotient.

◆ N_VDotProd_MultiFab()

amrex::Real amrex::sundials::N_VDotProd_MultiFab ( N_Vector  x,
N_Vector  y 
)

Return the dot product x · y.

Parameters
xFirst operand.
ySecond operand.
Returns
Scalar dot product.

◆ N_VGetContent_MultiFab()

N_VectorContent_MultiFab amrex::sundials::N_VGetContent_MultiFab ( N_Vector  v)

Access the implementation-specific content stored in v.

Parameters
vVector whose content is returned.
Returns
Pointer to the MultiFab content structure.

◆ N_VGetLength_MultiFab()

sunindextype amrex::sundials::N_VGetLength_MultiFab ( N_Vector  v)

Return the logical length of N_Vector v.

Parameters
vVector to inspect.
Returns
Number of scalar entries represented by v.

◆ N_VGetOwnMF_MultiFab()

int amrex::sundials::N_VGetOwnMF_MultiFab ( N_Vector  v)

Query whether v owns its MultiFab storage.

Parameters
vVector to inspect.
Returns
Non-zero if the vector owns its MultiFab, zero otherwise.

◆ N_VGetVectorAlias_MultiFab()

MultiFab amrex::sundials::N_VGetVectorAlias_MultiFab ( N_Vector  v)

Return a shallow alias of the MultiFab stored in v.

Parameters
vVector whose data are aliased.
Returns
MultiFab alias referencing the same storage as v.

◆ N_VGetVectorPointer_MultiFab()

MultiFab * amrex::sundials::N_VGetVectorPointer_MultiFab ( N_Vector  v)

Return the wrapped MultiFab pointer from v.

Parameters
vVector whose MultiFab pointer is returned.
Returns
Pointer to the underlying MultiFab.

◆ N_VInv_MultiFab()

void amrex::sundials::N_VInv_MultiFab ( N_Vector  x,
N_Vector  z 
)

Compute the element-wise inverse z = 1 / x.

Parameters
xInput vector.
zOutput vector receiving the reciprocals.

◆ N_VInvTest_MultiFab()

int amrex::sundials::N_VInvTest_MultiFab ( N_Vector  x,
N_Vector  z 
)

Compute the element-wise inverse test z = 1 / x, returning failure if zero encountered.

Parameters
xInput vector.
zOutput vector receiving reciprocals.
Returns
1 on success, 0 if a zero pivot was encountered.

◆ N_VL1Norm_MultiFab()

amrex::Real amrex::sundials::N_VL1Norm_MultiFab ( N_Vector  x)

Return the L1 norm (sum of absolute values) of x.

Parameters
xVector whose norm is computed.
Returns
L1 norm.

◆ N_VLinearSum_MultiFab()

void amrex::sundials::N_VLinearSum_MultiFab ( amrex::Real  a,
N_Vector  x,
amrex::Real  b,
N_Vector  y,
N_Vector  z 
)

Compute z = a x + b y.

Parameters
aScalar multiplier for x.
xFirst operand.
bScalar multiplier for y.
ySecond operand.
zOutput vector receiving the sum.

◆ N_VMake_MultiFab()

N_Vector amrex::sundials::N_VMake_MultiFab ( sunindextype  vec_length,
amrex::MultiFab mf,
::sundials::Context *  sunctx = The_Sundials_Context() 
)

Wrap an existing MultiFab mf as an N_Vector without copying.

Parameters
vec_lengthNumber of scalar entries represented.
mfMultiFab that supplies the storage.
sunctxOptional SUNDIALS context; defaults to The_Sundials_Context().
Returns
Non-owning N_Vector referencing mf.

◆ N_VMaxNorm_MultiFab()

amrex::Real amrex::sundials::N_VMaxNorm_MultiFab ( N_Vector  x)

Return the infinity norm of x.

Parameters
xVector whose norm is computed.
Returns
Infinity norm.

◆ N_VMin_MultiFab()

amrex::Real amrex::sundials::N_VMin_MultiFab ( N_Vector  x)

Return the minimum entry of x.

Parameters
xVector to inspect.
Returns
Minimum value.

◆ N_VMinQuotient_MultiFab()

amrex::Real amrex::sundials::N_VMinQuotient_MultiFab ( N_Vector  num,
N_Vector  denom 
)

Return the minimum element-wise quotient num / denom.

Parameters
numNumerator vector.
denomDenominator vector.
Returns
Minimum quotient over all entries.

◆ N_VNew_MultiFab()

N_Vector amrex::sundials::N_VNew_MultiFab ( sunindextype  vec_length,
const amrex::BoxArray ba,
const amrex::DistributionMapping dm,
sunindextype  nComp,
sunindextype  nGhost,
::sundials::Context *  sunctx = The_Sundials_Context() 
)

Allocate a MultiFab-backed N_Vector of length vec_length.

Parameters
vec_lengthNumber of scalar entries represented.
baGrid layout.
dmDistribution map for ba.
nCompNumber of state components per cell.
nGhostNumber of grow cells.
sunctxOptional SUNDIALS context used for bookkeeping.
Returns
Newly allocated N_Vector that owns its MultiFab data.

◆ N_VNewEmpty_MultiFab()

N_Vector amrex::sundials::N_VNewEmpty_MultiFab ( sunindextype  vec_length,
::sundials::Context *  sunctx = The_Sundials_Context() 
)

Create an empty MultiFab N_Vector shell of length vec_length.

The returned vector owns no data until a MultiFab is attached.

Parameters
vec_lengthNumber of scalar entries represented.
sunctxOptional SUNDIALS context; defaults to amrex::sundials::The_Sundials_Context().
Returns
Newly allocated N_Vector shell.

◆ N_VProd_MultiFab()

void amrex::sundials::N_VProd_MultiFab ( N_Vector  x,
N_Vector  y,
N_Vector  z 
)

Compute the element-wise product z = x * y.

Parameters
xFirst operand.
ySecond operand.
zOutput vector receiving the product.

◆ N_VScale_MultiFab()

void amrex::sundials::N_VScale_MultiFab ( amrex::Real  c,
N_Vector  x,
N_Vector  z 
)

Compute the scalar product z = c * x.

Parameters
cScalar multiplier.
xInput vector.
zOutput vector receiving the scaled values.

◆ N_VSetOwnMF_MultiFab()

void amrex::sundials::N_VSetOwnMF_MultiFab ( N_Vector  v,
int  own_mf 
)

Set the ownership flag on v's MultiFab.

Parameters
vVector whose flag is modified.
own_mfNon-zero if the vector should free its MultiFab on destroy.

◆ N_VSpace_MultiFab()

void amrex::sundials::N_VSpace_MultiFab ( N_Vector  v,
sunindextype *  lrw,
sunindextype *  liw 
)

Return workspace requirements for v.

Parameters
vVector to inspect.
lrwSet to the number of real workspace entries.
liwSet to the number of integer workspace entries.

◆ N_VWL2Norm_MultiFab()

amrex::Real amrex::sundials::N_VWL2Norm_MultiFab ( N_Vector  x,
N_Vector  w 
)

Return the weighted L2 norm of x using weights w.

Parameters
xVector whose norm is computed.
wWeight vector.
Returns
Weighted L2 norm.

◆ N_VWrmsNorm_MultiFab()

amrex::Real amrex::sundials::N_VWrmsNorm_MultiFab ( N_Vector  x,
N_Vector  w 
)

Return the weighted RMS norm of x using weights w.

Parameters
xVector whose norm is computed.
wWeight vector.
Returns
Weighted RMS norm.

◆ N_VWrmsNormMask_MultiFab()

amrex::Real amrex::sundials::N_VWrmsNormMask_MultiFab ( N_Vector  x,
N_Vector  w,
N_Vector  id 
)

Return the weighted RMS norm restricted by mask id.

Parameters
xVector whose norm is computed.
wWeight vector.
idMask vector indicating included entries.
Returns
Masked weighted RMS norm.

◆ NormHelper_NVector_MultiFab()

amrex::Real amrex::sundials::NormHelper_NVector_MultiFab ( N_Vector  x,
N_Vector  w,
N_Vector  id,
int  use_id,
bool  rms 
)

Helper that computes weighted norms or RMS values.

Parameters
xInput vector.
wWeight vector (optional).
idMask vector (optional).
use_idNon-zero to restrict to entries where id is non-zero.
rmsTrue for RMS norm, false for weighted L2.
Returns
Computed norm value.

◆ The_Sundials_Context()

sundials::Context * amrex::sundials::The_Sundials_Context ( int  i = amrex::OpenMP::get_thread_num())

Get the i-th SUNDIALS context instance.

Parameters
[in]iThe index of the SUNDIALS context to return.

A SUNDIALS context should not be used concurrently from different threads.

◆ The_SUNMemory_Helper()

MemoryHelper * amrex::sundials::The_SUNMemory_Helper ( int  i = amrex::OpenMP::get_thread_num())

Get the OpenMP-thread-local SUNMemoryHelper instance.

Parameters
[in]iThread index (defaults to current thread).
Returns
Helper aligned with the i-th SUNContext.