chombo-discharge
Loading...
Searching...
No Matches
CD_LeastSquares.H
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021-2026 SINTEF Energy Research
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
12
13#ifndef CD_LEASTSQUARES_H
14#define CD_LEASTSQUARES_H
15
16// Chombo includes
17#include <Stencils.H>
18#include <EBISBox.H>
19#include <IntVectSet.H>
20#include <RealVect.H>
21#include <VolIndex.H>
22
23// Our includes
24#include <CD_VofUtils.H>
25#include <CD_Location.H>
26#include <CD_NamespaceHeader.H>
27
32{
33public:
37 LeastSquares() = delete;
38
42 ~LeastSquares() = delete;
43
52
68 static VoFStencil
70 CellLocation a_otherCellsPos,
71 Connectivity a_connectivity,
72 const VolIndex& a_startVof,
73 const EBISBox& a_ebisbox,
74 Real a_dx,
75 int a_p,
76 int a_radius,
77 int a_order,
78 bool a_addStartingVof);
79
95 static VoFStencil
96 getGradSten(const VolIndex& a_vof,
97 CellLocation a_gradLocation,
98 CellLocation a_cellLocation,
99 const EBISBox& a_ebisbox,
100 Real a_dx,
101 int a_radius,
102 int a_p,
103 int a_order,
104 const IntVectSet& a_knownTerms = IntVectSet());
105
121 static VoFStencil
122 getGradSten(const FaceIndex& a_face,
123 FaceLocation a_gradLocation,
124 CellLocation a_cellLocation,
125 const EBISBox& a_ebisbox,
126 Real a_dx,
127 int a_radius,
128 int a_p,
129 int a_order,
130 const IntVectSet& a_knownTerms = IntVectSet());
131
149 static VoFStencil
150 getBndryGradSten(const VolIndex& a_vof,
151 Neighborhood a_neighborhood,
152 CellLocation a_cellPositions,
153 const EBISBox& a_ebisbox,
154 Real a_dx,
155 int a_radius,
156 int a_p,
157 int a_order,
158 bool a_addStartingVof);
159
166 static Real
167 sumWeights(const VoFStencil& a_stencil, int a_variable);
168
174 static Real
175 sumAllWeights(const VoFStencil& a_stencil);
176
184 static VoFStencil
185 projectGradSten(const VoFStencil& a_stencil, const RealVect& a_projection);
186
197 static RealVect
199 CellLocation a_to,
200 const VolIndex& a_fromVof,
201 const VolIndex& a_toVof,
202 const EBISBox& a_ebisbox,
203 const Real& a_dx);
204
215 static RealVect
216 displacement(FaceLocation a_fromLoc,
217 CellLocation a_toLoc,
218 const FaceIndex& a_fromFace,
219 const VolIndex& a_toVof,
220 const EBISBox& a_ebisbox,
221 const Real& a_dx);
222
235 static RealVect
237 CellLocation a_to,
238 const VolIndex& a_fromVof,
239 const VolIndex& a_toVof,
240 const EBISBox& a_ebisboxFrom,
241 const EBISBox& a_ebisboxTo,
242 const Real& a_dxFrom,
243 const Real& a_dxTo);
244
256 static Vector<RealVect>
258 CellLocation a_to,
259 const VolIndex& a_fromVof,
260 const Vector<VolIndex>& a_toVofs,
261 const EBISBox& a_ebisbox,
262 const Real& a_dx);
263
275 static Vector<RealVect>
277 CellLocation a_to,
278 const FaceIndex& a_fromFace,
279 const Vector<VolIndex>& a_toVofs,
280 const EBISBox& a_ebisbox,
281 const Real& a_dx);
282
290 inline static Vector<Real>
291 makeDiagWeights(const Vector<RealVect>& a_displacements, int a_pow);
292
305 static VoFStencil
306 computeGradSten(const Vector<VolIndex>& a_allVofs,
307 const Vector<RealVect>& a_displacements,
308 int a_p,
309 int a_order,
310 const IntVectSet& a_knownTerms);
311
328 static VoFStencil
329 computeGradSten(const Vector<VolIndex>& a_allVofs,
330 const Vector<RealVect>& a_displacements,
331 const Vector<Real>& a_weights,
332 int a_order,
333 const IntVectSet& a_knownTerms);
334
340 static int
341 getTaylorExpansionSize(int a_order);
342
350 static Real
351 getLengthScale(const Vector<RealVect>& a_displacements) noexcept;
352
362 static VoFStencil
363 computeInterpolationStencil(const Vector<VolIndex>& a_allVofs,
364 const Vector<RealVect>& a_displacements,
365 int a_pow,
366 int a_order);
367
378 static VoFStencil
379 computeInterpolationStencil(const Vector<VolIndex>& a_allVofs,
380 const Vector<RealVect>& a_displacements,
381 const Vector<Real>& a_weights,
382 int a_order);
383
404 static std::map<IntVect, VoFStencil>
405 computeSingleLevelStencils(const IntVectSet& a_derivs,
406 const IntVectSet& a_knownTerms,
407 const Vector<VolIndex>& a_allVofs,
408 const Vector<RealVect>& a_displacements,
409 int a_p,
410 int a_order);
411
434 static std::map<IntVect, VoFStencil>
435 computeSingleLevelStencils(const IntVectSet& a_derivs,
436 const IntVectSet& a_knownTerms,
437 const Vector<VolIndex>& a_allVofs,
438 const Vector<RealVect>& a_displacements,
439 const Vector<Real>& a_weights,
440 int a_order);
441
469 template <typename T>
470 static std::map<IntVect, std::pair<VoFStencil, VoFStencil>>
471 computeDualLevelStencils(const IntVectSet& a_derivs,
472 const IntVectSet& a_knownTerms,
473 const Vector<VolIndex>& a_fineVofs,
474 const Vector<VolIndex>& a_coarVofs,
475 const Vector<RealVect>& a_fineDisplacements,
476 const Vector<RealVect>& a_coarDisplacements,
477 int a_p,
478 int a_order);
479
508 template <typename T>
509 static std::map<IntVect, std::pair<VoFStencil, VoFStencil>>
510 computeDualLevelStencils(const IntVectSet& a_derivs,
511 const IntVectSet& a_knownTerms,
512 const Vector<VolIndex>& a_fineVofs,
513 const Vector<VolIndex>& a_coarVofs,
514 const Vector<RealVect>& a_fineDisplacements,
515 const Vector<RealVect>& a_coarDisplacements,
516 const Vector<Real>& a_fineWeights,
517 const Vector<Real>& a_coarWeights,
518 int a_order);
519};
520
521#include <CD_NamespaceFooter.H>
522
524
525#endif
Implementation of CD_LeastSquares.H.
Declaration of cell positions.
Various functions for getting Vofs near cut-cells.
Location::Face FaceLocation
Face type alias.
Definition CD_LeastSquares.H:47
static VoFStencil computeGradSten(const Vector< VolIndex > &a_allVofs, const Vector< RealVect > &a_displacements, int a_p, 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:321
static Real sumWeights(const VoFStencil &a_stencil, int a_variable)
Return the sum of weights in the stencil, for a specific variable.
Definition CD_LeastSquares.cpp:392
static VoFStencil computeInterpolationStencil(const Vector< VolIndex > &a_allVofs, const Vector< RealVect > &a_displacements, int a_pow, int a_order)
Compute an interpolation stencil to specified order by solving a least squares system.
Definition CD_LeastSquares.cpp:441
static Vector< Real > makeDiagWeights(const Vector< RealVect > &a_displacements, 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:23
static Real getLengthScale(const Vector< RealVect > &a_displacements) noexcept
Get the length scale that the least squares systems are built in.
Definition CD_LeastSquares.cpp:420
VofUtils::Neighborhood Neighborhood
Neighborhood type alias.
Definition CD_LeastSquares.H:51
static Real sumAllWeights(const VoFStencil &a_stencil)
Compute the sum of all weights in a stencil.
Definition CD_LeastSquares.cpp:408
static VoFStencil getBndryGradSten(const VolIndex &a_vof, Neighborhood a_neighborhood, CellLocation a_cellPositions, const EBISBox &a_ebisbox, Real a_dx, int a_radius, int a_p, int a_order, bool a_addStartingVof)
Compute a least squares gradient stencil on the EB centroid with specified order.
Definition CD_LeastSquares.cpp:157
static Vector< RealVect > getDisplacements(CellLocation a_from, 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:282
VofUtils::Connectivity Connectivity
Connectivity type alias.
Definition CD_LeastSquares.H:49
Location::Cell CellLocation
Cell type alias.
Definition CD_LeastSquares.H:45
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:374
~LeastSquares()=delete
Static class, no destruction here.
static RealVect displacement(CellLocation a_from, 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:236
static std::map< IntVect, VoFStencil > computeSingleLevelStencils(const IntVectSet &a_derivs, const IntVectSet &a_knownTerms, const Vector< VolIndex > &a_allVofs, const Vector< RealVect > &a_displacements, int a_p, int a_order)
Compute a least squares interpolation to a specified order.
Definition CD_LeastSquares.cpp:479
static VoFStencil getInterpolationStencil(CellLocation a_cellPos, CellLocation a_otherCellsPos, Connectivity a_connectivity, const VolIndex &a_startVof, const EBISBox &a_ebisbox, Real a_dx, int a_p, int a_radius, int a_order, bool a_addStartingVof)
Get an interpolation stencil to a point in a cell with a specified order and radius.
Definition CD_LeastSquares.cpp:20
LeastSquares()=delete
Static class, no construction here.
static VoFStencil getGradSten(const VolIndex &a_vof, CellLocation a_gradLocation, CellLocation a_cellLocation, const EBISBox &a_ebisbox, Real a_dx, int a_radius, int a_p, int a_order, const IntVectSet &a_knownTerms=IntVectSet())
Compute a least squares gradient stencil in a cell.
Definition CD_LeastSquares.cpp:58
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, int a_p, int a_order)
Compute a least squares interpolation to a specified order. This version separates the stencils into ...
Definition CD_LeastSquaresImplem.H:46
static int getTaylorExpansionSize(int a_order)
Get the size of a Taylor expansion for a given order.
Definition CD_LeastSquares.cpp:432
Neighborhood
Neighborhood type.
Definition CD_VofUtils.H:57
Connectivity
Class for specifying connectivity of Vofs.
Definition CD_VofUtils.H:44
Cell
Enum for distinguishing between cell locations.
Definition CD_Location.H:31
Face
Enum for distinguishing between face locations.
Definition CD_Location.H:41