67 static constexpr double EdgeLengthTolerance = 1.0e-10;
70 static constexpr UInt m_maximumNumberOfIrregularElementsAlongEdge = 5;
73 enum class MergeIndicator
81 using BoundedIntegerArray = std::array<UInt, m_maximumNumberOfIrregularElementsAlongEdge>;
84 using NodesToMerge = std::pair<UInt, UInt>;
87 struct IrregularEdgeInfo
90 BoundedIntegerArray hangingNodes{constants::missing::uintValue,
91 constants::missing::uintValue,
92 constants::missing::uintValue,
93 constants::missing::uintValue,
94 constants::missing::uintValue};
98 UInt startNode = constants::missing::uintValue;
100 UInt endNode = constants::missing::uintValue;
104 using IrregularEdgeInfoArray = std::vector<IrregularEdgeInfo>;
116 static void AreEdgesAdjacent(
const Mesh2D& mesh,
117 const double separationFraction,
123 const std::vector<double>& edgeLengths);
131 static void GetQuadrilateralElementsOnDomainBoundary(
const Mesh2D& mesh,
132 std::vector<UInt>& elementsOnDomainBoundary,
133 std::vector<UInt>& edgesOnDomainBoundary,
134 std::vector<double>& edgeLengths);
143 static void GetOrderedDistanceFromPoint(
const Mesh2D& mesh,
144 const std::vector<UInt>& nodeIndices,
145 const UInt numberOfNodes,
147 BoundedIntegerArray& nearestNeighbours);
154 static std::unique_ptr<meshkernel::UndoAction> MergeNodes(Mesh2D& mesh,
const std::vector<NodesToMerge>& nodesToMerge, std::vector<MergeIndicator>& mergeIndicator);
162 [[nodiscard]]
static std::unique_ptr<meshkernel::UndoAction> FreeOneHangingNode(Mesh2D& mesh,
163 const BoundedIntegerArray& hangingNodes,
164 const UInt startNode,
175 [[nodiscard]]
static std::unique_ptr<meshkernel::UndoAction> FreeTwoHangingNodes(Mesh2D& mesh,
178 const BoundedIntegerArray& hangingNodes,
179 const UInt startNode,
190 [[nodiscard]]
static std::unique_ptr<meshkernel::UndoAction> FreeThreeHangingNodes(Mesh2D& mesh,
193 const BoundedIntegerArray& hangingNodes,
194 const UInt startNode,
205 [[nodiscard]]
static std::unique_ptr<meshkernel::UndoAction> FreeFourHangingNodes(Mesh2D& mesh,
208 const BoundedIntegerArray& hangingNodes,
209 const UInt startNode,
221 [[nodiscard]]
static std::unique_ptr<meshkernel::UndoAction> FreeHangingNodes(Mesh2D& mesh,
222 const UInt numberOfHangingNodes,
223 const std::vector<UInt>& hangingNodesOnEdge,
225 const Edge& boundaryEdge,
226 const Point& boundaryNode,
236 static void GatherHangingNodeIds(
const Mesh2D& mesh,
237 const double separationFraction,
238 const std::vector<UInt>& edgesOnDomainBoundary,
239 const std::vector<double>& edgeLengths,
240 IrregularEdgeInfoArray& irregularEdges);
251 static void GatherNodesToMerge(
const UInt startNode,
253 const Edge& boundaryEdge,
254 std::vector<NodesToMerge>& nodesToMerge,
255 std::vector<MergeIndicator>& mergeIndicator);
265 static void GatherHangingNodes(
const UInt primaryStartNode,
266 const UInt primaryEndNode,
267 const Edge& irregularEdge,
268 std::vector<UInt>& hangingNodesOnEdge,
269 UInt& numberOfHangingNodes,
270 std::vector<MergeIndicator>& mergeIndicator);