Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
amrex::FArrayBox Class Reference

A Fortran Array of REALs. More...

#include <AMReX_FArrayBox.H>

Inheritance diagram for amrex::FArrayBox:
amrex::BaseFab< Real > amrex::DataAllocator amrex::CutFab amrex::EBFArrayBox

Public Member Functions

 FArrayBox () noexcept=default
 Construct an invalid FAB with no memory.
 FArrayBox (Arena *ar) noexcept
 Construct an invalid FAB that will allocate from the supplied arena.
 FArrayBox (const Box &b, int ncomp, Arena *ar)
 Allocate ncomp components over b using arena-managed memory.
 FArrayBox (const Box &b, int ncomp=1, bool alloc=true, bool shared=false, Arena *ar=nullptr)
 Construct an initial FAB with the data space allocated but not initialized. ncomp is the number of components (variables) at each data point in the Box.
 FArrayBox (const FArrayBox &rhs, MakeType make_type, int scomp, int ncomp)
 Construct from another FAB either by aliasing or deep-copying components.
 FArrayBox (const Box &b, int ncomp, Real const *p) noexcept
 Wrap an externally owned const buffer; no memory is allocated or freed.
 FArrayBox (const Box &b, int ncomp, Real *p) noexcept
 Wrap an externally owned mutable buffer; no memory is allocated or freed.
 FArrayBox (Array4< Real > const &a) noexcept
 FArrayBox (Array4< Real > const &a, IndexType t) noexcept
 FArrayBox (Array4< Real const > const &a) noexcept
 FArrayBox (Array4< Real const > const &a, IndexType t) noexcept
 ~FArrayBox () noexcept override=default
 The destructor.
 FArrayBox (FArrayBox &&rhs) noexcept=default
 Move-construct by transferring ownership of rhs storage.
FArrayBox & operator= (FArrayBox &&) noexcept=default
 Move-assign, releasing existing storage then adopting rhs memory.
 FArrayBox (const FArrayBox &)=delete
FArrayBox & operator= (const FArrayBox &)=delete
template<RunOn run_on>
FArrayBox & operator= (Real v) noexcept
 Set the fab to the value r.
template<RunOn run_on>
bool contains_nan () const noexcept
 Test whether any NaN is present anywhere in the FAB.
template<RunOn run_on>
bool contains_nan (const Box &bx, int scomp, int ncomp) const noexcept
 Test whether any NaN is present in a sub-box and component range.
template<RunOn run_on>
bool contains_nan (IntVect &where) const noexcept
 Test the whole FAB for a NaN, reporting a location if found.
template<RunOn run_on>
bool contains_nan (const Box &bx, int scomp, int ncomp, IntVect &where) const noexcept
 Test a sub-box and component range for a NaN, reporting a location if found.
template<RunOn run_on>
bool contains_inf () const noexcept
 Test whether any Inf is present anywhere in the FAB.
template<RunOn run_on>
bool contains_inf (const Box &bx, int scomp, int ncomp) const noexcept
 Test whether any Inf is present in a sub-box and component range.
template<RunOn run_on>
bool contains_inf (IntVect &where) const noexcept
 Test the whole FAB for an Inf, reporting a location if found.
template<RunOn run_on>
bool contains_inf (const Box &bx, int scomp, int ncomp, IntVect &where) const noexcept
 Test a sub-box and component range for an Inf, reporting a location if found.
void resize (const Box &b, int N=1, Arena *ar=nullptr)
 For debugging purposes we hide BaseFab version and do some extra work.
FabType getType () const noexcept
 Return the embedded-boundary FabType of this FAB (always regular for a plain FArrayBox).
void initVal () noexcept
void writeOn (std::ostream &os) const
 Write every component of the FAB using the current FABio format (the default format is NATIVE).
void writeOn (std::ostream &os, int comp, int num_comp=1) const
 Write only selected range of components. comp specifies from which component (starting at 0) to write at each point in space. num_comp specifies how many data points to write out at each point is space – it defaults to 1. It must be the case the comp >= 0 && num_comp >= 1 && (comp+num_comp) <= nComp(). The FAB is written out in whatever format you've set, with the default format being NATIVE. The FAB that is written to disk will be an num_comp component FAB.
void readFrom (std::istream &is)
 Read FAB from is using whichever FABio format it was written with.
