Chombo + EB  3.0
Stencils.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 _STENCILS_H_
12 #define _STENCILS_H_
13 
14 #include "Vector.H"
15 #include "VolIndex.H"
16 #include "BaseIndex.H"
17 #include "FaceIndex.H"
18 #include "REAL.H"
19 #include "NamespaceHeader.H"
20 ///
21 /**
22  class for vofstencil and basestencil to inherit from
23  so AggStencil can unify them.
24 */
26 {
27 public:
28  ///
30  {
31  }
32 
33  ///
34  virtual ~BaseStencil()
35  {
36  }
37 
38  ///
39  virtual int size() const = 0;
40 
41  ///
42  virtual const BaseIndex& index(int isten) const = 0;
43 
44 
45  ///
46  virtual const Real& weight(int isten) const = 0;
47 
48  ///
49  virtual const int& variable(int isten) const = 0;
50 };
51 
52 /// VoF-centered stencil
53 /**
54  This stencil is a fundamental tool for building
55  eb applications by making the ability to cache
56  stencil information. This object consists of
57  a vector of VoFs and a vector of weights.
58 */
59 class VoFStencil: public BaseStencil
60 {
61 public:
62  ///
63  /**
64  default constructor. makes empty vectors.
65  */
66  VoFStencil();
67 
68  ///
69  virtual ~VoFStencil();
70 
71  ///
72  void clear();
73 
74  ///
75  /**
76  add a VoF to the Stencil, with it's associated weight
77  it is required that all VoFs are in the same EBIndexSpace
78  If the vof is already in the
79  stencil, add the weights.
80  */
81  void
82  add(const VolIndex& vof,const Real& weight, int ivar = 0);
83 
84  ///
85  /**
86  number of VoFs in the Stencil
87  */
88  virtual int size() const;
89 
90  ///
91  /**
92  access a VoF
93  */
94  const VolIndex& vof(int i) const;
95 
96 
97  ///
98  virtual BaseIndex& index(int i) const
99  {
100  return (BaseIndex&)(vof(i));
101  }
102 
103  ///
104  /**
105  access a weight
106  */
107  virtual const Real& weight(int i) const;
108 
109  ///
110  /**
111  access a weight
112  */
113  virtual Real& weight(int i);
114 
115 
116  ///
117  virtual const int& variable(int i) const;
118 
119  ///
120  virtual int& variable(int i);
121 
122  ///
123  /**
124  add all faces and weights of inputs
125  to this. If a vof is already in the
126  stencil, add the weights.
127  only addition is well-defined here
128  as far as arithmatic operations are
129  concerned.
130  */
131  VoFStencil&
132  operator+=(const VoFStencil& a_vofsten);
133 
134  ///
135  /**
136  */
137  void operator*=(const Real& scaling);
138 
139  ///
140  VoFStencil&
141  operator=(const VoFStencil& a_vofsten);
142 
143  ///
144  VoFStencil(const VoFStencil& a_vofstenin);
145 
146  void setAllVariables(int a_var)
147  {
148  if (vofs.size() > 0)
149  {
150  variables = Vector<int>(vofs.size(), a_var);
151  }
152  }
153 protected:
154 
155  /// the VoFs
157  /// the weights
159 
161 };
162 
163 ///
164 /**
165  Face-centered Stencil for embedded boundary applications.
166 */
168 {
169 public:
170  ///
171  FaceStencil();
172 
173  ///
174  virtual ~FaceStencil();
175 
176  ///
177  void clear();
178 
179  ///
180  /**
181  add an Face and it's weight
182  If the face is already in the
183  stencil, add the weights.
184  */
185  void add(const FaceIndex& face,const Real& weight, int variable=0);
186 
187  ///
188  /**
189  number of Faces in the Stencil
190  */
191  virtual int size() const;
192 
193  ///
194  void setAllVariables(int a_var)
195  {
196  if (faces.size() > 0)
197  {
198  variables = Vector<int>(faces.size(), a_var);
199  }
200  }
201 
202  ///
203  /** access an Face
204  */
205  const FaceIndex& face(int i) const;
206 
207  ///
208  /**
209  access a weight
210  */
211  virtual const Real& weight(int i) const;
212 
213  ///
214  virtual BaseIndex& index(int i) const
215  {
216  return (BaseIndex&)(face(i));
217  }
218 
219  ///
220  virtual const int& variable(int i) const;
221 
222  ///
223  virtual int& variable(int i);
224 
225  ///
226  /**
227  add all faces and weights of inputs
228  to this. If a face is already in the
229  stencil, add the weights.
230  only addition is well-defined here
231  as far as arithmatic operations are
232  concerned.
233  */
234  FaceStencil& operator+=(const FaceStencil& a_facesten);
235 
236  ///
237  FaceStencil& operator=(const FaceStencil& a_facesten);
238 
239  ///
240  FaceStencil(const FaceStencil& a_facesten);
241 
242  ///
243  /**
244  */
245  void operator*=(const Real& scaling);
246 
247 private:
248  /// the Faces
250  /// the weights
252  /// the variable numbers
254 
255 };
256 
257 class EBCellFAB;
258 class EBFaceFAB;
259 ///variable argument ignored---now uses the variables that live in the stencil
260 extern Real applyVoFStencil(const VoFStencil& a_vofSten, const EBCellFAB& a_fab, const int& a_comp);
261 
262 ///variable argument ignored---now uses the variables that live in the stencil
263 extern Real applyFaceStencil(const FaceStencil& a_faceSten, const EBFaceFAB& a_fab, const int& a_comp);
264 
265 /** inlines */
266 
267 /**************/
268 inline int
270 {
271  return weights.size();
272 }
273 /**************/
274 /**************/
275 inline const VolIndex&
276 VoFStencil::vof(int i) const
277 {
278  return vofs[i];
279 }
280 /**************/
281 /**************/
282 inline const Real&
283 VoFStencil::weight(int i) const
284 {
285  return weights[i];
286 }
287 
288 inline Real&
290 {
291  return weights[i];
292 }
293 
294 #ifdef CH_EXPLICIT_TEMPLATES
295 //
296 // Extra no-op stuff required for successful explicit template instantiation.
297 //
298 inline int linearSize( const FaceStencil& fs )
299 {
300  CH_assert(0);
301  return -1;
302 }
303 template<> inline
304 void linearIn<FaceStencil>(FaceStencil& a_outputT, const void* const inBuf)
305 {
306  CH_assert(0);
307 }
308 template<> inline
309 void linearOut<FaceStencil>(void* const a_outBuf, const FaceStencil& a_inputT)
310 {
311  CH_assert(0);
312 }
313 
314 
315 inline int linearSize( const VoFStencil& fs )
316 {
317  CH_assert(0);
318  return -1;
319 }
320 template<> inline
321 void linearIn<VoFStencil>(VoFStencil& a_outputT, const void* const inBuf)
322 {
323  CH_assert(0);
324 }
325 template<> inline
326 void linearOut<VoFStencil>(void* const a_outBuf, const VoFStencil& a_inputT)
327 {
328  CH_assert(0);
329 }
330 
331 
332 inline int linearSize( const bool& fs )
333 {
334  CH_assert(0);
335  return -1;
336 }
337 template<> inline
338 void linearIn<bool>(bool& a_outputT, const void* const inBuf)
339 {
340  CH_assert(0);
341 }
342 template<> inline
343 void linearOut<bool>(void* const a_outBuf, const bool& a_inputT)
344 {
345  CH_assert(0);
346 }
347 
348 
349 #endif // CH_EXPLICIT_TEMPLATES
350 
351 
352 #include "NamespaceFooter.H"
353 #endif
Vector< int > variables
the variable numbers
Definition: Stencils.H:253
Definition: Stencils.H:167
void operator*=(const Real &scaling)
#define CH_assert(cond)
Definition: CHArray.H:37
Vector< FaceIndex > faces
the Faces
Definition: Stencils.H:249
virtual int size() const =0
Real applyFaceStencil(const FaceStencil &a_faceSten, const EBFaceFAB &a_fab, const int &a_comp)
variable argument ignored—now uses the variables that live in the stencil
virtual const int & variable(int i) const
void clear()
Definition: FaceIndex.H:28
virtual BaseIndex & index(int i) const
Definition: Stencils.H:214
void operator*=(const Real &scaling)
virtual const BaseIndex & index(int isten) const =0
virtual int size() const
void setAllVariables(int a_var)
Definition: Stencils.H:146
virtual const Real & weight(int i) const
Definition: Stencils.H:283
index for other indicies to inherit
Definition: BaseIndex.H:26
const VolIndex & vof(int i) const
Definition: Stencils.H:276
Definition: EBFaceFAB.H:28
virtual const Real & weight(int i) const
void add(const FaceIndex &face, const Real &weight, int variable=0)
void clear()
virtual const int & variable(int i) const
VoFStencil & operator=(const VoFStencil &a_vofsten)
FaceStencil & operator=(const FaceStencil &a_facesten)
VoF-centered stencil.
Definition: Stencils.H:59
void add(const VolIndex &vof, const Real &weight, int ivar=0)
Vector< Real > weights
the weights
Definition: Stencils.H:158
VoFStencil & operator+=(const VoFStencil &a_vofsten)
Real applyVoFStencil(const VoFStencil &a_vofSten, const EBCellFAB &a_fab, const int &a_comp)
variable argument ignored—now uses the variables that live in the stencil
void setAllVariables(int a_var)
Definition: Stencils.H:194
Definition: EBCellFAB.H:29
double Real
Definition: REAL.H:33
const FaceIndex & face(int i) const
int linearSize(const T &inputT)
Definition: SPMDI.H:20
virtual ~BaseStencil()
Definition: Stencils.H:34
BaseStencil()
Definition: Stencils.H:29
virtual int size() const
Definition: Stencils.H:269
Definition: Stencils.H:25
Vector< VolIndex > vofs
the VoFs
Definition: Stencils.H:156
FaceStencil & operator+=(const FaceStencil &a_facesten)
Vector< Real > weights
the weights
Definition: Stencils.H:251
virtual ~VoFStencil()
size_t size() const
Definition: Vector.H:177
Volume of Fluid Index.
Definition: VolIndex.H:31
virtual BaseIndex & index(int i) const
Definition: Stencils.H:98
virtual ~FaceStencil()
Vector< int > variables
Definition: Stencils.H:160
virtual const Real & weight(int isten) const =0
virtual const int & variable(int isten) const =0