4 #include <AMReX_Config.H>
101 virtual void read (std::istream& is,
110 virtual void write (std::ostream& os,
113 int num_comp)
const = 0;
120 virtual void skip (std::istream& is,
123 virtual void skip (std::istream& is,
125 int nCompToSkip)
const = 0;
155 int& nCompAvailable);
168 void read (std::istream& is,
171 void write (std::ostream& os,
174 int num_comp)
const override;
176 void skip (std::istream& is,
179 void skip (std::istream& is,
181 int nCompToSkip)
const override;
186 int nvar)
const override;
249 Arena* ar =
nullptr);
253 FArrayBox (const
Box& b,
int ncomp, Real const* p) noexcept;
275 #if defined(AMREX_USE_GPU)
276 template <RunOn run_on>
278 template <RunOn run_on=RunOn::Host>
287 #if defined(AMREX_USE_GPU)
288 template <RunOn run_on>
290 template <RunOn run_on=RunOn::Host>
294 #if defined(AMREX_USE_GPU)
295 template <RunOn run_on>
297 template <RunOn run_on=RunOn::Host>
299 [[nodiscard]]
bool contains_nan (
const Box& bx,
int scomp,
int ncomp)
const noexcept;
304 #if defined(AMREX_USE_GPU)
305 template <RunOn run_on>
307 template <RunOn run_on=RunOn::Host>
311 #if defined(AMREX_USE_GPU)
312 template <RunOn run_on>
314 template <RunOn run_on=RunOn::Host>
322 #if defined(AMREX_USE_GPU)
323 template <RunOn run_on>
325 template <RunOn run_on=RunOn::Host>
329 #if defined(AMREX_USE_GPU)
330 template <RunOn run_on>
332 template <RunOn run_on=RunOn::Host>
334 [[nodiscard]]
bool contains_inf (
const Box& bx,
int scomp,
int ncomp)
const noexcept;
339 #if defined(AMREX_USE_GPU)
340 template <RunOn run_on>
342 template <RunOn run_on=RunOn::Host>
346 #if defined(AMREX_USE_GPU)
347 template <RunOn run_on>
349 template <RunOn run_on=RunOn::Host>
361 friend std::ostream& operator<< (std::ostream& os, const
FArrayBox& fb);
363 friend std::istream& operator>> (std::istream& is,
FArrayBox& fb);
368 void writeOn (std::ostream& os) const;
381 void writeOn (std::ostream& os,
383 int num_comp=1) const;
394 int readFrom (std::istream& is,
int compIndex);
405 static
void skipFAB (std::istream& is);
496 template <
RunOn run_on>
504 template <RunOn run_on>
515 reduce_op.
eval(n, reduce_data,
520 ReduceTuple hv = reduce_data.
value(reduce_op);
521 return amrex::get<0>(hv);
525 for (Long i = 0; i < n; i++) {
534 template <RunOn run_on>
544 const auto& a = this->
array();
551 reduce_op.
eval(bx, reduce_data,
555 for (
int n = scomp; n < scomp+ncomp; ++n) {
558 return {
static_cast<int>(t) };
560 ReduceTuple hv = reduce_data.
value(reduce_op);
561 return amrex::get<0>(hv);
567 for (
int n = scomp; n < scomp+ncomp; ++n) {
568 for (
int k = lo.z; k <= hi.z; ++k) {
569 for (
int j = lo.y; j <= hi.y; ++j) {
570 for (
int i = lo.x; i <= hi.x; ++i) {
582 template <RunOn run_on>
586 return contains_nan<run_on>(
domain, 0,
nComp(), where);
589 template <RunOn run_on>
599 const auto& a = this->
array();
603 std::numeric_limits<int>::lowest(),
604 std::numeric_limits<int>::lowest())};
612 for (
int n = scomp; n < scomp+ncomp; ++n) {
615 if (t && (*flag == 0)) {
632 for (
int n = scomp; n < scomp+ncomp; ++n) {
633 for (
int k = lo.z; k <= hi.z; ++k) {
634 for (
int j = lo.y; j <= hi.y; ++j) {
635 for (
int i = lo.x; i <= hi.x; ++i) {
648 template <RunOn run_on>
659 reduce_op.
eval(n, reduce_data,
664 ReduceTuple hv = reduce_data.
value(reduce_op);
665 return amrex::get<0>(hv);
669 for (Long i = 0; i < n; i++) {
678 template <RunOn run_on>
688 const auto& a = this->
array();
695 reduce_op.
eval(bx, reduce_data,
699 for (
int n = scomp; n < scomp+ncomp; ++n) {
702 return {
static_cast<int>(t) };
704 ReduceTuple hv = reduce_data.
value(reduce_op);
705 return amrex::get<0>(hv);
711 for (
int n = scomp; n < scomp+ncomp; ++n) {
712 for (
int k = lo.z; k <= hi.z; ++k) {
713 for (
int j = lo.y; j <= hi.y; ++j) {
714 for (
int i = lo.x; i <= hi.x; ++i) {
726 template <RunOn run_on>
730 return contains_inf<run_on>(
domain,0,
nComp(),where);
733 template <RunOn run_on>
743 const auto& a = this->
array();
747 std::numeric_limits<int>::lowest(),
748 std::numeric_limits<int>::lowest())};
756 for (
int n = scomp; n < scomp+ncomp; ++n) {
759 if (t && (*flag == 0)) {
776 for (
int n = scomp; n < scomp+ncomp; ++n) {
777 for (
int k = lo.z; k <= hi.z; ++k) {
778 for (
int j = lo.y; j <= hi.y; ++j) {
779 for (
int i = lo.x; i <= hi.x; ++i) {
#define BL_ASSERT(EX)
Definition: AMReX_BLassert.H:39
#define AMREX_GPU_DEVICE
Definition: AMReX_GpuQualifiers.H:18
#define AMREX_D_TERM(a, b, c)
Definition: AMReX_SPACE.H:129
#define AMREX_D_DECL(a, b, c)
Definition: AMReX_SPACE.H:104
A virtual base class for objects that manage their own dynamic memory allocation.
Definition: AMReX_Arena.H:100
A FortranArrayBox(FAB)-like object.
Definition: AMReX_BaseFab.H:183
AMREX_FORCE_INLINE Array4< Real const > array() const noexcept
Definition: AMReX_BaseFab.H:379
Box domain
My index space.
Definition: AMReX_BaseFab.H:1650
Real * dptr
The data pointer.
Definition: AMReX_BaseFab.H:1649
int nvar
Number components.
Definition: AMReX_BaseFab.H:1651
Long numPts() const noexcept
Returns the number of points.
Definition: AMReX_BaseFab.H:285
int nComp() const noexcept
Returns the number of components.
Definition: AMReX_BaseFab.H:277
AMREX_GPU_HOST_DEVICE bool contains(const IntVectND< dim > &p) const noexcept
Returns true if argument is contained within BoxND.
Definition: AMReX_Box.H:204
Definition: AMReX_FabFactory.H:76
Definition: AMReX_FArrayBox.H:164
std::unique_ptr< RealDescriptor > realDesc
Definition: AMReX_FArrayBox.H:188
void read(std::istream &is, FArrayBox &fb) const override
Pure virtual function. Derived classes MUST override this function to read an FArrayBox from the istr...
Definition: AMReX_FArrayBox.cpp:915
void write_header(std::ostream &os, const FArrayBox &f, int nvar) const override
Write out a header describing FArrayBox f that contains nvar components. It must be the case that nva...
Definition: AMReX_FArrayBox.cpp:905
void skip(std::istream &is, FArrayBox &f) const override
Pure virtual function. Derived classes MUST override this function to skip over the next FAB f in the...
Definition: AMReX_FArrayBox.cpp:949
FABio_binary(RealDescriptor *rd_)
Definition: AMReX_FArrayBox.cpp:898
void write(std::ostream &os, const FArrayBox &fb, int comp, int num_comp) const override
Pure virtual function. Derived classes MUST override this function to write the FArrayBox to the ostr...
Definition: AMReX_FArrayBox.cpp:929
A Class Facilitating I/O for Fabs.
Definition: AMReX_FArrayBox.H:30
Format
An enum which controls format of FAB output.
Definition: AMReX_FArrayBox.H:67
@ FAB_IEEE
Definition: AMReX_FArrayBox.H:69
@ FAB_NATIVE_32
Definition: AMReX_FArrayBox.H:77
@ FAB_ASCII
Definition: AMReX_FArrayBox.H:68
@ FAB_NATIVE
Definition: AMReX_FArrayBox.H:70
@ FAB_8BIT
Definition: AMReX_FArrayBox.H:75
@ FAB_IEEE_32
Definition: AMReX_FArrayBox.H:76
virtual void skip(std::istream &is, FArrayBox &f) const =0
Pure virtual function. Derived classes MUST override this function to skip over the next FAB f in the...
Precision
An enum which controls precision of FAB output. Valid values are FAB_FLOAT and FAB_DOUBLE....
Definition: AMReX_FArrayBox.H:40
@ FAB_DOUBLE
Definition: AMReX_FArrayBox.H:42
@ FAB_FLOAT
Definition: AMReX_FArrayBox.H:41
virtual void read(std::istream &is, FArrayBox &fb) const =0
Pure virtual function. Derived classes MUST override this function to read an FArrayBox from the istr...
virtual void skip(std::istream &is, FArrayBox &f, int nCompToSkip) const =0
static FABio * read_header(std::istream &is, FArrayBox &f)
Read in the header from the istream. Returns a new'd FABio of the written-out type....
Definition: AMReX_FArrayBox.cpp:448
virtual void write(std::ostream &os, const FArrayBox &fb, int comp, int num_comp) const =0
Pure virtual function. Derived classes MUST override this function to write the FArrayBox to the ostr...
Ordering
An enum which controls byte ordering of FAB output. Valid values are FAB_NORMAL_ORDER,...
Definition: AMReX_FArrayBox.H:88
@ FAB_REVERSE_ORDER
Definition: AMReX_FArrayBox.H:90
@ FAB_NORMAL_ORDER
Definition: AMReX_FArrayBox.H:89
@ FAB_REVERSE_ORDER_2
Definition: AMReX_FArrayBox.H:91
virtual ~FABio()=default
The virtual destructor.
virtual void write_header(std::ostream &os, const FArrayBox &f, int nvar) const
Write out a header describing FArrayBox f that contains nvar components. It must be the case that nva...
Definition: AMReX_FArrayBox.cpp:95
A Fortran Array of REALs.
Definition: AMReX_FArrayBox.H:229
void initVal() noexcept
Definition: AMReX_FArrayBox.cpp:143
static void Finalize()
Definition: AMReX_FArrayBox.cpp:431
static std::string getClassName()
Definition: AMReX_FArrayBox.cpp:222
static bool initialized
Definition: AMReX_FArrayBox.H:472
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 n...
Definition: AMReX_FArrayBox.cpp:673
static void Initialize()
Initialize from ParmParse with "fab" prefix.
Definition: AMReX_FArrayBox.cpp:333
static FABio::Precision getPrecision()
Returns the FABio::Precision. This is deprecated. It is not useful with the "new" FAB I/O format....
Definition: AMReX_FArrayBox.cpp:298
FabType getType() const noexcept
Definition: AMReX_FArrayBox.H:356
static void setOrdering(FABio::Ordering ordering)
Set the FABio::Ordering for reading old FABs. It does NOT set the ordering for output....
Definition: AMReX_FArrayBox.cpp:278
void writeOn(std::ostream &os) const
Writes out the FAB in whatever format you've set. The default format is NATIVE.
Definition: AMReX_FArrayBox.cpp:228
FArrayBox(Array4< Real const > const &a) noexcept
Definition: AMReX_FArrayBox.H:261
static Real initval
Definition: AMReX_FArrayBox.H:490
static const FABio & getFABio()
Returns reference to the FABio object used by the program.
Definition: AMReX_FArrayBox.cpp:191
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" FAB...
Definition: AMReX_FArrayBox.cpp:241
static void setPrecision(FABio::Precision precision)
Set the FABio::Precision. This is deprecated. It is not useful with the "new" FAB I/O format.
Definition: AMReX_FArrayBox.cpp:292
static void setFABio(FABio *rd)
Sets the FABio object used by the program. It is an error if the passed pointer rd is the null pointe...
Definition: AMReX_FArrayBox.cpp:197
static FABio * fabio
The FABio pointer describing our output format.
Definition: AMReX_FArrayBox.H:486
FabType m_type
Definition: AMReX_FArrayBox.H:476
void readFrom(std::istream &is)
Read FAB from istream. Format is as it was written out.
Definition: AMReX_FArrayBox.cpp:625
static FABio::Format format
Format and ordering for all FAB output. This stuff exists solely to support reading old FABs.
Definition: AMReX_FArrayBox.H:482
FArrayBox(Array4< Real const > const &a, IndexType t) noexcept
Definition: AMReX_FArrayBox.H:263
FArrayBox(Array4< Real > const &a, IndexType t) noexcept
Definition: AMReX_FArrayBox.H:259
FArrayBox & operator=(FArrayBox &&) noexcept=default
static FABio::Ordering ordering
Definition: AMReX_FArrayBox.H:483
static std::unique_ptr< RealDescriptor > getDataDescriptor()
Definition: AMReX_FArrayBox.cpp:205
static FABio::Ordering getOrdering()
Gets the FABio::Ordering set in the program. This is deprecated. It does NOT do the right thing with ...
Definition: AMReX_FArrayBox.cpp:285
static Real get_initval()
Definition: AMReX_FArrayBox.cpp:327
static bool do_initval
initial value
Definition: AMReX_FArrayBox.H:489
bool contains_nan() const noexcept
Are there any NaNs in the FAB? This may return false, even if the FAB contains NaNs,...
Definition: AMReX_FArrayBox.H:506
FArrayBox() noexcept=default
Construct an invalid FAB with no memory.
static FABio::Format getFormat()
Gets the FABio::Format set in the program.
Definition: AMReX_FArrayBox.cpp:185
static Real set_initval(Real iv)
Definition: AMReX_FArrayBox.cpp:319
static bool set_do_initval(bool tf)
Definition: AMReX_FArrayBox.cpp:305
void resize(const Box &b, int N=1, Arena *ar=nullptr)
For debugging purposes we hide BaseFab version and do some extra work.
Definition: AMReX_FArrayBox.cpp:178
static bool get_do_initval()
Definition: AMReX_FArrayBox.cpp:313
static bool init_snan
Definition: AMReX_FArrayBox.H:491
~FArrayBox() noexcept override=default
The destructor.
bool contains_inf() const noexcept
Are there any Infs in the FAB? This may return false, even if the FAB contains Infs,...
Definition: AMReX_FArrayBox.H:650
Definition: AMReX_Tuple.H:93
Definition: AMReX_PODVector.H:246
T * data() noexcept
Definition: AMReX_PODVector.H:593
A Descriptor of the Real Type.
Definition: AMReX_FabConv.H:105
Definition: AMReX_Reduce.H:249
Type value()
Definition: AMReX_Reduce.H:281
Definition: AMReX_Reduce.H:364
std::enable_if_t< IsFabArray< MF >::value > eval(MF const &mf, IntVect const &nghost, D &reduce_data, F &&f)
Definition: AMReX_Reduce.H:441
static constexpr Type_t regular
Definition: AMReX_EB2_Graph.H:38
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T Exch(T *address, T val) noexcept
Definition: AMReX_GpuAtomic.H:485
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool isinf(T m) noexcept
Definition: AMReX_GpuUtility.H:161
void streamSynchronize() noexcept
Definition: AMReX_GpuDevice.H:237
void dtoh_memcpy_async(void *p_h, const void *p_d, const std::size_t sz) noexcept
Definition: AMReX_GpuDevice.H:265
bool inLaunchRegion() noexcept
Definition: AMReX_GpuControl.H:86
void htod_memcpy_async(void *p_d, const void *p_h, const std::size_t sz) noexcept
Definition: AMReX_GpuDevice.H:251
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool isnan(T m) noexcept
Definition: AMReX_GpuUtility.H:150
static int f(amrex::Real t, N_Vector y_data, N_Vector y_rhs, void *user_data)
Definition: AMReX_SundialsIntegrator.H:44
Definition: AMReX_Amr.cpp:49
std::enable_if_t< std::is_integral_v< T > > ParallelFor(TypeList< CTOs... > ctos, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
Definition: AMReX_CTOParallelForImpl.H:200
MakeType
Definition: AMReX_MakeType.H:7
RunOn
Definition: AMReX_GpuControl.H:69
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 ubound(Array4< T > const &a) noexcept
Definition: AMReX_Array4.H:315
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 lbound(Array4< T > const &a) noexcept
Definition: AMReX_Array4.H:308
IntVectND< AMREX_SPACEDIM > IntVect
Definition: AMReX_BaseFwd.H:30
FabType
Definition: AMReX_FabFactory.H:18
std::array< T, N > Array
Definition: AMReX_Array.H:24
integer, parameter dp
Definition: AMReX_SDCquadrature.F90:8
Definition: AMReX_Array4.H:61
void * alloc(std::size_t sz) const noexcept
Definition: AMReX_DataAllocator.H:16