Chombo + EB  3.2
EBFluxFAB.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
7  * Please refer to Copyright.txt, in Chombo's root directory.
8  */
9 #endif
10 
11 // DTG 7-31-2001
12 
13 #ifndef _EBFLUXFAB_H_
14 #define _EBFLUXFAB_H_
15 
16 #include "Box.H"
17 #include "Vector.H"
18 #include "EBFaceFAB.H"
19 #include "NamespaceHeader.H"
20 
21 /// A EBFaceFAB-like container for edge-centered fluxes
22 /**
23  This is a class to contain face-centered fluxes on a box.
24  */
25 class EBFluxFAB
26 {
27 
28 public:
29 
30  ///
31  /**
32  This stuff required by LevelData in parallel:
33  */
34  static int preAllocatable()
35  {
36  return 1; // symmetric messaging
37  }
38 
39  /// default constructor
40  EBFluxFAB();
41 
42  /// destructor
43  ~EBFluxFAB();
44 
45  /// this function returns the EBFluxFAB to the undefined state
46  void clear();
47 
48  ///
49  EBFluxFAB& operator+=(const EBFluxFAB& a_ebfab)
50  {
51  for (int idir = 0; idir < SpaceDim; idir++)
52  {
53  (*m_fluxes[idir]) += (*a_ebfab.m_fluxes[idir]);
54  }
55  return *this;
56  }
57 
58 
59  ///
60  EBFluxFAB& operator-=(const EBFluxFAB& a_ebfab)
61  {
62  for (int idir = 0; idir < SpaceDim; idir++)
63  {
64  (*m_fluxes[idir]) -= (*a_ebfab.m_fluxes[idir]);
65  }
66  return *this;
67  }
68 
69 
70  ///
71  EBFluxFAB& operator*=(const EBFluxFAB& a_ebfab)
72  {
73  for (int idir = 0; idir < SpaceDim; idir++)
74  {
75  (*m_fluxes[idir]) *= (*a_ebfab.m_fluxes[idir]);
76  }
77  return *this;
78  }
79 
80 
81  ///
82  EBFluxFAB& operator/=(const EBFluxFAB& a_ebfab)
83  {
84  for (int idir = 0; idir < SpaceDim; idir++)
85  {
86  (*m_fluxes[idir]) /= (*a_ebfab.m_fluxes[idir]);
87  }
88  return *this;
89  }
90 
91  const Box& box() const
92  {
93  return getRegion();
94  }
95 
96  void define(const EBFluxFAB& a_fb)
97  {
98  define(a_fb.getEBISBox(), a_fb.box(), a_fb.nComp());
99  }
100 
101  //! Returns the maximum value for the given component in the FAB for
102  //! the given direction.
103  //! \param a_dir The direction in which the maximum value will be returned.
104  //! \param a_comp The component whose maximum value will be returned.
105  Real max(int a_dir, int a_comp = 0) const
106  {
107  return m_fluxes[a_dir]->max(a_comp);
108  }
109 
110  //! Returns the minimum value for the given component in the FAB for
111  //! the given direction.
112  //! \param a_dir The direction in which the minimum value will be returned.
113  //! \param a_comp The component whose minimum value will be returned.
114  Real min(int a_dir, int a_comp = 0) const
115  {
116  return m_fluxes[a_dir]->min(a_comp);
117  }
118 
119  /// {\bf access functions}
120 
121  /// number of components
122  int nComp() const;
123 
124  /// returns cell-centered box which defines fluxBox
125  const Box& getRegion() const;
126 
127  /// returns EBFaceFAB in direction dir
128  EBFaceFAB& operator[] (const int dir);
129 
130  /// constant version
131  const EBFaceFAB& operator[] (const int dir) const;
132 
133  void setVal(const Real& val);
134 
135  ///defines this from input and copies the values
136  void clone(const EBFluxFAB& a_input);
137 
138  ///
139  /** Copies from a subsection of one box into another.
140  Assumes the boxes are both in the same index space, and that
141  box R is completely contained in both the src and destination
142  boxes. This function equired by BoxLayoutData */
143  void copy(const Box& Rfrom,
144  const Interval& Cdest,
145  const Box& Rto,
146  const EBFluxFAB& src,
147  const Interval& Csrc);
148 
149  ///
150  bool isDefined() const;
151 
152  ///
153  EBFluxFAB(const EBISBox& a_ebisBox, const Box& bx, int n);
154 
155  ///
156  void define(const EBISBox& a_ebisBox, const Box& bx, int n);
157 
158  int size(const Box& R, const Interval& comps) const;
159 
160  void linearOut(void* buf, const Box& R, const Interval& comps) const;
161 
162  void linearIn(void* buf, const Box& R, const Interval& comps);
163 
164  ///
165  /**
166  Can only be used for an undefined ebfluxfab.
167  Turns off deletion of pointers.
168  */
169  void alias(Vector<EBFaceFAB*> a_inputFAB);
170 
171  /// Invalid but necessary for LevelData<EBFluxFAB> to compile
172  EBFluxFAB(const Box& bx, int n)
173  {
174  MayDay::Error("invalid constructor called for EBFluxFAB");
175  }
177  {
178  return m_ebisBox;
179  }
180 
181 protected:
182  void setDefaultValues();
183 
184  ///true if facefabs set by hand, false otherwise
185  bool m_aliased;
186  ///
188 
189  ///
191 
192  ///
193  int m_nComp;
194 
196 
197  /// CH_SPACEDIM EBFaceFABes which hold fluxes
199 
200 
201 private:
202  /// these are disallowed
203 
205  {
206  MayDay::Error("bogus constructor");
207  }
208 
209  void operator = (const EBFluxFAB&)
210  {
211  MayDay::Error("bogus constructor");
212  }
213 
214 };
215 
216 #include "NamespaceFooter.H"
217 #endif
void clone(const EBFluxFAB &a_input)
defines this from input and copies the values
const Box & getRegion() const
returns cell-centered box which defines fluxBox
EBFluxFAB()
default constructor
bool isDefined() const
int size(const Box &R, const Interval &comps) const
one dimensional dynamic array
Definition: Vector.H:53
void copy(const Box &Rfrom, const Interval &Cdest, const Box &Rto, const EBFluxFAB &src, const Interval &Csrc)
EBFluxFAB & operator*=(const EBFluxFAB &a_ebfab)
Definition: EBFluxFAB.H:71
Definition: EBISBox.H:46
EBFluxFAB(const EBFluxFAB &)
these are disallowed
Definition: EBFluxFAB.H:204
Definition: EBFaceFAB.H:28
const int SpaceDim
Definition: SPACE.H:38
void operator=(const EBFluxFAB &)
Definition: EBFluxFAB.H:209
void define(const EBFluxFAB &a_fb)
Definition: EBFluxFAB.H:96
A EBFaceFAB-like container for edge-centered fluxes.
Definition: EBFluxFAB.H:25
EBFluxFAB & operator-=(const EBFluxFAB &a_ebfab)
Definition: EBFluxFAB.H:60
Structure for passing component ranges in code.
Definition: Interval.H:23
void linearIn(void *buf, const Box &R, const Interval &comps)
void setVal(const Real &val)
double Real
Definition: REAL.H:33
bool m_aliased
true if facefabs set by hand, false otherwise
Definition: EBFluxFAB.H:185
bool m_isDefined
Definition: EBFluxFAB.H:195
EBISBox m_ebisBox
Definition: EBFluxFAB.H:190
const Box & box() const
Definition: EBFluxFAB.H:91
EBFluxFAB(const Box &bx, int n)
Invalid but necessary for LevelData<EBFluxFAB> to compile.
Definition: EBFluxFAB.H:172
Tuple< EBFaceFAB *, CH_SPACEDIM > m_fluxes
CH_SPACEDIM EBFaceFABes which hold fluxes.
Definition: EBFluxFAB.H:198
~EBFluxFAB()
destructor
static void Error(const char *const a_msg=m_nullString, int m_exitCode=CH_DEFAULT_ERROR_CODE)
Print out message to cerr and exit with the specified exit code.
EBFluxFAB & operator/=(const EBFluxFAB &a_ebfab)
Definition: EBFluxFAB.H:82
Real max(int a_dir, int a_comp=0) const
Definition: EBFluxFAB.H:105
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
Box m_region
Definition: EBFluxFAB.H:187
Real min(int a_dir, int a_comp=0) const
Definition: EBFluxFAB.H:114
void linearOut(void *buf, const Box &R, const Interval &comps) const
EBFluxFAB & operator+=(const EBFluxFAB &a_ebfab)
Definition: EBFluxFAB.H:49
EBISBox getEBISBox() const
Definition: EBFluxFAB.H:176
EBFaceFAB & operator[](const int dir)
returns EBFaceFAB in direction dir
void alias(Vector< EBFaceFAB *> a_inputFAB)
void clear()
this function returns the EBFluxFAB to the undefined state
void setDefaultValues()
static int preAllocatable()
Definition: EBFluxFAB.H:34
int nComp() const
{ access functions}
int m_nComp
Definition: EBFluxFAB.H:193