Skip to content

Commit

Permalink
Merge branch 'master' into feature/GRIDEDIT-432_sign_dlls
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottWillcox authored Oct 17, 2023
2 parents 20fad45 + e6b2122 commit 456a340
Show file tree
Hide file tree
Showing 5 changed files with 460 additions and 89 deletions.
133 changes: 74 additions & 59 deletions libs/MeshKernel/include/MeshKernel/ConnectMeshes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,21 @@ namespace meshkernel
class ConnectMeshes final
{
public:
/// @brief The default and maximum value of the fraction of the edge length used to determine if edges are adjacent.
static constexpr double DefaultMaximumSeparationFraction = 0.4;

/// @brief The cos of the minimum angle between two lines to be considered parallel or almost parallel.
///
/// The angle may be close to 0 or pi.
static constexpr double minimumParallelDeviation = 0.9;

/// @brief Connect grids.
///
/// @param [in,out] mesh The mesh
void Compute(Mesh2D& mesh) const;
/// @param [in] separationFraction The fraction of the shortest edge to use when determining neighbour edge closeness
/// @note separationFraction should be in the interval (0, max], where max = DefaultMaximumSeparationFraction,
/// If the value is outside of this range then a RangeError will be thrown.
static void Compute(Mesh2D& mesh, const double separationFraction = DefaultMaximumSeparationFraction);

private:
/// @brief The maximum number of hanging nodes along a single element edge
Expand Down Expand Up @@ -91,26 +102,28 @@ namespace meshkernel
/// @brief Determine if the edges are adjacent, if so then return the start and end points (adjacent.f90)
///
/// @param [in] mesh The mesh
/// @param [in] separationFraction The fraction of the shortest edge to use when determining neighbour edge closeness
/// @param [in] edge1 One of the edges for adjacency check
/// @param [in] edge2 Another of the edges for adjacency check
/// @param [out] areAdjacent Indicates is edge1 and edge2 are adjacent
/// @param [out] startNode End point nodes, if not nullvalue then node is hanging node
/// @param [out] endNode End point nodes, if not nullvalue then node is hanging node
void AreEdgesAdjacent(const Mesh2D& mesh,
const UInt edge1,
const UInt edge2,
bool& areAdjacent,
UInt& startNode,
UInt& endNode) const;
static void AreEdgesAdjacent(const Mesh2D& mesh,
const double separationFraction,
const UInt edge1,
const UInt edge2,
bool& areAdjacent,
UInt& startNode,
UInt& endNode);

/// @brief Find all quadrilateral elements that do no have a neighbour across any of edges.
///
/// @param [in] mesh The mesh
/// @param [in,out] elementsOnDomainBoundary List of elements that do not have neighbour
/// @param [in,out] edgesOnDomainBoundary List of edges that do have elements on one side only
void GetQuadrilateralElementsOnDomainBoundary(const Mesh2D& mesh,
std::vector<UInt>& elementsOnDomainBoundary,
std::vector<UInt>& edgesOnDomainBoundary) const;
static void GetQuadrilateralElementsOnDomainBoundary(const Mesh2D& mesh,
std::vector<UInt>& elementsOnDomainBoundary,
std::vector<UInt>& edgesOnDomainBoundary);

/// @brief Get list of node id's ordered with distance from given point.
///
Expand All @@ -119,29 +132,29 @@ namespace meshkernel
/// @param [in] numberOfNodes Number of nodes to have distance computed
/// @param [in] point Start point from which node distances are to be computed
/// @param [out] nearestNeighbours List of nearest nodes in order of distance from point
void GetOrderedDistanceFromPoint(const Mesh2D& mesh,
const std::vector<UInt>& nodeIndices,
const UInt numberOfNodes,
const Point& point,
BoundedIntegerArray& nearestNeighbours) const;
static void GetOrderedDistanceFromPoint(const Mesh2D& mesh,
const std::vector<UInt>& nodeIndices,
const UInt numberOfNodes,
const Point& point,
BoundedIntegerArray& nearestNeighbours);

/// @brief Merge coincident nodes
///
/// @param [in,out] mesh The mesh
/// @param [in] nodesToMerge List of nodes to be merged
/// @param [in,out] mergeIndicator Indicates if node needs to be merged.
void MergeNodes(Mesh2D& mesh, const std::vector<NodesToMerge>& nodesToMerge, std::vector<MergeIndicator>& mergeIndicator) const;
static void MergeNodes(Mesh2D& mesh, const std::vector<NodesToMerge>& nodesToMerge, std::vector<MergeIndicator>& mergeIndicator);

/// @brief Free one hanging node along an irregular edge.
///
/// @brief [in] mesh The mesh
/// @brief [in] hangingNodes List of hanging nodes for edge
/// @brief [in] startNode End point of regular edge, to which the hanging node will be connected
/// @brief [in] endNode Other end point of regular edge, to which the hanging node will be connected
void FreeOneHangingNode(Mesh2D& mesh,
const BoundedIntegerArray& hangingNodes,
const UInt startNode,
const UInt endNode) const;
static void FreeOneHangingNode(Mesh2D& mesh,
const BoundedIntegerArray& hangingNodes,
const UInt startNode,
const UInt endNode);

/// @brief Free two hanging nodes along an irregular edge.
///
Expand All @@ -151,12 +164,12 @@ namespace meshkernel
/// @brief [in] hangingNodes List of hanging nodes for edge
/// @brief [in] startNode End point of regular edge, to which the hanging nodes will be connected
/// @brief [in] endNode Other end point of regular edge, to which the hanging nodes will be connected
void FreeTwoHangingNodes(Mesh2D& mesh,
const UInt faceId,
const UInt edgeId,
const BoundedIntegerArray& hangingNodes,
const UInt startNode,
const UInt endNode) const;
static void FreeTwoHangingNodes(Mesh2D& mesh,
const UInt faceId,
const UInt edgeId,
const BoundedIntegerArray& hangingNodes,
const UInt startNode,
const UInt endNode);

/// @brief Free three hanging nodes along an irregular edge.
///
Expand All @@ -166,12 +179,12 @@ namespace meshkernel
/// @brief [in] hangingNodes List of hanging nodes for edge
/// @brief [in] startNode End point of regular edge, to which the hanging nodes will be connected
/// @brief [in] endNode Other end point of regular edge, to which the hanging nodes will be connected
void FreeThreeHangingNodes(Mesh2D& mesh,
const UInt faceId,
const UInt edgeId,
const BoundedIntegerArray& hangingNodes,
const UInt startNode,
const UInt endNode) const;
static void FreeThreeHangingNodes(Mesh2D& mesh,
const UInt faceId,
const UInt edgeId,
const BoundedIntegerArray& hangingNodes,
const UInt startNode,
const UInt endNode);

/// @brief Free four hanging nodes along an irregular edge.
///
Expand All @@ -181,12 +194,12 @@ namespace meshkernel
/// @brief [in] hangingNodes List of hanging nodes for edge
/// @brief [in] startNode End point of regular edge, to which the hanging nodes will be connected
/// @brief [in] endNode Other end point of regular edge, to which the hanging nodes will be connected
void FreeFourHangingNodes(Mesh2D& mesh,
const UInt faceId,
const UInt edgeId,
const BoundedIntegerArray& hangingNodes,
const UInt startNode,
const UInt endNode) const;
static void FreeFourHangingNodes(Mesh2D& mesh,
const UInt faceId,
const UInt edgeId,
const BoundedIntegerArray& hangingNodes,
const UInt startNode,
const UInt endNode);

/// @brief Free any hanging nodes along an irregular edge.
///
Expand All @@ -197,22 +210,24 @@ namespace meshkernel
/// @brief [in] boundaryEdge The irregular edge
/// @brief [in] boundaryNode End point of erregular edge, required to order the hanging nodes
/// @brief [in] edgeId Edge along opposite side of irregular edge, required to get next adjacent element
void FreeHangingNodes(Mesh2D& mesh,
const UInt numberOfHangingNodes,
const std::vector<UInt>& hangingNodesOnEdge,
const UInt faceId,
const Edge& boundaryEdge,
const Point& boundaryNode,
const UInt edgeId) const;
static void FreeHangingNodes(Mesh2D& mesh,
const UInt numberOfHangingNodes,
const std::vector<UInt>& hangingNodesOnEdge,
const UInt faceId,
const Edge& boundaryEdge,
const Point& boundaryNode,
const UInt edgeId);

/// @brief Find and retain any hanging node id's
///
/// @param [in] mesh The mesh
/// @param [in] separationFraction The fraction of the shortest edge to use when determining neighbour edge closeness
/// @param [in] edgesOnDomainBoundary List of edges along domain boundary, more specifically edges with only a single element attached
/// @param [in,out] irregularEdges List of irregular edges with hanging nodes
void GatherHangingNodeIds(const Mesh2D& mesh,
const std::vector<UInt>& edgesOnDomainBoundary,
IrregularEdgeInfoArray& irregularEdges) const;
static void GatherHangingNodeIds(const Mesh2D& mesh,
const double separationFraction,
const std::vector<UInt>& edgesOnDomainBoundary,
IrregularEdgeInfoArray& irregularEdges);

/// @brief Gather all the nodes that need to be merged.
///
Expand All @@ -223,11 +238,11 @@ namespace meshkernel
/// @param [in,out] mergeIndicator List of indicators, indicating if node has been processed and should be merged or not
///
/// Before merging there may be 2 or more nodes that are at the same point.
void GatherNodesToMerge(const UInt startNode,
const UInt endNode,
const Edge& boundaryEdge,
std::vector<NodesToMerge>& nodesToMerge,
std::vector<MergeIndicator>& mergeIndicator) const;
static void GatherNodesToMerge(const UInt startNode,
const UInt endNode,
const Edge& boundaryEdge,
std::vector<NodesToMerge>& nodesToMerge,
std::vector<MergeIndicator>& mergeIndicator);

/// @brief Gather hanging nodes along the irregular edge.
///
Expand All @@ -237,12 +252,12 @@ namespace meshkernel
/// @param [in,out] hangingNodesOnEdge List of hanging node along edge
/// @param [in,out] numberOfHangingNodes Number of hanging nodes along edge
/// @param [in,out] mergeIndicator List of indicators, indicating if node has been processed and should be merged or not
void GatherHangingNodes(const UInt primaryStartNode,
const UInt primaryEndNode,
const Edge& irregularEdge,
std::vector<UInt>& hangingNodesOnEdge,
UInt& numberOfHangingNodes,
std::vector<MergeIndicator>& mergeIndicator) const;
static void GatherHangingNodes(const UInt primaryStartNode,
const UInt primaryEndNode,
const Edge& irregularEdge,
std::vector<UInt>& hangingNodesOnEdge,
UInt& numberOfHangingNodes,
std::vector<MergeIndicator>& mergeIndicator);
};

} // namespace meshkernel
Loading

0 comments on commit 456a340

Please sign in to comment.