Skip to content

Commit

Permalink
ConvertCurvilinearToNodesAndEdges made private
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasbuykx committed Feb 8, 2024
1 parent 2565db8 commit ba9d5b5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,6 @@ namespace meshkernel
return m_mesh->m_edges;
}

/// @brief Converting a curvilinear mesh to a set of nodes, edges and returns the original mapping (gridtonet)
/// @details Nodes and grid indices from the matrix are serialized in row-major order (n runs fastest).
/// Edges are serialized as follows: first all m-oriented edges ((m,n)-(m+1,n)) in row-major order, then all
/// n-oriented edges ((m,n)-(m,n+1)), in row-major order.
/// @note Also invalid nodes are serialized to points, edges and grid indices
/// @returns The nodes, the edges, and the original mapping (m and n indices for each node)
[[nodiscard]] std::tuple<std::vector<Point>, std::vector<Edge>, std::vector<CurvilinearGridNodeIndices>> ConvertCurvilinearToNodesAndEdges() const;

/// @brief Get the m and n indices of the node closest to the point
/// @param[in] point The input grid points
[[nodiscard]] CurvilinearGridNodeIndices GetNodeIndices(Point point);
Expand Down Expand Up @@ -308,6 +300,14 @@ namespace meshkernel
/// @brief Build the edges lookup in the internal mesh representation
void BuildEdgesTree() const;

/// @brief Converting a curvilinear mesh to a set of nodes, edges and returns the original mapping (gridtonet)
/// @details Nodes and grid indices from the matrix are serialized in row-major order (n runs fastest).
/// Edges are serialized as follows: first all m-oriented edges ((m,n)-(m+1,n)) in row-major order, then all
/// n-oriented edges ((m,n)-(m,n+1)), in row-major order.
/// @note Also invalid nodes are serialized to points, edges and grid indices
/// @returns The nodes, the edges, and the original mapping (m and n indices for each node)
[[nodiscard]] std::tuple<std::vector<Point>, std::vector<Edge>, std::vector<CurvilinearGridNodeIndices>> ConvertCurvilinearToNodesAndEdges() const;

/// @brief Get the matrix indices for the node at serialization index.
/// @note the serialization index is determined by the ConvertCurvilinearToNodesAndEdges method.
CurvilinearGridNodeIndices GetNodeIndices(UInt index) const;
Expand Down
29 changes: 17 additions & 12 deletions libs/MeshKernel/tests/src/CurvilinearGridRectangularTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,15 @@ TEST(CurvilinearGridUniform, MakeCurvilinearInEmptyPolygonSpherical)

// 2 Execution
CurvilinearGridRectangular const curvilinearGridCreateRectangular(Projection::spherical);
const auto [nodes, edges, gridIndices] = curvilinearGridCreateRectangular.Compute(numColumns,
numRows,
originX,
originY,
angle,
blockSizeX,
blockSizeY)
->ConvertCurvilinearToNodesAndEdges();
const auto grid = curvilinearGridCreateRectangular.Compute(numColumns,
numRows,
originX,
originY,
angle,
blockSizeX,
blockSizeY);
const auto nodes = grid->GetNodeVector();
const auto edges = grid->GetEdgeVector();

Mesh2D mesh(edges, nodes, Projection::spherical);

Expand Down Expand Up @@ -526,7 +527,8 @@ TEST(CurvilinearGridUniform, ConvertCurvilinearToNodesAndEdges_ReturnsSerialized
EXPECT_EQ(3, grid->NumM());
EXPECT_EQ(2, grid->NumN());

const auto [nodes, edges, gridIndices] = grid->ConvertCurvilinearToNodesAndEdges();
const auto nodes = grid->GetNodeVector();
const auto edges = grid->GetEdgeVector();
const std::vector<Point> expected_nodes = {{2., 1.}, {2., 2.}, {4., 1.}, {4., 2.}, {6., 1.}, {6., 2.}};

EXPECT_EQ(expected_nodes.size(), nodes.size());
Expand All @@ -552,7 +554,8 @@ TEST(CurvilinearGridUniform, ConvertCurvilinearToNodesAndEdges_ReturnsSerialized

grid->GetNode(2, 1).SetInvalid();

const auto [nodes, edges, gridIndices] = grid->ConvertCurvilinearToNodesAndEdges();
const auto nodes = grid->GetNodeVector();
const auto edges = grid->GetEdgeVector();
const std::vector<Point> expected_nodes = {{2., 1.}, {2., 2.}, {4., 1.}, {4., 2.}, {6., 1.}, {-999., -999.}};

EXPECT_EQ(expected_nodes.size(), nodes.size());
Expand All @@ -576,7 +579,8 @@ TEST(CurvilinearGridUniform, ConvertCurvilinearToNodesAndEdges_ReturnsSerialized
EXPECT_EQ(3, grid->NumM());
EXPECT_EQ(2, grid->NumN());

const auto [nodes, edges, gridIndices] = grid->ConvertCurvilinearToNodesAndEdges();
const auto nodes = grid->GetNodeVector();
const auto edges = grid->GetEdgeVector();
const std::vector<Edge> expected_edges = {{{0u, 2u}, {1u, 3u}, {2u, 4u}, {3u, 5u}, {0u, 1u}, {2u, 3u}, {4u, 5u}}};

EXPECT_EQ(expected_edges.size(), edges.size());
Expand All @@ -602,7 +606,8 @@ TEST(CurvilinearGridUniform, ConvertCurvilinearToNodesAndEdges_ReturnsSerialized

grid->GetNode(0, 1).SetInvalid();

const auto [nodes, edges, gridIndices] = grid->ConvertCurvilinearToNodesAndEdges();
const auto nodes = grid->GetNodeVector();
const auto edges = grid->GetEdgeVector();
const std::vector<Edge> expected_edges = {{{0u, 2u}, {1u, 3u}, {2u, 4u}, {3u, 5u}, {0u, 1u}, {2u, 3u}, {4u, 5u}}};

EXPECT_EQ(expected_edges.size(), edges.size());
Expand Down

0 comments on commit ba9d5b5

Please sign in to comment.