Block-Structured AMR Software Framework
AMReX_FabConv.H
Go to the documentation of this file.
1 
2 #ifndef BL_FABCONV_H
3 #define BL_FABCONV_H
4 #include <AMReX_Config.H>
5 
6 #include <AMReX_Array.H>
7 #include <AMReX_Vector.H>
8 #include <AMReX_BLassert.H>
9 #include <AMReX_REAL.H>
10 #include <AMReX_INT.H>
11 
12 #include <iosfwd>
13 
14 namespace amrex {
15 
29 {
30 
31 public:
38  enum Ordering { NormalOrder = 1, ReverseOrder = 2 };
45  IntDescriptor () = default;
47  IntDescriptor (Long nb,
48  Ordering ordering = NormalOrder);
50  [[nodiscard]] Ordering order () const;
52  [[nodiscard]] int numBytes () const;
54  bool operator== (const IntDescriptor& id) const;
56  bool operator!= (const IntDescriptor& id) const;
57 
58 private:
59  friend std::istream& operator>> (std::istream& is, IntDescriptor& id);
60  Long numbytes;
62 };
63 
67 std::ostream& operator<< (std::ostream& os, const IntDescriptor& id);
71 std::istream& operator>> (std::istream& is, IntDescriptor& id);
72 
105 {
106 public:
113  RealDescriptor () = default;
119  RealDescriptor (const Long* fr_, const int* ord_, int ordl_);
121  [[nodiscard]] const Long* format () const&;
122  const Long* format () && = delete;
123 
125  [[nodiscard]] const Vector<Long>& formatarray () const&;
126  const Vector<Long>& formatarray () && = delete;
127 
129  [[nodiscard]] const int* order () const&;
130  const int* order () && = delete;
131 
133  [[nodiscard]] const Vector<int>& orderarray () const&;
134  const Vector<int>& orderarray () && = delete;
135 
137  [[nodiscard]] int numBytes () const;
138 
140  bool operator== (const RealDescriptor& rd) const;
141 
143  bool operator != (const RealDescriptor& rd) const;
144 
146  static void SetFixDenormals ();
147 
149  static void SetReadBufferSize (int rbs);
150  static void SetWriteBufferSize (int wbs);
151 
156  [[nodiscard]] RealDescriptor* clone () const;
157 
164  static RealDescriptor* newRealDescriptor (int fmt, int prec, const char* systype,
165  int ordering);
171  static void convertToNativeFormat (Real* out,
172  Long nitems,
173  void* in,
174  const RealDescriptor& id);
175 
181  static void convertToNativeFormat (Real* out,
182  Long nitems,
183  std::istream& is,
184  const RealDescriptor& id);
185 
190  static void convertFromNativeFormat (std::ostream& os,
191  Long nitems,
192  const Real* in,
193  const RealDescriptor& od);
199  static void convertFromNativeFormat (void* out,
200  Long nitems,
201  const void* in,
202  const RealDescriptor& od);
203 
208  static void convertFromNativeFloatFormat (std::ostream& os,
209  Long nitems,
210  const float* in,
211  const RealDescriptor& od);
212 
217  static void convertFromNativeDoubleFormat (std::ostream& os,
218  Long nitems,
219  const double* in,
220  const RealDescriptor& od);
221 
227  static void convertToNativeFloatFormat (float* out,
228  Long nitems,
229  std::istream& is,
230  const RealDescriptor& id);
231 
237  static void convertToNativeDoubleFormat (double* out,
238  Long nitems,
239  std::istream& is,
240  const RealDescriptor& id);
241 
242 private:
243 
244  Vector<Long> fr;
245  Vector<int> ord;
246  static bool bAlwaysFixDenormals;
247  static int writeBufferSize;
248  static int readBufferSize;
249 };
250 
254 std::ostream& operator<< (std::ostream& os, const amrex::RealDescriptor& rd);
258 std::istream& operator>> (std::istream& is, amrex::RealDescriptor& rd);
259 
260 }
261 
262 #endif /*BL_FABCONV_H*/
A Descriptor of the Long Integer type.
Definition: AMReX_FabConv.H:29
Long numbytes
Definition: AMReX_FabConv.H:60
Ordering ord
Definition: AMReX_FabConv.H:61
Ordering
An enumeration describing the two orderings that we currently support: NormalOrder and ReverseOrder....
Definition: AMReX_FabConv.H:38
@ ReverseOrder
Definition: AMReX_FabConv.H:38
@ NormalOrder
Definition: AMReX_FabConv.H:38
bool operator==(const IntDescriptor &id) const
The equality operator.
Definition: AMReX_FabConv.cpp:38
bool operator!=(const IntDescriptor &id) const
The inequality operator.
Definition: AMReX_FabConv.cpp:44
IntDescriptor()=default
The default constructor. Does not build a proper IntDescriptor. This should only be used when you nee...
friend std::istream & operator>>(std::istream &is, IntDescriptor &id)
Definition: AMReX_FabConv.cpp:66
int numBytes() const
Returns the number of bytes.
Definition: AMReX_FabConv.cpp:32
Ordering order() const
Returns the ordering.
Definition: AMReX_FabConv.cpp:26
A Descriptor of the Real Type.
Definition: AMReX_FabConv.H:105
static void SetReadBufferSize(int rbs)
Set read and write buffer sizes.
Definition: AMReX_FabConv.cpp:150
static void convertToNativeFormat(Real *out, Long nitems, void *in, const RealDescriptor &id)
Convert nitems in RealDescriptor format to native Real format. The out array is assumed to be large e...
Definition: AMReX_FabConv.cpp:974
const Vector< int > & orderarray() const &
Returns const Vector<int> reference to the order array.
Definition: AMReX_FabConv.cpp:118
static int writeBufferSize
Definition: AMReX_FabConv.H:247
static void convertFromNativeDoubleFormat(std::ostream &os, Long nitems, const double *in, const RealDescriptor &od)
Convert nitems doubles in native format to RealDescriptor format and write them to the ostream.
Definition: AMReX_FabConv.cpp:1147
static void convertFromNativeFormat(std::ostream &os, Long nitems, const Real *in, const RealDescriptor &od)
Convert nitems Reals in native format to RealDescriptor format and write them to the ostream.
Definition: AMReX_FabConv.cpp:1063
RealDescriptor()=default
The default constructor. Does not build a proper RealDescriptor. This should only be used when you ne...
static void convertFromNativeFloatFormat(std::ostream &os, Long nitems, const float *in, const RealDescriptor &od)
Convert nitems floats in native format to RealDescriptor format and write them to the ostream.
Definition: AMReX_FabConv.cpp:1105
static void convertToNativeDoubleFormat(double *out, Long nitems, std::istream &is, const RealDescriptor &id)
Read nitems from istream in RealDescriptor format and convert them to the native double format....
Definition: AMReX_FabConv.cpp:1230
static bool bAlwaysFixDenormals
Definition: AMReX_FabConv.H:246
static int readBufferSize
Definition: AMReX_FabConv.H:248
static void SetWriteBufferSize(int wbs)
Definition: AMReX_FabConv.cpp:157
static RealDescriptor * newRealDescriptor(int fmt, int prec, const char *systype, int ordering)
Returns a RealDescriptor on the heap detailing requested floating-point type. Here format,...
Definition: AMReX_FabConv.cpp:218
const Vector< Long > & formatarray() const &
Returns const Vector<Long> reference to the format array.
Definition: AMReX_FabConv.cpp:104
const int * order() const &
Returns the order array as a const int*.
Definition: AMReX_FabConv.cpp:111
static void SetFixDenormals()
Set to always fix denormals when converting to native format.
Definition: AMReX_FabConv.cpp:144
const Long * format() const &
Returns the format array as a const Long*.
Definition: AMReX_FabConv.cpp:97
Vector< Long > fr
Definition: AMReX_FabConv.H:244
RealDescriptor * clone() const
Returns a copy of this RealDescriptor on the heap. The user is responsible for deletion.
Definition: AMReX_FabConv.cpp:164
static void convertToNativeFloatFormat(float *out, Long nitems, std::istream &is, const RealDescriptor &id)
Read nitems from istream in RealDescriptor format and convert them to the native float format....
Definition: AMReX_FabConv.cpp:1188
int numBytes() const
Returns the number of bytes in the Real.
Definition: AMReX_FabConv.cpp:125
Vector< int > ord
Definition: AMReX_FabConv.H:245
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
std::ostream & operator<<(std::ostream &os, AmrMesh const &amr_mesh)
Definition: AMReX_AmrMesh.cpp:1236
std::istream & operator>>(std::istream &is, BoxND< dim > &bx)
Read from istream.
Definition: AMReX_Box.H:1700