OPAL (Object Oriented Parallel Accelerator Library)
2021.1.99
OPAL
|
PPSolveFactory solves the system of linear equations to interpolate from a grid of points using higher order polynomials, creating a PolynomialPatch object. The order of the polynomial is user-defined. More...
#include <PPSolveFactory.h>
Public Member Functions | |
PPSolveFactory (Mesh *points, std::vector< std::vector< double > > values, int polyPatchOrder, int smoothingOrder) | |
~PPSolveFactory () | |
PolynomialPatch * | solve () |
Static Public Member Functions | |
static std::vector< std::vector< int > > | getNearbyPointsSquares (int pointDim, int polyOrderLower, int polyOrderUpper) |
Private Member Functions | |
void | getPoints () |
void | getValues (Mesh::Iterator it) |
void | getDerivPoints () |
void | getDerivs (const Mesh::Iterator &it) |
std::vector< double > | outOfBoundsPosition (Mesh::Iterator outOfBoundsIt) |
PolynomialCoefficient | getDeltaIterator (Mesh::Iterator it1, Mesh::Iterator it2, int valueIndex) |
Static Private Member Functions | |
static void | nearbyPointsRecursive (std::vector< int > check, size_t checkIndex, size_t polyPower, std::vector< std::vector< int > > &nearbyPoints) |
Private Attributes | |
int | polyPatchOrder_m |
int | smoothingOrder_m |
int | polyDim_m |
int | valueDim_m |
Mesh * | polyMesh_m |
Mesh * | points_m |
std::vector< std::vector< double > > | values_m |
std::vector< SquarePolynomialVector * > | polynomials_m |
std::vector< std::vector< double > > | thisPoints_m |
std::vector< std::vector< double > > | thisValues_m |
std::vector< std::vector< double > > | derivPoints_m |
std::vector< std::vector< double > > | derivValues_m |
std::vector< std::vector< int > > | derivOrigins_m |
std::vector< std::vector< int > > | derivIndices_m |
std::vector< MVector< double > > | derivPolyVec_m |
std::vector< std::vector< std::vector< int > > > | edgePoints_m |
std::vector< std::vector< int > > | smoothingPoints_m |
PPSolveFactory solves the system of linear equations to interpolate from a grid of points using higher order polynomials, creating a PolynomialPatch object. The order of the polynomial is user-defined.
The PPSolveFactory can be used to match nearby points for smoothing or for straight fitting.
PPSolveFactory generates polynomials on a grid that is at the centre point of each of the mesh squares; PPSolveFactory picks nearby points in a square around the PPSolveFactory, picked by getNearbyPointsSquares. Two sets of points are chosen; the nearest points are used for fitting; smoothing is performed by choosing the points on the edge of the grid, and smoothing to derivatives on these points.
Because we work in a square grid, we have matching polynomials and derivatives; so e.g. 2D points are (0, 0), (1, 0), (0, 1), (1, 1) so corresponding polynomial coefficients that we solve for are x^0 y^0, x^1 y^0, x^0 y^1, x^1 y^1; note that hence we define "first order" to be all terms with no single x/y vector power > 1; i.e. "first order" in x OR first order in y, etc. We allow products so long as the maximum power in any one dimension <= 1
The PPSolveFactory sits on top of SolveFactory; PPSolveFactory has the job of picking values and derivatives for fitting, SolveFactory then does the actual solve for each individual polynomial.
Definition at line 65 of file PPSolveFactory.h.
interpolation::PPSolveFactory::PPSolveFactory | ( | Mesh * | points, |
std::vector< std::vector< double > > | values, | ||
int | polyPatchOrder, | ||
int | smoothingOrder | ||
) |
Constructor
points | Set of points on which values are stored. Must be a rectangular grid. PPSolveFactory takes ownership of points (will delete on exit). The solve will return a wrong answer if the grid does not have regular spacing. |
values | Set of values to which we fit. Must be one value per mesh point and each value must have the same size. |
polyPatchOrder | The order of the fitted part of the polynomial. |
smoothingOrder | The total order of the fitted and the smoothed part of the polynomial. Smoothing order should always be >= polyPatchOrder. So for example if polyPatchOrder is 2 and smoothing order is 2, we get a 2nd order function with no derivative matching. If polyPatchOrder is 2 and smoothing order is 3, we get a 3rd order function with derivative matching in first order at two mesh points from the centre. |
Definition at line 63 of file PPSolveFactory.cpp.
References interpolation::Mesh::dual(), edgePoints_m, interpolation::Mesh::end(), getNearbyPointsSquares(), interpolation::Mesh::getPositionDimension(), polyDim_m, polyMesh_m, polyPatchOrder_m, smoothingPoints_m, and interpolation::Mesh::Iterator::toInteger().
|
inline |
Destructor deletes points_
Definition at line 91 of file PPSolveFactory.h.
|
private |
|
private |
Definition at line 185 of file PPSolveFactory.cpp.
References derivIndices_m, derivOrigins_m, derivPoints_m, derivPolyVec_m, edgePoints_m, interpolation::Mesh::getPositionDimension(), interpolation::SquarePolynomialVector::IndexByPower(), interpolation::SquarePolynomialVector::NumberOfPolynomialCoefficients(), points_m, polyPatchOrder_m, pow(), smoothingOrder_m, and smoothingPoints_m.
Referenced by solve().
|
private |
Definition at line 242 of file PPSolveFactory.cpp.
References derivIndices_m, derivOrigins_m, derivPoints_m, derivPolyVec_m, derivValues_m, interpolation::Mesh::end(), endl(), interpolation::Mesh::Iterator::getMesh(), interpolation::Mesh::Iterator::getPosition(), interpolation::Mesh::Iterator::getState(), polyDim_m, polynomials_m, polyPatchOrder_m, smoothingOrder_m, and interpolation::Mesh::Iterator::toInteger().
Referenced by solve().
|
static |
Get nearby points in a square pattern
Get nearby points at least poly_order_lower distance away and less than poly_order_upper distance away; e.g. getNearbyPointsSquares(2, 4, 6) will get nearby points on a 2D grid at least 4 grid points and at most 6 grid points, like:
x x x o o x ... x x x o o x x x x o o x o o o o o x o o o o o x x x x x x x ...
Definition at line 347 of file PPSolveFactory.cpp.
References nearbyPointsRecursive().
Referenced by getPoints(), getValues(), PPSolveFactory(), and interpolation::SolveFactory::SolveFactory().
|
private |
Definition at line 141 of file PPSolveFactory.cpp.
References getNearbyPointsSquares(), interpolation::Mesh::getPositionDimension(), points_m, polyPatchOrder_m, and thisPoints_m.
Referenced by solve().
|
private |
Definition at line 156 of file PPSolveFactory.cpp.
References interpolation::Mesh::end(), end(), getNearbyPointsSquares(), interpolation::Mesh::Iterator::getState(), points_m, polyPatchOrder_m, thisValues_m, interpolation::Mesh::Iterator::toInteger(), and values_m.
Referenced by solve().
|
staticprivate |
Definition at line 330 of file PPSolveFactory.cpp.
Referenced by getNearbyPointsSquares().
|
private |
Definition at line 116 of file PPSolveFactory.cpp.
References interpolation::Mesh::begin(), interpolation::Mesh::end(), end(), interpolation::Mesh::Iterator::getMesh(), interpolation::Mesh::Iterator::getPosition(), and interpolation::Mesh::Iterator::getState().
PolynomialPatch * interpolation::PPSolveFactory::solve | ( | ) |
Solve the system of equations to generate a PolynomialPatch object.
Returns a PolynomialPatch object, caller owns the returned memory.
Definition at line 296 of file PPSolveFactory.cpp.
References interpolation::Mesh::begin(), begin(), derivIndices_m, derivPoints_m, derivValues_m, interpolation::Mesh::end(), end(), endl(), getDerivPoints(), getDerivs(), getPoints(), interpolation::Mesh::getPositionDimension(), getValues(), gmsg, points_m, polyDim_m, polyMesh_m, polynomials_m, interpolation::SolveFactory::PolynomialSolve(), smoothingOrder_m, thisPoints_m, thisValues_m, and interpolation::Mesh::Iterator::toInteger().
Referenced by SectorMagneticFieldMap::IO::getInterpolatorPolyPatch().
|
private |
Definition at line 151 of file PPSolveFactory.h.
Referenced by getDerivPoints(), getDerivs(), and solve().
|
private |
Definition at line 150 of file PPSolveFactory.h.
Referenced by getDerivPoints(), and getDerivs().
|
private |
Definition at line 148 of file PPSolveFactory.h.
Referenced by getDerivPoints(), getDerivs(), and solve().
|
private |
Definition at line 152 of file PPSolveFactory.h.
Referenced by getDerivPoints(), and getDerivs().
|
private |
Definition at line 149 of file PPSolveFactory.h.
Referenced by getDerivs(), and solve().
|
private |
Definition at line 154 of file PPSolveFactory.h.
Referenced by getDerivPoints(), and PPSolveFactory().
|
private |
Definition at line 142 of file PPSolveFactory.h.
Referenced by getDerivPoints(), getPoints(), getValues(), and solve().
|
private |
Definition at line 139 of file PPSolveFactory.h.
Referenced by getDerivs(), PPSolveFactory(), and solve().
|
private |
Definition at line 141 of file PPSolveFactory.h.
Referenced by PPSolveFactory(), and solve().
|
private |
Definition at line 144 of file PPSolveFactory.h.
Referenced by getDerivs(), and solve().
|
private |
Definition at line 137 of file PPSolveFactory.h.
Referenced by getDerivPoints(), getDerivs(), getPoints(), getValues(), and PPSolveFactory().
|
private |
Definition at line 138 of file PPSolveFactory.h.
Referenced by getDerivPoints(), getDerivs(), and solve().
|
private |
Definition at line 155 of file PPSolveFactory.h.
Referenced by getDerivPoints(), and PPSolveFactory().
|
private |
Definition at line 146 of file PPSolveFactory.h.
Referenced by getPoints(), and solve().
|
private |
Definition at line 147 of file PPSolveFactory.h.
Referenced by getValues(), and solve().
|
private |
Definition at line 140 of file PPSolveFactory.h.
|
private |
Definition at line 143 of file PPSolveFactory.h.
Referenced by getValues().