MeshKernel
Contacts.hpp
1 //---- GPL ---------------------------------------------------------------------
2 //
3 // Copyright (C) Stichting Deltares, 2011-2020.
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/Mesh1D.hpp>
31 #include <MeshKernel/Mesh2D.hpp>
32 
35 namespace meshkernel
36 {
42  class Contacts
43  {
44  public:
48  Contacts(Mesh1D& mesh1d, Mesh2D& mesh2d);
49 
70  void ComputeSingleContacts(const std::vector<bool>& oneDNodeMask, const Polygons& polygons, double projectionFactor);
71 
88  void ComputeMultipleContacts(const std::vector<bool>& oneDNodeMask);
89 
100  void ComputeContactsWithPolygons(const std::vector<bool>& oneDNodeMask, const Polygons& polygons);
101 
111  void ComputeContactsWithPoints(const std::vector<bool>& oneDNodeMask, const std::vector<Point>& points);
112 
126  void ComputeBoundaryContacts(const std::vector<bool>& oneDNodeMask,
127  const Polygons& polygons,
128  double searchRadius);
129 
132  std::vector<UInt> const& Mesh1dIndices() const { return m_mesh1dIndices; }
133 
136  std::vector<UInt> const& Mesh2dIndices() const { return m_mesh2dIndices; }
137 
141  void SetIndices(const std::vector<meshkernel::UInt>& mesh1dIndices,
142  const std::vector<meshkernel::UInt>& mesh2dIndices);
143 
146  [[nodiscard]] bool AreComputed() const { return m_areComputed; }
147 
148  private:
153  [[nodiscard]] bool IsContactIntersectingMesh1d(UInt node, UInt face) const;
154 
159  [[nodiscard]] bool IsContactIntersectingContact(UInt node, UInt face) const;
160 
164  void Connect1dNodesWithCrossingFaces(UInt node,
165  double projectionFactor);
166 
168  void Validate() const;
169 
170  Mesh1D& m_mesh1d;
171  Mesh2D& m_mesh2d;
172  std::vector<UInt> m_mesh1dIndices;
173  std::vector<UInt> m_mesh2dIndices;
174  bool m_areComputed = false;
175  };
176 } // namespace meshkernel
meshkernel::Contacts::ComputeContactsWithPolygons
void ComputeContactsWithPolygons(const std::vector< bool > &oneDNodeMask, const Polygons &polygons)
Computes 1d-2d contacts, where a 2d face per polygon is connected to the closest 1d node (ggeo_make1D...
meshkernel::Contacts
A class describing an 1d-2d contacts.
Definition: Contacts.hpp:42
meshkernel::Contacts::Mesh1dIndices
std::vector< UInt > const & Mesh1dIndices() const
Gets the 1d mesh indices.
Definition: Contacts.hpp:132
meshkernel::Mesh2D
A class derived from Mesh, which describes unstructures 2d meshes.
Definition: Mesh2D.hpp:55
meshkernel::Mesh1D
A class derived from Mesh, which describes 1d meshes.
Definition: Mesh1D.hpp:42
meshkernel::Contacts::ComputeBoundaryContacts
void ComputeBoundaryContacts(const std::vector< bool > &oneDNodeMask, const Polygons &polygons, double searchRadius)
Computes 1d-2d contacts, where 1d nodes are connected to the closest 2d faces at the boundary (ggeo_m...
meshkernel::Contacts::Contacts
Contacts(Mesh1D &mesh1d, Mesh2D &mesh2d)
Constructor taking the 1d and 2d meshes to connect.
meshkernel::Contacts::ComputeSingleContacts
void ComputeSingleContacts(const std::vector< bool > &oneDNodeMask, const Polygons &polygons, double projectionFactor)
Computes 1d-2d contacts, where every single 1d node is connected to one 2d face circumcenter (ggeo_ma...
meshkernel::Contacts::AreComputed
bool AreComputed() const
checks whether contacts have been computed
Definition: Contacts.hpp:146
meshkernel::Contacts::Mesh2dIndices
std::vector< UInt > const & Mesh2dIndices() const
Gets the 2d mesh indices.
Definition: Contacts.hpp:136
meshkernel
Contains the logic of the C++ static library.
Definition: AveragingInterpolation.hpp:36
meshkernel::Contacts::ComputeMultipleContacts
void ComputeMultipleContacts(const std::vector< bool > &oneDNodeMask)
Computes 1d-2d contacts, where a single 1d node is connected to multiple 2d face circumcenters (ggeo_...
meshkernel::UInt
std::uint32_t UInt
Integer type used when indexing mesh graph entities.
Definition: Definitions.hpp:38
meshkernel::Contacts::ComputeContactsWithPoints
void ComputeContactsWithPoints(const std::vector< bool > &oneDNodeMask, const std::vector< Point > &points)
Computes 1d-2d contacts, where 1d nodes are connected to the 2d faces mass centers containing the inp...
meshkernel::Polygons
A class containing a list of polygonaly enclosed regions.
Definition: Polygons.hpp:44
meshkernel::Contacts::SetIndices
void SetIndices(const std::vector< meshkernel::UInt > &mesh1dIndices, const std::vector< meshkernel::UInt > &mesh2dIndices)
Sets the 1d and 2d mesh indices.