int readFrom (std::istream &is, int compIndex)
 Read a single component (indexed by compIndex) from the serialized FAB, using whichever FABio format it was written with.
Public Member Functions inherited from amrex::BaseFab< Real >
BaseFab< Real > & operator= (Real const &t) noexcept
virtual ~BaseFab () noexcept
 The destructor deletes the array memory.
void resize (const Box &b, int N=1, Arena *ar=nullptr)
 This function resizes a BaseFab so it covers the Box b with N components.
Elixir elixir () noexcept
 Transfer owned storage to an Elixir when running in a GPU launch region.
void clear ()
 The function returns the BaseFab to the invalid state. The memory is freed.
std::unique_ptr< Real, DataDeleter > release () noexcept
 Release ownership of memory.
std::size_t nBytes () const noexcept
 Returns how many bytes used.
std::size_t nBytesOwned () const noexcept
int nComp () const noexcept
 Returns the number of components.
const int * nCompPtr () const noexcept
 for calls to fortran.
Long numPts () const noexcept
 Returns the number of points.
Long size () const noexcept
 Returns the total number of points of all components.
const Box & box () const noexcept
 Returns the domain (box) where the array is defined.
IntVect length () const noexcept
 Returns a pointer to an array of SPACEDIM integers giving the length of the domain in each direction.
const IntVect & smallEnd () const noexcept
 Returns the lower corner of the domain See class Box for analogue.
const IntVect & bigEnd () const noexcept
 Returns the upper corner of the domain. See class Box for analogue.
const int * loVect () const noexcept
 Returns the lower corner of the domain.
const int * hiVect () const noexcept
 Returns the upper corner of the domain.
bool contains (const BaseFab< Real > &fab) const noexcept
 Returns true if the domain of fab is totally contained within the domain of this BaseFab.
Real * dataPtr (int n=0) noexcept
 Returns a pointer to an object of type T that is the value of the Nth component associated with the cell at the low end of the domain. This is commonly used to get a pointer to data in the array which is then handed off to a Fortran subroutine. Remember that data is stored in Fortran array order, with the component index coming last. In other words, dataPtr returns a pointer to all the Nth components.
void setPtr (Real *p, Long sz) noexcept
 Attach externally allocated storage without taking ownership.
void prefetchToHost () const noexcept
 Advise the runtime to migrate storage to the host.
void prefetchToDevice () const noexcept
 Advise the runtime to migrate storage to the active device.
Array4< Real const > array () const noexcept
 Create an Array4 view over all components.
Array4< Real const > const_array () const noexcept
 Return a const-qualified Array4 view over all components.
bool isAllocated () const noexcept
 Returns true if the data for the FAB has been allocated.
Real & operator() (const IntVect &p, int N) noexcept
 Returns a reference to the Nth component value defined at position p in the domain. This operator may be inefficient if the C++ compiler is unable to optimize the C++ code.
void getVal (Real *data, const IntVect &pos, int N, int numcomp) const noexcept
 This function puts numcomp component values, starting at component N, from position pos in the domain into array data, that must be allocated by the user.
void fill_snan () noexcept
void setVal (Real const &x, const Box &bx, int dcomp, int ncomp) noexcept
 The setVal functions set sub-regions in the BaseFab to a constant value. This most general form specifies the sub-box, the starting component number, and the number of components to be set.
void setValIfNot (Real const &val, const Box &bx, const BaseFab< int > &mask, int nstart, int num) noexcept
void setComplement (Real const &x, const Box &b, int ns, int num) noexcept
 This function is analogous to the fourth form of setVal above, except that instead of setting values on the Box b, values are set on the complement of b in the domain.
BaseFab< Real > & copy (const BaseFab< Real > &src, const Box &srcbox, int srccomp, const Box &destbox, int destcomp, int numcomp) noexcept
 The copy functions copy the contents of one BaseFab into another. The destination BaseFab is always the object which invokes the function. This, the most general form of copy, specifies the contents of any sub-box srcbox in BaseFab src may be copied into a (possibly different) destbox in the destination BaseFab. Note that although the srcbox and the destbox may be disjoint, they must be the same size and shape. If the sizes differ, the copy is undefined and a runtime error results. This copy function is the only one of the copy functions to allow a copy between differing boxes. The user also specifies how many components are copied, starting at component srccomp in src and stored starting at component destcomp. The results are UNDEFINED if the src and dest are the same and the srcbox and destbox overlap.
