00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _CUTCELLMOMENTS_H_
00012 #define _CUTCELLMOMENTS_H_
00013
00014 #if defined(CH_Darwin) && defined(__GNUC__) && ( __GNUC__ == 3 )
00015
00016 #include <unistd.h>
00017 #define _GLIBCPP_USE_C99 1
00018 #endif
00019
00020 #include <map>
00021 using std::map;
00022
00023 #include "Vector.H"
00024 #include "REAL.H"
00025 #include "IndexTM.H"
00026
00027 #include "Notation.H"
00028 #include "LSquares.H"
00029 #include "IFData.H"
00030 #include "RefinementCriterion.H"
00031
00032 #include "NamespaceHeader.H"
00033
00034 template <int dim> class LSProblem;
00035
00036 template <int dim> class CutCellMoments
00037 {
00038 public:
00039 typedef IndexTM<int,dim> IvDim;
00040 typedef IndexTM<Real,dim> RvDim;
00041
00042 typedef map<IvDim,Real,LexLT <IvDim > > PthMoment;
00043
00044 typedef map<IndexTM<int,dim-1>,Real,LexLT < IndexTM<int,dim-1> > > PthMomentLesserDimension;
00045
00046 typedef map<IndexTM<int,1>,Real > OneDMoments;
00047 typedef map<int,IvDim> LocPthMoment;
00048 typedef map<IvDim,int,LexLT <IvDim> > PthMomentLoc;
00049
00050 typedef map<Iv2,CutCellMoments<dim-1>, LexLT<Iv2> > BdCutCellMoments;
00051
00052
00053 inline CutCellMoments();
00054 inline CutCellMoments(const CutCellMoments<dim>& a_cutCellMoments);
00055
00056
00057 inline CutCellMoments(const IFData<dim>& a_info);
00058
00059
00060 inline ~CutCellMoments();
00061
00062
00063 inline const CutCellMoments<dim - 1> getBdCutCellMoments(const Iv2& a_bdId) const;
00064
00065
00066 inline void computeMoments(const int & a_order,
00067 const int & a_degreeP,
00068 const bool & a_useConstraints,
00069 RefinementCriterion & a_refinementCriterion);
00070
00071
00072 inline Real fullCellQuadrature(const IvDim& a_mono);
00073
00074 inline Vector<Real> computeRhs(LSProblem<dim> & a_lsp,
00075 const int & a_order);
00076
00077
00078 inline Vector< CutCellMoments<dim> > refine(const int & a_order,
00079 const int & a_degreeP,
00080 const bool & a_useConstraints,
00081 RefinementCriterion & a_refinementCriterion,
00082 const Vector<int> & a_refineInDir);
00083
00084 inline void addMomentMaps(const Vector<CutCellMoments<dim> > & a_refinedCutCellVector,
00085 const int & a_degreeP,
00086 const bool & a_useConstraints);
00087
00088 inline void addMoments(PthMoment & a_momentMap,
00089 PthMoment & a_refinedMomentMap,
00090 const IndexTM<Real,dim> & a_refinedCenterDelta);
00091
00092 inline void addBdMoments(CutCellMoments<dim> & a_coarseCutCell,
00093 const IFData<dim+1> & a_iFData,
00094 const int & a_degreeP,
00095 const bool & a_useConstraints,
00096 const IndexTM<Real,dim> & a_refinedCenterDelta,
00097 const IndexTM<int,dim> & a_localHilo);
00098
00099 inline Real changeMomentCoordinates(PthMoment & a_refinedMomentMap,
00100 const IndexTM<int,dim> & a_monomial,
00101 const IndexTM<Real,dim> & a_refinedCenterDelta);
00102
00103 inline void initialize(CutCellMoments<dim> & a_refinedCutCell);
00104
00105 inline void initializeMap(PthMoment & a_map1,
00106 PthMoment & a_map2);
00107
00108 inline void initializeMap(PthMomentLesserDimension & a_map1,
00109 PthMomentLesserDimension & a_map2);
00110
00111 inline void initializeMap(OneDMoments & a_map1,
00112 OneDMoments & a_map2);
00113
00114
00115
00116
00117 inline Real getBdMoment(const IvDim & a_mono,
00118 const IFData<dim+1> & a_iFData,
00119 const IndexTM<Real,dim> & a_refinedCenterDelta,
00120 PthMoment a_fullCellMap = PthMoment());
00121
00122 inline Real getBdEBMoment(const IvDim & a_mono,
00123 const IFData<dim+1> & a_iFData,
00124 const IndexTM<Real,dim> & a_refinedCenterDelta);
00125
00126 inline void computeResiduals(const int & a_order,
00127 const int & a_degreeP,
00128 const bool & a_useConstraints);
00129
00130 inline void computeResiduals(const Vector<CutCellMoments<dim> > & a_refinedCCMoms,
00131 const int & a_degreeP);
00132
00133
00134 inline Real getMoment(const IvDim & a_mono,
00135 const EBorVol & a_EBorVOL) const;
00136
00137
00138 inline Real getVol(const EBorVol & a_EBorVol) const;
00139
00140 inline RvDim getCentroid(const EBorVol & a_EBorVOL) const;
00141
00142 inline Real getResidual(const int & a_iDegree,
00143 const int & a_normJ) const;
00144
00145 inline bool isCovered() const;
00146
00147 inline bool isRegular() const;
00148
00149
00150 inline void print(ostream& out) const;
00151
00152 inline void dump() const;
00153
00154 inline void printMoments();
00155
00156 inline void printBdMoments();
00157
00158
00159 inline void operator=(const CutCellMoments<dim>& a_cutCellMoments);
00160
00161
00162 PthMoment m_moments;
00163 PthMoment m_EBmoments;
00164 BdCutCellMoments m_bdCutCellMoments;
00165 IFData<dim> m_iFData;
00166 bool m_bdCCOn;
00167
00168
00169 Vector<Vector<Real> > m_residual;
00170 };
00171
00172
00173 template <> class CutCellMoments<1>
00174 {
00175 public:
00176 typedef map<IndexTM<int,1>,Real> OneDMoments;
00177
00178
00179 inline CutCellMoments();
00180 inline CutCellMoments(const CutCellMoments<1> & a_cutCellMoments);
00181 inline CutCellMoments(const IFData<1>& a_info);
00182
00183
00184 inline ~CutCellMoments();
00185
00186 inline void computeMoments(const int & a_order,
00187 const int & a_degree,
00188 const bool & a_useConstraints,
00189 RefinementCriterion & a_refinementCriterion);
00190
00191 inline void simpleComputeMoments(const Real & a_loPt,
00192 const Real & a_hiPt,
00193 const int & a_degree);
00194
00195 inline void computeMomentsUsingBinomial(const Real & a_loPt,
00196 const Real & a_hiPt,
00197 const int & a_loSign,
00198 const int & a_hiSign,
00199 const int & a_degree);
00200
00201 inline void addBdMoments(CutCellMoments<1> & a_coarseCutCell,
00202 const IFData<2> & a_iFData,
00203 const int & a_degreeP,
00204 const bool & a_useConstraints,
00205 const IndexTM<Real,1> & a_refinedCenterDelta,
00206 const IndexTM<int,1> & a_localHilo);
00207
00208 inline Real changeMomentCoordinates(OneDMoments & a_refinedMap,
00209 const IndexTM<int,1> & a_monomial,
00210 const IndexTM<Real,1> & a_refinedCenterDelta);
00211
00212 inline void initialize(CutCellMoments<1> & a_refinedCutCell);
00213
00214 inline void initializeMap(OneDMoments & a_map1,
00215 OneDMoments & a_map2);
00216
00217 inline Real getBdMoment(const IndexTM<int,1> & a_mono,
00218 const IFData<2> & a_iFData,
00219 const IndexTM<Real,1> & a_refinedCenterDelta,
00220 OneDMoments a_fullCellMap = OneDMoments());
00221
00222 inline Real getBdEBMoment(const IndexTM<int,1> & a_mono,
00223 const IFData<2> & a_iFData,
00224 const IndexTM<Real,1> & a_refinedCenterDelta);
00225
00226
00227 inline Real getMoment(const IndexTM<int,1> & a_mono,
00228 const EBorVol & a_EBorVOL) const;
00229
00230 inline Real getMoment(const IndexTM<int,1>& a_mono) const;
00231
00232
00233 inline Real getVol(const EBorVol& a_EBorVol) const;
00234
00235 inline IndexTM<Real,1> getCentroid(const EBorVol& a_EBorVol) const;
00236
00237 inline bool isCovered() const;
00238
00239 inline bool isRegular() const;
00240
00241
00242 inline void print(ostream& out) const;
00243
00244 inline void dump() const;
00245
00246
00247 inline void operator=(const CutCellMoments<1>& a_cutCellMoments);
00248
00249
00250 OneDMoments m_moments;
00251 IFData<1> m_iFData;
00252 bool m_bdCCOn;
00253
00254
00255 OneDMoments m_EBmoments;
00256 };
00257
00258 #include "NamespaceFooter.H"
00259
00260 #include "CutCellMomentsImplem.H"
00261
00262 #endif