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