std::size_t copyToMem (const Box &srcbox, int srccomp, int numcomp, void *dst) const noexcept
 Copy from the srcbox of this Fab to raw memory and return the number of bytes copied.
std::size_t copyFromMem (const Box &dstbox, int dstcomp, int numcomp, const void *src) noexcept
 Copy from raw memory to the dstbox of this Fab and return the number of bytes copied.
std::size_t addFromMem (const Box &dstbox, int dstcomp, int numcomp, const void *src) noexcept
 Add from raw memory to the dstbox of this Fab and return the number of bytes copied.
BaseFab< Real > & shift (const IntVect &v) noexcept
 Perform shifts upon the domain of the BaseFab. They are completely analogous to the corresponding Box functions. There is no effect upon the array memory.
BaseFab< Real > & shiftHalf (int dir, int n_cell) noexcept
 Perform shifts upon the domain of the BaseFab. They are completely analogous to the corresponding Box functions. There is no effect upon the array memory.
Real norminfmask (const Box &subbox, const BaseFab< int > &mask, int scomp=0, int ncomp=1) const noexcept
Real norm (int p, int scomp=0, int numcomp=1) const
 Compute the Lp-norm of this FAB using components (scomp : scomp+ncomp-1). p < 0 -> ERROR p = 0 -> infinity norm (max norm) p = 1 -> sum of ABS(FAB).
void abs () noexcept
 Compute absolute value for all components of this FAB.
Real min (int comp=0) const noexcept
Real max (int comp=0) const noexcept
std::pair< Real, Real > minmax (int comp=0) const noexcept
Real maxabs (int comp=0) const noexcept
IntVect indexFromValue (const Box &subbox, int comp, Real const &value) const noexcept
IntVect minIndex (int comp=0) const noexcept
IntVect maxIndex (int comp=0) const noexcept
int maskLT (BaseFab< int > &mask, Real const &val, int comp=0) const noexcept
 Compute mask array with value of 1 in cells where BaseFab has value less than val, 0 otherwise. mask is resized by this function. The number of cells marked with 1 returned.
int maskLE (BaseFab< int > &mask, Real const &val, int comp=0) const noexcept
 Mark cells with value <= val.
int maskEQ (BaseFab< int > &mask, Real const &val, int comp=0) const noexcept
 Mark cells with value equal to val.
int maskGT (BaseFab< int > &mask, Real const &val, int comp=0) const noexcept
 Mark cells with value greater than val.
int maskGE (BaseFab< int > &mask, Real const &val, int comp=0) const noexcept
 Mark cells with value greater than or equal to val.
Real sum (int comp, int numcomp=1) const noexcept
 Returns sum of given component of FAB state vector.
BaseFab< Real > & invert (Real const &r, const Box &b, int comp=0, int numcomp=1) noexcept
 Most general version, specify subbox and which components.
BaseFab< Real > & negate (const Box &b, int comp=0, int numcomp=1) noexcept
 Negate BaseFab, most general.
BaseFab< Real > & plus (Real const &r, const Box &b, int comp=0, int numcomp=1) noexcept
 Scalar addition (a[i] <- a[i] + r), most general.
BaseFab< Real > & atomicAdd (const BaseFab< Real > &x) noexcept
 Atomic FAB addition (a[i] <- a[i] + b[i]).
BaseFab< Real > & lockAdd (const BaseFab< Real > &src, const Box &srcbox, const Box &destbox, int srccomp, int destcomp, int numcomp) noexcept
 Atomically add srcbox region of src FAB to destbox region of this FAB. The srcbox and destbox must be same size. When OMP is on, this uses OMP locks in the implementation and it's usually faster than atomicAdd.
BaseFab< Real > & saxpy (Real a, const BaseFab< Real > &x, const Box &srcbox, const Box &destbox, int srccomp, int destcomp, int numcomp=1) noexcept
 FAB SAXPY (y[i] <- y[i] + a * x[i]), in place.
BaseFab< Real > & xpay (Real a, const BaseFab< Real > &x, const Box &srcbox, const Box &destbox, int srccomp, int destcomp, int numcomp=1) noexcept
 FAB XPAY (y[i] <- x[i] + a * y[i]).
