Peano
Loading...
Searching...
No Matches
interpolation.h
Go to the documentation of this file.
1#ifndef APPARENT_HORIZON_FINDER_INTERPOLATION_H_
2#define APPARENT_HORIZON_FINDER_INTERPOLATION_H_
3
4#include "ahf-data.h"
5
6#include <limits>
7#include <memory>
8#include <span>
9#include <vector>
10
11namespace exahype2::ccz4::ahf {
12
20 const AHGuessPoint& surfacePoint,
21 const ReferencePoint& referencePoint
22);
23
27 std::array<Vector3, 2> gradient{};
29 std::array<Tensor3, 2> hessian{};
30};
31
34
42 const GridCoordinate& globalCoordinate,
43 const ReferencePoint& referencePoint
44);
45
55std::vector<std::size_t> FindNearestGridCellsBruteForce(
56 const GridData& gridData,
57 const GridCoordinate& target,
58 std::size_t neighbourCount
59);
60
63public:
64 explicit CartesianSpatialIndex(const GridData& gridData);
65 std::vector<std::size_t> findNearest(
66 const GridCoordinate& target,
67 std::size_t neighbourCount
68 ) const;
70 std::vector<std::size_t> findWithinRadius(
71 const GridCoordinate& target,
72 double radius
73 ) const;
74 std::size_t size() const;
75
76private:
77 struct Implementation;
78 std::shared_ptr<const Implementation> _implementation;
79};
80
82std::vector<std::size_t> FindNearestGridCells(
83 const CartesianSpatialIndex& spatialIndex,
84 const GridCoordinate& target,
85 std::size_t neighbourCount
86);
87
89std::vector<std::size_t> FindGridCellsWithinRadius(
90 const CartesianSpatialIndex& spatialIndex,
91 const GridCoordinate& target,
92 double radius
93);
94
99std::vector<std::size_t> FindNearestGridCells(
100 const GridData& gridData,
101 const GridCoordinate& target,
102 std::size_t neighbourCount
103);
104
106 double value = 0.0;
108 double lengthScale = 0.0;
109};
110
112 std::size_t x = 0;
113 std::size_t y = 0;
114 std::size_t z = 0;
115
116 bool operator==(const PolynomialExponent&) const = default;
117};
118
120 static constexpr std::size_t NoTerm = std::numeric_limits<std::size_t>::max();
121 std::vector<PolynomialExponent> terms;
122 std::size_t constant = 0;
123 std::size_t linearX = NoTerm;
124 std::size_t linearY = NoTerm;
125 std::size_t linearZ = NoTerm;
126};
127
128std::size_t PolynomialBasisSize(std::size_t degree);
130
136
154
157 double distance,
158 double lengthScale,
159 const LinearReconstructionOptions& options
160);
161
163double WendlandC2Weight(double q);
164
181 std::span<const GridCoordinate> sampleCoordinates,
182 std::span<const double> sampleValues,
183 const GridCoordinate& target,
184 const LinearReconstructionOptions& options = {}
185);
186
188 std::array<double, NumberOfCompactFields> values{};
189 std::array<Vector3, NumberOfCompactFields> gradients{};
190 std::size_t numberOfNeighbours = 0;
191 std::size_t polynomialDegree = 1;
192 std::size_t rank = 0;
193 double lengthScale = 0.0;
195 double conditionEstimate = 1.0;
196};
197
204 const GridData& gridData,
205 std::span<const std::size_t> neighbourIndices,
206 const GridCoordinate& target,
207 const LinearReconstructionOptions& options = {}
208);
209
222
229
237public:
239 const GridData& gridData,
240 const CartesianToSurfaceOptions& options = {}
241 );
242
250 bool coversTarget(const GridCoordinate& target) const;
251
255
258 std::span<const GridCoordinate> targets,
259 std::vector<InterpolatedCartesianPoint>& output
260 ) const;
261
262private:
268 double _domainDiagonal = 0.0;
269};
270
273 const CartesianPointInterpolator& interpolator,
274 const AHGuess& ahGuess,
275 const ReferencePoint& referencePoint,
276 InterpolatedSurface& interpolatedSurface
277);
278
288 const GridData& gridData,
289 const AHGuess& ahGuess,
290 const ReferencePoint& referencePoint,
291 InterpolatedSurface& interpolatedSurface,
292 const CartesianToSurfaceOptions& options = {}
293);
294
304 const GridData& gridData,
305 const AHGuess& ahGuess,
306 const ReferencePoint& referencePoint,
307 InterpolatedSurface& interpolatedSurface
308);
309
314 const AHGuess& ahGuess,
315 const ReferencePoint& referencePoint,
316 InterpolatedShell& interpolatedShell,
317 std::span<const AngularSample> angularSamples = {});
318
323 const AHGuess& ahGuess,
324 const ReferencePoint& referencePoint,
325 InterpolatedSurface& interpolatedSurface);
326
327} // namespace exahype2::ccz4::ahf
328
329#endif // APPARENT_HORIZON_FINDER_INTERPOLATION_H_
Reusable Cartesian reconstruction context.
bool coversTarget(const GridCoordinate &target) const
True when target lies inside the sampled Cartesian domain, widened by the configured domainRelativeTo...
CartesianPointInterpolator(const GridData &gridData, const CartesianToSurfaceOptions &options={})
GridCoordinate domainMinimum() const
Corner-to-corner extent of the sampled domain, for diagnostics.
void interpolatePoints(std::span< const GridCoordinate > targets, std::vector< InterpolatedCartesianPoint > &output) const
Reconstruct physical fields in exactly the order of targets.
Immutable k-d tree; concurrent nearest-neighbour queries are read-only.
std::vector< std::size_t > findNearest(const GridCoordinate &target, std::size_t neighbourCount) const
CartesianSpatialIndex(const GridData &gridData)
std::vector< std::size_t > findWithinRadius(const GridCoordinate &target, double radius) const
Return all cells with Euclidean distance strictly less than radius.
std::shared_ptr< const Implementation > _implementation
std::vector< std::size_t > FindNearestGridCells(const CartesianSpatialIndex &spatialIndex, const GridCoordinate &target, std::size_t neighbourCount)
Query a previously built index without rebuilding it.
void InterpolateFromShellToSurface(const InterpolatedShell &interpolatedShell, const AHGuess &ahGuess, const ReferencePoint &referencePoint, InterpolatedSurface &interpolatedSurface)
Interpolate the shell data to the apparent-horizon surface defined by the current AH guess.
std::size_t PolynomialBasisSize(std::size_t degree)
void InterpolateCartesianToSurface(const CartesianPointInterpolator &interpolator, const AHGuess &ahGuess, const ReferencePoint &referencePoint, InterpolatedSurface &interpolatedSurface)
Surface adapter using an already-built, persistent Cartesian interpolator.
GridCoordinate SurfacePointToCartesian(const AHGuessPoint &surfacePoint, const ReferencePoint &referencePoint)
Convert one AH point (r, longitude rho, latitude sigma) into its global Cartesian target coordinate r...
CompactLinearFit FitCompactLinearPolynomial(const GridData &gridData, std::span< const std::size_t > neighbourIndices, const GridCoordinate &target, const LinearReconstructionOptions &options={})
Reconstruct all fourteen compact fields with one shared polynomial design matrix and one column-pivot...
double WendlandC2Weight(double q)
Wendland C2 compact kernel: (1-q)^4(4q+1) for 0<=q<1, else zero.
Tensor3 ComputeRadialProjectionTensor(const GridCoordinate &relativeCoordinate)
Compute T_ij = r^2 delta_ij - x_i x_j from relative coordinates.
std::array< double, 3 > Vector3
Definition ahf-data.h:518
PolynomialBasis GeneratePolynomialBasis(std::size_t degree)
double LinearReconstructionWeight(double distance, double lengthScale, const LinearReconstructionOptions &options)
Evaluate the configured unweighted, Gaussian, or compact-support row weight.
LinearPolynomialFit FitLinearPolynomial(std::span< const GridCoordinate > sampleCoordinates, std::span< const double > sampleValues, const GridCoordinate &target, const LinearReconstructionOptions &options={})
Scalar total-degree polynomial least-squares reconstruction using a column-pivoted QR solve.
void InterpolateToSurfaceNearestNeighbour(const GridData &gridData, const AHGuess &ahGuess, const ReferencePoint &referencePoint, InterpolatedSurface &interpolatedSurface)
Sample each AH surface point from its nearest Cartesian cell centre and reconstruct the physical spat...
void InterpolateFromCartesianToShell(const GridData &gridData, const AHGuess &ahGuess, const ReferencePoint &referencePoint, InterpolatedShell &interpolatedShell, std::span< const AngularSample > angularSamples={})
Interpolate the Cartesian grid data to a shell-like subdomain around the current AH guess.
std::array< std::array< double, 3 >, 3 > Tensor3
Definition ahf-data.h:519
std::vector< std::size_t > FindGridCellsWithinRadius(const CartesianSpatialIndex &spatialIndex, const GridCoordinate &target, double radius)
Query every indexed cell strictly inside radius, sorted by distance/index.
AnalyticCoordinateGeometry ComputeAnalyticCoordinateGeometry(const GridCoordinate &globalCoordinate, const ReferencePoint &referencePoint)
Compute the appendix's analytic rho/sigma coordinate geometry.
std::vector< std::size_t > FindNearestGridCellsBruteForce(const GridData &gridData, const GridCoordinate &target, std::size_t neighbourCount)
Return the indices of the neighbourCount nearest Cartesian cell centres.
One point on an apparent-horizon guess, expressed in spherical coordinates.
Definition ahf-data.h:29
One apparent-horizon hypersurface guess.
Definition ahf-data.h:48
std::array< Vector3, 2 > gradient
[u][i], with u=0 for rho, u=1 for sigma, and i=x,y,z.
std::array< Tensor3, 2 > hessian
[u][i][j] = partial_i partial_j u, with u=0 rho and u=1 sigma.
double supportRadius
Used only by RadiusWeightedPolynomial; must be finite and positive.
double domainRelativeTolerance
Allowed distance outside the grid AABB as a fraction of its diagonal.
std::array< Vector3, NumberOfCompactFields > gradients
std::array< double, NumberOfCompactFields > values
double conditionEstimate
Approximate max/min absolute diagonal ratio of the pivoted R factor.
Cartesian coordinate for one sampled grid point.
Definition ahf-data.h:55
Pointwise Cartesian grid data.
Definition ahf-data.h:429
Physical fields reconstructed at one arbitrary Cartesian target.
Physical and geometrical quantities shared by shell and surface samples.
Definition ahf-data.h:627
Interpolated data on the shell-like subdomain around an AH guess.
Definition ahf-data.h:656
Interpolated data on the current AH surface r = h(rho, sigma).
Definition ahf-data.h:750
double rankToleranceMultiplier
Multiplier applied to epsilon*n*largest-column-norm for rank detection.
std::size_t numberOfNeighbours
Zero uses every supplied sample; otherwise use the first requested samples.
double weightSupport
Gaussian support alpha in exp(-(distance/(alpha*ell))^2).
double supportRadius
Physical compact-support radius for RadiusWeightedWendlandC2.
std::size_t polynomialDegree
Supported reconstruction degree, currently 0 through 3.
std::vector< PolynomialExponent > terms
static constexpr std::size_t NoTerm
bool operator==(const PolynomialExponent &) const =default
Cartesian reference coordinate for one apparent-horizon centre point.
Definition ahf-data.h:20