00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _REFERENCEHEIGHTIF_H_
00012 #define _REFERENCEHEIGHTIF_H_
00013
00014 #include "Notation.H"
00015 #include "RealVect.H"
00016 #include "IndexTM.H"
00017 #include "BaseIF.H"
00018 #include "PolynomialIF.H"
00019
00020 #include "NamespaceHeader.H"
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 class ReferenceHeightIF : public BaseIF
00032 {
00033 public:
00034
00035
00036
00037
00038
00039 ReferenceHeightIF(const BaseIF & a_implicitFunction,
00040 const Real & a_referenceHeight,
00041 const IndexTM<Real,GLOBALDIM> & a_origin)
00042 :
00043 m_implicitFunction(a_implicitFunction.newImplicitFunction()),
00044 m_referenceSurface(NULL),
00045 m_referenceHeight(a_referenceHeight),
00046 m_origin(a_origin)
00047 {
00048 }
00049
00050 ReferenceHeightIF(const BaseIF & a_implicitFunction,
00051 const PolynomialIF & a_referenceSurface,
00052 const Real & a_referenceHeight,
00053 const IndexTM<Real,GLOBALDIM> & a_origin)
00054 :
00055 m_implicitFunction(a_implicitFunction.newImplicitFunction()),
00056 m_referenceSurface(static_cast<PolynomialIF*>(a_referenceSurface.newImplicitFunction())),
00057 m_referenceHeight(a_referenceHeight),
00058 m_origin(a_origin)
00059 {
00060 }
00061
00062
00063 virtual ~ReferenceHeightIF()
00064 {
00065 delete m_implicitFunction;
00066 }
00067
00068 Real value(const IndexTM<int,GLOBALDIM> & a_partialDerivative,
00069 const IndexTM<Real,GLOBALDIM>& a_point) const
00070 {
00071 Real ifVal = m_implicitFunction->value(a_partialDerivative,a_point);
00072
00073
00074 if (m_referenceSurface != NULL)
00075 {
00076 Real refSurfVal = m_referenceSurface->value(a_partialDerivative, a_point);
00077 ifVal -= refSurfVal;
00078 }
00079
00080 return (ifVal);
00081 }
00082
00083
00084
00085
00086
00087
00088
00089
00090 virtual Real value(const RealVect& a_point) const
00091 {
00092 IndexTM<Real,GLOBALDIM> pt;
00093
00094 for (int idir = 0; idir < SpaceDim; ++idir)
00095 {
00096 pt[idir] = a_point[idir];
00097 }
00098
00099 if (GLOBALDIM == 3 && SpaceDim == 2)
00100 {
00101 pt[SpaceDim] = m_referenceHeight + m_origin[SpaceDim];
00102 }
00103
00104 Real ifVal = value(pt);
00105
00106 if (m_referenceSurface != NULL)
00107 {
00108 Real refSurfVal = m_referenceSurface->value(a_point);
00109 ifVal -= refSurfVal;
00110 }
00111
00112 else
00113 {
00114 MayDay::Abort("No reference surface defined");
00115 }
00116
00117 return (ifVal);
00118 }
00119
00120
00121
00122
00123
00124 virtual Real value(const IndexTM<Real,GLOBALDIM>& a_point) const
00125 {
00126 return m_implicitFunction->value(a_point);
00127 };
00128
00129
00130
00131
00132
00133
00134 virtual ReferenceHeightIF* newImplicitFunction() const
00135 {
00136 if (m_referenceSurface != NULL)
00137 {
00138 return new ReferenceHeightIF(*m_implicitFunction, *m_referenceSurface, m_referenceHeight, m_origin);
00139 }
00140 else
00141 {
00142 return new ReferenceHeightIF(*m_implicitFunction, m_referenceHeight,m_origin);
00143 }
00144 }
00145 virtual void print(ostream& a_out) const
00146 {
00147 m_implicitFunction->print(a_out);
00148 };
00149
00150
00151
00152
00153
00154 Real getReferenceHeight() const
00155 {
00156 return m_referenceHeight;
00157 }
00158
00159
00160
00161
00162
00163 IndexTM<Real,GLOBALDIM> getOrigin() const
00164 {
00165 return m_origin;
00166 }
00167
00168
00169
00170
00171
00172 void getReferenceSurfacePolynomial(Vector<PolyTerm>& a_polynomial,
00173 bool & a_inside) const
00174 {
00175 return m_referenceSurface->GetParams(a_polynomial,a_inside);
00176 }
00177
00178
00179
00180
00181
00182 Real evaluateReferenceSurfacePolynomial(const RealVect & a_point) const
00183 {
00184 return m_referenceSurface->value(a_point);
00185 }
00186
00187
00188
00189
00190
00191 virtual void boxLayoutChanged(const DisjointBoxLayout & a_newBoxLayout,
00192 const RealVect & a_dx)
00193 {
00194 m_implicitFunction->boxLayoutChanged(a_newBoxLayout,a_dx);
00195
00196 if (m_referenceSurface != NULL)
00197 {
00198 m_referenceSurface->boxLayoutChanged(a_newBoxLayout,a_dx);
00199 }
00200 }
00201
00202
00203
00204
00205
00206
00207 BaseIF* getPointer2IF()const
00208 {
00209 return m_implicitFunction;
00210 }
00211
00212
00213 ReferenceHeightIF* newChangedIF(const BaseIF* a_newIF )const
00214 {
00215 return new ReferenceHeightIF( *a_newIF, m_referenceHeight, m_origin);
00216 }
00217
00218 bool hasReferenceSurface() const
00219 {
00220 if (m_referenceSurface==NULL)
00221 {
00222 return false;
00223 }
00224 return true;
00225 }
00226
00227 private:
00228
00229
00230
00231
00232 ReferenceHeightIF()
00233 {
00234 }
00235
00236 BaseIF* m_implicitFunction;
00237 PolynomialIF* m_referenceSurface;
00238 Real m_referenceHeight;
00239 IndexTM<Real,GLOBALDIM> m_origin;
00240 };
00241
00242 #include "NamespaceFooter.H"
00243 #endif