Chombo + EB  3.0
LSProblem.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
8  */
9 #endif
10
11
12 #ifndef _LSPROBLEM_H_
13 #define _LSPROBLEM_H_
14
15 #include <map>
16 using std::map;
17
18 #include "Vector.H"
19 #include "REAL.H"
20 #include "LSquares.H"
21 #include "IndexTM.H"
22 #include "Notation.H"
23 #include "IFData.H"
24
26
27 template <int dim> class CutCellMoments;
28
29 template <int dim> class LSProblem
30 {
32  typedef map<IvDim,int,LexLT <IvDim> > PthMomentLoc;
33  typedef map<int,IvDim> LocPthMoment;
34
35 public:
36
37  //destructor will free m_matrix and free matrixes in m_rhs
38  ~LSProblem();
39
40  //constructor for just accessing fill map function
41  LSProblem(const int & a_degreeP,
42  const bool & a_useConstraints);
43
44  //constructor
45  LSProblem(const int & a_orderAccuracy,
46  const int & a_degreeP,
47  const bool & a_useConstraints,
48  const IndexTM<Real,dim> & a_normal);
49
50  //Solves over determined system matrix*unknown = rhs
51  int invertNormalEq(const Vector<Real> & a_rhs,
52  Vector<Real> & a_residual);
53
54
55  //accessor functions
56  int getDegree()
57  {
58  return m_degreeP;
59  }
60
62  {
63  return m_order;
64  }
65
66  void getMatrix(Real ** a_matrix);
67
68  void getRhs(Vector<Real>& a_rhs);
69
70  //getUnknowns will return the geometry info at the current level
71  void getUnknowns(Vector<Real>& a_unknown);
72
73  // Compute max and min values of monomial over the cell in local coordinates
74  void monoMaxMin(Real & a_maxVal,
75  Real & a_minVal,
76  const IndexTM<int,dim> & a_mono,
77  const IFData<dim> & a_IFData);
78
79  void computeBounds(const IndexTM<Real,dim> & a_dx,
80  const CutCellMoments<dim> & a_ccm);
81
82  void print(ostream & a_out) const;
83
84  void outputMatrix() const;
85  void outputRhs() const;
86  void outputUnknowns() const;
87  void outputBounds() const;
88
89  const LocPthMoment& getLocMonomialMapDegreeP() const
90  {
91  return (const LocPthMoment&)m_locMonoP;
92  }
93
94  const PthMomentLoc& getMonomialLocMapDegreeP() const
95  {
96  return (const PthMomentLoc&)m_monoLocP;
97  }
98
99  const PthMomentLoc& getMonomialLocMapDegreePLess1() const
100  {
101  return (const PthMomentLoc&)m_monoLocPLess1;
102  }
103
104  Real getUnknown(int loc)
105  {
106  return m_unknowns[loc];
107  }
108
110  {
111  return m_numP;
112  }
113
115  {
116  return m_numPLess1;
117  }
118
119  int numActiveBounds() const
120  {
121  return m_numActiveBounds;
122  }
123
124
125
126 private:
127  void setRhs(const Vector<Real>& a_rhs); //deprecated
128
129  //constructs matrix of overdetermined system
130  void setMatrix();
131
132  void momentBounds(Real & a_lobnd,
133  Real & a_hibnd,
134  const IvDim & a_mono,
135  const IFData<dim> & a_ifData);
136
137  //\partial/\partial xidir (mono) = coeff*Dmono
138  void differentiate(int & a_coeff,
139  IvDim & a_Dmono,
140  int & a_idir,
141  const IvDim& a_mono);
142
143  int nChooseR(int a_n,
144  int a_r);
145
146  //makes a list of monomials of degreeP
147  void fillMap(PthMomentLoc & a_monoLoc,
148  LocPthMoment & a_locMono,
149  const int & a_degree);
150
151  //computes number of monomials of degree a_monoDegree
152  int numMonomials(const int & a_monoDegree);
153
154  int factorial(const int & a_n,
155  const int & a_m=0);
156
157  //array tools
158  void allocArray(const int & a_rows,
159  const int & a_cols,
160  Real** & a_A);
161
162  void freeArray(const int & a_rows,
163  const int & a_cols,
164  Real** & a_A);
165
166  //order of accuracy
167  int m_order;
168
169  //degree of monomial
171
172  //number of active constraints
174
175  //use constrained LS
177
178  //normal
180
181  //monomials of degree P
182  PthMomentLoc m_monoLocP;
183  LocPthMoment m_locMonoP;
184
185  //number of monomials of degreeP
186  int m_numP;
187
188  //monomials of degree P-1
189  PthMomentLoc m_monoLocPLess1;
190  LocPthMoment m_locMonoPLess1;
191
192  //number of monomials of degreeP
194
195
196  //matrix
200
203 };
204
205 template<>class LSProblem<1>
206 {
207 public:
208
209  //number of monomials of degree P
210  int m_numP;
211
212  //number of monomials of degree P-1
214
215  //monomials of degree P
217
218  //used in filling the map
220
221  //Destructor
222  ~LSProblem();
223
224  //copy constructor
225  LSProblem(const LSProblem<1> & a_lsProblem);
226
227  //empty Constructor
228  LSProblem();
229
230  //count num monomials
231  int recursiveCount(const int & a_degreeP);
232
233  void setNumMonomials();
234
235  //print
236  void print(ostream & a_out)const;
237
238  //equals operator
239  void operator=(const LSProblem & a_lSProblem);
240 };
241
242 #include "NamespaceFooter.H"
243
244 #include "LSProblemImplem.H"
245
246 #endif
void computeBounds(const IndexTM< Real, dim > &a_dx, const CutCellMoments< dim > &a_ccm)
Definition: LSProblemImplem.H:94
void getMatrix(Real **a_matrix)
void differentiate(int &a_coeff, IvDim &a_Dmono, int &a_idir, const IvDim &a_mono)
Definition: LSProblemImplem.H:508
map< IvDim, int, LexLT< IvDim > > PthMomentLoc
Definition: LSProblem.H:32
void print(ostream &a_out) const
Definition: LSProblemImplem.H:587
int m_numP
Definition: LSProblem.H:186
bool m_useConstraints
Definition: LSProblem.H:176
int m_ithMoment
Definition: LSProblem.H:219
int getDegree()
Definition: LSProblem.H:56
void outputRhs() const
Definition: LSProblemImplem.H:652
void outputMatrix() const
Definition: LSProblemImplem.H:636
Vector< Real > m_rhs
Definition: LSProblem.H:199
void outputBounds() const
Definition: LSProblemImplem.H:670
Real getUnknown(int loc)
Definition: LSProblem.H:104
int m_numPLess1
Definition: LSProblem.H:213
int numMonomials(const int &a_monoDegree)
Definition: LSProblemImplem.H:426
Definition: ComputeCutCellMoments.H:35
void momentBounds(Real &a_lobnd, Real &a_hibnd, const IvDim &a_mono, const IFData< dim > &a_ifData)
Definition: LSProblemImplem.H:250
LSProblem(const int &a_degreeP, const bool &a_useConstraints)
Definition: LSProblemImplem.H:303
PthMomentLoc m_monoLocPLess1
Definition: LSProblem.H:189
void outputUnknowns() const
Definition: LSProblemImplem.H:661
Real m_pMoments
Definition: LSProblem.H:216
Definition: IndexTM.H:36
int getOrderAccuracy()
Definition: LSProblem.H:61
~LSProblem()
Definition: LSProblemImplem.H:290
void fillMap(PthMomentLoc &a_monoLoc, LocPthMoment &a_locMono, const int &a_degree)
Definition: LSProblemImplem.H:537
int factorial(const int &a_n, const int &a_m=0)
Definition: LSProblemImplem.H:411
map< int, IvDim > LocPthMoment
Definition: LSProblem.H:33
int numActiveBounds() const
Definition: LSProblem.H:119
const PthMomentLoc & getMonomialLocMapDegreeP() const
Definition: LSProblem.H:94
Definition: IFData.H:35
int getNumberDegPLess1()
Definition: LSProblem.H:114
const PthMomentLoc & getMonomialLocMapDegreePLess1() const
Definition: LSProblem.H:99
int nChooseR(int a_n, int a_r)
Definition: LSProblemImplem.H:36
double Real
Definition: REAL.H:33
int invertNormalEq(const Vector< Real > &a_rhs, Vector< Real > &a_residual)
Definition: LSProblemImplem.H:344
void monoMaxMin(Real &a_maxVal, Real &a_minVal, const IndexTM< int, dim > &a_mono, const IFData< dim > &a_IFData)
Definition: LSProblemImplem.H:50
PthMomentLoc m_monoLocP
Definition: LSProblem.H:182
void getUnknowns(Vector< Real > &a_unknown)
void setRhs(const Vector< Real > &a_rhs)
Definition: LSProblemImplem.H:533
int m_order
Definition: LSProblem.H:167
int m_numPLess1
Definition: LSProblem.H:193
Real ** m_matrix
Definition: LSProblem.H:197
const LocPthMoment & getLocMonomialMapDegreeP() const
Definition: LSProblem.H:89
int getNumberDegP()
Definition: LSProblem.H:109
LocPthMoment m_locMonoP
Definition: LSProblem.H:183
Definition: LSProblem.H:205
int m_numP
Definition: LSProblem.H:210
int m_numActiveBounds
Definition: LSProblem.H:173
int m_degreeP
Definition: LSProblem.H:170
Vector< Real > m_upperBound
Definition: LSProblem.H:202
void getRhs(Vector< Real > &a_rhs)
void allocArray(const int &a_rows, const int &a_cols, Real **&a_A)
Definition: LSProblemImplem.H:557
void freeArray(const int &a_rows, const int &a_cols, Real **&a_A)
Definition: LSProblemImplem.H:575
IndexTM< int, dim > IvDim
Definition: LSProblem.H:31
void setMatrix()
Definition: LSProblemImplem.H:457
Definition: CutCellMoments.H:32
Vector< Real > m_unknowns
Definition: LSProblem.H:198
IndexTM< Real, dim > m_normal
Definition: LSProblem.H:179
Vector< Real > m_lowerBound
Definition: LSProblem.H:201
LocPthMoment m_locMonoPLess1
Definition: LSProblem.H:190