Chombo + EB  3.2
EBStencil.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 #ifndef _EBSTENCIL_H_
12 #define _EBSTENCIL_H_
13 
14 #include "Stencils.H"
15 #include "Vector.H"
16 #include "VolIndex.H"
17 #include "REAL.H"
18 #include "Box.H"
19 #include "FArrayBox.H"
20 #include "EBIndexSpace.H"
21 #include "EBCellFAB.H"
22 #include "NamespaceHeader.H"
23 
24 /// EB stencil
25 /**
26  */
27 class EBStencil
28 {
29 public:
30  ///
31  /**
32  Destructor
33  */
34  ~EBStencil();
35 
36  ///
37  /**
38  Full constructor. Box is unghosted.
39  When setting Lphi(i,j) = L(phi(i,j))
40  GhostVectPhi is the ghost vect of phi
41  GhostVectLph is the ghost vect of lphi
42  */
43  EBStencil(const Vector<VolIndex>& a_srcVofs,
44  const BaseIVFAB<VoFStencil>& a_vofstencil,
45  const Box& a_box,
46  const EBISBox& a_ebisbox,
47  const IntVect& a_ghostVectPhi,
48  const IntVect& a_ghostVectLph,
49  int a_varDest = 0,
50  bool a_doRelaxOpt = false,
51  int ncomp = 1,
52  IntVectSet a_setIrreg = IntVectSet(),
53  bool a_useInputSets = false);
54 
55  ///
56  /**
57  Second constructor for creating stencil
58  where dest and src live on 2 different levels
59  and dest is Lphi and src is Phi.
60  no relax optimization here
61  */
62  EBStencil(const Vector<VolIndex>& a_srcVofs,
63  const Vector<VoFStencil>& a_vofStencil,
64  const Box& a_boxLph,
65  const Box& a_boxPhi,
66  const EBISBox& a_ebisBoxLph,
67  const EBISBox& a_ebisBoxPhi,
68  const IntVect& a_ghostVectLph,
69  const IntVect& a_ghostVectPhi,
70  int a_varDest = 0,
71  int ncomp = 1,
72  IntVectSet a_setIrreg = IntVectSet(),
73  bool a_useInputSets = false);
74 
75 
76 
77  ///
78  /**
79  Applies stencil to each component of phi using the stencil weights and offsets to compute L.
80  If incrementOnly = true, a_lofphi is incremented without any set to zero.
81  If false, a_lofphi is set to zero and set equal to L(phi).
82  ivar is so you can apply a scalar ebstencil to a component of a
83  larger holder
84  */
85  void
86  apply(EBCellFAB& a_lofphi, const EBCellFAB& a_phi, bool incrementOnly = false, int ivar = 0) const;
87 
88 
89  ///
90  /**
91  Applies stencil to each component of phi using the stencil weights and offsets to compute L.
92  but with constants.
93  a_lofphi_i = alpha*phi_i + beta*lphi_i
94  If incrementOnly = true, a_lofphi is incremented without any set to zero.
95  If false, a_lofphi is set to zero and set equal to a_lofphi_i
96  Alpha and beta are defined over getIrregIVS(lphBox) where lphBox = grow(a_box, a_ghostVectLph)
97  where a_box are given in the constructor.
98  */
99  void
100  apply(EBCellFAB& a_lofphi, const EBCellFAB& a_phi,
101  const BaseIVFAB<Real>& a_alphaWeight,
102  Real a_alpha, Real a_beta, bool incrementOnly = false) const;
103 
104  void
105  apply(EBCellFAB& a_lofphi,
106  const EBCellFAB& a_phi,
107  const Real a_lambdaFactor,
108  const Real a_alpha,
109  const BaseIVFAB<Real>& a_alphaWeight,
110  const Real a_beta,
111  const BaseIVFAB<Real>& a_betaWeight,
112  Real a_one,
113  bool incrementOnly = false) const;
114 
115  void
116  applyInhomDomBC(EBCellFAB& a_lofphi,
117  const EBCellFAB& a_phi,
118  const Real a_factor) const;
119 
120  ///
121  void
122  relax(EBCellFAB& a_phi,
123  const EBCellFAB& a_rhs,
124  const BaseIVFAB<Real>& a_alphaWeight,
125  const BaseIVFAB<Real>& a_betaWeight,
126  Real a_alpha, Real a_beta, Real a_safety) const;
127 
128  ///
129  void
130  relaxClone(EBCellFAB& a_phi,
131  const EBCellFAB& a_phiOld,
132  const EBCellFAB& a_rhs,
133  const BaseIVFAB<Real>& a_alphaWeight,
134  const BaseIVFAB<Real>& a_betaWeight,
135  Real a_alpha, Real a_beta, Real a_safety) const;
136 
137  ///
138  /**
139  Cache lphi.
140  ivar is so you can apply a scalar ebstencil to a component of a
141  larger holder */
142  void
143  cache(const EBCellFAB& a_lphi, int a_ivar = 0) const;
144 
145  ///
146  /**
147  Cache phi
148  ivar is so you can apply a scalar ebstencil to a component of a
149  larger holder */
150  void
151  cachePhi(const EBCellFAB& a_lphi, int a_ivar = 0) const;
152 
153 
154  ///
155  /**
156  Uncache lphi
157  ivar is so you can apply a scalar ebstencil to a component of a
158  larger holder */
159  void
160  uncache(EBCellFAB& a_lphi, int a_ivar = 0) const;
161 
162  ///
163  /**
164  Uncache phi
165  ivar is so you can apply a scalar ebstencil to a component of a
166  larger holder */
167  void
168  uncachePhi(EBCellFAB& a_phi, int a_ivar = 0) const;
169 
170 
171  ///
172  /**
173  Compute integer offsets for stencil operations
174  */
175  void
176  computeOffsets(const Vector<VolIndex>& a_srcVoFs, const BaseIVFAB<VoFStencil>& a_vofstencil);
177 
178 
179  struct
180  {
181  int offset;
183  } typedef destTerm_t;
184 
185  struct
186  {
187  int offset;
189  //only used when debugging
190  // VolIndex vof;
191  } typedef stencilTerm;
192 
193  struct
194  {
197  } typedef ebstencil_t;
198 
199 protected:
200 
215  int m_nComp;
218  //only used when debugging
219 // Vector<VolIndex> m_srcVoFs;
220 private:
221  ///
222  /*
223  Default constructor.
224  */
226  {
227  MayDay::Error("invalid operator");
228  }
229 
230  ///
231  /*
232  Operator =.
233  */
234  void
235  operator=(const EBStencil& stenin)
236  {
237  MayDay::Error("invalid operator");
238  }
239 
240  ///
241  /*
242  Copy constructor.
243  */
244  EBStencil(const EBStencil& stenin)
245  {
246  MayDay::Error("invalid operator");
247  }
248 
249 };
250 
251 
252 #include "NamespaceFooter.H"
253 #endif
void uncache(EBCellFAB &a_lphi, int a_ivar=0) const
Vector< destTerm_t > m_destTerms
Definition: EBStencil.H:209
void computeOffsets(const Vector< VolIndex > &a_srcVoFs, const BaseIVFAB< VoFStencil > &a_vofstencil)
An irregular domain on an integer lattice.
Definition: IntVectSet.H:44
Vector< destTerm_t > m_sourTerms
Definition: EBStencil.H:210
Definition: EBStencil.H:185
EBStencil()
Definition: EBStencil.H:225
EBStencil(const EBStencil &stenin)
Definition: EBStencil.H:244
void uncachePhi(EBCellFAB &a_phi, int a_ivar=0) const
IntVectSet m_setIrreg
Definition: EBStencil.H:216
Definition: EBISBox.H:46
bool m_useInputSets
Definition: EBStencil.H:217
Box m_box
Definition: EBStencil.H:201
Vector< Real > m_cachePhi
Definition: EBStencil.H:213
int m_destVar
Definition: EBStencil.H:207
void operator=(const EBStencil &stenin)
Definition: EBStencil.H:235
bool m_doRelaxOpt
Definition: EBStencil.H:214
void cache(const EBCellFAB &a_lphi, int a_ivar=0) const
Vector< stencilTerm > single
Definition: EBStencil.H:195
void relax(EBCellFAB &a_phi, const EBCellFAB &a_rhs, const BaseIVFAB< Real > &a_alphaWeight, const BaseIVFAB< Real > &a_betaWeight, Real a_alpha, Real a_beta, Real a_safety) const
Vector< Real > m_cacheLph
Definition: EBStencil.H:212
Definition: EBCellFAB.H:29
Real weight
Definition: EBStencil.H:188
IntVect m_ghostVectPhi
Definition: EBStencil.H:205
int m_nComp
Definition: EBStencil.H:215
double Real
Definition: REAL.H:33
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.
int offset
Definition: EBStencil.H:187
int offset
Definition: EBStencil.H:181
void cachePhi(const EBCellFAB &a_lphi, int a_ivar=0) const
EBISBox m_ebisBox
Definition: EBStencil.H:202
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
Box m_phiBox
Definition: EBStencil.H:204
bool multiValued
Definition: EBStencil.H:182
void apply(EBCellFAB &a_lofphi, const EBCellFAB &a_phi, bool incrementOnly=false, int ivar=0) const
Definition: EBStencil.H:179
void relaxClone(EBCellFAB &a_phi, const EBCellFAB &a_phiOld, const EBCellFAB &a_rhs, const BaseIVFAB< Real > &a_alphaWeight, const BaseIVFAB< Real > &a_betaWeight, Real a_alpha, Real a_beta, Real a_safety) const
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
Box m_lphBox
Definition: EBStencil.H:203
Vector< stencilTerm > multi
Definition: EBStencil.H:196
EB stencil.
Definition: EBStencil.H:27
Vector< int > m_alphaBeta
Definition: EBStencil.H:211
Definition: BaseIVFAB.H:32
void applyInhomDomBC(EBCellFAB &a_lofphi, const EBCellFAB &a_phi, const Real a_factor) const
IntVect m_ghostVectLph
Definition: EBStencil.H:206
Definition: EBStencil.H:193
Vector< ebstencil_t > m_ebstencil
Definition: EBStencil.H:208