Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
AMReX_NVector_MultiFab.H
Go to the documentation of this file.
1/*------------------------------------------------------------------------------
2 Header file for N_Vector wrap of an AMReX 'MultiFab'. Based on example codes
3 for the 2019 Argonne Training Program in Extreme-Scale Computing with SUNDIALS
4 and AMReX.
5
6 Authors (alphabetical):
7 David Gardner (gardner48@llnl.gov)
8 John Loffeld (loffeld1@llnl.gov)
9 Daniel Reynolds (reynolds@smu.edu)
10 Donald Willcox (dewillcox@lbl.gov)
11 ----------------------------------------------------------------------------*/
12#ifndef AMREX_NVECTOR_MULTIFAB_H_
13#define AMREX_NVECTOR_MULTIFAB_H_
14
22#include <AMReX_Array.H>
23#include <AMReX_Geometry.H>
24#include <AMReX_MultiFab.H>
25#include <AMReX_MultiFabUtil.H>
26#include <AMReX_Sundials_Core.H>
27
28#include <sundials/sundials_nvector.h>
29#include <cstdio>
30
31#ifdef __cplusplus /* wrapper to enable C++ usage */
32namespace amrex::sundials {
33extern "C" {
34#endif
35
36/* -----------------------------------------------------------------
37 * Vector content structure
38 * -----------------------------------------------------------------*/
39
45
47
48/* -----------------------------------------------------------------
49 * Exported functions
50 * -----------------------------------------------------------------*/
51
61N_Vector N_VNewEmpty_MultiFab(sunindextype vec_length,
62 ::sundials::Context* sunctx = The_Sundials_Context());
63
75N_Vector N_VNew_MultiFab(sunindextype vec_length,
76 const amrex::BoxArray &ba,
78 sunindextype nComp,
79 sunindextype nGhost,
80 ::sundials::Context* sunctx = The_Sundials_Context());
81
90N_Vector N_VMake_MultiFab(sunindextype vec_length,
92 ::sundials::Context* sunctx = The_Sundials_Context());
93
100sunindextype N_VGetLength_MultiFab(N_Vector v);
101
108int N_VGetOwnMF_MultiFab(N_Vector v);
109
116void N_VSetOwnMF_MultiFab(N_Vector v, int own_mf);
117
124N_Vector N_VCloneEmpty_MultiFab(N_Vector w);
125
132N_Vector N_VClone_MultiFab(N_Vector w);
133
139void N_VDestroy_MultiFab(N_Vector v);
140
148void N_VSpace_MultiFab(N_Vector v, sunindextype *lrw,
149 sunindextype *liw);
150
158
166
177amrex::Real NormHelper_NVector_MultiFab(N_Vector x, N_Vector w, N_Vector id, int use_id, bool rms);
178
179/* standard vector operations */
180
190void N_VLinearSum_MultiFab(amrex::Real a, N_Vector x,
191 amrex::Real b, N_Vector y, N_Vector z);
192
199void N_VConst_MultiFab(amrex::Real c, N_Vector z);
200
208void N_VProd_MultiFab(N_Vector x, N_Vector y, N_Vector z);
209
217void N_VDiv_MultiFab(N_Vector x, N_Vector y, N_Vector z);
218
226void N_VScale_MultiFab(amrex::Real c, N_Vector x, N_Vector z);
227
234void N_VAbs_MultiFab(N_Vector x, N_Vector z);
235
242void N_VInv_MultiFab(N_Vector x, N_Vector z);
243
251void N_VAddConst_MultiFab(N_Vector x, amrex::Real b, N_Vector z);
252
260amrex::Real N_VDotProd_MultiFab(N_Vector x, N_Vector y);
261
269
277amrex::Real N_VWrmsNorm_MultiFab(N_Vector x, N_Vector w);
278
287amrex::Real N_VWrmsNormMask_MultiFab(N_Vector x, N_Vector w,
288 N_Vector id);
289
297
305amrex::Real N_VWL2Norm_MultiFab(N_Vector x, N_Vector w);
306
314
322void N_VCompare_MultiFab(amrex::Real a, N_Vector x, N_Vector z);
323
331int N_VInvTest_MultiFab(N_Vector x, N_Vector z);
332
341int N_VConstrMask_MultiFab(N_Vector a_a, N_Vector x,
342 N_Vector m);
343
351amrex::Real N_VMinQuotient_MultiFab(N_Vector num, N_Vector denom);
352
353#ifdef __cplusplus
354} // extern "C"
355
362MultiFab*& getMFptr(N_Vector v);
363
371
372}//namespace amrex::sundials
373#endif
374
375#endif
A collection of Boxes stored in an Array.
Definition AMReX_BoxArray.H:568
Calculates the distribution of FABs to MPI processes.
Definition AMReX_DistributionMapping.H:43
A collection (stored as an array) of FArrayBox objects.
Definition AMReX_MultiFab.H:40
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:79
Definition AMReX_NVector_MultiFab.cpp:17
N_Vector N_VClone_MultiFab(N_Vector w)
Create a deep clone of w including its MultiFab data.
Definition AMReX_NVector_MultiFab.cpp:181
N_Vector N_VMake_MultiFab(sunindextype length, amrex::MultiFab *v_mf, ::sundials::Context *sunctx)
Wrap an existing MultiFab mf as an N_Vector without copying.
Definition AMReX_NVector_MultiFab.cpp:105
void N_VConst_MultiFab(amrex::Real c, N_Vector z)
Fill z with the constant c.
Definition AMReX_NVector_MultiFab.cpp:268
void N_VSetOwnMF_MultiFab(N_Vector v, int own_mf_in)
Set the ownership flag on v's MultiFab.
Definition AMReX_NVector_MultiFab.cpp:144
void N_VSpace_MultiFab(N_Vector v, sunindextype *lrw, sunindextype *liw)
Return workspace requirements for v.
Definition AMReX_NVector_MultiFab.cpp:219
void N_VAbs_MultiFab(N_Vector x, N_Vector z)
Compute the element-wise absolute value z = |x|.
Definition AMReX_NVector_MultiFab.cpp:315
void N_VCompare_MultiFab(amrex::Real a, N_Vector x, N_Vector z)
Build a mask z where entries of x exceed a.
Definition AMReX_NVector_MultiFab.cpp:503
amrex::Real N_VDotProd_MultiFab(N_Vector x, N_Vector y)
Return the dot product x ยท y.
Definition AMReX_NVector_MultiFab.cpp:364
sunindextype N_VGetLength_MultiFab(N_Vector v)
Return the logical length of N_Vector v.
Definition AMReX_NVector_MultiFab.cpp:124
N_Vector N_VCloneEmpty_MultiFab(N_Vector w)
Create an empty clone of w that owns no data.
Definition AMReX_NVector_MultiFab.cpp:157
void N_VAddConst_MultiFab(N_Vector x, amrex::Real b, N_Vector z)
Compute z = x + b.
Definition AMReX_NVector_MultiFab.cpp:351
void N_VScale_MultiFab(amrex::Real c, N_Vector x, N_Vector z)
Compute the scalar product z = c * x.
Definition AMReX_NVector_MultiFab.cpp:302
N_VectorContent_MultiFab N_VGetContent_MultiFab(N_Vector v)
Access the implementation-specific content stored in v.
Definition AMReX_NVector_MultiFab.cpp:225
amrex::Real N_VMin_MultiFab(N_Vector x)
Return the minimum entry of x.
Definition AMReX_NVector_MultiFab.cpp:416
amrex::Real N_VMaxNorm_MultiFab(N_Vector x)
Return the infinity norm of x.
Definition AMReX_NVector_MultiFab.cpp:379
int N_VConstrMask_MultiFab(N_Vector a_a, N_Vector a_x, N_Vector a_m)
Apply constraint masking from a_a to produce mask m.
Definition AMReX_NVector_MultiFab.cpp:557
amrex::Real N_VMinQuotient_MultiFab(N_Vector a_num, N_Vector a_denom)
Return the minimum element-wise quotient num / denom.
Definition AMReX_NVector_MultiFab.cpp:602
N_Vector N_VNewEmpty_MultiFab(sunindextype length, ::sundials::Context *sunctx)
Create an empty MultiFab N_Vector shell of length vec_length.
Definition AMReX_NVector_MultiFab.cpp:29
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.
Definition AMReX_NVector_MultiFab.cpp:254
amrex::Real NormHelper_NVector_MultiFab(N_Vector a_x, N_Vector a_w, N_Vector id, int use_id, bool rms)
Helper that computes weighted norms or RMS values.
Definition AMReX_NVector_MultiFab.cpp:440
int N_VGetOwnMF_MultiFab(N_Vector v)
Query whether v owns its MultiFab storage.
Definition AMReX_NVector_MultiFab.cpp:134
amrex::Real N_VWrmsNormMask_MultiFab(N_Vector x, N_Vector w, N_Vector id)
Return the weighted RMS norm restricted by mask id.
Definition AMReX_NVector_MultiFab.cpp:411
::sundials::Context * The_Sundials_Context(int i)
Get the i-th SUNDIALS context instance.
Definition AMReX_Sundials_Core.cpp:50
void N_VDiv_MultiFab(N_Vector x, N_Vector y, N_Vector z)
Compute the element-wise quotient z = x / y.
Definition AMReX_NVector_MultiFab.cpp:288
int N_VInvTest_MultiFab(N_Vector x, N_Vector z)
Compute the element-wise inverse test z = 1 / x, returning failure if zero encountered.
Definition AMReX_NVector_MultiFab.cpp:525
void N_VProd_MultiFab(N_Vector x, N_Vector y, N_Vector z)
Compute the element-wise product z = x * y.
Definition AMReX_NVector_MultiFab.cpp:274
void N_VInv_MultiFab(N_Vector x, N_Vector z)
Compute the element-wise inverse z = 1 / x.
Definition AMReX_NVector_MultiFab.cpp:338
amrex::Real N_VL1Norm_MultiFab(N_Vector x)
Return the L1 norm (sum of absolute values) of x.
Definition AMReX_NVector_MultiFab.cpp:482
void N_VDestroy_MultiFab(N_Vector v)
Destroy v and free its resources (MultiFab if owned).
Definition AMReX_NVector_MultiFab.cpp:206
amrex::MultiFab N_VGetVectorAlias_MultiFab(N_Vector v)
Return a shallow alias of the MultiFab stored in v.
Definition AMReX_NVector_MultiFab.cpp:247
amrex::Real N_VWrmsNorm_MultiFab(N_Vector x, N_Vector w)
Return the weighted RMS norm of x using weights w.
Definition AMReX_NVector_MultiFab.cpp:404
amrex::MultiFab *& getMFptr(N_Vector v)
Access the MultiFab pointer stored inside v (non-const).
Definition AMReX_NVector_MultiFab.cpp:233
amrex::MultiFab * N_VGetVectorPointer_MultiFab(N_Vector v)
Return the wrapped MultiFab pointer from v.
Definition AMReX_NVector_MultiFab.cpp:238
N_Vector N_VNew_MultiFab(sunindextype length, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm, sunindextype nComp, sunindextype nGhost, ::sundials::Context *sunctx)
Allocate a MultiFab-backed N_Vector of length vec_length.
Definition AMReX_NVector_MultiFab.cpp:80
amrex::Real N_VWL2Norm_MultiFab(N_Vector x, N_Vector w)
Return the weighted L2 norm of x using weights w.
Definition AMReX_NVector_MultiFab.cpp:475
int nComp(FabArrayBase const &fa)
Definition AMReX_FabArrayBase.cpp:2851
Definition AMReX_NVector_MultiFab.H:40
sunindextype length
Logical vector length (number of scalar entries).
Definition AMReX_NVector_MultiFab.H:41
amrex::MultiFab * mf
Wrapped MultiFab storage.
Definition AMReX_NVector_MultiFab.H:43
int own_mf
Non-zero if this wrapper owns the MultiFab.
Definition AMReX_NVector_MultiFab.H:42