Chombo + EB  3.2
VarCoefStencil.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 _VARCOEFSTENCIL_H_
12 #define _VARCOEFSTENCIL_H_
13 
14 #include "Vector.H"
15 #include "VolIndex.H"
16 #include "FaceIndex.H"
17 #include "REAL.H"
18 #include "NamespaceHeader.H"
19 
20 /// VoF-centered stencil
21 /**
22  This stencil is a fundamental tool for building
23  eb applications by making the ability to cache
24  stencil information. This object consists of
25  a vector of VoFs and a vector of weights.
26  */
28 {
29 public:
30  ///
31  /**
32  default constructor. makes empty vectors.
33  */
35 
36  ///
38 
39  ///
40  void clear();
41 
42  ///
43  /**
44  add a VoF to the Stencil, with it's associated weight
45  it is required that all VoFs are in the same EBIndexSpace
46  If the vof is already in the
47  stencil, add the weights.
48  */
49  void
50  add(const VolIndex& vof,const FaceIndex& coefloc, const Real& weight, int ivar);
51 
52  ///
53  /**
54  number of VoFs in the Stencil
55  */
56  int
57  size() const;
58 
59  ///
60  /**
61  access a VoF
62  */
63  const VolIndex&
64  vof(int i) const;
65 
66  ///
67  /**
68  access a VoF
69  */
70  const FaceIndex&
71  coefLoc(int i) const;
72 
73 
74  ///
75  /**
76  access a weight
77  */
78  const Real&
79  weight(int i) const;
80 
81  ///
82  /**
83  access a weight
84  */
85  Real& weight(int i);
86 
87 
88  ///
89  const int& variable(int i) const;
90 
91  ///
92  int& variable(int i);
93 
94  ///
95  /**
96  add all faces and weights of inputs
97  to this. If a vof is already in the
98  stencil, add the weights.
99  only addition is well-defined here
100  as far as arithmatic operations are
101  concerned.
102  */
104  operator+=(const VarCoefStencil& a_vofsten);
105 
106  ///
107  /**
108  */
109  void operator*=(const Real& scaling);
110 
111  ///
113  operator=(const VarCoefStencil& a_vofsten);
114 
115  ///
116  VarCoefStencil(const VarCoefStencil& a_vofstenin);
117 
118  void setAllVariables(int a_var)
119  {
120  if (vofs.size() > 0)
121  {
122  variables = Vector<int>(vofs.size(), a_var);
123  }
124  }
125 protected:
126 
127  /// the VoFs
129 
130 
131  /// the weights
133 
135 
136  /// Where the face-centered coefficients live
138 };
139 
140 
141 /** inlines */
142 
143 /**************/
144 inline int
146 {
147  return weights.size();
148 }
149 /**************/
150 inline const FaceIndex&
152 {
153  return coefLocs[i];
154 }
155 /**************/
156 inline const VolIndex&
158 {
159  return vofs[i];
160 }
161 /**************/
162 inline const Real&
164 {
165  return weights[i];
166 }
167 
168 inline Real&
170 {
171  return weights[i];
172 }
173 
174 #ifdef CH_EXPLICIT_TEMPLATES
175 //
176 // Extra no-op stuff required for successful explicit template instantiation.
177 //
178 
179 
180 inline int linearSize( const VarCoefStencil& fs )
181 {
182  CH_assert(0);
183  return -1;
184 }
185 template<> inline
186 void linearIn<VarCoefStencil>(VarCoefStencil& a_outputT, const void* const inBuf)
187 {
188  CH_assert(0);
189 }
190 template<> inline
191 void linearOut<VarCoefStencil>(void* const a_outBuf, const VarCoefStencil& a_inputT)
192 {
193  CH_assert(0);
194 }
195 
196 
197 inline int linearSize( const bool& fs )
198 {
199  CH_assert(0);
200  return -1;
201 }
202 template<> inline
203 void linearIn<bool>(bool& a_outputT, const void* const inBuf)
204 {
205  CH_assert(0);
206 }
207 template<> inline
208 void linearOut<bool>(void* const a_outBuf, const bool& a_inputT)
209 {
210  CH_assert(0);
211 }
212 
213 
214 #endif // CH_EXPLICIT_TEMPLATES
215 
216 
217 #include "NamespaceFooter.H"
218 #endif
VarCoefStencil & operator+=(const VarCoefStencil &a_vofsten)
#define CH_assert(cond)
Definition: CHArray.H:37
const VolIndex & vof(int i) const
Definition: VarCoefStencil.H:157
Definition: FaceIndex.H:28
VarCoefStencil & operator=(const VarCoefStencil &a_vofsten)
VoF-centered stencil.
Definition: VarCoefStencil.H:27
int size() const
Definition: VarCoefStencil.H:145
Vector< VolIndex > vofs
the VoFs
Definition: VarCoefStencil.H:128
void operator*=(const Real &scaling)
Vector< int > variables
Definition: VarCoefStencil.H:134
const FaceIndex & coefLoc(int i) const
Definition: VarCoefStencil.H:151
double Real
Definition: REAL.H:33
const Real & weight(int i) const
Definition: VarCoefStencil.H:163
int linearSize(const T &inputT)
Definition: SPMDI.H:21
size_t size() const
Definition: Vector.H:192
void add(const VolIndex &vof, const FaceIndex &coefloc, const Real &weight, int ivar)
Vector< FaceIndex > coefLocs
Where the face-centered coefficients live.
Definition: VarCoefStencil.H:137
Vector< Real > weights
the weights
Definition: VarCoefStencil.H:132
Volume of Fluid Index.
Definition: VolIndex.H:31
const int & variable(int i) const
void setAllVariables(int a_var)
Definition: VarCoefStencil.H:118