Block-Structured AMR Software Framework
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 
15 #include <AMReX_Array.H>
16 #include <AMReX_Geometry.H>
17 #include <AMReX_MultiFab.H>
18 #include <AMReX_MultiFabUtil.H>
19 #include <AMReX_Sundials_Core.H>
20 
21 #include <sundials/sundials_nvector.h>
22 #include <cstdio>
23 
24 #ifdef __cplusplus /* wrapper to enable C++ usage */
25 namespace amrex::sundials {
26 extern "C" {
27 #endif
28 
29 /* -----------------------------------------------------------------
30  * Vector content structure
31  * -----------------------------------------------------------------*/
32 
34  sunindextype length; /* vector length */
35  int own_mf; /* MultiFab ownership flag */
36  amrex::MultiFab *mf; /* wrapped MultiFab */
37 };
38 
40 
41 /* -----------------------------------------------------------------
42  * Exported functions
43  * -----------------------------------------------------------------*/
44 
45 N_Vector N_VNewEmpty_MultiFab(sunindextype vec_length,
46  ::sundials::Context* sunctx = The_Sundials_Context());
47 N_Vector N_VNew_MultiFab(sunindextype vec_length,
48  const amrex::BoxArray &ba,
50  sunindextype nComp,
51  sunindextype nGhost,
52  ::sundials::Context* sunctx = The_Sundials_Context());
53 N_Vector N_VMake_MultiFab(sunindextype vec_length,
54  amrex::MultiFab *mf,
55  ::sundials::Context* sunctx = The_Sundials_Context());
56 sunindextype N_VGetLength_MultiFab(N_Vector v);
57 int N_VGetOwnMF_MultiFab(N_Vector v);
58 void N_VSetOwnMF_MultiFab(N_Vector v, int own_mf);
59 N_Vector N_VCloneEmpty_MultiFab(N_Vector w);
60 N_Vector N_VClone_MultiFab(N_Vector w);
61 void N_VDestroy_MultiFab(N_Vector v);
62 void N_VSpace_MultiFab(N_Vector v, sunindextype *lrw,
63  sunindextype *liw);
65 MultiFab* N_VGetVectorPointer_MultiFab(N_Vector v);
66 amrex::Real NormHelper_NVector_MultiFab(N_Vector x, N_Vector w, N_Vector id, int use_id, bool rms);
67 /* standard vector operations */
68 void N_VLinearSum_MultiFab(amrex::Real a, N_Vector x,
69  amrex::Real b, N_Vector y, N_Vector z);
70 void N_VConst_MultiFab(amrex::Real c, N_Vector z);
71 void N_VProd_MultiFab(N_Vector x, N_Vector y, N_Vector z);
72 void N_VDiv_MultiFab(N_Vector x, N_Vector y, N_Vector z);
73 void N_VScale_MultiFab(amrex::Real c, N_Vector x, N_Vector z);
74 void N_VAbs_MultiFab(N_Vector x, N_Vector z);
75 void N_VInv_MultiFab(N_Vector x, N_Vector z);
76 void N_VAddConst_MultiFab(N_Vector x, amrex::Real b, N_Vector z);
77 amrex::Real N_VDotProd_MultiFab(N_Vector x, N_Vector y);
78 amrex::Real N_VMaxNorm_MultiFab(N_Vector x);
79 amrex::Real N_VWrmsNorm_MultiFab(N_Vector x, N_Vector w);
80 amrex::Real N_VWrmsNormMask_MultiFab(N_Vector x, N_Vector w,
81  N_Vector id);
82 amrex::Real N_VMin_MultiFab(N_Vector x);
83 amrex::Real N_VWL2Norm_MultiFab(N_Vector x, N_Vector w);
84 amrex::Real N_VL1Norm_MultiFab(N_Vector x);
85 void N_VCompare_MultiFab(amrex::Real a, N_Vector x, N_Vector z);
86 int N_VInvTest_MultiFab(N_Vector x, N_Vector z);
87 int N_VConstrMask_MultiFab(N_Vector a_a, N_Vector x,
88  N_Vector m);
89 amrex::Real N_VMinQuotient_MultiFab(N_Vector num, N_Vector denom);
90 
91 #ifdef __cplusplus
92 } // extern "C"
93 
94 MultiFab*& getMFptr(N_Vector v);
95 MultiFab N_VGetVectorAlias_MultiFab(N_Vector v);
96 
97 }//namespace amrex::sundials
98 #endif
99 
100 #endif
A collection of Boxes stored in an Array.
Definition: AMReX_BoxArray.H:550
Calculates the distribution of FABs to MPI processes.
Definition: AMReX_DistributionMapping.H:41
A collection (stored as an array) of FArrayBox objects.
Definition: AMReX_MultiFab.H:38
Definition: AMReX_NVector_MultiFab.cpp:15
int N_VConstrMask_MultiFab(N_Vector a_a, N_Vector a_x, N_Vector a_m)
Definition: AMReX_NVector_MultiFab.cpp:552
N_Vector N_VClone_MultiFab(N_Vector w)
Definition: AMReX_NVector_MultiFab.cpp:179
void N_VConst_MultiFab(amrex::Real c, N_Vector z)
Definition: AMReX_NVector_MultiFab.cpp:263
amrex::MultiFab N_VGetVectorAlias_MultiFab(N_Vector v)
Definition: AMReX_NVector_MultiFab.cpp:242
void N_VSpace_MultiFab(N_Vector v, sunindextype *lrw, sunindextype *liw)
Definition: AMReX_NVector_MultiFab.cpp:214
void N_VAbs_MultiFab(N_Vector x, N_Vector z)
Definition: AMReX_NVector_MultiFab.cpp:310
void N_VCompare_MultiFab(amrex::Real a, N_Vector x, N_Vector z)
Definition: AMReX_NVector_MultiFab.cpp:497
amrex::MultiFab *& getMFptr(N_Vector v)
Definition: AMReX_NVector_MultiFab.cpp:228
amrex::Real N_VDotProd_MultiFab(N_Vector x, N_Vector y)
Definition: AMReX_NVector_MultiFab.cpp:359
sunindextype N_VGetLength_MultiFab(N_Vector v)
Definition: AMReX_NVector_MultiFab.cpp:122
N_Vector N_VCloneEmpty_MultiFab(N_Vector w)
Definition: AMReX_NVector_MultiFab.cpp:155
void N_VAddConst_MultiFab(N_Vector x, amrex::Real b, N_Vector z)
Definition: AMReX_NVector_MultiFab.cpp:346
void N_VScale_MultiFab(amrex::Real c, N_Vector x, N_Vector z)
Definition: AMReX_NVector_MultiFab.cpp:297
N_VectorContent_MultiFab N_VGetContent_MultiFab(N_Vector v)
Definition: AMReX_NVector_MultiFab.cpp:220
amrex::Real N_VMinQuotient_MultiFab(N_Vector a_num, N_Vector a_denom)
Definition: AMReX_NVector_MultiFab.cpp:597
amrex::Real N_VMin_MultiFab(N_Vector x)
Definition: AMReX_NVector_MultiFab.cpp:410
amrex::Real N_VMaxNorm_MultiFab(N_Vector x)
Definition: AMReX_NVector_MultiFab.cpp:374
void N_VLinearSum_MultiFab(amrex::Real a, N_Vector x, amrex::Real b, N_Vector y, N_Vector z)
Definition: AMReX_NVector_MultiFab.cpp:249
amrex::Real NormHelper_NVector_MultiFab(N_Vector a_x, N_Vector a_w, N_Vector id, int use_id, bool rms)
Definition: AMReX_NVector_MultiFab.cpp:434
int N_VGetOwnMF_MultiFab(N_Vector v)
Definition: AMReX_NVector_MultiFab.cpp:132
amrex::Real N_VWrmsNormMask_MultiFab(N_Vector x, N_Vector w, N_Vector id)
Definition: AMReX_NVector_MultiFab.cpp:405
::sundials::Context * The_Sundials_Context(int i)
Get the i-th SUNDIALS context instance.
Definition: AMReX_Sundials_Core.cpp:50
amrex::MultiFab * N_VGetVectorPointer_MultiFab(N_Vector v)
Definition: AMReX_NVector_MultiFab.cpp:233
void N_VDiv_MultiFab(N_Vector x, N_Vector y, N_Vector z)
Definition: AMReX_NVector_MultiFab.cpp:283
N_Vector N_VMake_MultiFab(sunindextype length, amrex::MultiFab *v_mf, ::sundials::Context *sunctx)
Definition: AMReX_NVector_MultiFab.cpp:103
int N_VInvTest_MultiFab(N_Vector x, N_Vector z)
Definition: AMReX_NVector_MultiFab.cpp:519
void N_VProd_MultiFab(N_Vector x, N_Vector y, N_Vector z)
Definition: AMReX_NVector_MultiFab.cpp:269
void N_VInv_MultiFab(N_Vector x, N_Vector z)
Definition: AMReX_NVector_MultiFab.cpp:333
amrex::Real N_VL1Norm_MultiFab(N_Vector x)
Definition: AMReX_NVector_MultiFab.cpp:476
void N_VDestroy_MultiFab(N_Vector v)
Definition: AMReX_NVector_MultiFab.cpp:204
N_Vector N_VNewEmpty_MultiFab(sunindextype length, ::sundials::Context *sunctx)
Definition: AMReX_NVector_MultiFab.cpp:27
amrex::Real N_VWrmsNorm_MultiFab(N_Vector x, N_Vector w)
Definition: AMReX_NVector_MultiFab.cpp:399
N_Vector N_VNew_MultiFab(sunindextype length, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm, sunindextype nComp, sunindextype nGhost, ::sundials::Context *sunctx)
Definition: AMReX_NVector_MultiFab.cpp:78
void N_VSetOwnMF_MultiFab(N_Vector v, int own_mf_in)
Definition: AMReX_NVector_MultiFab.cpp:142
amrex::Real N_VWL2Norm_MultiFab(N_Vector x, N_Vector w)
Definition: AMReX_NVector_MultiFab.cpp:469
int nComp(FabArrayBase const &fa)
Definition: AMReX_NVector_MultiFab.H:33
int own_mf
Definition: AMReX_NVector_MultiFab.H:35
amrex::MultiFab * mf
Definition: AMReX_NVector_MultiFab.H:36
sunindextype length
Definition: AMReX_NVector_MultiFab.H:34