Chombo + EB  3.0
PolyGeom.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
8  */
9 #endif
10
11 // ANAG, LBNL
12
13 #ifndef _POLYGEOM_H_
14 #define _POLYGEOM_H_
15
16 #include "REAL.H"
17 #include "RealVect.H"
18 #include "Tuple.H"
19 #include "Vector.H"
20
21 #include "VolIndex.H"
22
24
25 class EBISBox;
26 ///
27 /**
28  PolyGeom encapsulates the functions
29  to generate centroids, normals, etc given
30  the geometric information.
31  It is meant to be used simply as a static class.
32  Its only data member (a static) is its tolerance.
33 */
34 class PolyGeom
35 {
36 public:
37
38  ///
39  /**
40  return the inverse of the input matrix. done using cramers rule
41  */
42  static void invertMatrix(Real a_AInverse[SpaceDim][SpaceDim],
43  const Real a_A[SpaceDim][SpaceDim], bool a_test);
44
45  ///
46  /**
47  // calculate the cofactor of element (row,col)
48  //this is the matrix which excludes row and column row, col
49  */
50  static void getMinor(Real a_Aminor[SpaceDim-1][SpaceDim-1],
51  const Real a_A[SpaceDim ][SpaceDim ],
52  int a_row, int acol);
53
54  ///
55  static Real determinantSD(const Real a_A[SpaceDim][SpaceDim]);
56
57  ///
58  static Real determinantSDM1(const Real a_A[SpaceDim-1][SpaceDim-1]);
59
60  ///
61  /**
62  find equation of line
63  between a line formed by a_pointOnLine = p0 and a_direction=v
64  l(t) = p0 + v t
65  and a point in space a_point.
66  returns closest point on line and the normal between the
67  closest point and the point in space
68  */
69  static void
70  pointToLine(RealVect& a_closestPt,
71  RealVect& a_normal,
72  const RealVect& a_point,
73  const RealVect& a_pointOnLine,
74  const RealVect& a_direction);
75
76  ///return distance from point to a plane
77  static Real
78  distancePointToPlane(const RealVect& a_point,
79  const RealVect& a_normal,
80  const RealVect& a_pointOnLine);
81
82  ///
83  /**
84  */
85  static void setTolerance(const Real& a_tolerance);
86
87  ///
88  /**
89  */
90  static void setVectDx(const RealVect& a_vectDx);
91
92  ///
93  /**
94  */
95  static void setVolumeTolerance(const Real& a_tolerance);
96
97  ///
98  /**
99  */
100  static void setAreaTolerance(const Real& a_tolerance);
101
102  ///
103  /**
104  */
105  static void setLengthTolerance(const Real& a_tolerance);
106
107  ///
108  /**
109  compute the cross product between xvec0 and xvec1
110  (returns xvec1 x xvec0)
111  */
112  static RealVect cross(const RealVect& a_xvec1,
113  const RealVect& a_xvec0);
114
115  ///
116  /**
117  compute the dot product between xvec0 and xvec1
118  (returns xvec1 dot xvec0)
119  */
120  static Real dot(const RealVect& a_xvec1,
121  const RealVect& a_xvec0);
122
123  ///
124  /**
125  */
126  static const Real& getTolerance();
127
128  ///
129  /**
130  */
131  static const RealVect& getVectDx();
132
133  ///
134  /**
135  */
136  static const Real& getVolumeTolerance();
137
138  ///
139  /**
140  */
141  static const Real& getAreaTolerance();
142
143  ///
144  /**
145  */
146  static const Real& getLengthTolerance();
147
148  ///
149  /**
150  Return the normal to the boundary at the
151  input VoF. If said normal is undefined,
152  returns the zero vector.
153  */
154  static RealVect normal(const VolIndex& a_vof,
155  const EBISBox& a_ebisBox,
156  const Real& a_bndryArea);
157
158  ///
159  /**
160  */
161  static Real bndryArea(const VolIndex& a_vof,
162  const EBISBox& a_ebisBox);
163
164  ///
165  /**
166  Return the inhomogeneous component of the plane
167  eqution ni xi = alpha.
168  Volume fraction must be positive and <= 1.0
169  and the normals can be in any order.
170  */
171  static Real computeAlpha(const Real& a_volFrac,
172  const RealVect& a_normal);
173
174  ///
175  /**
176  Compute the volume fraction in the cell given
177  alpha and the normal.
178  */
179  static Real computeVolume(const Real& a_alpha,
180  const RealVect& a_normal);
181
182  ///
183  /**
184  Get the normal and alpha given the points in a polygon.
185  Solves the linear system \\
186  ni xi - alpha = 0\\
187  \sum ni*ni = 1\\
188  for ni and alpha.
189  Always returns nromal[updir] >= 0
190  */
191  static void computeNormalAndAlpha(Real& a_alpha,
192  RealVect& a_normal,
193  const int& a_upDir,
194  const Tuple<RealVect, CH_SPACEDIM>& a_poly);
195
196  // solve ax = b (gives icomp component of x using cramers rule).
197  static Real
198  matrixSolveComp(const Vector<Vector<Real> >& a_A,
199  const Vector<Real>& a_rhs,
200  const int& a_icomp);
201
202  //return the determinant of a
203  static Real
204  determinant(const Vector< Vector<Real> >& a_A);
205
206  /**
207  andzvolume computes the volume under
208  the curve (covered volume).
209  Does so using Scardovelli
210  and Zaleski's direct formulae.
211  The normal has to be all positive numbers.
212  The normals also must be ordered from lowest
213  to highest.
214  */
215  static Real sAndZVolume(const Real& a_alpha,
216  const RealVect& a_normal);
217
218  ///
220  {;}
221  ///
223  {;}
224
225  ///
226  /**
227  Sort vector from low to high. All comps must be positive.
228  Return reverse mapping
229  */
230  static void sortVector(RealVect& vect, IntVect& ivmap);
231
232  ///make vector all pos and return the signs
233  static void posifyVector(RealVect& vect, IntVect& signs);
234
235  ///make vector into a unit vector and return the sum of squares
236  static void unifyVector(RealVect& normal, Real& sumSquare);
237
238  ///
239  static Tuple<int, CH_SPACEDIM-1> computeTanDirs(int upDir);
240
241 protected:
242
243  static Real twoDFunc(const Real& arg);
244  static Real threeDFunc(const Real& arg);
245
246  static Real computeAnyVolume(const Real& a_alpha,
247  const Real& a_norm0,
248  const Real& a_norm1,
249  const Real& a_norm2);
250
252
254
256
258
259  static RealVect tetCentroid(const RealVect& normal,
260  const Real& alpha);
261
262  static Real tetVolume(const RealVect& normal,
263  const Real& alpha);
264
265
266 private:
267 };
268
269 #include "NamespaceFooter.H"
270 #endif
static Real determinant(const Vector< Vector< Real > > &a_A)
static Real matrixSolveComp(const Vector< Vector< Real > > &a_A, const Vector< Real > &a_rhs, const int &a_icomp)
static void getMinor(Real a_Aminor[SpaceDim-1][SpaceDim-1], const Real a_A[SpaceDim][SpaceDim], int a_row, int acol)
#define CH_SPACEDIM
Definition: SPACE.H:52
static RealVect cross(const RealVect &a_xvec1, const RealVect &a_xvec0)
static Real bndryArea(const VolIndex &a_vof, const EBISBox &a_ebisBox)
static void setVectDx(const RealVect &a_vectDx)
one dimensional dynamic array
Definition: Vector.H:52
static Real s_areatolerance
Definition: PolyGeom.H:257
static const RealVect & getVectDx()
static RealVect tetCentroid(const RealVect &normal, const Real &alpha)
Definition: EBISBox.H:46
PolyGeom()
Definition: PolyGeom.H:219
static void invertMatrix(Real a_AInverse[SpaceDim][SpaceDim], const Real a_A[SpaceDim][SpaceDim], bool a_test)
static RealVect normal(const VolIndex &a_vof, const EBISBox &a_ebisBox, const Real &a_bndryArea)
~PolyGeom()
Definition: PolyGeom.H:222
static Real s_lengthtolerance
Definition: PolyGeom.H:255
static Real computeVolume(const Real &a_alpha, const RealVect &a_normal)
const int SpaceDim
Definition: SPACE.H:39
static const Real & getTolerance()
static void setLengthTolerance(const Real &a_tolerance)
Definition: PolyGeom.H:34
static Real s_tolerance
Definition: PolyGeom.H:253
static void sortVector(RealVect &vect, IntVect &ivmap)
static Real determinantSD(const Real a_A[SpaceDim][SpaceDim])
static Real threeDFunc(const Real &arg)
double Real
Definition: REAL.H:33
static Tuple< int, CH_SPACEDIM-1 > computeTanDirs(int upDir)
static Real computeAnyVolume(const Real &a_alpha, const Real &a_norm0, const Real &a_norm1, const Real &a_norm2)
static Real dot(const RealVect &a_xvec1, const RealVect &a_xvec0)
Ordered Tuples for Types T.
Definition: Tuple.H:30
static const Real & getVolumeTolerance()
static void setAreaTolerance(const Real &a_tolerance)
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
static const Real & getLengthTolerance()
static void computeNormalAndAlpha(Real &a_alpha, RealVect &a_normal, const int &a_upDir, const Tuple< RealVect, CH_SPACEDIM > &a_poly)
static Real twoDFunc(const Real &arg)
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
Volume of Fluid Index.
Definition: VolIndex.H:31
static void setTolerance(const Real &a_tolerance)
static Real distancePointToPlane(const RealVect &a_point, const RealVect &a_normal, const RealVect &a_pointOnLine)
return distance from point to a plane
static RealVect s_vectDx
Definition: PolyGeom.H:251
static void posifyVector(RealVect &vect, IntVect &signs)
make vector all pos and return the signs
static Real determinantSDM1(const Real a_A[SpaceDim-1][SpaceDim-1])
static const Real & getAreaTolerance()
static Real tetVolume(const RealVect &normal, const Real &alpha)
static void pointToLine(RealVect &a_closestPt, RealVect &a_normal, const RealVect &a_point, const RealVect &a_pointOnLine, const RealVect &a_direction)
static void unifyVector(RealVect &normal, Real &sumSquare)
make vector into a unit vector and return the sum of squares
static Real computeAlpha(const Real &a_volFrac, const RealVect &a_normal)
static Real sAndZVolume(const Real &a_alpha, const RealVect &a_normal)
static void setVolumeTolerance(const Real &a_tolerance)