Block-Structured AMR Software Framework
 
Loading...
Searching...
No Matches
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
13namespace 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*/
30 :
31 public FabArray<IArrayBox>
32{
33public:
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
431 static void Add (iMultiFab& dst,
432 const iMultiFab& src,
433 int srccomp,
434 int dstcomp,
435 int numcomp,
436 const IntVect& nghost);
437
449 static void Copy (iMultiFab& dst,
450 const iMultiFab& src,
451 int srccomp,
452 int dstcomp,
453 int numcomp,
454 int nghost);
455
456 static void Copy (iMultiFab& dst,
457 const iMultiFab& src,
458 int srccomp,
459 int dstcomp,
460 int numcomp,
461 const IntVect& nghost);
462
468 static void Swap (iMultiFab& dst,
469 iMultiFab& src,
470 int srccomp,
471 int dstcomp,
472 int numcomp,
473 int nghost);
474
475 static void Swap (iMultiFab& dst,
476 iMultiFab& src,
477 int srccomp,
478 int dstcomp,
479 int numcomp,
480 const IntVect& nghost);
481
493 static void Subtract (iMultiFab& dst,
494 const iMultiFab& src,
495 int srccomp,
496 int dstcomp,
497 int numcomp,
498 int nghost);
499
500 static void Subtract (iMultiFab& dst,
501 const iMultiFab& src,
502 int srccomp,
503 int dstcomp,
504 int numcomp,
505 const IntVect& nghost);
506
518 static void Multiply (iMultiFab& dst,
519 const iMultiFab& src,
520 int srccomp,
521 int dstcomp,
522 int numcomp,
523 int nghost);
524
525 static void Multiply (iMultiFab& dst,
526 const iMultiFab& src,
527 int srccomp,
528 int dstcomp,
529 int numcomp,
530 const IntVect& nghost);
531
543 static void Divide (iMultiFab& dst,
544 const iMultiFab& src,
545 int srccomp,
546 int dstcomp,
547 int numcomp,
548 int nghost);
549
550 static void Divide (iMultiFab& dst,
551 const iMultiFab& src,
552 int srccomp,
553 int dstcomp,
554 int numcomp,
555 const IntVect& nghost);
556
557 void define (const BoxArray& bxs,
558 const DistributionMapping& dm,
559 int nvar,
560 const IntVect& ngrow,
561#ifdef AMREX_STRICT_MODE
562 const MFInfo& info,
563 const FabFactory<IArrayBox>& factory);
564#else
565 const MFInfo& info = MFInfo(),
567#endif
568
569 void define (const BoxArray& bxs,
570 const DistributionMapping& dm,
571 int nvar,
572 int ngrow,
573#ifdef AMREX_STRICT_MODE
574 const MFInfo& info,
575 const FabFactory<IArrayBox>& factory);
576#else
577 const MFInfo& info = MFInfo(),
579#endif
580
581 static void Initialize ();
582 static void Finalize ();
583};
584
585// ngrow != IntVect{0} is a special case that should not be used in normal cases,
586// because it may mark valid cells as non-owner and ghost cells as owners.
587std::unique_ptr<iMultiFab>
588OwnerMask (FabArrayBase const& mf, const Periodicity& period, const IntVect& ngrow=IntVect{0});
589
590}
591
592#endif /*BL_IMULTIFAB_H*/
A virtual base class for objects that manage their own dynamic memory allocation.
Definition AMReX_Arena.H:105
A collection of Boxes stored in an Array.
Definition AMReX_BoxArray.H:551
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:42
An Array of FortranArrayBox(FAB)-like Objects.
Definition AMReX_FabArray.H:345
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:210
IntVect maxIndex(int comp, int nghost=0) const
Definition AMReX_iMultiFab.cpp:581
static void Swap(iMultiFab &dst, iMultiFab &src, int srccomp, int dstcomp, int numcomp, int nghost)
Swap from src to dst including nghost ghost cells. The two iMultiFabs MUST have the same underlying B...
Definition AMReX_iMultiFab.cpp:74
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:264
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:370
Long sum(int comp, int nghost=0, bool local=false) const
Returns the sum in component comp.
Definition AMReX_iMultiFab.cpp:454
static void Finalize()
Definition AMReX_iMultiFab.cpp:220
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:286
iMultiFab() noexcept=default
Constructs an empty iMultiFab. Data can be defined at a later time using the define member functions ...
iMultiFab & operator=(iMultiFab &&rhs) noexcept=default
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:93
IntVect minIndex(int comp, int nghost=0) const
Definition AMReX_iMultiFab.cpp:573
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:589
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:147
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:607
~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:598
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:120
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:676
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:649
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:51
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:699
FabArray memory allocation information.
Definition AMReX_FabArray.H:66