BaseFab< Real > & addproduct (const Box &destbox, int destcomp, int numcomp, const BaseFab< Real > &src1, int comp1, const BaseFab< Real > &src2, int comp2) noexcept
 y[i] <- y[i] + x1[i] * x2[i])
BaseFab< Real > & minus (const BaseFab< Real > &src, int srccomp, int destcomp, int numcomp=1) noexcept
 Subtract src components (srccomp:srccomp+numcomp-1) to this FABs components (destcomp:destcomp+numcomp-1) where the two FABs intersect.
BaseFab< Real > & mult (Real const &r, int comp, int numcomp=1) noexcept
 Scalar multiplication applied to selected components over the entire domain.
BaseFab< Real > & divide (Real const &r, int comp, int numcomp=1) noexcept
 Divide selected components by a scalar across the entire domain.
BaseFab< Real > & protected_divide (const BaseFab< Real > &src) noexcept
 Divide wherever "src" is "true" or "non-zero".
BaseFab< Real > & linInterp (const BaseFab< Real > &f1, const Box &b1, int comp1, const BaseFab< Real > &f2, const Box &b2, int comp2, Real t1, Real t2, Real t, const Box &b, int comp, int numcomp=1) noexcept
 Linear interpolation / extrapolation. Result is (t2-t)/(t2-t1)*f1 + (t-t1)/(t2-t1)*f2 Data is taken from b1 region of f1, b2 region of f2 and stored in b region of this FAB. Boxes b, b1 and b2 must be the same size. Data is taken from component comp1 of f1, comp2 of f2, and stored in component comp of this FAB. This FAB is returned as a reference for chaining.
BaseFab< Real > & linComb (const BaseFab< Real > &f1, const Box &b1, int comp1, const BaseFab< Real > &f2, const Box &b2, int comp2, Real alpha, Real beta, const Box &b, int comp, int numcomp=1) noexcept
 Linear combination. Result is alpha*f1 + beta*f2. Data is taken from b1 region of f1, b2 region of f2 and stored in b region of this FAB. Boxes b, b1 and b2 must be the same size. Data is taken from component comp1 of f1, comp2 of f2, and stored in component comp of this FAB. This FAB is returned as a reference for chaining.
Real dot (const Box &xbx, int xcomp, const BaseFab< Real > &y, const Box &ybx, int ycomp, int numcomp=1) const noexcept
 Dot product of x (i.e.,this) and y.
Real dotmask (const BaseFab< int > &mask, const Box &xbx, int xcomp, const BaseFab< Real > &y, const Box &ybx, int ycomp, int numcomp) const noexcept
void SetBoxType (const IndexType &typ) noexcept
 Change the Box type without change the length.
void setValIf (Real const &val, const BaseFab< int > &mask) noexcept
BaseFab< Real > & operator+= (Real const &val) noexcept
BaseFab< Real > & operator-= (Real const &val) noexcept
BaseFab< Real > & operator*= (Real const &val) noexcept
BaseFab< Real > & operator/= (Real const &val) noexcept
Public Member Functions inherited from amrex::DataAllocator
 DataAllocator () noexcept=default
 Default-construct; alloc/free will use The_Arena().
 DataAllocator (Arena *ar) noexcept
 Construct with an explicit arena ar.
void * alloc (std::size_t sz) const
 Allocate sz bytes from the arena. Throws OutOfMemoryError on failure.
void free (void *pt) const noexcept
 Return the allocation at pt to the arena.
Arena * arena () const noexcept
 Return the stored arena, or The_Arena() if none was set.

Static Public Member Functions

static Box skipFAB (std::istream &is, int &num_comp)
 Skip over the next FAB from the input stream. Return the Box defining the domain of the FAB and the number of components.
static void skipFAB (std::istream &is)
 Skip over the next FAB from the input stream.
static void setFormat (FABio::Format fmt)
 Set the FABio::Format in the program. This is the preferred way to set the output format in "new" FABs. When designing new programs, this should be the only function that needs to be called in order to set the format.
static FABio::Format getFormat ()
 Gets the FABio::Format set in the program.
static void setOrdering (FABio::Ordering ordering)
 Set the FABio::Ordering for reading old FABs. It does NOT set the ordering for output. This is deprecated. It exists only to facilitate reading old FABs. When you're reading in an "old" FAB, you must set the Ordering, before attempting to read it in. This is because FABs written out in the "old" format weren't self-describing; i.e. information such as the Ordering was lost when the "old" FAB was written out.
