chombo-discharge
|
Static class containing useful routines for (weighted) least squares polynomial reconstruction. More...
#include <CD_LeastSquares.H>
Public Types | |
using | CellLocation = Location::Cell |
using | FaceLocation = Location::Face |
using | Connectivity = VofUtils::Connectivity |
using | Neighborhood = VofUtils::Neighborhood |
Public Member Functions | |
LeastSquares ()=delete | |
Static class, no construction here. | |
~LeastSquares ()=delete | |
Static class, no destruction here. | |
Static Public Member Functions | |
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. More... | |
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. More... | |
static VoFStencil | getGradSten (const FaceIndex &a_face, const FaceLocation 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 on a grid face. More... | |
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. More... | |
static Real | sumWeights (const VoFStencil &a_stencil, const int a_variable) |
Return the sum of weights in the stencil, for a specific variable. More... | |
static Real | sumAllWeights (const VoFStencil &a_stencil) |
Compute the sum of all weights in a stencil. More... | |
static VoFStencil | projectGradSten (const VoFStencil &a_stencil, const RealVect &a_projection) |
Assuming that a_stencil is a gradient stencil, project it along a direction. More... | |
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. More... | |
static RealVect | displacement (const FaceLocation a_fromLoc, const CellLocation a_toLoc, const FaceIndex &a_fromFace, const VolIndex &a_toVof, const EBISBox &a_ebisbox, const Real &a_dx) |
Computes the distance between a vof and and a face. More... | |
static RealVect | displacement (const CellLocation a_from, const CellLocation a_to, const VolIndex &a_fromVof, const VolIndex &a_toVof, const EBISBox &a_ebisboxFrom, const EBISBox &a_ebisboxTo, const Real &a_dxFrom, const Real &a_dxTo) |
Computes the distance between two Vofs that are defined on two different grid levels. More... | |
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, i.e. x = (xFrom - xTo). More... | |
static Vector< RealVect > | getDisplacements (const FaceLocation a_fromLoc, const CellLocation a_to, const FaceIndex &a_fromFace, 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, i.e. x = (xFrom - xTo). More... | |
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. The weights are given as 1/||x1-x0||^a where a is the power. More... | |
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. This routine eliminates the value in the point where the gradient is computed (which is assumed to be known.) More... | |
static VoFStencil | computeGradSten (const Vector< VolIndex > &a_allVofs, const Vector< RealVect > &a_displacements, const Vector< Real > &a_weights, const int a_order, const IntVectSet a_knownTerms) |
Get a least squares gradient stencil solution for a system of first-order Taylor extrapolation for computing the gradient at a point. More... | |
static int | getTaylorExpansionSize (const int a_order) |
Get the size of a Taylor expansion for a given order. More... | |
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. More... | |
static VoFStencil | computeInterpolationStencil (const Vector< VolIndex > &a_allVofs, const Vector< RealVect > &a_displacements, const Vector< Real > &a_weights, const int a_order) |
Compute an interpolation stencil to specified order by solving a least squares system. More... | |
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. More... | |
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 Vector< Real > &a_weights, const int a_order) |
Compute a least squares interpolation to a specified order. More... | |
template<typename T > | |
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 two levels. More... | |
template<typename T > | |
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 Vector< Real > &a_fineWeights, const Vector< Real > &a_coarWeights, const int a_order) |
Compute a least squares interpolation to a specified order. This version separates the stencils into two levels. More... | |
Static class containing useful routines for (weighted) least squares polynomial reconstruction.
|
static |
Compute a least squares interpolation to a specified order. This version separates the stencils into two levels.
This is the general version which lets the caller specify why derivatives he wants out of the interpolation. The user specifies this via a_derivs where each IntVect represent a differentiation. E.g. IntVect(0,0,0) is just f, IntVect(1,0,0) = d/dx, IntVect(1,1,2) = (d^4)/(dx dy dz^2) and so on. The stencils for the directional derivatives are coded onto the return map. E.g. if a_derivs contains IntVect(1,0,0) the stencil for d/dx is found in map.at(IntVect(1,0,0)). The user can solve a smaller system if some of the terms in the expansion are known, typically used when computing an approximation to the gradient at a point in space where the scalar value is known. Note that this will modify the right hand side of the system, and the user will have to figure out how to make sense of the stencil.
[in] | a_derivs | Specification of which unknowns in the Taylor series will be returned. |
[in] | a_knownTerms | Which terms in the Taylor series are known. |
[in] | a_fineVofs | Fine-level vofs to include in the interpolation method. |
[in] | a_coarVofs | Coar-level vofs to include in the interpolation method. |
[in] | a_fineDisplacements | Displacement vectors from the fine Vofs to the interpolation point |
[in] | a_coarDisplacements | Displacement vectors from the coar Vofs to the interpolation point |
[in] | a_p | Weighting factor for weighted least squares |
[in] | a_order | Order of the interpolation. |
|
static |
Compute a least squares interpolation to a specified order. This version separates the stencils into two levels.
This is the general version which lets the caller specify why derivatives he wants out of the interpolation. The user specifies this via a_derivs where each IntVect represent a differentiation. E.g. IntVect(0,0,0) is just f, IntVect(1,0,0) = d/dx, IntVect(1,1,2) = (d^4)/(dx dy dz^2) and so on. The stencils for the directional derivatives are coded onto the return map. E.g. if a_derivs contains IntVect(1,0,0) the stencil for d/dx is found in map.at(IntVect(1,0,0)). The user can solve a smaller system if some of the terms in the expansion are known, typically used when computing an approximation to the gradient at a point in space where the scalar value is known. Note that this will modify the right hand side of the system, and the user will have to figure out how to make sense of the stencil.
[in] | a_derivs | Specification of which unknowns in the Taylor series will be returned. |
[in] | a_knownTerms | Which terms in the Taylor series are known. |
[in] | a_fineVofs | Fine-level vofs to include in the interpolation method. |
[in] | a_coarVofs | Coar-level vofs to include in the interpolation method. |
[in] | a_fineDisplacements | Displacement vectors from the fine Vofs to the interpolation point |
[in] | a_coarDisplacements | Displacement vectors from the coar Vofs to the interpolation point |
[in] | a_fineWeights | Weights for the fine level |
[in] | a_coarWeights | Weights for the coarse level |
[in] | a_order | Order of the interpolation. |
|
static |
Get a least squares gradient stencil solution for computing the gradient at a point. This routine eliminates the value in the point where the gradient is computed (which is assumed to be known.)
[in] | a_allVofs | Vofs for which the displacement vectors were computed. |
[in] | a_displacements | Displacement vectors from Vofs to the interpolation point |
[in] | a_p | Weighting exponent for system |
[in] | a_order | Desired order. |
|
static |
Get a least squares gradient stencil solution for a system of first-order Taylor extrapolation for computing the gradient at a point.
This routine eliminates the value in the point where the gradient is computed (which is assumed to be known.)
[in] | a_allVofs | Vofs for which the displacement vectors were computed. |
[in] | a_displacements | Displacement vectors from Vofs to the interpolation point |
[in] | a_weights | Weights for each system of equations. |
[in] | a_order | Interpolation order |
|
static |
Compute an interpolation stencil to specified order by solving a least squares system.
[in] | a_allVofs | Vofs to include in the interpolation method. |
[in] | a_displacements | Displacement vectors from the Vofs to the interpolation point |
[in] | a_order | Order of the interpolation. |
[in] | a_weightP | Weighting order for the least squares system. Must be > 0 to have an effect. |
|
static |
Compute an interpolation stencil to specified order by solving a least squares system.
[in] | a_allVofs | Vofs to include in the interpolation method. |
[in] | a_displacements | Displacement vectors from the Vofs to the interpolation point |
[in] | a_order | Order of the interpolation. |
[in] | a_weightP | Weighting order for the least squares system. Must be > 0 to have an effect. |
|
static |
Compute a least squares interpolation to a specified order.
This is the general version which lets the caller specify why derivatives he wants out of the interpolation. The user specifies this via a_derivs where each IntVect represent a differentiation. E.g. IntVect(0,0,0) is just f, IntVect(1,0,0) = d/dx, IntVect(1,1,2) = (d^4)/(dx dy dz^2) and so on. The stencils for the directional derivatives are coded onto the return map. E.g. if a_derivs contains IntVect(1,0,0) the stencil for d/dx is found in map.at(IntVect(1,0,0)). The user can solve a smaller system if some of the terms in the expansion are known, typically used when computing an approximation to the gradient at a point in space where the scalar value is known. Note that this will modify the right hand side of the system, and the user will have to figure out how to make sense of the stencil.
[in] | a_derivs | Specification of which terms to obtain from the series. |
[in] | a_knownTerms | Which terms in the Taylor series are known, and will be eliminated from the least squares system. |
[in] | a_allVofs | Vofs to include in the interpolation method. |
[in] | a_displacements | Displacement vectors from the Vofs to the interpolation point |
[in] | a_p | Weighting order for the least squares system. Must be > 0 to have an effect. |
[in] | a_order | Order of the interpolation. |
|
static |
Compute a least squares interpolation to a specified order.
This is the general version which lets the caller specify why derivatives he wants out of the interpolation. The user specifies this via a_derivs where each IntVect represent a differentiation. E.g. IntVect(0,0,0) is just f, IntVect(1,0,0) = d/dx, IntVect(1,1,2) = (d^4)/(dx dy dz^2) and so on. The stencils for the directional derivatives are coded onto the return map. E.g. if a_derivs contains IntVect(1,0,0) the stencil for d/dx is found in map.at(IntVect(1,0,0)). The user can solve a smaller system if some of the terms in the expansion are known, typically used when computing an approximation to the gradient at a point in space where the scalar value is known. Note that this will modify the right hand side of the system, and the user will have to figure out how to make sense of the stencil.
[in] | a_derivs | Specification of which unknowns in the Taylor series will be returned. |
[in] | a_knownTerms | Which terms in the Taylor series are known. |
[in] | a_allVofs | Vofs to include in the interpolation method. |
[in] | a_displacements | Displacement vectors from the Vofs to the interpolation point |
[in] | a_weights | Weights for the least squares system. |
[in] | a_order | Order of the returned interpolation. |
|
static |
Computes the distance between two Vofs that are defined on the same grid level.
[in] | a_from | Specifying position in the cell defined by a_fromVof |
[in] | a_to | Specifying position in the cell defined by a_toVof |
[in] | a_fromVof | Vof to compute the distance from |
[in] | a_toVof | Vof to compute the distance to |
[in] | a_ebisbox | EBISBox |
[in] | a_dx | Grid resolution |
|
static |
Computes the distance between two Vofs that are defined on two different grid levels.
[in] | a_from | Specifying position in the cell defined by a_fromVof |
[in] | a_to | Specifying position in the cell defined by a_toVof |
[in] | a_fromVof | Vof to compute the distance from |
[in] | a_toVof | Vof to compute the distance to |
[in] | a_ebisboxFrom | EBISBox which can reach a_fromVof |
[in] | a_ebisboxTo | EBISBox which can reach a_toVof |
[in] | a_dxFrom | Grid resolution for the a_fromVof vof |
[in] | a_dxTo | Grid resolution for the a_toVof vof |
|
static |
Computes the distance between a vof and and a face.
[in] | a_fromLoc | Specifying position in the cell defined by a_fromVof |
[in] | a_toLoc | Specifying position in the cell defined by a_toVof |
[in] | a_fromFace | face to compute the distance from |
[in] | a_toVof | Vof to compute the distance to |
[in] | a_ebisbox | EBISBox |
[in] | a_dx | Grid resolution |
|
static |
Compute a least squares gradient stencil on the EB centroid with specified order.
This routine eliminates the value on the boundary and the user will have to fetch the weight for this point from the returned stencil.
[in] | a_vof | Input vof |
[in] | a_neighborhood | Neighboorhood specification |
[in] | a_cellPositions | How to interpret cell positions |
[in] | a_ebisbox | ebisbox |
[in] | a_radius | Stencil radius |
[in] | a_dx | Resolution |
[in] | a_p | Weight scaling |
[in] | a_order | Order of the gradient. |
[in] | a_addStartingVof | Use a_vof in the expression for the gradient. This can be ill-conditioned for cell-centered expressions. |
|
static |
Get displacement vectors from a cell position to another cell position for a list of Vofs, i.e. x = (xFrom - xTo).
[in] | a_from | From this position |
[in] | a_to | To this position. |
[in] | a_curVof | Origin vof |
[in] | a_toVofs | Vofs to compute the distance to/from |
[in] | a_ebisbox | EBISBox |
[in] | a_dx | Grid resolution |
|
static |
Get displacement vectors from a cell position to another cell position for a list of Vofs, i.e. x = (xFrom - xTo).
|
static |
Compute a least squares gradient stencil on a grid face.
This routine computes grad(phi) using a least squares reconstruction to specified order.
[in] | a_face | Input face |
[in] | a_gradLocation | Where (on the face) the gradient will be computed |
[in] | a_cellLocation | Cell location |
[in] | a_ebisbox | ebisbox |
[in] | a_dx | Resolution |
[in] | a_radius | Stencil radius |
[in] | a_p | Weighting factor for least squares |
[in] | a_order | Truncation order. |
|
static |
Compute a least squares gradient stencil in a cell.
This routine computes grad(phi) using a least squares reconstruction to specified order.
[in] | a_vof | Input vof |
[in] | a_gradLocation | Where (in the vof) the gradient is evaluated |
[in] | a_cellLocation | Cell locations |
[in] | a_ebisbox | ebisbox |
[in] | a_dx | Resolution |
[in] | a_radius | Stencil radius |
[in] | a_p | Weighting factor for least squares |
[in] | a_order | Truncation order. |
|
static |
Get an interpolation stencil to a point in a cell with a specified order and radius.
[in] | a_cellPos | Position in the cell of the starting Vof. |
[in] | a_otherCellsPos | Positions in the other cells. |
[in] | a_startVof | The vof to compute for. |
[in] | a_ebisbox | EBISBox. |
[in] | a_dx | Grid resolution. |
[in] | a_p | Power factor for weights. |
[in] | a_radius | Stencil radius. |
[in] | a_order | Interpolation order. |
[in] | a_addStartingVof | Add starting vof or not (can't be used with a_p > 0) as it would lead to ill-conditioned systems. |
|
static |
Get the size of a Taylor expansion for a given order.
[in] | a_order | Desired order in Taylor expansion |
|
inlinestatic |
Create a list of weights. This routine returns a list of diagonal weights for a least squares system. The weights are given as 1/||x1-x0||^a where a is the power.
[in] | a_displacements | Displacement vectors, i.e. (x1-x0,x2-x0, x3-x0,...,(xN-x0)^T. |
[in] | a_power | Power factor for weights. |
|
static |
Assuming that a_stencil is a gradient stencil, project it along a direction.
[in] | a_stencil | Stencil describing a gradient. |
[in] | a_projection | Vector to project stencil along. |
|
static |
Compute the sum of all weights in a stencil.
[in] | a_stencil | Stencil |
|
static |
Return the sum of weights in the stencil, for a specific variable.
[in] | a_stencil | Stencil |
[in] | a_variable | Which variable to sum. |