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
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
352 static VoFStencil
353 computeInterpolationStencil(const Vector<VolIndex>& a_allVofs,
354 const Vector<RealVect>& a_displacements,
355 int a_pow,
356 int a_order);
357
368 static VoFStencil
369 computeInterpolationStencil(const Vector<VolIndex>& a_allVofs,
370 const Vector<RealVect>& a_displacements,
371 const Vector<Real>& a_weights,
372 int a_order);
373
394 static std::map<IntVect, VoFStencil>
395 computeSingleLevelStencils(const IntVectSet& a_derivs,
396 const IntVectSet& a_knownTerms,
397 const Vector<VolIndex>& a_allVofs,
398 const Vector<RealVect>& a_displacements,
399 int a_p,
400 int a_order);
401
423 static std::map<IntVect, VoFStencil>
424 computeSingleLevelStencils(const IntVectSet& a_derivs,
425 const IntVectSet& a_knownTerms,
426 const Vector<VolIndex>& a_allVofs,
427 const Vector<RealVect>& a_displacements,
428 const Vector<Real>& a_weights,
429 int a_order);
430
457 template <typename T>
458 static std::map<IntVect, std::pair<VoFStencil, VoFStencil>>
459 computeDualLevelStencils(const IntVectSet& a_derivs,
460 const IntVectSet& a_knownTerms,
461 const Vector<VolIndex>& a_fineVofs,
462 const Vector<VolIndex>& a_coarVofs,
463 const Vector<RealVect>& a_fineDisplacements,
464 const Vector<RealVect>& a_coarDisplacements,
465 int a_p,
466 int a_order);
467
495 template <typename T>
496 static std::map<IntVect, std::pair<VoFStencil, VoFStencil>>
497 computeDualLevelStencils(const IntVectSet& a_derivs,
498 const IntVectSet& a_knownTerms,
499 const Vector<VolIndex>& a_fineVofs,
500 const Vector<VolIndex>& a_coarVofs,
501 const Vector<RealVect>& a_fineDisplacements,
502 const Vector<RealVect>& a_coarDisplacements,
503 const Vector<Real>& a_fineWeights,
504 const Vector<Real>& a_coarWeights,
505 int a_order);
506};
507
508#include <CD_NamespaceFooter.H>
509
511
512#endif
Implementation of CD_LeastSquares.H.
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:32
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:429
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 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
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:467
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:49
static int getTaylorExpansionSize(int a_order)
Get the size of a Taylor expansion for a given order.
Definition CD_LeastSquares.cpp:420
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