static FABio::Ordering getOrdering ()
 Gets the FABio::Ordering set in the program. This is deprecated. It does NOT do the right thing with the new FAB I/O format.
static void setPrecision (FABio::Precision precision)
 Set the FABio::Precision. This is deprecated. It is not useful with the "new" FAB I/O format.
static FABio::Precision getPrecision ()
 Returns the FABio::Precision. This is deprecated. It is not useful with the "new" FAB I/O format. Always returns FABio::Float.
static const FABio & getFABio ()
 Returns reference to the FABio object used by the program.
static void setFABio (FABio *rd)
 Replace the global FABio helper used by the program, taking ownership of rd. It is an error if rd is the null pointer.
static std::unique_ptr< RealDescriptor > getDataDescriptor ()
 Return a copy of the RealDescriptor describing the on-disk layout.
static std::string getClassName ()
 Return the runtime class name (for metadata headers).
static bool set_do_initval (bool tf)
 Enable or disable initializing newly allocated elements to the init value.
static bool get_do_initval ()
 Query whether init-value filling is enabled.
static Real set_initval (Real iv)
 Set the default value used for initialization.
static Real get_initval ()
 Query the current initialization value.
static void Initialize ()
 Initialize from ParmParse with "fab" prefix.
static void Finalize ()
Static Public Member Functions inherited from amrex::BaseFab< Real >
static void Initialize ()
 Initialize static tracking/profiling metadata used by all BaseFabs.
static void Finalize ()
 Release static tracking/profiling metadata allocated by Initialize().

Static Public Attributes

static bool initialized = false

Protected Attributes

FabType m_type = FabType::regular
Protected Attributes inherited from amrex::BaseFab< Real >
Real * dptr
 The data pointer.
Box domain
 My index space.
int nvar
 Number components.
Long truesize
 nvar*numpts that was allocated on heap.
bool ptr_owner
 Owner of T*?
bool shared_memory
 Is the memory allocated in shared memory?
gpuStream_t alloc_stream

Static Protected Attributes

static FABio::Format format
 Format and ordering for all FAB output. This stuff exists solely to support reading old FABs.
static FABio::Ordering ordering = FABio::FAB_NORMAL_ORDER
static FABio * fabio = nullptr
 The FABio pointer describing our output format.
static bool do_initval = false
 initial value
static Real initval
static bool init_snan

Friends

class FABio
 FABio is a friend of ours.
std::ostream & operator<< (std::ostream &os, const FArrayBox &fb)
 Write FABs in ASCII form.
std::istream & operator>> (std::istream &is, FArrayBox &fb)
 Read FABs in ASCII form.

Additional Inherited Members

Public Types inherited from amrex::BaseFab< Real >
using value_type
Public Attributes inherited from amrex::DataAllocator
Arena * m_arena = nullptr
 Stored arena pointer (may be null).
Protected Member Functions inherited from amrex::BaseFab< Real >
void define ()
 Allocates memory for the BaseFab<T>.

Detailed Description

A Fortran Array of REALs.

Fortran Array Box's (generally called FAB's) are objects constructed to emulate the FORTRAN array. Useful operations can be performed upon FAB's in C++, and they provide a convenient interface to FORTRAN when it is necessary to retreat into that language.

FArrayBox is derived from BaseFab<Real>. FArrayBox adds additional useful capabilities which make sense for Real types, such as I/O and L**p norms.

FArrayBox's may be output in various formats (see FABio above).

The format and precision may be set in a file read by the ParmParse class by the "fab.format" variable. Allowed values are: ASCII 8BIT NATIVE NATIVE_32 IEEE32

FABs written using operator<< are always written in ASCII. FABS written using writOn use the FABio::Format specified with setFormat or the FABio::Format specified in the ParmParse file read by init. If the FABio::Format is not set explicitly by either of these two methods, then it defaults to NATIVE.

The C pre-processor macro AMREX_SPACEDIM must be defined to use this class. The internal precision of FARRAYBOX objects is set by defining either BL_USE_FLOAT or BL_USE_DOUBLE

This class does NOT provide a copy constructor or assignment operator, but it has a move constructor.

