chombo-discharge
CD_LeastSquares.H
Go to the documentation of this file.
1 /* chombo-discharge
2  * Copyright © 2021 SINTEF Energy Research.
3  * Please refer to Copyright.txt and LICENSE in the chombo-discharge root directory.
4  */
5 
12 #ifndef CD_LeastSquares_H
13 #define CD_LeastSquares_H
14 
15 // Chombo includes
16 #include <Stencils.H>
17 #include <EBISBox.H>
18 #include <IntVectSet.H>
19 #include <RealVect.H>
20 #include <VolIndex.H>
21 
22 // Our includes
23 #include <CD_VofUtils.H>
24 #include <CD_Location.H>
25 #include <CD_NamespaceHeader.H>
26 
31 {
32 public:
36  LeastSquares() = delete;
37 
41  ~LeastSquares() = delete;
42 
47 
60  static VoFStencil
61  getInterpolationStencil(const CellLocation a_cellPos,
62  const CellLocation a_otherCellsPos,
63  const Connectivity a_connectivity,
64  const VolIndex& a_startVof,
65  const EBISBox& a_ebisbox,
66  const Real a_dx,
67  const int a_p,
68  const int a_radius,
69  const int a_order,
70  const bool a_addStartingVof);
71 
85  static VoFStencil
86  getGradSten(const VolIndex& a_vof,
87  const CellLocation a_gradLocation,
88  const CellLocation a_cellLocation,
89  const EBISBox& a_ebisbox,
90  const Real a_dx,
91  const int a_radius,
92  const int a_p,
93  const int a_order,
94  const IntVectSet a_knownTerms = IntVectSet());
95 
109  static VoFStencil
110  getGradSten(const FaceIndex& a_face,
111  const FaceLocation a_gradLocation,
112  const CellLocation a_cellLocation,
113  const EBISBox& a_ebisbox,
114  const Real a_dx,
115  const int a_radius,
116  const int a_p,
117  const int a_order,
118  const IntVectSet a_knownTerms = IntVectSet());
119 
134  static VoFStencil
135  getBndryGradSten(const VolIndex& a_vof,
136  const Neighborhood a_neighborhood,
137  const CellLocation a_cellPositions,
138  const EBISBox& a_ebisbox,
139  const Real a_dx,
140  const int a_radius,
141  const int a_p,
142  const int a_order,
143  const bool a_addStartingVof);
144 
151  static Real
152  sumWeights(const VoFStencil& a_stencil, const int a_variable);
153 
159  static Real
160  sumAllWeights(const VoFStencil& a_stencil);
161 
169  static VoFStencil
170  projectGradSten(const VoFStencil& a_stencil, const RealVect& a_projection);
171 
182  static RealVect
183  displacement(const CellLocation a_from,
184  const CellLocation a_to,
185  const VolIndex& a_fromVof,
186  const VolIndex& a_toVof,
187  const EBISBox& a_ebisbox,
188  const Real& a_dx);
189 
200  static RealVect
201  displacement(const FaceLocation a_fromLoc,
202  const CellLocation a_toLoc,
203  const FaceIndex& a_fromFace,
204  const VolIndex& a_toVof,
205  const EBISBox& a_ebisbox,
206  const Real& a_dx);
207 
220  static RealVect
221  displacement(const CellLocation a_from,
222  const CellLocation a_to,
223  const VolIndex& a_fromVof,
224  const VolIndex& a_toVof,
225  const EBISBox& a_ebisboxFrom,
226  const EBISBox& a_ebisboxTo,
227  const Real& a_dxFrom,
228  const Real& a_dxTo);
229 
239  static Vector<RealVect>
240  getDisplacements(const CellLocation a_from,
241  const CellLocation a_to,
242  const VolIndex& a_fromVof,
243  const Vector<VolIndex>& a_toVofs,
244  const EBISBox& a_ebisbox,
245  const Real& a_dx);
246 
256  static Vector<RealVect>
257  getDisplacements(const FaceLocation a_fromLoc,
258  const CellLocation a_to,
259  const FaceIndex& a_fromFace,
260  const Vector<VolIndex>& a_toVofs,
261  const EBISBox& a_ebisbox,
262  const Real& a_dx);
263 
270  inline static Vector<Real>
271  makeDiagWeights(const Vector<RealVect>& a_displacements, const int a_pow);
272 
283  static VoFStencil
284  computeGradSten(const Vector<VolIndex>& a_allVofs,
285  const Vector<RealVect>& a_displacements,
286  const int a_p,
287  const int a_order,
288  const IntVectSet a_knownTerms);
289 
301  static VoFStencil
302  computeGradSten(const Vector<VolIndex>& a_allVofs,
303  const Vector<RealVect>& a_displacements,
304  const Vector<Real>& a_weights,
305  const int a_order,
306  const IntVectSet a_knownTerms);
307 
313  static int
314  getTaylorExpansionSize(const int a_order);
315 
325  static VoFStencil
326  computeInterpolationStencil(const Vector<VolIndex>& a_allVofs,
327  const Vector<RealVect>& a_displacements,
328  const int a_pow,
329  const int a_order);
330 
341  static VoFStencil
342  computeInterpolationStencil(const Vector<VolIndex>& a_allVofs,
343  const Vector<RealVect>& a_displacements,
344  const Vector<Real>& a_weights,
345  const int a_order);
346 
365  static std::map<IntVect, VoFStencil>
366  computeSingleLevelStencils(const IntVectSet& a_derivs,
367  const IntVectSet& a_knownTerms,
368  const Vector<VolIndex>& a_allVofs,
369  const Vector<RealVect>& a_displacements,
370  const int a_p,
371  const int a_order);
372 
392  static std::map<IntVect, VoFStencil>
393  computeSingleLevelStencils(const IntVectSet& a_derivs,
394  const IntVectSet& a_knownTerms,
395  const Vector<VolIndex>& a_allVofs,
396  const Vector<RealVect>& a_displacements,
397  const Vector<Real>& a_weights,
398  const int a_order);
399 
423  template <typename T>
424  static std::map<IntVect, std::pair<VoFStencil, VoFStencil>>
425  computeDualLevelStencils(const IntVectSet& a_derivs,
426  const IntVectSet& a_knownTerms,
427  const Vector<VolIndex>& a_fineVofs,
428  const Vector<VolIndex>& a_coarVofs,
429  const Vector<RealVect>& a_fineDisplacements,
430  const Vector<RealVect>& a_coarDisplacements,
431  const int a_p,
432  const int a_order);
433 
458  template <typename T>
459  static std::map<IntVect, std::pair<VoFStencil, VoFStencil>>
460  computeDualLevelStencils(const IntVectSet& a_derivs,
461  const IntVectSet& a_knownTerms,
462  const Vector<VolIndex>& a_fineVofs,
463  const Vector<VolIndex>& a_coarVofs,
464  const Vector<RealVect>& a_fineDisplacements,
465  const Vector<RealVect>& a_coarDisplacements,
466  const Vector<Real>& a_fineWeights,
467  const Vector<Real>& a_coarWeights,
468  const int a_order);
469 };
470 
471 #include <CD_NamespaceFooter.H>
472 
473 #include <CD_LeastSquaresImplem.H>
474 
475 #endif
Declaration of cell positions.
Various functions for getting Vofs near cut-cells.
Static class containing useful routines for (weighted) least squares polynomial reconstruction.
Definition: CD_LeastSquares.H:31
static std::map< IntVect, std::pair< VoFStencil, VoFStencil > > computeDualLevelStencils(const IntVectSet &a_derivs, const IntVectSet &a_knownTerms, const Vector< VolIndex > &a_fineVofs, const Vector< VolIndex > &a_coarVofs, const Vector< RealVect > &a_fineDisplacements, const Vector< RealVect > &a_coarDisplacements, const int a_p, const int a_order)
Compute a least squares interpolation to a specified order. This version separates the stencils into ...
Definition: CD_LeastSquaresImplem.H:41
static Vector< RealVect > getDisplacements(const CellLocation a_from, const CellLocation a_to, const VolIndex &a_fromVof, const Vector< VolIndex > &a_toVofs, const EBISBox &a_ebisbox, const Real &a_dx)
Get displacement vectors from a cell position to another cell position for a list of Vofs,...
Definition: CD_LeastSquares.cpp:278
static RealVect displacement(const CellLocation a_from, const CellLocation a_to, const VolIndex &a_fromVof, const VolIndex &a_toVof, const EBISBox &a_ebisbox, const Real &a_dx)
Computes the distance between two Vofs that are defined on the same grid level.
Definition: CD_LeastSquares.cpp:232
static int getTaylorExpansionSize(const int a_order)
Get the size of a Taylor expansion for a given order.
Definition: CD_LeastSquares.cpp:416
static VoFStencil computeInterpolationStencil(const Vector< VolIndex > &a_allVofs, const Vector< RealVect > &a_displacements, const int a_pow, const int a_order)
Compute an interpolation stencil to specified order by solving a least squares system.
Definition: CD_LeastSquares.cpp:425
static VoFStencil computeGradSten(const Vector< VolIndex > &a_allVofs, const Vector< RealVect > &a_displacements, const int a_p, const int a_order, const IntVectSet a_knownTerms)
Get a least squares gradient stencil solution for computing the gradient at a point....
Definition: CD_LeastSquares.cpp:317
static VoFStencil getGradSten(const VolIndex &a_vof, const CellLocation a_gradLocation, const CellLocation a_cellLocation, const EBISBox &a_ebisbox, const Real a_dx, const int a_radius, const int a_p, const int a_order, const IntVectSet a_knownTerms=IntVectSet())
Compute a least squares gradient stencil in a cell.
Definition: CD_LeastSquares.cpp:57
static Real sumAllWeights(const VoFStencil &a_stencil)
Compute the sum of all weights in a stencil.
Definition: CD_LeastSquares.cpp:404
static Real sumWeights(const VoFStencil &a_stencil, const int a_variable)
Return the sum of weights in the stencil, for a specific variable.
Definition: CD_LeastSquares.cpp:388
static VoFStencil getInterpolationStencil(const CellLocation a_cellPos, const CellLocation a_otherCellsPos, const Connectivity a_connectivity, const VolIndex &a_startVof, const EBISBox &a_ebisbox, const Real a_dx, const int a_p, const int a_radius, const int a_order, const bool a_addStartingVof)
Get an interpolation stencil to a point in a cell with a specified order and radius.
Definition: CD_LeastSquares.cpp:19
static VoFStencil projectGradSten(const VoFStencil &a_stencil, const RealVect &a_projection)
Assuming that a_stencil is a gradient stencil, project it along a direction.
Definition: CD_LeastSquares.cpp:370
~LeastSquares()=delete
Static class, no destruction here.
static std::map< IntVect, VoFStencil > computeSingleLevelStencils(const IntVectSet &a_derivs, const IntVectSet &a_knownTerms, const Vector< VolIndex > &a_allVofs, const Vector< RealVect > &a_displacements, const int a_p, const int a_order)
Compute a least squares interpolation to a specified order.
Definition: CD_LeastSquares.cpp:463
LeastSquares()=delete
Static class, no construction here.
static VoFStencil getBndryGradSten(const VolIndex &a_vof, const Neighborhood a_neighborhood, const CellLocation a_cellPositions, const EBISBox &a_ebisbox, const Real a_dx, const int a_radius, const int a_p, const int a_order, const bool a_addStartingVof)
Compute a least squares gradient stencil on the EB centroid with specified order.
Definition: CD_LeastSquares.cpp:153
static Vector< Real > makeDiagWeights(const Vector< RealVect > &a_displacements, const int a_pow)
Create a list of weights. This routine returns a list of diagonal weights for a least squares system....
Definition: CD_LeastSquaresImplem.H:22
Neighborhood
Neighborhood type.
Definition: CD_VofUtils.H:55
Connectivity
Class for specifying connectivity of Vofs.
Definition: CD_VofUtils.H:42
Cell
Enum for distinguishing between cell locations.
Definition: CD_Location.H:30
Face
Enum for distinguishing between face locations.
Definition: CD_Location.H:40