Block-Structured AMR Software Framework
AMReX_IArrayBox.H
Go to the documentation of this file.
1 
2 #ifndef BL_IFARRAYBOX_H
3 #define BL_IFARRAYBOX_H
4 #include <AMReX_Config.H>
5 
6 #include <AMReX_Box.H>
7 #include <AMReX_BaseFab.H>
8 #include <AMReX_SPACE.H>
9 
10 #include <iosfwd>
11 
12 namespace amrex {
13 
14 class IArrayBox;
15 class IntDescriptor;
16 
17 class IFABio
18 {
19 public:
20  static void write_header (std::ostream& os, const IArrayBox& fab, int nvar) ;
21  static void read (std::istream& is, IArrayBox& fab, IntDescriptor const& data_descriptor) ;
22 };
23 
44 class IArrayBox
45  :
46  public BaseFab<int>
47 {
48 public:
49  friend class IFABio;
50 
52  IArrayBox () noexcept = default;
53 
54  explicit IArrayBox (Arena* ar) noexcept;
55 
56  IArrayBox (const Box& b, int ncomp, Arena* ar);
57 
63  explicit IArrayBox (const Box& b,
64  int ncomp=1,
65  bool alloc=true,
66  bool shared=false,
67  Arena* ar = nullptr);
68 
69  IArrayBox (const IArrayBox& rhs, MakeType make_type, int scomp, int ncomp);
70 
71  explicit IArrayBox (Array4<int> const& a) noexcept : BaseFab<int>(a) {}
72 
73  explicit IArrayBox (Array4<int> const& a, IndexType t) noexcept : BaseFab<int>(a,t) {}
74 
75  explicit IArrayBox (Array4<int const> const& a) noexcept : BaseFab<int>(a) {}
76 
77  explicit IArrayBox (Array4<int const> const& a, IndexType t) noexcept : BaseFab<int>(a,t) {}
78 
80  ~IArrayBox () noexcept override = default;
81 
82  IArrayBox (IArrayBox&& rhs) noexcept = default;
83  IArrayBox& operator= (IArrayBox&&) = default;
84 
85  IArrayBox (const IArrayBox&) = delete;
86  IArrayBox& operator= (const IArrayBox&) = delete;
87 
89  template <RunOn run_on>
90  IArrayBox& operator= (int v) noexcept;
91 
93  void resize (const Box& b, int N = 1, Arena* ar = nullptr);
94 
95  void readFrom (std::istream& is);
96 
97  static void Initialize ();
98  static void Finalize ();
99 
100  static std::unique_ptr<IntDescriptor> getDataDescriptor ();
101 
102  static IFABio const& getFABio ();
103 
104  static std::string getClassName ();
105 
106 private:
107 
108  static bool do_initval;
109  static std::unique_ptr<IFABio> ifabio;
110 
111 };
112 
113 template <RunOn run_on>
114 IArrayBox&
115 IArrayBox::operator= (int v) noexcept
116 {
117  BaseFab<int>::operator=<run_on>(v);
118  return *this;
119 }
120 
121 }
122 
123 #endif /*BL_IFARRAYBOX_H*/
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
A Fortran Array of ints.
Definition: AMReX_IArrayBox.H:47
IArrayBox() noexcept=default
Construct an invalid FAB with no memory.
static std::unique_ptr< IntDescriptor > getDataDescriptor()
Definition: AMReX_IArrayBox.cpp:98
void readFrom(std::istream &is)
Definition: AMReX_IArrayBox.cpp:116
static std::string getClassName()
Definition: AMReX_IArrayBox.cpp:104
static bool do_initval
Definition: AMReX_IArrayBox.H:108
IArrayBox(Array4< int const > const &a) noexcept
Definition: AMReX_IArrayBox.H:75
~IArrayBox() noexcept override=default
The destructor.
static void Finalize()
Definition: AMReX_IArrayBox.cpp:42
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_IArrayBox.cpp:80
IArrayBox(Array4< int const > const &a, IndexType t) noexcept
Definition: AMReX_IArrayBox.H:77
IArrayBox(Array4< int > const &a, IndexType t) noexcept
Definition: AMReX_IArrayBox.H:73
static IFABio const & getFABio()
Definition: AMReX_IArrayBox.cpp:110
static std::unique_ptr< IFABio > ifabio
Definition: AMReX_IArrayBox.H:109
static void Initialize()
Definition: AMReX_IArrayBox.cpp:31
Definition: AMReX_IArrayBox.H:18
static void write_header(std::ostream &os, const IArrayBox &fab, int nvar)
Definition: AMReX_IArrayBox.cpp:154
static void read(std::istream &is, IArrayBox &fab, IntDescriptor const &data_descriptor)
Definition: AMReX_IArrayBox.cpp:162
A Descriptor of the Long Integer type.
Definition: AMReX_FabConv.H:29
Definition: AMReX_Amr.cpp:49
MakeType
Definition: AMReX_MakeType.H:7
RunOn
Definition: AMReX_GpuControl.H:69
Definition: AMReX_Array4.H:61
void * alloc(std::size_t sz) const noexcept
Definition: AMReX_DataAllocator.H:16