Constructor & Destructor Documentation

◆ FArrayBox() [1/13]

amrex::FArrayBox::FArrayBox ( )
defaultnoexcept

Construct an invalid FAB with no memory.

◆ FArrayBox() [2/13]

amrex::FArrayBox::FArrayBox ( Arena * ar)
explicitnoexcept

Construct an invalid FAB that will allocate from the supplied arena.

◆ FArrayBox() [3/13]

amrex::FArrayBox::FArrayBox ( const Box & b,
int ncomp,
Arena * ar )

Allocate ncomp components over b using arena-managed memory.

◆ FArrayBox() [4/13]

amrex::FArrayBox::FArrayBox ( const Box & b,
int ncomp = 1,
bool alloc = true,
bool shared = false,
Arena * ar = nullptr )
explicit

Construct an initial FAB with the data space allocated but not initialized. ncomp is the number of components (variables) at each data point in the Box.

◆ FArrayBox() [5/13]

amrex::FArrayBox::FArrayBox ( const FArrayBox & rhs,
MakeType make_type,
int scomp,
int ncomp )

Construct from another FAB either by aliasing or deep-copying components.

Parameters
rhsSource FAB providing the data.
make_typeUse amrex::make_alias to share storage or amrex::make_deep_copy to allocate new storage and copy.
scompFirst component to import from rhs.
ncompNumber of components to import.

◆ FArrayBox() [6/13]

amrex::FArrayBox::FArrayBox ( const Box & b,
int ncomp,
Real const * p )
noexcept

Wrap an externally owned const buffer; no memory is allocated or freed.

Note
The constness of the buffer is preserved only when this object is const.

◆ FArrayBox() [7/13]

amrex::FArrayBox::FArrayBox ( const Box & b,
int ncomp,
Real * p )
noexcept

Wrap an externally owned mutable buffer; no memory is allocated or freed.

◆ FArrayBox() [8/13]

amrex::FArrayBox::FArrayBox ( Array4< Real > const & a)
inlineexplicitnoexcept

◆ FArrayBox() [9/13]

amrex::FArrayBox::FArrayBox ( Array4< Real > const & a,
IndexType t )
inlinenoexcept

◆ FArrayBox() [10/13]

amrex::FArrayBox::FArrayBox ( Array4< Real const > const & a)
inlineexplicitnoexcept

◆ FArrayBox() [11/13]

amrex::FArrayBox::FArrayBox ( Array4< Real const > const & a,
IndexType t )
inlineexplicitnoexcept

◆ ~FArrayBox()

amrex::FArrayBox::~FArrayBox ( )
overridedefaultnoexcept

The destructor.

◆ FArrayBox() [12/13]

amrex::FArrayBox::FArrayBox ( FArrayBox && rhs)
defaultnoexcept

Move-construct by transferring ownership of rhs storage.

◆ FArrayBox() [13/13]

amrex::FArrayBox::FArrayBox ( const FArrayBox & )
delete

Member Function Documentation

◆ contains_inf() [1/4]

template<RunOn run_on>
bool amrex::FArrayBox::contains_inf ( ) const
nodiscardnoexcept

Test whether any Inf is present anywhere in the FAB.

May return false even if the FAB contains Infs, when the machine does not support the appropriate Inf-testing functions.

Returns
true if an Inf is found.

◆ contains_inf() [2/4]

template<RunOn run_on>
bool amrex::FArrayBox::contains_inf ( const Box & bx,
int scomp,
int ncomp ) const
nodiscardnoexcept

Test whether any Inf is present in a sub-box and component range.

Parameters
bxRegion to inspect (must lie within the FAB).
scompFirst component to test.
ncompNumber of components to inspect.
Returns
true if an Inf is found.

◆ contains_inf() [3/4]

template<RunOn run_on>
bool amrex::FArrayBox::contains_inf ( const Box & bx,
int scomp,
int ncomp,
IntVect & where ) const
noexcept

Test a sub-box and component range for an Inf, reporting a location if found.

Parameters
bxRegion to inspect (must lie within the FAB).
scompFirst component to test.
ncompNumber of components to inspect.
whereIf an Inf is found, set to its cell index (the component is not reported; on the GPU this is not guaranteed to be the first Inf).
Returns
true if an Inf was found, in which case where holds the cell index of one.

