diff --git a/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGrid.hpp b/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGrid.hpp index 9a4df8708..f4919dbd4 100644 --- a/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGrid.hpp +++ b/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGrid.hpp @@ -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, std::vector> 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); @@ -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, std::vector> 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; diff --git a/libs/MeshKernel/tests/src/CurvilinearGridRectangularTests.cpp b/libs/MeshKernel/tests/src/CurvilinearGridRectangularTests.cpp index cc5146463..453250234 100644 --- a/libs/MeshKernel/tests/src/CurvilinearGridRectangularTests.cpp +++ b/libs/MeshKernel/tests/src/CurvilinearGridRectangularTests.cpp @@ -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); @@ -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 expected_nodes = {{2., 1.}, {2., 2.}, {4., 1.}, {4., 2.}, {6., 1.}, {6., 2.}}; EXPECT_EQ(expected_nodes.size(), nodes.size()); @@ -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 expected_nodes = {{2., 1.}, {2., 2.}, {4., 1.}, {4., 2.}, {6., 1.}, {-999., -999.}}; EXPECT_EQ(expected_nodes.size(), nodes.size()); @@ -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 expected_edges = {{{0u, 2u}, {1u, 3u}, {2u, 4u}, {3u, 5u}, {0u, 1u}, {2u, 3u}, {4u, 5u}}}; EXPECT_EQ(expected_edges.size(), edges.size()); @@ -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 expected_edges = {{{0u, 2u}, {1u, 3u}, {2u, 4u}, {3u, 5u}, {0u, 1u}, {2u, 3u}, {4u, 5u}}}; EXPECT_EQ(expected_edges.size(), edges.size());