Loading [MathJax]/jax/input/TeX/config.js
MeshKernel
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages Concepts
OrthogonalizationAndSmoothing.hpp
1//---- GPL ---------------------------------------------------------------------
2//
3// Copyright (C) Stichting Deltares, 2011-2021.
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/Definitions.hpp>
31#include <MeshKernel/LandBoundaries.hpp>
32#include <MeshKernel/Orthogonalizer.hpp>
33#include <MeshKernel/Parameters.hpp>
34#include <MeshKernel/Smoother.hpp>
35#include <MeshKernel/UndoActions/UndoAction.hpp>
36
37namespace meshkernel
38{
39 // Forward declare everything to reduce compile time dependency
40 class Point;
41 class Mesh2D;
42 class Polygons;
43 enum class Projection;
44
83 {
84
85 public:
93 std::unique_ptr<Polygons> polygon,
94 std::unique_ptr<LandBoundaries> landBoundaries,
95 LandBoundaries::ProjectToLandBoundaryOption projectToLandBoundaryOption,
96 const OrthogonalizationParameters& orthogonalizationParameters);
97
99 [[nodiscard]] std::unique_ptr<UndoAction> Initialize();
100
102 void Compute();
103
106
108 void Solve();
109
112
113 private:
115 MeshNodeType GetNodeType(const UInt nodeId) const { return m_nodesTypes[nodeId]; }
116
118 void FindNeighbouringBoundaryNodes(const UInt nodeId,
119 const UInt nearestPointIndex,
120 UInt& leftNode,
121 UInt& rightNode) const;
122
124 void SnapMeshToOriginalMeshBoundary();
125
127 void ComputeLinearSystemTerms();
128
134 void ComputeLocalIncrements(UInt nodeIndex,
135 double& dx0,
136 double& dy0,
137 std::array<double, 2>& weightsSum);
138
141 void UpdateNodeCoordinates(UInt nodeIndex);
142
144 void AllocateLinearSystem();
145
147 void ComputeCoordinates() const;
148
149 std::vector<std::vector<UInt>> m_nodesNodes;
150 std::vector<MeshNodeType> m_nodesTypes;
151
152 Mesh2D& m_mesh;
153 Smoother m_smoother;
154 Orthogonalizer m_orthogonalizer;
155 std::unique_ptr<Polygons> m_polygons;
156 std::unique_ptr<LandBoundaries> m_landBoundaries;
157 LandBoundaries::ProjectToLandBoundaryOption m_projectToLandBoundaryOption;
158 OrthogonalizationParameters m_orthogonalizationParameters;
159
160 std::vector<UInt> m_localCoordinatesIndices;
161 std::vector<Point> m_localCoordinates;
162 std::vector<Point> m_orthogonalCoordinates;
163 std::vector<Point> m_originalNodes;
164
165 // Linear system terms
166 std::vector<UInt> m_compressedEndNodeIndex;
167 std::vector<UInt> m_compressedStartNodeIndex;
168 std::vector<double> m_compressedWeightX;
169 std::vector<double> m_compressedWeightY;
170 std::vector<double> m_compressedRhs;
171 std::vector<UInt> m_compressedNodesNodes;
172
173 // run-time parameters
174 double m_mumax = 0.0;
175 double m_mu = 0.0;
176 };
177} // namespace meshkernel
ProjectToLandBoundaryOption
Enumerator describing the options how to project to the land boundary.
Definition LandBoundaries.hpp:55
A class derived from Mesh, which describes unstructures 2d meshes.
Definition Mesh2D.hpp:58
Orthogonalizion (optimize the aspect ratios) and mesh smoothing (optimize internal face angles or are...
Definition OrthogonalizationAndSmoothing.hpp:83
void Compute()
Executes the entire algorithm.
std::unique_ptr< UndoAction > Initialize()
Initializes the object.
OrthogonalizationAndSmoothing(Mesh2D &mesh, std::unique_ptr< Polygons > polygon, std::unique_ptr< LandBoundaries > landBoundaries, LandBoundaries::ProjectToLandBoundaryOption projectToLandBoundaryOption, const OrthogonalizationParameters &orthogonalizationParameters)
void FinalizeOuterIteration()
Finalize the outer iteration, computes new mu and face areas, masscenters, circumcenters.
void Solve()
Performs an inner iteration, update the mesh node positions.
void PrepareOuterIteration()
Prepares the outer iteration, calculates orthogonalizer and smoother coefficients and assable the lin...
Orthogonalizion (optimize the aspect ratios) and mesh smoothing (optimize internal face angles or are...
Definition Orthogonalizer.hpp:42
Orthogonalizion (optimize the aspect ratios) and mesh smoothing (optimize internal face angles or are...
Definition Smoother.hpp:43
Contains the logic of the C++ static library.
Definition AveragingInterpolation.hpp:37
Projection
Enumerator describing the supported projections.
Definition Definitions.hpp:43
MeshNodeType
Possible unstructured node types.
Definition Definitions.hpp:148
std::uint32_t UInt
Integer type used when indexing mesh graph entities.
Definition Definitions.hpp:39
A struct used to describe the orthogonalization parameters in a C-compatible manner.
Definition Parameters.hpp:238