◆ contains_inf() [4/4]

template<RunOn run_on>
bool amrex::FArrayBox::contains_inf ( IntVect & where) const
noexcept

Test the whole FAB for an Inf, reporting a location if found.

Parameters
whereIf an Inf is found, set to its cell index (the component is not reported; on the GPU this is not guaranteed to be the first Inf).
Returns
true if an Inf was found, in which case where holds the cell index of one.

◆ contains_nan() [1/4]

template<RunOn run_on>
bool amrex::FArrayBox::contains_nan ( ) const
nodiscardnoexcept

Test whether any NaN is present anywhere in the FAB.

May return false even if the FAB contains NaNs, when the machine does not support the appropriate NaN-testing functions.

Returns
true if a NaN is found.

◆ contains_nan() [2/4]

template<RunOn run_on>
bool amrex::FArrayBox::contains_nan ( const Box & bx,
int scomp,
int ncomp ) const
nodiscardnoexcept

Test whether any NaN is present in a sub-box and component range.

Parameters
bxRegion to inspect (must lie within the FAB).
scompFirst component to test.
ncompNumber of components to inspect.
Returns
true if a NaN is found.

◆ contains_nan() [3/4]

template<RunOn run_on>
bool amrex::FArrayBox::contains_nan ( const Box & bx,
int scomp,
int ncomp,
IntVect & where ) const
noexcept

Test a sub-box and component range for a NaN, reporting a location if found.

Parameters
bxRegion to inspect (must lie within the FAB).
scompFirst component to test.
ncompNumber of components to inspect.
whereIf a NaN is found, set to its cell index (the component is not reported; on the GPU this is not guaranteed to be the first NaN).
Returns
true if a NaN was found, in which case where holds the cell index of one.

◆ contains_nan() [4/4]

template<RunOn run_on>
bool amrex::FArrayBox::contains_nan ( IntVect & where) const
noexcept

Test the whole FAB for a NaN, reporting a location if found.

Parameters
whereIf a NaN is found, set to its cell index (the component is not reported; on the GPU this is not guaranteed to be the first NaN).
Returns
true if a NaN was found, in which case where holds the cell index of one.

◆ Finalize()

void amrex::FArrayBox::Finalize ( )
static

◆ get_do_initval()

bool amrex::FArrayBox::get_do_initval ( )
static

Query whether init-value filling is enabled.

◆ get_initval()

Real amrex::FArrayBox::get_initval ( )
static

Query the current initialization value.

◆ getClassName()

std::string amrex::FArrayBox::getClassName ( )
static

Return the runtime class name (for metadata headers).

◆ getDataDescriptor()

std::unique_ptr< RealDescriptor > amrex::FArrayBox::getDataDescriptor ( )
static

Return a copy of the RealDescriptor describing the on-disk layout.

◆ getFABio()

const FABio & amrex::FArrayBox::getFABio ( )
static

Returns reference to the FABio object used by the program.

◆ getFormat()

FABio::Format amrex::FArrayBox::getFormat ( )
static

Gets the FABio::Format set in the program.

◆ getOrdering()

FABio::Ordering amrex::FArrayBox::getOrdering ( )
static

Gets the FABio::Ordering set in the program. This is deprecated. It does NOT do the right thing with the new FAB I/O format.

◆ getPrecision()

FABio::Precision amrex::FArrayBox::getPrecision ( )
static

Returns the FABio::Precision. This is deprecated. It is not useful with the "new" FAB I/O format. Always returns FABio::Float.

◆ getType()

FabType amrex::FArrayBox::getType ( ) const
inlinenodiscardnoexcept

Return the embedded-boundary FabType of this FAB (always regular for a plain FArrayBox).

◆ Initialize()

void amrex::FArrayBox::Initialize ( )
static

Initialize from ParmParse with "fab" prefix.

◆ initVal()

void amrex::FArrayBox::initVal ( )
noexcept

◆ operator=() [1/3]

FArrayBox & amrex::FArrayBox::operator= ( const FArrayBox & )
delete

◆ operator=() [2/3]

FArrayBox & amrex::FArrayBox::operator= ( FArrayBox && )
defaultnoexcept

Move-assign, releasing existing storage then adopting rhs memory.

◆ operator=() [3/3]

