|
chombo-discharge
|
Static class containing useful routines for (weighted) least squares polynomial reconstruction. More...
#include <CD_LeastSquares.H>
Public Types | |
| using | CellLocation = Location::Cell |
| Cell type alias. | |
| using | FaceLocation = Location::Face |
| Face type alias. | |
| using | Connectivity = VofUtils::Connectivity |
| Connectivity type alias. | |
| using | Neighborhood = VofUtils::Neighborhood |
| Neighborhood type alias. | |
Public Member Functions | |
| LeastSquares ()=delete | |
| Static class, no construction here. | |
| ~LeastSquares ()=delete | |
| Static class, no destruction here. | |
Static Public Member Functions | |
| 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. | |
| 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. | |
| static VoFStencil | getGradSten (const FaceIndex &a_face, FaceLocation 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 on a grid face. | |
| 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. | |
| static Real | sumWeights (const VoFStencil &a_stencil, int a_variable) |
| Return the sum of weights in the stencil, for a specific variable. | |
| static Real | sumAllWeights (const VoFStencil &a_stencil) |
| Compute the sum of all weights in a stencil. | |
| static VoFStencil | projectGradSten (const VoFStencil &a_stencil, const RealVect &a_projection) |
| Assuming that a_stencil is a gradient stencil, project it along a direction. | |
| 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. | |
| static RealVect | displacement (FaceLocation a_fromLoc, 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. | |
| static RealVect | displacement (CellLocation a_from, 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. | |
| 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, i.e. x = (xFrom - xTo). | |
| static Vector< RealVect > | getDisplacements (FaceLocation a_fromLoc, 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). | |
| 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. The weights are given as 1/||x1-x0||^a where a is the power. | |
| 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. This routine eliminates the value in the point where the gradient is computed (which is assumed to be known.) | |
| static VoFStencil | computeGradSten (const Vector< VolIndex > &a_allVofs, const Vector< RealVect > &a_displacements, const Vector< Real > &a_weights, 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. | |
| static int | getTaylorExpansionSize (int a_order) |
| Get the size of a Taylor expansion for a given order. | |
| 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. | |
| static VoFStencil | computeInterpolationStencil (const Vector< VolIndex > &a_allVofs, const Vector< RealVect > &a_displacements, const Vector< Real > &a_weights, int a_order) |
| Compute an interpolation stencil to specified order by solving a least squares system. | |
| 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. | |
| 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, int a_order) |
| Compute a least squares interpolation to a specified order. | |
| 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, int a_p, int a_order) |
| Compute a least squares interpolation to a specified order. This version separates the stencils into two levels. | |
| 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, int a_order) |
| Compute a least squares interpolation to a specified order. This version separates the stencils into two levels. | |
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_fineWeights | Weights for the fine level |
| [in] | a_coarWeights | Weights for the coarse level |
| [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_p | Weighting factor for weighted least squares |
| [in] | a_order | Order of the interpolation. |
|
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 |
| [in] | a_knownTerms | Description However, the routine does not check if the inputs are degenerate. |
|
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. |
| [in] | a_knownTerms | Description |
|
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_weights | Weights |
|
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_pow | Pow |
|
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 |
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 |
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 | Neighborhood 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_toVofs | Vofs to compute the distance to/from |
| [in] | a_ebisbox | EBISBox |
| [in] | a_dx | Grid resolution |
| [in] | a_fromVof | From vof |
|
static |
Get displacement vectors from a cell position to another cell position for a list of Vofs, i.e. x = (xFrom - xTo).
| [in] | a_fromLoc | Location on face |
| [in] | a_fromFace | Origin face |
| [in] | a_toVofs | Vofs to compute the distance to/from |
| [in] | a_ebisbox | EBISBox |
| [in] | a_dx | Grid resolution |
| [in] | a_to | To |
|
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. |
| [in] | a_knownTerms | Description |
|
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. |
| [in] | a_knownTerms | Description |
|
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. |
| [in] | a_connectivity | Description |
|
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_pow | Pow |
|
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. |