Loading [MathJax]/extensions/tex2jax.js
MeshKernel
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages Concepts
AveragingInterpolation.hpp
1//---- GPL ---------------------------------------------------------------------
2//
3// Copyright (C) Stichting Deltares, 2011-2023.
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation version 3.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16//
17// contact: delft3d.support@deltares.nl
18// Stichting Deltares
19// P.O. Box 177
20// 2600 MH Delft, The Netherlands
21//
22// All indications and logos of, and references to, "Delft3D" and "Deltares"
23// are registered trademarks of Stichting Deltares, and remain the property of
24// Stichting Deltares. All rights reserved.
25//
26//------------------------------------------------------------------------------
27
28#pragma once
29
30#include "MeshKernel/AveragingStrategies/AveragingStrategy.hpp"
31#include "MeshKernel/Definitions.hpp"
32#include "MeshKernel/Mesh2D.hpp"
33#include "MeshKernel/MeshInterpolation.hpp"
34#include "MeshKernel/Utilities/RTreeBase.hpp"
35
36namespace meshkernel
37{
38 // Forward declarations
39 class Mesh;
40 class Sample;
41
76 {
77 public:
79 enum class Method
80 {
81 SimpleAveraging = 1,
82 Closest = 2,
83 Max = 3,
84 Min = 4,
86 MinAbsValue = 6
87 };
88
99 std::vector<Sample>& samples,
100 Method method,
101 Location locationType,
102 double relativeSearchRadius,
103 bool useClosestSampleIfNoneAvailable,
104 bool subtractSampleValues,
105 UInt minNumSamples);
106
108 void Compute() override;
109
110 private:
112 static constexpr UInt DefaultMaximumCacheSize = 100;
113
118 double ComputeOnPolygon(const std::vector<Point>& polygon,
119 const Point& interpolationPoint);
120
122 void DecreaseValueOfSamples();
123
128 [[nodiscard]] std::vector<Point> GetSearchPolygon(std::vector<Point> const& polygon, Point const& interpolationPoint) const;
129
134 [[nodiscard]] double ComputeInterpolationResultFromNeighbors(const Point& interpolationPoint, std::vector<Point> const& searchPolygon);
135
139 [[nodiscard]] double GetSampleValueFromRTree(UInt index);
140
145 [[nodiscard]] double GetSearchRadiusSquared(std::vector<Point> const& searchPolygon,
146 Point const& interpolationPoint) const;
147
148 Mesh2D& m_mesh;
149 std::vector<Sample>& m_samples;
150 Location m_interpolationLocation;
151 double m_relativeSearchRadius;
152 bool m_useClosestSampleIfNoneAvailable = false;
153 bool m_transformSamples = false;
154 std::vector<Sample> m_interpolationSampleCache;
155
156 std::unique_ptr<RTreeBase> m_samplesRtree;
157 std::unique_ptr<averaging::AveragingStrategy> m_strategy;
158 };
159} // namespace meshkernel
The class used to interpolate based on averaging.
Definition AveragingInterpolation.hpp:76
Method
Averaging methods.
Definition AveragingInterpolation.hpp:80
@ Closest
Takes the value of the closest sample to the interpolation location.
@ Max
Takes the maximum sample value.
@ MinAbsValue
Computes the minimum absolute value.
@ SimpleAveraging
Computes a simple mean.
@ Min
Takes the minimum sample value.
@ InverseWeightedDistance
Computes the inverse weighted sample mean.
void Compute() override
Compute interpolation.
AveragingInterpolation(Mesh2D &mesh, std::vector< Sample > &samples, Method method, Location locationType, double relativeSearchRadius, bool useClosestSampleIfNoneAvailable, bool subtractSampleValues, UInt minNumSamples)
Interpolation based on averaging.
A class derived from Mesh, which describes unstructures 2d meshes.
Definition Mesh2D.hpp:58
A class describing an unstructured mesh. This class contains the shared functionality between 1d or 2...
Definition Mesh.hpp:99
Interface for interpolation methods.
Definition MeshInterpolation.hpp:43
A struct describing a point in a two-dimensional space.
Definition Point.hpp:41
A struct describing a sample with two coordinates and a value.
Definition Entities.hpp:102
Contains the logic of the C++ static library.
Definition AveragingInterpolation.hpp:37
Location
Mesh locations enumeration.
Definition Definitions.hpp:76
std::uint32_t UInt
Integer type used when indexing mesh graph entities.
Definition Definitions.hpp:39