Block-Structured AMR Software Framework
AMReX_iMultiFab.H
Go to the documentation of this file.
1 
2 #ifndef BL_IMULTIFAB_H
3 #define BL_IMULTIFAB_H
4 #include <AMReX_Config.H>
5 
6 #include <AMReX_BLassert.H>
7 #include <AMReX_IArrayBox.H>
8 #include <AMReX_FabArray.H>
10 #include <AMReX_Geometry.H>
11 #include <memory>
12 
13 namespace amrex {
14 
15 /*
16 * A Collection of IArrayBoxes
17 *
18 * The iMultiFab class is publicly derived from the
19 * FabArray<int,IArrayBox> class. It is a collection (stored as an array) of
20 * IArrayBoxes useful for storing integer data on a domain defined by
21 * a union of rectangular regions embedded in a uniform index space. The
22 * iMultiFab class extends the function of the underlying FabArray class just
23 * as the IArrayBox class extends the function of BaseFab<int>. Additional
24 * member functions are defined for I/O and simple arithmetic operations on
25 * these aggregate objects.
26 *
27 * This class does NOT provide a copy constructor or assignment operator.
28 */
29 class iMultiFab
30  :
31  public FabArray<IArrayBox>
32 {
33 public:
34 
40  iMultiFab () noexcept = default;
41 
49  explicit iMultiFab (Arena* a) noexcept;
50 
55  iMultiFab (const BoxArray& bxs,
56  const DistributionMapping& dm,
57  int ncomp,
58  int ngrow,
59 #ifdef AMREX_STRICT_MODE
60  const MFInfo& info,
61  const FabFactory<IArrayBox>& factory);
62 #else
63  const MFInfo& info = MFInfo(),
65 #endif
66 
67  iMultiFab (const BoxArray& bxs,
68  const DistributionMapping& dm,
69  int ncomp,
70  const IntVect& ngrow,
71 #ifdef AMREX_STRICT_MODE
72  const MFInfo& info,
73  const FabFactory<IArrayBox>& factory);
74 #else
75  const MFInfo& info = MFInfo(),
77 #endif
78 
90  iMultiFab (const iMultiFab& rhs, MakeType maketype, int scomp, int ncomp);
91 
92  ~iMultiFab () = default;
93 
94  iMultiFab (iMultiFab&& rhs) noexcept = default;
95  iMultiFab& operator= (iMultiFab&& rhs) noexcept = default;
96 
97  iMultiFab (const iMultiFab& rhs) = delete;
98  iMultiFab& operator= (const iMultiFab& rhs) = delete;
99 
100  iMultiFab& operator= (int r);
101 
112  [[nodiscard]] int min (int comp,
113  int nghost = 0,
114  bool local = false) const;
115 
125  [[nodiscard]] int min (const Box& region,
126  int comp,
127  int nghost = 0,
128  bool local = false) const;
129 
140  [[nodiscard]] int max (int comp,
141  int nghost = 0,
142  bool local = false) const;
143 
153  [[nodiscard]] int max (const Box& region,
154  int comp,
155  int nghost = 0,
156  bool local = false) const;
157 
165  [[nodiscard]] Long sum (int comp, int nghost = 0, bool local = false) const;
166 
170  [[nodiscard]] Long sum (Box const& region, int comp = 0, bool local = false) const;
171 
185  void plus (int val,
186  int comp,
187  int num_comp,
188  int nghost = 0);
189 
201  void plus (int val,
202  const Box& region,
203  int comp,
204  int num_comp,
205  int nghost = 0);
206 
216  void plus (int val,
217  int nghost);
218 
230  void plus (int val,
231  const Box& region,
232  int nghost);
233 
247  void mult (int val,
248  int comp,
249  int num_comp,
250  int nghost = 0);
251 
265  void mult (int val,
266  const Box& region,
267  int comp,
268  int num_comp,
269  int nghost = 0);
270 
280  void mult (int val,
281  int nghost = 0);
282 
294  void mult (int val,
295  const Box& region,
296  int nghost = 0);
297 
309  void negate (int comp,
310  int num_comp,
311  int nghost = 0);
312 
323  void negate (const Box& region,
324  int comp,
325  int num_comp,
326  int nghost = 0);
327 
335  void negate (int nghost = 0);
336 
346  void negate (const Box& region,
347  int nghost = 0);
348 
349  [[nodiscard]] IntVect minIndex (int comp,
350  int nghost = 0) const;
351 
352  [[nodiscard]] IntVect maxIndex (int comp,
353  int nghost = 0) const;
354 
369  void plus (const iMultiFab& mf,
370  int strt_comp,
371  int num_comp,
372  int nghost);
373 
388  void minus (const iMultiFab& mf,
389  int strt_comp,
390  int num_comp,
391  int nghost);
392 
408  void divide (const iMultiFab& mf,
409  int strt_comp,
410  int num_comp,
411  int nghost);
412 
424  static void Add (iMultiFab& dst,
425  const iMultiFab& src,
426  int srccomp,
427  int dstcomp,
428  int numcomp,
429  int nghost);
430 
442  static void Copy (iMultiFab& dst,
443  const iMultiFab& src,
444  int srccomp,
445  int dstcomp,
446  int numcomp,
447  int nghost);
448 
449  static void Copy (iMultiFab& dst,
450  const iMultiFab& src,
451  int srccomp,
452  int dstcomp,
453  int numcomp,
454  const IntVect& nghost);
455 
467  static void Subtract (iMultiFab& dst,
468  const iMultiFab& src,
469  int srccomp,
470  int dstcomp,
471  int numcomp,
472  int nghost);
473 
485  static void Multiply (iMultiFab& dst,
486  const iMultiFab& src,
487  int srccomp,
488  int dstcomp,
489  int numcomp,
490  int nghost);
491 
503  static void Divide (iMultiFab& dst,
504  const iMultiFab& src,
505  int srccomp,
506  int dstcomp,
507  int numcomp,
508  int nghost);
509 
510  void define (const BoxArray& bxs,
511  const DistributionMapping& dm,
512  int nvar,
513  const IntVect& ngrow,
514 #ifdef AMREX_STRICT_MODE
515  const MFInfo& info,
516  const FabFactory<IArrayBox>& factory);
517 #else
518  const MFInfo& info = MFInfo(),
520 #endif
521 
522  void define (const BoxArray& bxs,
523  const DistributionMapping& dm,
524  int nvar,
525  int ngrow,
526 #ifdef AMREX_STRICT_MODE
527  const MFInfo& info,
528  const FabFactory<IArrayBox>& factory);
529 #else
530  const MFInfo& info = MFInfo(),
532 #endif
533 
534  static void Initialize ();
535  static void Finalize ();
536 };
537 
538 // ngrow != IntVect{0} is a special case that should not be used in normal cases,
539 // because it may mark valid cells as non-owner and ghost cells as owners.
540 std::unique_ptr<iMultiFab>
541 OwnerMask (FabArrayBase const& mf, const Periodicity& period, const IntVect& ngrow=IntVect{0});
542 
543 }
544 
545 #endif /*BL_IMULTIFAB_H*/
A virtual base class for objects that manage their own dynamic memory allocation.
Definition: AMReX_Arena.H:100
A collection of Boxes stored in an Array.
Definition: AMReX_BoxArray.H:549
Definition: AMReX_FabFactory.H:76
Calculates the distribution of FABs to MPI processes.
Definition: AMReX_DistributionMapping.H:41
Base class for FabArray.
Definition: AMReX_FabArrayBase.H:41
An Array of FortranArrayBox(FAB)-like Objects.
Definition: AMReX_FabArray.H:344
Definition: AMReX_FabFactory.H:50
This provides length of period for periodic domains. 0 means it is not periodic in that direction....
Definition: AMReX_Periodicity.H:17
Definition: AMReX_iMultiFab.H:32
static void Initialize()
Definition: AMReX_iMultiFab.cpp:148
IntVect maxIndex(int comp, int nghost=0) const
Definition: AMReX_iMultiFab.cpp:519
void define(const BoxArray &bxs, const DistributionMapping &dm, int nvar, const IntVect &ngrow, const MFInfo &info=MFInfo(), const FabFactory< IArrayBox > &factory=DefaultFabFactory< IArrayBox >())
Definition: AMReX_iMultiFab.cpp:202
int max(int comp, int nghost=0, bool local=false) const
Returns the maximum value contained in component comp of the iMultiFab. The parameter nghost determin...
Definition: AMReX_iMultiFab.cpp:308
Long sum(int comp, int nghost=0, bool local=false) const
Returns the sum in component comp.
Definition: AMReX_iMultiFab.cpp:392
static void Finalize()
Definition: AMReX_iMultiFab.cpp:158
int min(int comp, int nghost=0, bool local=false) const
Returns the minimum value contained in component comp of the iMultiFab. The parameter nghost determin...
Definition: AMReX_iMultiFab.cpp:224
iMultiFab() noexcept=default
Constructs an empty iMultiFab. Data can be defined at a later time using the define member functions ...
static void Subtract(iMultiFab &dst, const iMultiFab &src, int srccomp, int dstcomp, int numcomp, int nghost)
Subtract src from dst including nghost ghost cells. The two iMultiFabs MUST have the same underlying ...
Definition: AMReX_iMultiFab.cpp:67
IntVect minIndex(int comp, int nghost=0) const
Definition: AMReX_iMultiFab.cpp:511
iMultiFab(iMultiFab &&rhs) noexcept=default
void minus(const iMultiFab &mf, int strt_comp, int num_comp, int nghost)
This function subtracts the values of the cells in mf from the corresponding cells of this iMultiFab....
Definition: AMReX_iMultiFab.cpp:527
static void Add(iMultiFab &dst, const iMultiFab &src, int srccomp, int dstcomp, int numcomp, int nghost)
Add src to dst including nghost ghost cells. The two iMultiFabs MUST have the same underlying BoxArra...
Definition: AMReX_iMultiFab.cpp:24
static void Divide(iMultiFab &dst, const iMultiFab &src, int srccomp, int dstcomp, int numcomp, int nghost)
Divide dst by src including nghost ghost cells. The two iMultiFabs MUST have the same underlying BoxA...
Definition: AMReX_iMultiFab.cpp:97
iMultiFab & operator=(iMultiFab &&rhs) noexcept=default
void plus(int val, int comp, int num_comp, int nghost=0)
Adds the scalar value val to the value of each cell in the specified subregion of the iMultiFab....
Definition: AMReX_iMultiFab.cpp:545
~iMultiFab()=default
void divide(const iMultiFab &mf, int strt_comp, int num_comp, int nghost)
This function divides the values of the cells in mf from the corresponding cells of this iMultiFab....
Definition: AMReX_iMultiFab.cpp:536
static void Multiply(iMultiFab &dst, const iMultiFab &src, int srccomp, int dstcomp, int numcomp, int nghost)
Multiply dst by src including nghost ghost cells. The two iMultiFabs MUST have the same underlying Bo...
Definition: AMReX_iMultiFab.cpp:82
void negate(int comp, int num_comp, int nghost=0)
Negates the value of each cell in the specified subregion of the iMultiFab. The subregion consists of...
Definition: AMReX_iMultiFab.cpp:614
void mult(int val, int comp, int num_comp, int nghost=0)
Scales the value of each cell in the specified subregion of the iMultiFab by the scalar val (a[i] <- ...
Definition: AMReX_iMultiFab.cpp:587
iMultiFab(const iMultiFab &rhs)=delete
static void Copy(iMultiFab &dst, const iMultiFab &src, int srccomp, int dstcomp, int numcomp, int nghost)
Copy from src to dst including nghost ghost cells. The two iMultiFabs MUST have the same underlying B...
Definition: AMReX_iMultiFab.cpp:39
Definition: AMReX_Amr.cpp:49
MakeType
Definition: AMReX_MakeType.H:7
std::unique_ptr< iMultiFab > OwnerMask(FabArrayBase const &mf, const Periodicity &period, const IntVect &ngrow)
Definition: AMReX_iMultiFab.cpp:637
FabArray memory allocation information.
Definition: AMReX_FabArray.H:66