Loading [MathJax]/extensions/tex2jax.js
MeshKernel
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages Concepts
SplineAlgorithms.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 <memory>
31
32#include "MeshKernel/Constants.hpp"
33#include "MeshKernel/Entities.hpp"
34#include "MeshKernel/LandBoundary.hpp"
35#include "MeshKernel/Utilities/LinearAlgebra.hpp"
36
37namespace meshkernel
38{
39
42 {
43 public:
49 [[nodiscard]] static std::vector<Point> SecondOrderDerivative(const std::vector<Point>& splines, size_t startIndex, size_t endIndex);
50
56 [[nodiscard]] static std::vector<double> SecondOrderDerivative(const std::vector<double>& coordinates, size_t startIndex, size_t endIndex);
57
64 static std::tuple<Point, Point, double>
65 ComputeCurvatureOnSplinePoint(const std::vector<Point>& splinePoints,
66 const std::vector<Point>& splineDerivative,
67 double adimensionalPointCoordinate,
68 const Projection projection);
69
76 static Point Evaluate(const std::vector<Point>& coordinates, const std::vector<Point>& secondDerivative, const double evaluationPoint);
77
86 static void SnapSplineToBoundary(std::vector<Point>& splinePoints,
87 const std::vector<Point>& splineDerivative,
88 const LandBoundary& landBoundary,
89 const Projection projection,
90 const int numberOfIterations = constants::numeric::defaultSnappingIterations);
91
92 private:
99 static lin_alg::ColVector<double> ComputeSplineWeights(const lin_alg::ColVector<double>& xf,
100 const lin_alg::ColVector<double>& yf,
101 const Projection projection);
107 static std::tuple<lin_alg::ColVector<double>, lin_alg::ColVector<double>> ComputeSamplePoints(const std::vector<Point>& splinePoints,
108 const lin_alg::Matrix<double, Eigen::ColMajor>& aMatrix);
109
116 static void SampleSpline(const std::vector<Point>& splinePoints,
117 const size_t intermediatePointCount,
118 std::vector<Point>& samplePoints);
119
126 static void ComputeInterpolationMatrix(const Eigen::Index numberOfSplinePoints,
127 const Eigen::Index intervalRefinement,
128 Eigen::Index& numberOfSamplePoints,
129 lin_alg::Matrix<double, Eigen::ColMajor>& interpolationMatrix);
130
137 static lin_alg::Matrix<double, Eigen::ColMajor> ComputeLeastSquaresMatrixInverse(const lin_alg::Matrix<double, Eigen::ColMajor>& splineCoefficients,
138 const lin_alg::ColVector<double>& weights);
139 };
140
141} // namespace meshkernel
A class containing the land boundary polylines.
Definition LandBoundary.hpp:40
A struct describing a point in a two-dimensional space.
Definition Point.hpp:41
Provide algorithms operating on splines.
Definition SplineAlgorithms.hpp:42
static std::vector< double > SecondOrderDerivative(const std::vector< double > &coordinates, size_t startIndex, size_t endIndex)
Second order derivative at spline corner point coordinates (splint)
static std::tuple< Point, Point, double > ComputeCurvatureOnSplinePoint(const std::vector< Point > &splinePoints, const std::vector< Point > &splineDerivative, double adimensionalPointCoordinate, const Projection projection)
Computes curvature in a spline point (comp_curv)
static void SnapSplineToBoundary(std::vector< Point > &splinePoints, const std::vector< Point > &splineDerivative, const LandBoundary &landBoundary, const Projection projection, const int numberOfIterations=constants::numeric::defaultSnappingIterations)
Snap the spline to the land boundary (snap_spline)
static Point Evaluate(const std::vector< Point > &coordinates, const std::vector< Point > &secondDerivative, const double evaluationPoint)
Evaluate a spline function (splint)
static std::vector< Point > SecondOrderDerivative(const std::vector< Point > &splines, size_t startIndex, size_t endIndex)
Second order derivative at spline corner points, from the start node to the end node of the spline (s...
Contains the logic of the C++ static library.
Definition AveragingInterpolation.hpp:37
Projection
Enumerator describing the supported projections.
Definition Definitions.hpp:43