1 #ifndef AMREX_Derive_H_
2 #define AMREX_Derive_H_
3 #include <AMReX_Config.H>
44 using DeriveFunc = void (*)(amrex::Real* data, AMREX_ARLIM_P(dlo), AMREX_ARLIM_P(dhi),
45 const int* nvar,
const amrex::Real* compdat,
46 AMREX_ARLIM_P(compdat_lo), AMREX_ARLIM_P(compdat_hi),
48 const int* lo,
const int* hi,
49 const int* domain_lo,
const int* domain_hi,
50 const amrex::Real* delta,
const amrex::Real* xlo,
51 const amrex::Real* time,
const amrex::Real* dt,
53 const int* level,
const int* grid_no) ;
78 using DeriveFunc3D = void (*)(amrex::Real* data,
const int* dlo,
const int* dhi,
const int* nvar,
79 const amrex::Real* compdat,
const int* clo,
const int* chi,
const int* ncomp,
80 const int* lo,
const int* hi,
81 const int* domain_lo,
const int* domain_hi,
82 const amrex::Real* delta,
const amrex::Real* xlo,
83 const amrex::Real* time,
const amrex::Real* dt,
85 const int* level,
const int* grid_no) ;
90 amrex::Real time,
const int* bcrec,
int level)>;
94 amrex::Real time,
const int* bcrec,
int level)>;
137 [[nodiscard]]
const std::string&
name () const noexcept;
144 [[nodiscard]] const std::
string&
variableName (
int comp) const noexcept;
172 [[nodiscard]]
int numDerive () const noexcept;
177 [[nodiscard]]
int numRange () const noexcept;
182 [[nodiscard]]
int numState () const noexcept;
187 [[nodiscard]] const
int*
getBC () const noexcept;
188 [[nodiscard]] const
int*
getBC3D () const noexcept;
203 int& num_comp) const;
271 Vector<std::
string> const& var_names,
279 Vector<std::
string> const& var_names,
287 Vector<std::
string> const& var_names,
295 Vector<std::
string> const& var_names,
383 [[nodiscard]]
bool canDerive (
const std::string& name)
const;
390 [[nodiscard]]
const DeriveRec*
get (
const std::string& name)
const;
402 void add (
const std::string& name,
409 void add (
const std::string& name,
416 void add (
const std::string& name,
423 void add (
const std::string& name,
438 void add (
const std::string& name,
454 void add (
const std::string& name,
462 void add (
const std::string& name,
470 void add (
const std::string& name,
478 void add (
const std::string& name,
501 [[nodiscard]] std::list<DeriveRec>&
dlist ();
A list of DeriveRecs.
Definition: AMReX_Derive.H:364
DeriveList(DeriveList &&)=delete
DeriveList()=default
The default constructor.
void add(const std::string &name, IndexType result_type, int nvar_derive, DeriveFunc der_func, const DeriveRec::DeriveBoxMap &bx_map, Interpolater *interp=&pc_interp)
Adds another entry to the registry.
Definition: AMReX_Derive.cpp:378
std::list< DeriveRec > & dlist()
Definition: AMReX_Derive.cpp:480
const DeriveRec * get(const std::string &name) const
Access the particular record in registry.
Definition: AMReX_Derive.cpp:505
DeriveList & operator=(const DeriveList &)=delete
void clear()
Definition: AMReX_Derive.H:503
std::list< DeriveRec > lst
Definition: AMReX_Derive.H:507
bool canDerive(const std::string &name) const
Determines whether quantity identified by <name> is in the registry.
Definition: AMReX_Derive.cpp:486
DeriveList(const DeriveList &)=delete
void addComponent(const std::string &name, const DescriptorList &d_list, int state_indx, int s_comp, int n_comp)
Adds another StateRange to the DeriveRec identified by <name>.
Definition: AMReX_Derive.cpp:524
Derived Type Record.
Definition: AMReX_Derive.H:109
IndexType deriveType() const noexcept
The IndexType of the derived type.
Definition: AMReX_Derive.cpp:187
int numState() const noexcept
Total number of state variables needed for derived type.
Definition: AMReX_Derive.cpp:241
DeriveFunc func
Function that computes derived quantity from state variables.
Definition: AMReX_Derive.H:332
DeriveFuncMF func_mf
Definition: AMReX_Derive.H:335
DeriveFunc3D derFunc3D() const noexcept
Definition: AMReX_Derive.cpp:199
const std::string & name() const noexcept
The name of the derived type.
Definition: AMReX_Derive.cpp:181
int * bcr
Array of bndry types.
Definition: AMReX_Derive.H:353
int numDerive() const noexcept
Number of components in the derived type.
Definition: AMReX_Derive.cpp:229
int n_state
Total number of state variables.
Definition: AMReX_Derive.H:344
void getRange(int k, int &state_indx, int &src_comp, int &num_comp) const
Sets state_indx, src_comp and num_comp for the kth range (or chunk) of state data components needed t...
Definition: AMReX_Derive.cpp:295
int * bcr3D
Definition: AMReX_Derive.H:354
int n_derive
Number of components in derived quantity.
Definition: AMReX_Derive.H:329
const std::string & variableName(int comp) const noexcept
The names of components.
Definition: AMReX_Derive.cpp:368
void buildBC(const DescriptorList &d_list)
Definition: AMReX_Derive.cpp:314
~DeriveRec()
The destructor.
Definition: AMReX_Derive.cpp:162
DeriveFuncMF derFuncMF() const noexcept
Definition: AMReX_Derive.cpp:211
const int * getBC3D() const noexcept
Definition: AMReX_Derive.cpp:254
DeriveFunc derFunc() const noexcept
The DeriveFunc used to calculate the derived type.
Definition: AMReX_Derive.cpp:193
DeriveFunc3D func_3d
Definition: AMReX_Derive.H:333
static Box GrowBoxByOne(const Box &box) noexcept
Definition: AMReX_Derive.cpp:16
int nsr
Number of state ranges.
Definition: AMReX_Derive.H:347
void addRange(const DescriptorList &d_list, int state_indx, int src_comp, int num_comp)
Definition: AMReX_Derive.cpp:261
std::string derive_name
Name of derived quantity.
Definition: AMReX_Derive.H:320
std::function< Box(const Box &)> DeriveBoxMap
A pointer to function taking and returning a Box.
Definition: AMReX_Derive.H:118
static Box TheSameBox(const Box &box) noexcept
Definition: AMReX_Derive.cpp:10
DeriveBoxMap boxMap() const noexcept
Maps state data box to derived data box.
Definition: AMReX_Derive.cpp:217
DeriveRec(DeriveRec &&)=delete
DeriveRec(DeriveRec const &)=delete
IndexType der_type
Type of derived quantity.
Definition: AMReX_Derive.H:326
Interpolater * mapper
Interpolater for mapping crse grid derived data to finer levels.
Definition: AMReX_Derive.H:338
const int * getBC() const noexcept
The boundary conditions.
Definition: AMReX_Derive.cpp:247
DeriveRec & operator=(DeriveRec const &)=delete
DeriveBoxMap bx_map
Box mapper that specifies constituent region given derived region.
Definition: AMReX_Derive.H:341
int numRange() const noexcept
Number of different chunks of state data needed for derived type.
Definition: AMReX_Derive.cpp:235
Interpolater * interp() const noexcept
Type of interpolater to use in computing derived type.
Definition: AMReX_Derive.cpp:223
StateRange * rng
List of state data subranges required to derive given quantity.
Definition: AMReX_Derive.H:350
void buildBC3D(const DescriptorList &d_list)
Definition: AMReX_Derive.cpp:338
DeriveFuncFab func_fab
Definition: AMReX_Derive.H:334
DeriveFuncFab derFuncFab() const noexcept
Definition: AMReX_Derive.cpp:205
Vector< std::string > variable_names
Names of derived variables.
Definition: AMReX_Derive.H:323
Definition: AMReX_StateDescriptor.H:437
A Fortran Array of REALs.
Definition: AMReX_FArrayBox.H:229
Rectangular problem domain geometry.
Definition: AMReX_Geometry.H:73
Virtual base class for interpolaters.
Definition: AMReX_Interpolater.H:22
A collection (stored as an array) of FArrayBox objects.
Definition: AMReX_MultiFab.H:38
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition: AMReX_Vector.H:27
Definition: AMReX_Amr.cpp:49
void(*)(amrex::Real *data, const int *dlo, const int *dhi, const int *nvar, const amrex::Real *compdat, const int *clo, const int *chi, const int *ncomp, const int *lo, const int *hi, const int *domain_lo, const int *domain_hi, const amrex::Real *delta, const amrex::Real *xlo, const amrex::Real *time, const amrex::Real *dt, const int *bcrec, const int *level, const int *grid_no) DeriveFunc3D
This is dimension agnostic. For example, dlo always has three elements.
Definition: AMReX_Derive.H:85
BoxND< AMREX_SPACEDIM > Box
Definition: AMReX_BaseFwd.H:27
std::function< void(amrex::MultiFab &der_mf, int dcomp, int ncomp, const amrex::MultiFab &data_mf, const amrex::Geometry &geomdata, amrex::Real time, const int *bcrec, int level)> DeriveFuncMF
Definition: AMReX_Derive.H:94
std::function< void(const amrex::Box &bx, amrex::FArrayBox &derfab, int dcomp, int ncomp, const amrex::FArrayBox &datafab, const amrex::Geometry &geomdata, amrex::Real time, const int *bcrec, int level)> DeriveFuncFab
Definition: AMReX_Derive.H:90
void(*)(amrex::Real *data, AMREX_ARLIM_P(dlo), AMREX_ARLIM_P(dhi), const int *nvar, const amrex::Real *compdat, AMREX_ARLIM_P(compdat_lo), AMREX_ARLIM_P(compdat_hi), const int *ncomp, const int *lo, const int *hi, const int *domain_lo, const int *domain_hi, const amrex::Real *delta, const amrex::Real *xlo, const amrex::Real *time, const amrex::Real *dt, const int *bcrec, const int *level, const int *grid_no) DeriveFunc
Type of extern "C" function called by DeriveRec to compute derived quantity.
Definition: AMReX_Derive.H:53
PCInterp pc_interp
CONSTRUCT A GLOBAL OBJECT OF EACH VERSION.
Definition: AMReX_Interpolater.cpp:35
An element of a linked list to point to state quantities in AmrLevels.
Definition: AMReX_Derive.H:310
int typ
Definition: AMReX_Derive.H:311
int nc
Definition: AMReX_Derive.H:313
StateRange * next
Definition: AMReX_Derive.H:314
int sc
Definition: AMReX_Derive.H:312