4#include <AMReX_Config.H>
106 virtual void read (std::istream& is,
115 virtual void write (std::ostream& os,
118 int num_comp)
const = 0;
125 virtual void skip (std::istream& is,
128 virtual void skip (std::istream& is,
130 int nCompToSkip)
const = 0;
160 int& nCompAvailable);
174 void read (std::istream& is,
177 void write (std::ostream& os,
180 int num_comp)
const override;
182 void skip (std::istream& is,
185 void skip (std::istream& is,
187 int nCompToSkip)
const override;
190 void write_header (std::ostream& os,
192 int nvar)
const override;
194 std::unique_ptr<RealDescriptor> realDesc;
259 Arena* ar =
nullptr);
323 [[nodiscard]]
bool contains_nan (const
Box& bx,
int scomp,
int ncomp) const noexcept;
370 [[nodiscard]]
bool contains_inf (const
Box& bx,
int scomp,
int ncomp) const noexcept;
407 friend std::ostream& operator<< (std::ostream& os, const
FArrayBox& fb);
409 friend std::istream& operator>> (std::istream& is,
FArrayBox& fb);
414 void writeOn (std::ostream& os) const;
427 void writeOn (std::ostream& os,
429 int num_comp=1) const;
441 int readFrom (std::istream& is,
int compIndex);
452 static
void skipFAB (std::istream& is);
549template <
RunOn run_on>
557template <RunOn run_on>
568 reduce_op.
eval(n, reduce_data,
571 return {
static_cast<int>(amrex::isnan(dp[i])) };
573 ReduceTuple hv = reduce_data.
value(reduce_op);
574 return amrex::get<0>(hv);
578 for (
Long i = 0; i < n; i++) {
579 if (amrex::isnan(*dp++)) {
587template <RunOn run_on>
597 const auto& a = this->
array();
604 reduce_op.
eval(bx, reduce_data,
608 for (
int n = scomp; n < scomp+ncomp; ++n) {
609 t = t || amrex::isnan(a(i,j,k,n));
611 return {
static_cast<int>(t) };
613 ReduceTuple hv = reduce_data.
value(reduce_op);
614 return amrex::get<0>(hv);
618 for (
int n = scomp; n < scomp+ncomp; ++n) {
619 for (
IntVect iv : bx.iterator()) {
620 if (amrex::isnan(a(iv, n))) {
629template <RunOn run_on>
633 return contains_nan<run_on>(
domain, 0,
nComp(), where);
636template <RunOn run_on>
646 const auto& a = this->
array();
650 std::numeric_limits<int>::lowest(),
651 std::numeric_limits<int>::lowest())};
659 for (
int n = scomp; n < scomp+ncomp; ++n) {
660 t = t || amrex::isnan(a(i,j,k,n));
662 if (t && (*flag == 0)) {
677 for (
int n = scomp; n < scomp+ncomp; ++n) {
678 for (
IntVect iv : bx.iterator()) {
679 if (amrex::isnan(a(iv, n))) {
689template <RunOn run_on>
700 reduce_op.
eval(n, reduce_data,
703 return {
static_cast<int>(amrex::isinf(dp[i])) };
705 ReduceTuple hv = reduce_data.
value(reduce_op);
706 return amrex::get<0>(hv);
710 for (
Long i = 0; i < n; i++) {
711 if (amrex::isinf(*dp++)) {
719template <RunOn run_on>
729 const auto& a = this->
array();
736 reduce_op.
eval(bx, reduce_data,
740 for (
int n = scomp; n < scomp+ncomp; ++n) {
741 t = t || amrex::isinf(a(i,j,k,n));
743 return {
static_cast<int>(t) };
745 ReduceTuple hv = reduce_data.
value(reduce_op);
746 return amrex::get<0>(hv);
750 for (
int n = scomp; n < scomp+ncomp; ++n) {
751 for (
IntVect iv : bx.iterator()) {
752 if (amrex::isinf(a(iv, n))) {
761template <RunOn run_on>
765 return contains_inf<run_on>(
domain,0,
nComp(),where);
768template <RunOn run_on>
778 const auto& a = this->
array();
782 std::numeric_limits<int>::lowest(),
783 std::numeric_limits<int>::lowest())};
791 for (
int n = scomp; n < scomp+ncomp; ++n) {
792 t = t || amrex::isinf(a(i,j,k,n));
794 if (t && (*flag == 0)) {
809 for (
int n = scomp; n < scomp+ncomp; ++n) {
810 for (
IntVect iv : bx.iterator()) {
811 if (amrex::isinf(a(iv, n))) {
#define BL_ASSERT(EX)
Definition AMReX_BLassert.H:39
BaseFab container template providing box-based field storage.
#define AMREX_DEFAULT_RUNON
Definition AMReX_GpuControl.H:69
#define AMREX_GPU_DEVICE
Definition AMReX_GpuQualifiers.H:18
#define AMREX_D_TERM(a, b, c)
Definition AMReX_SPACE.H:172
#define AMREX_D_DECL(a, b, c)
Definition AMReX_SPACE.H:171
Abstract base class for memory arenas.
Definition AMReX_Arena.H:153
A FortranArrayBox(FAB)-like object.
Definition AMReX_BaseFab.H:222
Array4< Real const > array() const noexcept
Create an Array4 view over all components.
Definition AMReX_BaseFab.H:475
Box domain
My index space.
Definition AMReX_BaseFab.H:1304
Real * dptr
The data pointer.
Definition AMReX_BaseFab.H:1303
int nvar
Number components.
Definition AMReX_BaseFab.H:1305
Long numPts() const noexcept
Returns the number of points.
Definition AMReX_BaseFab.H:351
int nComp() const noexcept
Returns the number of components.
Definition AMReX_BaseFab.H:343
__host__ __device__ bool contains(const IntVectND< dim > &p) const noexcept
Return true if argument is contained within BoxND.
Definition AMReX_Box.H:233
Definition AMReX_FabFactory.H:76
Definition AMReX_FArrayBox.H:169
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:918
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:952
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:932
A Class Facilitating I/O for Fabs.
Definition AMReX_FArrayBox.H:35
Format
An enum which controls format of FAB output.
Definition AMReX_FArrayBox.H:72
@ FAB_IEEE
Definition AMReX_FArrayBox.H:74
@ FAB_NATIVE_32
Definition AMReX_FArrayBox.H:82
@ FAB_ASCII
Definition AMReX_FArrayBox.H:73
@ FAB_NATIVE
Definition AMReX_FArrayBox.H:75
@ FAB_8BIT
Definition AMReX_FArrayBox.H:80
@ FAB_IEEE_32
Definition AMReX_FArrayBox.H:81
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:45
@ FAB_DOUBLE
Definition AMReX_FArrayBox.H:47
@ FAB_FLOAT
Definition AMReX_FArrayBox.H:46
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:93
@ FAB_REVERSE_ORDER
Definition AMReX_FArrayBox.H:95
@ FAB_NORMAL_ORDER
Definition AMReX_FArrayBox.H:94
@ FAB_REVERSE_ORDER_2
Definition AMReX_FArrayBox.H:96
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:237
void initVal() noexcept
Definition AMReX_FArrayBox.cpp:143
static void Finalize()
Definition AMReX_FArrayBox.cpp:431
static std::string getClassName()
Return the runtime class name (for metadata headers).
Definition AMReX_FArrayBox.cpp:222
static bool initialized
Definition AMReX_FArrayBox.H:525
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
Return the embedded-boundary FabType of this FAB (always regular for a plain FArrayBox).
Definition AMReX_FArrayBox.H:402
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
Write every component of the FAB using the current FABio format (the default format is NATIVE).
Definition AMReX_FArrayBox.cpp:228
FArrayBox(Array4< Real const > const &a) noexcept
Definition AMReX_FArrayBox.H:285
static Real initval
Definition AMReX_FArrayBox.H:543
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)
Replace the global FABio helper used by the program, taking ownership of rd. It is an error if rd is ...
Definition AMReX_FArrayBox.cpp:197
static FABio * fabio
The FABio pointer describing our output format.
Definition AMReX_FArrayBox.H:539
FabType m_type
Definition AMReX_FArrayBox.H:529
void readFrom(std::istream &is)
Read FAB from is using whichever FABio format it was written with.
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:535
FArrayBox(Array4< Real const > const &a, IndexType t) noexcept
Definition AMReX_FArrayBox.H:287
FArrayBox(Array4< Real > const &a, IndexType t) noexcept
Definition AMReX_FArrayBox.H:283
static FABio::Ordering ordering
Definition AMReX_FArrayBox.H:536
static std::unique_ptr< RealDescriptor > getDataDescriptor()
Return a copy of the RealDescriptor describing the on-disk layout.
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()
Query the current initialization value.
Definition AMReX_FArrayBox.cpp:327
static bool do_initval
initial value
Definition AMReX_FArrayBox.H:542
bool contains_nan() const noexcept
Test whether any NaN is present anywhere in the FAB.
Definition AMReX_FArrayBox.H:559
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)
Set the default value used for initialization.
Definition AMReX_FArrayBox.cpp:319
static bool set_do_initval(bool tf)
Enable or disable initializing newly allocated elements to the init value.
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()
Query whether init-value filling is enabled.
Definition AMReX_FArrayBox.cpp:313
static bool init_snan
Definition AMReX_FArrayBox.H:544
~FArrayBox() noexcept override=default
The destructor.
bool contains_inf() const noexcept
Test whether any Inf is present anywhere in the FAB.
Definition AMReX_FArrayBox.H:691
GPU-compatible tuple.
Definition AMReX_Tuple.H:98
Dynamically allocated vector for trivially copyable data.
Definition AMReX_PODVector.H:308
T * data() noexcept
Definition AMReX_PODVector.H:666
A Descriptor of the Real Type.
Definition AMReX_FabConv.H:105
Definition AMReX_Reduce.H:438
Type value()
Definition AMReX_Reduce.H:473
Definition AMReX_Reduce.H:597
void eval(MF const &mf, IntVect const &nghost, D &reduce_data, F &&f)
Definition AMReX_Reduce.H:731
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:79
amrex_long Long
Definition AMReX_INT.H:30
std::array< T, N > Array
Definition AMReX_Array.H:31
__host__ __device__ AMREX_FORCE_INLINE T Exch(T *address, T val) noexcept
Definition AMReX_GpuAtomic.H:487
void streamSynchronize() noexcept
Definition AMReX_GpuDevice.H:310
void dtoh_memcpy_async(void *p_h, const void *p_d, const std::size_t sz) noexcept
Definition AMReX_GpuDevice.H:435
bool inLaunchRegion() noexcept
Definition AMReX_GpuControl.H:88
void htod_memcpy_async(void *p_d, const void *p_h, const std::size_t sz) noexcept
Definition AMReX_GpuDevice.H:421
Definition AMReX_Amr.cpp:50
MakeType
Definition AMReX_MakeType.H:7
RunOn
Definition AMReX_GpuControl.H:65
void ParallelFor(TypeList< CTOs... > ctos, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
Definition AMReX_CTOParallelForImpl.H:202
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:38
FabType
Definition AMReX_FabFactory.H:18
A multidimensional array accessor.
Definition AMReX_Array4.H:288
void * alloc(std::size_t sz) const noexcept
Allocate sz bytes from the arena.
Definition AMReX_DataAllocator.H:31