Chombo + EB + MF  3.2
ReferenceHeightIF.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 _REFERENCEHEIGHTIF_H_
12 #define _REFERENCEHEIGHTIF_H_
13 
14 #include "Notation.H"
15 #include "RealVect.H"
16 #include "IndexTM.H"
17 #include "BaseIF.H"
18 #include "PolynomialIF.H"
19 
20 #include "NamespaceHeader.H"
21 
22 ///
23 /**
24  This adapter wraps any BaseIF subclass and gives it the
25  the concept of a reference height. The adapter passes through
26  all function calls to the adapted object, except value(RealVect)..
27  The reference height is used to evaluate the value function when
28  SpaceDim=GLOBALDIM-1,
29 
30  */
31 class ReferenceHeightIF : public BaseIF
32 {
33 public:
34 
35  /**
36  Construct the ReferenceHeightIF using another IF plus
37  a reference height. The delegate IF will be copied.
38  */
39  ReferenceHeightIF(const BaseIF & a_implicitFunction,
40  const Real & a_referenceHeight,
41  const IndexTM<Real,GLOBALDIM> & a_origin)
42  :
43  m_implicitFunction(a_implicitFunction.newImplicitFunction()),
44  m_referenceSurface(NULL),
45  m_referenceHeight(a_referenceHeight),
46  m_origin(a_origin)
47  {
48  }
49 
50  ReferenceHeightIF(const BaseIF & a_implicitFunction,
51  const PolynomialIF & a_referenceSurface,
52  const Real & a_referenceHeight,
53  const IndexTM<Real,GLOBALDIM> & a_origin)
54  :
55  m_implicitFunction(a_implicitFunction.newImplicitFunction()),
56  m_referenceSurface(static_cast<PolynomialIF*>(a_referenceSurface.newImplicitFunction())),
57  m_referenceHeight(a_referenceHeight),
58  m_origin(a_origin)
59  {
60  }
61 
62  /// Destructor cleans up the member implicit function
64  {
65  delete m_implicitFunction;
66  }
67 
68  Real value(const IndexTM<int,GLOBALDIM> & a_partialDerivative,
69  const IndexTM<Real,GLOBALDIM>& a_point) const
70  {
71  Real ifVal = m_implicitFunction->value(a_partialDerivative,a_point);
72 
73  //There is a constructor that doesn't create a reference surface.
74  if (m_referenceSurface != NULL)
75  {
76  Real refSurfVal = m_referenceSurface->value(a_partialDerivative, a_point);
77  ifVal -= refSurfVal;
78  }
79 
80  return (ifVal);
81  }
82  ///
83  /**
84  Return the value of the function at a_point. value(RealVect)
85  to value(IndexTM). However, in the case where GLOBALDIM == 3 and
86  SpaceDim == 2 the missing dimension is filled in with the reference height.
87  Subclasses need not implement this function, but if
88 
89  */
90  virtual Real value(const RealVect& a_point) const
91  {
93 
94  for (int idir = 0; idir < SpaceDim; ++idir)
95  {
96  pt[idir] = a_point[idir];
97  }
98 
99  if (GLOBALDIM == 3 && SpaceDim == 2)
100  {
102  }
103 
104  Real ifVal = value(pt);
105 
106  if (m_referenceSurface != NULL)
107  {
108  Real refSurfVal = m_referenceSurface->value(a_point);
109  ifVal -= refSurfVal;
110  }
111 
112  else
113  {
114  MayDay::Abort("No reference surface defined");
115  }
116 
117  return (ifVal);
118  }
119 
120  ///
121  /**
122  Return the value of the function at a_point (of type INdexTM).
123  */
124  virtual Real value(const IndexTM<Real,GLOBALDIM>& a_point) const
125  {
126  return m_implicitFunction->value(a_point);
127  };
128 
129  ///
130  /**
131  Return a newly allocated derived class. The responsibility
132  for deleting the memory is left to the calling function.
133  */
135  {
136  if (m_referenceSurface != NULL)
137  {
139  }
140  else
141  {
143  }
144  }
145  virtual void print(ostream& a_out) const
146  {
147  m_implicitFunction->print(a_out);
148  };
149 
150  ///
151  /**
152  Return the reference height for this IF
153  */
155  {
156  return m_referenceHeight;
157  }
158 
159  ///
160  /**
161  Return the physical origin of the domain
162  */
164  {
165  return m_origin;
166  }
167 
168  ///
169  /**
170  Return the reference surface for this IF
171  */
173  bool & a_inside) const
174  {
175  return m_referenceSurface->GetParams(a_polynomial,a_inside);
176  }
177 
178  ///
179  /**
180  Evaluate the reference surface at a point
181  */
183  {
184  return m_referenceSurface->value(a_point);
185  }
186 
187  ///
188  /**
189  Pass this call onto the IFs contained in this IF class.
190  */
191  virtual void boxLayoutChanged(const DisjointBoxLayout & a_newBoxLayout,
192  const RealVect & a_dx)
193  {
194  m_implicitFunction->boxLayoutChanged(a_newBoxLayout,a_dx);
195 
196  if (m_referenceSurface != NULL)
197  {
198  m_referenceSurface->boxLayoutChanged(a_newBoxLayout,a_dx);
199  }
200  }
201 
202 ///
203 /**
204 return the pointer to the implicit function m_implicitFunction
205 */
206 
208  {
209  return m_implicitFunction;
210  }
211 
212 //return a pointer to a new ReferenceHeight that has a_newIF as m_implicitFunction and NULL as m_referenceSurface
213  ReferenceHeightIF* newChangedIF(const BaseIF* a_newIF )const
214  {
215  return new ReferenceHeightIF( *a_newIF, m_referenceHeight, m_origin);
216  }
217 
218  bool hasReferenceSurface() const
219  {
220  if (m_referenceSurface==NULL)
221  {
222  return false;
223  }
224  return true;
225  }
226 
227 private:
228 
229  // Default constructor is disabled in order to prevent initialization
230  // without reference height. Base classes should all use the constructor
231  // version that takes a reference height
233  {
234  }
235 
240 };
241 
242 #include "NamespaceFooter.H"
243 #endif
Real m_referenceHeight
Definition: ReferenceHeightIF.H:238
BaseIF * m_implicitFunction
Definition: ReferenceHeightIF.H:236
ReferenceHeightIF(const BaseIF &a_implicitFunction, const Real &a_referenceHeight, const IndexTM< Real, GLOBALDIM > &a_origin)
Definition: ReferenceHeightIF.H:39
ReferenceHeightIF(const BaseIF &a_implicitFunction, const PolynomialIF &a_referenceSurface, const Real &a_referenceHeight, const IndexTM< Real, GLOBALDIM > &a_origin)
Definition: ReferenceHeightIF.H:50
virtual void print(ostream &a_out) const
Definition: ReferenceHeightIF.H:145
ReferenceHeightIF * newChangedIF(const BaseIF *a_newIF) const
Definition: ReferenceHeightIF.H:213
ReferenceHeightIF()
Definition: ReferenceHeightIF.H:232
virtual void boxLayoutChanged(const DisjointBoxLayout &a_newBoxLayout, const RealVect &a_dx)
Definition: BaseIF.H:259
virtual void GetParams(Vector< PolyTerm > &a_polynomial, bool &a_inside) const
const int SpaceDim
Definition: SPACE.H:38
Real value(const IndexTM< int, GLOBALDIM > &a_partialDerivative, const IndexTM< Real, GLOBALDIM > &a_point) const
Definition: ReferenceHeightIF.H:68
Definition: PolynomialIF.H:63
Real getReferenceHeight() const
Definition: ReferenceHeightIF.H:154
Real evaluateReferenceSurfacePolynomial(const RealVect &a_point) const
Definition: ReferenceHeightIF.H:182
PolynomialIF * m_referenceSurface
Definition: ReferenceHeightIF.H:237
Definition: BaseIF.H:32
virtual ReferenceHeightIF * newImplicitFunction() const
Definition: ReferenceHeightIF.H:134
bool hasReferenceSurface() const
Definition: ReferenceHeightIF.H:218
virtual Real value(const RealVect &a_point) const =0
virtual Real value(const RealVect &a_point) const
Definition: ReferenceHeightIF.H:90
Definition: ReferenceHeightIF.H:31
double Real
Definition: REAL.H:33
IndexTM< Real, GLOBALDIM > getOrigin() const
Definition: ReferenceHeightIF.H:163
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
void getReferenceSurfacePolynomial(Vector< PolyTerm > &a_polynomial, bool &a_inside) const
Definition: ReferenceHeightIF.H:172
virtual void print(ostream &out) const
Definition: BaseIF.H:220
BaseIF * getPointer2IF() const
Definition: ReferenceHeightIF.H:207
virtual void boxLayoutChanged(const DisjointBoxLayout &a_newBoxLayout, const RealVect &a_dx)
Definition: ReferenceHeightIF.H:191
virtual Real value(const RealVect &a_point, const Vector< PolyTerm > &a_polynomial) const
virtual Real value(const IndexTM< Real, GLOBALDIM > &a_point) const
Definition: ReferenceHeightIF.H:124
#define GLOBALDIM
Definition: Notation.H:35
IndexTM< Real, GLOBALDIM > m_origin
Definition: ReferenceHeightIF.H:239
virtual ~ReferenceHeightIF()
Destructor cleans up the member implicit function.
Definition: ReferenceHeightIF.H:63
static void Abort(const char *const a_msg=m_nullString)
Print out message to cerr and exit via abort() (if serial) or MPI_Abort() (if parallel).