30 #include <MeshKernel/AveragingInterpolation.hpp>
31 #include <MeshKernel/Parameters.hpp>
32 #include <MeshKernel/Polygons.hpp>
33 #include <MeshKernel/Utilities/RTreeBase.hpp>
77 enum class FaceLocation
98 std::unique_ptr<MeshInterpolation> interpolant,
107 std::unique_ptr<MeshInterpolation> interpolant,
109 bool useNodalRefinement);
132 [[nodiscard]] std::unique_ptr<UndoAction>
Compute();
136 void FindBrotherEdges();
140 void ComputeNodeMaskAtPolygonPerimeter();
143 void ComputeRefinementMasksFromSamples();
146 void ComputeRefinementMaskFromEdgeSize();
149 void ComputeRefinementMasksForRefinementLevels(
UInt face,
150 size_t& numberOfEdgesToRefine,
151 std::vector<UInt>& edgeToRefine)
const;
154 bool DetermineRequiredRefinement(
const UInt face,
155 const UInt edge)
const;
158 void ResetNumberOfEdgesToRefineForFace(
const UInt face,
159 const std::vector<UInt>& edgeToRefine,
160 size_t& numberOfEdgesToRefine)
const;
163 void DetermineEdgesToRefine(
const UInt face,
164 std::vector<UInt>& edgeToRefine,
165 size_t& numberOfEdgesToRefine)
const;
168 void ComputeRefinementMasksForWaveCourant(
UInt face,
169 size_t& numberOfEdgesToRefine,
170 std::vector<UInt>& edgeToRefine);
173 void ComputeRefinementMasksForRidgeDetection(
UInt face,
174 size_t& numberOfEdgesToRefine,
175 std::vector<UInt>& edgeToRefine)
const;
180 void ComputeRefinementMasksFromSamples(
UInt face);
183 void ComputeEdgesRefinementMask();
187 void FindHangingNodes(
UInt face);
191 UInt CountHangingNodes()
const;
195 UInt CountHangingEdges()
const;
200 UInt CountEdgesToRefine(
UInt face)
const;
203 void UpdateFaceMask(
const int level);
206 [[nodiscard]]
UInt DeleteIsolatedHangingnodes();
212 void ConnectOneHangingNodeForQuadrilateral(
const UInt numNonHangingNodes,
213 const std::vector<UInt>& edgeEndNodeCache,
214 std::vector<UInt>& hangingNodeCache,
215 CompoundUndoAction& hangingNodeAction);
218 void ConnectTwoHangingNodesForQuadrilateral(
const UInt numNonHangingNodes,
219 const std::vector<UInt>& edgeEndNodeCache,
220 std::vector<UInt>& hangingNodeCache,
221 CompoundUndoAction& hangingNodeAction);
224 void ConnectOneHangingNodeForTriangle(
const UInt numNonHangingNodes,
225 const std::vector<UInt>& edgeEndNodeCache,
226 std::vector<UInt>& hangingNodeCache,
227 CompoundUndoAction& hangingNodeAction);
230 void ConnectTwoHangingNodesForTriangle(
const UInt numNonHangingNodes,
231 std::vector<UInt>& hangingNodeCache,
232 CompoundUndoAction& hangingNodeAction);
235 std::unique_ptr<meshkernel::UndoAction> ConnectHangingNodes();
238 void FindEdgesToSplit(
const UInt faceId,
240 std::vector<bool>& splitEdge)
const;
243 void UpdateFaceRefinementMask(std::vector<bool>& splitEdge);
246 void UpdateEdgeRefinementMask();
249 void SmoothRefinementMasks();
252 bool IsSplittingIsRequiredForFace(
const UInt faceId)
const;
256 UInt UpdateEdgeMaskForNonHangingEdge(
const UInt faceId,
257 const UInt numFaceNodes,
262 void ComputeIfFaceShouldBeSplit();
265 Point ComputeMidPoint(
const Point& firstNode,
const Point& secondNode)
const;
268 int DetermineNodeMaskValue(
const int firstNodeMask,
const int secondNodeMask)
const;
271 bool DetermineIfParentIsCrossed(
const UInt faceId,
const UInt numEdges)
const;
274 bool FindNonHangingNodeEdges(
const UInt faceId,
276 std::vector<UInt>& notHangingFaceNodes,
277 std::vector<UInt>& nonHangingEdges,
278 UInt& numBrotherEdges)
const;
281 void ComputeSplittingNode(
const UInt faceId,
282 std::vector<Point>& facePolygonWithoutHangingNodes,
283 std::vector<UInt>& localEdgesNumFaces,
284 Point& splittingNode)
const;
287 void FindFacePolygonWithoutHangingNodes(
const UInt faceId,
288 const std::vector<UInt>& nonHangingEdges,
289 std::vector<Point>& facePolygonWithoutHangingNodes,
290 std::vector<UInt>& localEdgesNumFaces)
const;
293 void SplitEdges(
const bool isParentCrossed,
294 const std::vector<UInt>& localEdgesNumFaces,
295 const std::vector<UInt>& notHangingFaceNodes,
296 const Point& splittingNode,
297 CompoundUndoAction& refineFacesAction);
300 std::unique_ptr<meshkernel::UndoAction> RefineFacesBySplittingEdges();
306 bool IsEdgeToBeRefinedBasedFaceLocationTypeAndCourantCriteria(
UInt edge, FaceLocation faceLocationType)
const;
312 bool IsRefineNeededBasedOnCourantCriteria(
UInt edge,
double depthValues)
const;
315 void ComputeFaceLocationTypes();
318 void ComputeEdgeBelowMinSizeAfterRefinement();
320 std::unique_ptr<RTreeBase> m_samplesRTree;
322 std::vector<int> m_faceMask;
323 std::vector<int> m_edgeMask;
324 std::vector<bool> m_isEdgeBelowMinSizeAfterRefinement;
325 std::vector<int> m_nodeMask;
326 std::vector<UInt> m_brotherEdges;
329 std::vector<bool> m_isHangingNodeCache;
330 std::vector<bool> m_isHangingEdgeCache;
331 std::vector<Point> m_polygonNodesCache;
332 std::vector<UInt> m_localNodeIndicesCache;
333 std::vector<UInt> m_globalEdgeIndicesCache;
334 std::vector<UInt> m_refineEdgeCache;
335 std::vector<FaceLocation> m_faceLocationType;
338 bool m_directionalRefinement =
false;
341 std::unique_ptr<MeshInterpolation> m_interpolant;
344 bool m_useNodalRefinement =
false;
345 const double m_mergingDistance = 0.001;
346 bool m_isRefinementBasedOnSamples =
false;