template<RunOn run_on>
FArrayBox & amrex::FArrayBox::operator= ( Real v)
noexcept

Set the fab to the value r.

◆ readFrom() [1/2]

void amrex::FArrayBox::readFrom ( std::istream & is)

Read FAB from is using whichever FABio format it was written with.

◆ readFrom() [2/2]

int amrex::FArrayBox::readFrom ( std::istream & is,
int compIndex )

Read a single component (indexed by compIndex) from the serialized FAB, using whichever FABio format it was written with.

Creates a single-component FAB and returns the number of components available in the FAB on disk.

◆ resize()

void amrex::FArrayBox::resize ( const Box & b,
int N = 1,
Arena * ar = nullptr )

For debugging purposes we hide BaseFab version and do some extra work.

◆ set_do_initval()

bool amrex::FArrayBox::set_do_initval ( bool tf)
static

Enable or disable initializing newly allocated elements to the init value.

◆ set_initval()

Real amrex::FArrayBox::set_initval ( Real iv)
static

Set the default value used for initialization.

◆ setFABio()

void amrex::FArrayBox::setFABio ( FABio * rd)
static

Replace the global FABio helper used by the program, taking ownership of rd. It is an error if rd is the null pointer.

◆ setFormat()

void amrex::FArrayBox::setFormat ( FABio::Format fmt)
static

Set the FABio::Format in the program. This is the preferred way to set the output format in "new" FABs. When designing new programs, this should be the only function that needs to be called in order to set the format.

◆ setOrdering()

void amrex::FArrayBox::setOrdering ( FABio::Ordering ordering)
static

Set the FABio::Ordering for reading old FABs. It does NOT set the ordering for output. This is deprecated. It exists only to facilitate reading old FABs. When you're reading in an "old" FAB, you must set the Ordering, before attempting to read it in. This is because FABs written out in the "old" format weren't self-describing; i.e. information such as the Ordering was lost when the "old" FAB was written out.

◆ setPrecision()

void amrex::FArrayBox::setPrecision ( FABio::Precision precision)
static

Set the FABio::Precision. This is deprecated. It is not useful with the "new" FAB I/O format.

◆ skipFAB() [1/2]

void amrex::FArrayBox::skipFAB ( std::istream & is)
static

Skip over the next FAB from the input stream.

◆ skipFAB() [2/2]

Box amrex::FArrayBox::skipFAB ( std::istream & is,
int & num_comp )
static

Skip over the next FAB from the input stream. Return the Box defining the domain of the FAB and the number of components.

◆ writeOn() [1/2]

void amrex::FArrayBox::writeOn ( std::ostream & os) const

Write every component of the FAB using the current FABio format (the default format is NATIVE).

◆ writeOn() [2/2]

void amrex::FArrayBox::writeOn ( std::ostream & os,
int comp,
int num_comp = 1 ) const

Write only selected range of components. comp specifies from which component (starting at 0) to write at each point in space. num_comp specifies how many data points to write out at each point is space – it defaults to 1. It must be the case the comp >= 0 && num_comp >= 1 && (comp+num_comp) <= nComp(). The FAB is written out in whatever format you've set, with the default format being NATIVE. The FAB that is written to disk will be an num_comp component FAB.

◆ FABio

friend class FABio
friend

FABio is a friend of ours.

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const FArrayBox & fb )
friend

Write FABs in ASCII form.

◆ operator>>

std::istream & operator>> ( std::istream & is,
FArrayBox & fb )
friend

Read FABs in ASCII form.

Member Data Documentation

◆ do_initval

bool amrex::FArrayBox::do_initval = false
staticprotected

initial value

◆ fabio

FABio * amrex::FArrayBox::fabio = nullptr
staticprotected

The FABio pointer describing our output format.

◆ format

FABio::Format amrex::FArrayBox::format
staticprotected

Format and ordering for all FAB output. This stuff exists solely to support reading old FABs.

◆ init_snan

bool amrex::FArrayBox::init_snan
staticprotected

◆ initialized

bool amrex::FArrayBox::initialized = false
static

◆ initval

Real amrex::FArrayBox::initval
staticprotected

◆ m_type

FabType amrex::FArrayBox::m_type = FabType::regular
protected

◆ ordering

FABio::Ordering amrex::FArrayBox::ordering = FABio::FAB_NORMAL_ORDER
staticprotected

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