diff --git a/libs/MeshKernel/CMakeLists.txt b/libs/MeshKernel/CMakeLists.txt index 349dbe451..213917e74 100644 --- a/libs/MeshKernel/CMakeLists.txt +++ b/libs/MeshKernel/CMakeLists.txt @@ -89,6 +89,7 @@ set( ${DOMAIN_INC_DIR}/BilinearInterpolationOnGriddedSamples.hpp ${DOMAIN_INC_DIR}/Constants.hpp ${DOMAIN_INC_DIR}/Contacts.hpp + ${DOMAIN_INC_DIR}/Definitions.hpp ${DOMAIN_INC_DIR}/Entities.hpp ${DOMAIN_INC_DIR}/Exceptions.hpp ${DOMAIN_INC_DIR}/FlipEdges.hpp diff --git a/libs/MeshKernel/benchmark/src/perf_orthogonalization.cpp b/libs/MeshKernel/benchmark/src/perf_orthogonalization.cpp index 7e3150cac..73c6985f4 100644 --- a/libs/MeshKernel/benchmark/src/perf_orthogonalization.cpp +++ b/libs/MeshKernel/benchmark/src/perf_orthogonalization.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -38,7 +39,7 @@ static void BM_Orthogonalization(benchmark::State& state) // move nodes to skew the mesh double const delta_x = dim_x / static_cast(n - 1); double const delta_y = dim_y / static_cast(m - 1); - for (size_t i = 0; i < mesh->m_nodes.size(); ++i) + for (meshkernel::Index i = 0; i < mesh->m_nodes.size(); ++i) { // only move inetrnal nodes if (!mesh->IsNodeOnBoundary(i)) diff --git a/libs/MeshKernel/include/MeshKernel/AveragingInterpolation.hpp b/libs/MeshKernel/include/MeshKernel/AveragingInterpolation.hpp index 81552708b..6da88fced 100644 --- a/libs/MeshKernel/include/MeshKernel/AveragingInterpolation.hpp +++ b/libs/MeshKernel/include/MeshKernel/AveragingInterpolation.hpp @@ -30,6 +30,7 @@ #include "MeshInterpolation.hpp" #include +#include #include #include @@ -102,7 +103,7 @@ namespace meshkernel double relativeSearchRadius, bool useClosestSampleIfNoneAvailable, bool subtractSampleValues, - size_t minNumSamples); + UInt minNumSamples); /// @brief Compute interpolation void Compute() override; @@ -133,7 +134,7 @@ namespace meshkernel /// @brief Gets the sample value from an r-tree query /// param[in] index The query index /// @return The sample value - [[nodiscard]] double GetSampleValueFromRTree(size_t index); + [[nodiscard]] double GetSampleValueFromRTree(UInt index); /// @brief Compute a search radius from a point and a polygon /// @param searchPolygon The input polygon @@ -149,7 +150,7 @@ namespace meshkernel double m_relativeSearchRadius; ///< Relative search radius bool m_useClosestSampleIfNoneAvailable = false; ///< Whether to use the closest sample if there is none available bool m_transformSamples = false; ///< Wheher to transform samples - size_t m_minNumSamples = 1; ///< The minimum amount of samples for a valid interpolation. Used in some interpolation algorithms. + UInt m_minNumSamples = 1; ///< The minimum amount of samples for a valid interpolation. Used in some interpolation algorithms. std::vector m_visitedSamples; ///< The visited samples diff --git a/libs/MeshKernel/include/MeshKernel/BilinearInterpolationOnGriddedSamples.hpp b/libs/MeshKernel/include/MeshKernel/BilinearInterpolationOnGriddedSamples.hpp index 31f149b8a..f17c9df7c 100644 --- a/libs/MeshKernel/include/MeshKernel/BilinearInterpolationOnGriddedSamples.hpp +++ b/libs/MeshKernel/include/MeshKernel/BilinearInterpolationOnGriddedSamples.hpp @@ -44,8 +44,8 @@ namespace meshkernel /// @param[in] cellSize The grid cell size /// @param[in] values The values of the gridded samples BilinearInterpolationOnGriddedSamples(const Mesh2D& mesh, - size_t numXCoord, - size_t numYCoord, + UInt numXCoord, + UInt numYCoord, const Point& origin, double cellSize, const std::vector& values); @@ -81,18 +81,17 @@ namespace meshkernel /// @brief Gets the sample value at specific row and column /// @return The sample value - [[nodiscard]] double getGriddedValue(size_t columnIndex, size_t rowIndex) const + [[nodiscard]] double getGriddedValue(UInt columnIndex, UInt rowIndex) const { const auto index = rowIndex * m_numXCoord + columnIndex; return m_values[index]; } const Mesh2D& m_mesh; ///< Pointer to the mesh - - size_t m_numXCoord; ///< The number of x coordinates of the gridded data - size_t m_numYCoord; ///< The number of y coordinates of the gridded data - Point m_origin; ///< The coordinate of the origin - double m_cellSize; ///< The grid cell size + UInt m_numXCoord; ///< The number of x coordinates of the gridded data + UInt m_numYCoord; ///< The number of y coordinates of the gridded data + Point m_origin; ///< The coordinate of the origin + double m_cellSize; ///< The grid cell size std::vector m_xCoordinates; ///< The x coordinates of the grid std::vector m_yCoordinates; ///< The y coordinates of the grid diff --git a/libs/MeshKernel/include/MeshKernel/Constants.hpp b/libs/MeshKernel/include/MeshKernel/Constants.hpp index 77a50aa14..3180c69f1 100644 --- a/libs/MeshKernel/include/MeshKernel/Constants.hpp +++ b/libs/MeshKernel/include/MeshKernel/Constants.hpp @@ -27,22 +27,25 @@ #pragma once +#include "MeshKernel/Definitions.hpp" + #include #include #include namespace meshkernel { + namespace constants { // missing values namespace missing { - constexpr double innerOuterSeparator = -998.0; ///< Double value used to separate the inner part of a polygon from its outer part - constexpr double doubleValue = -999.0; ///< Double value used as missing value - constexpr int intValue = -999; ///< Integer value used as missing value - constexpr size_t sizetValue = std::numeric_limits::max(); ///< std::size_t missing value used for invalid indices - } // namespace missing + constexpr double innerOuterSeparator = -998.0; ///< Double value used to separate the inner part of a polygon from its outer part + constexpr double doubleValue = -999.0; ///< Double value used as missing value + constexpr int intValue = -999; ///< Integer value used as missing value + constexpr UInt uintValue = std::numeric_limits::max(); ///< missing value used for invalid indices + } // namespace missing // often used values namespace numeric diff --git a/libs/MeshKernel/include/MeshKernel/Contacts.hpp b/libs/MeshKernel/include/MeshKernel/Contacts.hpp index ea2f7b508..5687bb78d 100644 --- a/libs/MeshKernel/include/MeshKernel/Contacts.hpp +++ b/libs/MeshKernel/include/MeshKernel/Contacts.hpp @@ -120,7 +120,7 @@ namespace meshkernel /// The algorithms works as follows: /// - For each oned node, find the closest 2d boundary faces within the search radius. /// - If a boundary face can be connected to multiple oned nodes, choose the closest one. - /// - Generate the 1d-2d contacts. + /// - Generate the 1d-2d contacts.Index m_numM = 0; ///< Number of columns in the curvilinear grid /// \image html ComputeBoundaryContacts.jpg "1d mesh connecting to 2d mesh using the ComputeBoundaryContacts algorithm. Contacts are shown in red. /// The mesh 2d boundary faces are connected to the closest 1d nodes." /// @@ -133,34 +133,34 @@ namespace meshkernel /// @brief Gets the 1d mesh indices /// @return Vector of 1d mesh indices - std::vector const& Mesh1dIndices() const { return m_mesh1dIndices; } + std::vector const& Mesh1dIndices() const { return m_mesh1dIndices; } /// @brief Gets the 2d mesh indices /// @return Vector of 2d mesh indices - std::vector const& Mesh2dIndices() const { return m_mesh2dIndices; } + std::vector const& Mesh2dIndices() const { return m_mesh2dIndices; } private: /// @brief Asserts if a contact is crossing a 1d mesh edge /// @param[in] node The 1d node index (start of the contact) /// @param[in] face The 2d face index (end of the contact) /// @return True if the contact is crossing a 1d mesh edge - [[nodiscard]] bool IsContactIntersectingMesh1d(size_t node, size_t face) const; + [[nodiscard]] bool IsContactIntersectingMesh1d(UInt node, UInt face) const; /// @brief Asserts if a contact is crossing an existing contact /// @param[in] node The 1d node index (start of the contact) /// @param[in] face The 2d face index (end of the contact) /// @return True if the contact is crossing an existing contact - [[nodiscard]] bool IsContactIntersectingContact(size_t node, size_t face) const; + [[nodiscard]] bool IsContactIntersectingContact(UInt node, UInt face) const; /// @brief Connect the current 1D line segment with the faces that intersect a semiline originating from the current node and perpendicular to the current 1D edge. /// @param[in] node The 1d node index (start of the contact) /// @param[in] projectionFactor The semiline length, as a multiplier of the current ad edge length - void Connect1dNodesWithCrossingFaces(size_t node, + void Connect1dNodesWithCrossingFaces(UInt node, double projectionFactor); - std::shared_ptr m_mesh1d; ///< The 1-d mesh to connect - std::shared_ptr m_mesh2d; ///< The 2-d mesh to connect - std::vector m_mesh1dIndices; ///< The indices of the connected 1-d nodes - std::vector m_mesh2dIndices; ///< The indices of the connected 2-d faces + std::shared_ptr m_mesh1d; ///< The 1-d mesh to connect + std::shared_ptr m_mesh2d; ///< The 2-d mesh to connect + std::vector m_mesh1dIndices; ///< The indices of the connected 1-d nodes + std::vector m_mesh2dIndices; ///< The indices of the connected 2-d faces }; } // namespace meshkernel diff --git a/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGrid.hpp b/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGrid.hpp index a13d3471a..a2fe00f10 100644 --- a/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGrid.hpp +++ b/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGrid.hpp @@ -29,6 +29,7 @@ #include +#include #include #include #include @@ -74,7 +75,7 @@ namespace meshkernel /// @brief Deletes a curvilinear grid inside a polygon /// @param[in] polygons The polygons /// @param[in] polygonIndex The index of the polygon to use for deletion - void Delete(std::shared_ptr polygons, size_t polygonIndex); + void Delete(std::shared_ptr polygons, UInt polygonIndex); /// @brief Lvalue constructor. Creates a new curvilinear grid from a given set of points /// @param[in] grid The input grid points @@ -109,7 +110,7 @@ namespace meshkernel /// @param[in] m The m coordinate /// @param[in] n The n coordinate /// @return True if the face is valid, false otherwise - [[nodiscard]] bool IsValidFace(size_t m, size_t n) const; + [[nodiscard]] bool IsValidFace(UInt m, UInt n) const; /// @brief Inserts a new face. The new face will be inserted on top of the closest edge. /// @param[in] point The point used for finding the closest edge. @@ -177,8 +178,8 @@ namespace meshkernel /// @param[in] toPoint The coordinates of the new position void MoveNode(Point const& fromPoint, Point const& toPoint); - size_t m_numM = 0; ///< The number of m coordinates (vertical lines) - size_t m_numN = 0; ///< The number of n coordinates (horizontal lines) + UInt m_numM = 0; ///< The number of m coordinates (vertical lines) + UInt m_numN = 0; ///< The number of n coordinates (horizontal lines) std::vector> m_gridNodes; ///< Member variable storing the grid std::vector> m_gridFacesMask; ///< The mask of the grid faces (true/false) std::vector> m_gridNodesTypes; ///< The grid node types diff --git a/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridCreateUniform.hpp b/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridCreateUniform.hpp index c485b8f87..b5d25011a 100644 --- a/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridCreateUniform.hpp +++ b/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridCreateUniform.hpp @@ -72,7 +72,7 @@ namespace meshkernel const double blockSizeX, const double blockSizeY, std::shared_ptr polygons, - size_t polygonIndex) const; + UInt polygonIndex) const; /// @brief Compute an uniform curvilinear grid in one polygon, given the block size and the extension. The grid angle is 0 /// @param[in] originX The x coordinate of the origin, located at the bottom left corner diff --git a/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridFromPolygon.hpp b/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridFromPolygon.hpp index 9bd2c7266..fc02b907e 100644 --- a/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridFromPolygon.hpp +++ b/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridFromPolygon.hpp @@ -45,11 +45,11 @@ namespace meshkernel /// @brief Compute curvilinear in a polygon (pol2curvi) /// @returns The computed curvilinear grid - CurvilinearGrid Compute(size_t firstNode, size_t secondNode, size_t thirdNode, bool useFourthSide) const; + CurvilinearGrid Compute(UInt firstNode, UInt secondNode, UInt thirdNode, bool useFourthSide) const; /// @brief Compute curvilinear in a triangle (pol2curvi_tri) /// @returns The computed curvilinear grid - CurvilinearGrid Compute(size_t firstNode, size_t secondNode, size_t thirdNode) const; + CurvilinearGrid Compute(UInt firstNode, UInt secondNode, UInt thirdNode) const; private: std::shared_ptr m_polygon; ///< A pointer to Polygons diff --git a/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridFromSplines.hpp b/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridFromSplines.hpp index c748ea5d5..ff9149207 100644 --- a/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridFromSplines.hpp +++ b/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridFromSplines.hpp @@ -27,6 +27,7 @@ #pragma once +#include #include #include @@ -115,7 +116,7 @@ namespace meshkernel /// @brief Performs one iteration for generating another layer on the advancing fronts /// @param[in] layer The index of the layer to be generated - void Iterate(size_t layer); + void Iterate(UInt layer); /// @brief For the central spline, computes the spline subdivisions along the spline (make_wholegridline) void MakeAllGridLines(); @@ -123,7 +124,7 @@ namespace meshkernel std::vector m_gridLine; ///< Coordinates of the first gridline (xg1, yg1) std::vector m_gridLineDimensionalCoordinates; ///< Center spline coordinates of the first gridline (sg1) std::vector m_maximumGridHeights; ///< Maximum transversal grid height () - size_t m_numM = 0; ///< Number of columns in the curvilinear grid + UInt m_numM = 0; ///< Number of columns in the curvilinear grid std::shared_ptr m_splines; ///< A pointer to spline class instance @@ -131,10 +132,10 @@ namespace meshkernel /// @brief From the layerIndex index gets the next grid layerIndex and the transversal sublayer index (get_isub) /// @param[in] layerIndex The current grid layerIndex index /// @returns The next grid layerIndex and the sub layerIndex index - std::tuple ComputeGridLayerAndSubLayer(size_t layerIndex); + std::tuple ComputeGridLayerAndSubLayer(UInt layerIndex); /// @brief Grow a layer starting from a given layer index - void GrowLayer(size_t layerIndex); + void GrowLayer(UInt layerIndex); /// @brief Compute the maximum allowable time step when growing a grid (comp_tmax_self) /// @param[in] coordinates The starting point coordinates @@ -147,22 +148,22 @@ namespace meshkernel /// @param[in] layerIndex The current grid layerIndex index /// @param[in] previousFrontVelocities The previous front velocities /// @returns The front velocities for the next front - std::vector CopyVelocitiesToFront(size_t layerIndex, const std::vector& previousFrontVelocities); + std::vector CopyVelocitiesToFront(UInt layerIndex, const std::vector& previousFrontVelocities); /// @brief Computes the points at front, which have to be moved. /// @returns The indices of the grid points, the front grid points and the number of front points - std::tuple>, std::vector, size_t> FindFront(); + std::tuple>, std::vector, UInt> FindFront(); /// @brief Compute growth velocity vectors at grid points (comp_vel) /// @param[in] layerIndex The current grid layerIndex index /// @returns The velocities at the grid point - std::vector ComputeVelocitiesAtGridPoints(size_t layerIndex); + std::vector ComputeVelocitiesAtGridPoints(UInt layerIndex); /// @brief Get left and right points at given layer for a given index (get_LR) /// @param[in] gridPoints The front grid points /// @param[in] index The front grid point index from which the neighbors should be searched /// @returns The left and the right index for the current front grid point index - std::tuple GetNeighbours(const std::vector& gridPoints, size_t index) const; + std::tuple GetNeighbours(const std::vector& gridPoints, UInt index) const; /// @brief Compute the edge grow velocities (comp_edgevel) /// TODO: can this be split in compute heights and computeGrowFactors @@ -171,7 +172,7 @@ namespace meshkernel /// @brief Compute the grid grow factor for a given total grid height, first grid layer height and number of grid layers (comp_dgrow) /// @param[in] splineIndex The current spline index /// @returns The computed grow factor - double ComputeGrowFactor(size_t splineIndex) const; + double ComputeGrowFactor(UInt splineIndex) const; /// @brief Computes the exponential grid height from the aspect ratio, the heights and the number of grid layers /// @brief[in] aspectRatio The aspect ratio @@ -180,12 +181,12 @@ namespace meshkernel /// @returns The new grid height [[nodiscard]] double ComputeTotalExponentialHeight(double aspectRatio, double height, - size_t numLayers) const; + UInt numLayers) const; /// @brief Compute the number of exponential layers for a given heightRatio /// @param[in] heightRatio The max height ratio between layers /// @returns The number of exponential layers - [[nodiscard]] size_t ComputeNumberExponentialLayers(double heightRatio) const; + [[nodiscard]] UInt ComputeNumberExponentialLayers(double heightRatio) const; /// @brief Computes the sub-interval velocities (left and right) /// @param[in] s @@ -199,15 +200,15 @@ namespace meshkernel /// @param[out] numPerpendicularFacesOnSubintervalAndEdge /// @param[out] edgeVelocities /// @param[out] hh0MaxRatio - void ComputeVelocitiesSubIntervals(size_t s, - size_t startGridLineIndex, - size_t endGridLineIndex, - size_t numHeights, - size_t numOtherSideHeights, + void ComputeVelocitiesSubIntervals(UInt s, + UInt startGridLineIndex, + UInt endGridLineIndex, + UInt numHeights, + UInt numOtherSideHeights, double firstHeight, - const std::vector& gridLineIndex, - const std::vector& otherGridLineIndex, - std::vector>& numPerpendicularFacesOnSubintervalAndEdge, + const std::vector& gridLineIndex, + const std::vector& otherGridLineIndex, + std::vector>& numPerpendicularFacesOnSubintervalAndEdge, std::vector& edgeVelocities, double& hh0MaxRatio); @@ -224,26 +225,25 @@ namespace meshkernel /// @param[out] localSplineDerivatives /// @param[out] crossingSplinesDimensionalCoordinates /// @param[out] heights - void FindNearestCrossSplines(size_t s, - size_t j, - const std::vector& numHeightsLeft, + void FindNearestCrossSplines(UInt s, + UInt j, + const std::vector& numHeightsLeft, const std::vector>& crossSplineLeftHeights, const std::vector& edgesCenterPoints, - std::vector& localValidSplineIndices, + std::vector& localValidSplineIndices, std::vector& localSplineDerivatives, std::vector& crossingSplinesDimensionalCoordinates, std::vector>& heights); /// @brief Computes the intersections on a given spline (get_crosssplines) /// @brief[in] splineIndex The current spline index - void GetSplineIntersections(size_t splineIndex); + void GetSplineIntersections(UInt splineIndex); /// @brief Generate a gridline on a spline with a prescribed maximum mesh width (make_gridline) /// @param[in] splineIndex The current spline index /// @param[in] startingIndex The start index in the gridline /// @returns The number of m subdivisions - size_t MakeGridLine(size_t splineIndex, - size_t startingIndex); + UInt MakeGridLine(UInt splineIndex, UInt startingIndex); /// @brief Compute the grid heights using ComputeSubHeights and calculates the maximum sub height (get_heights) void ComputeHeights(); @@ -254,7 +254,7 @@ namespace meshkernel /// /// @param[in] centerSplineIndex /// @param[in] crossingSplineLocalIndex - void ComputeSubHeights(size_t centerSplineIndex, size_t crossingSplineLocalIndex); + void ComputeSubHeights(UInt centerSplineIndex, UInt crossingSplineLocalIndex); /// @brief Delete skewed cells and cells whose aspect ratio exceeds a prescribed value (postgrid) void DeleteSkinnyTriangles(); @@ -275,42 +275,42 @@ namespace meshkernel CurvilinearParameters m_curvilinearParameters; ///< Curvilinear parameters SplinesToCurvilinearParameters m_splinesToCurvilinearParameters; ///< Splines to curvilinear parameters - const size_t m_maxNumCenterSplineHeights = 10; ///< Nsubmax, naz number of different heights a cross spline can have (is determined by how many crossing spline the user can input) - const size_t m_maxNUniformPart = 5; ///< Maximum number of layers in the uniform part - double m_onTopOfEachOtherSquaredTolerance; ///< On top of each other squared tolerance - size_t m_numOriginalSplines = 0; ///< The original number of splines + const UInt m_maxNumCenterSplineHeights = 10; ///< Nsubmax, naz number of different heights a cross spline can have (is determined by how many crossing spline the user can input) + const UInt m_maxNUniformPart = 5; ///< Maximum number of layers in the uniform part + double m_onTopOfEachOtherSquaredTolerance; ///< On top of each other squared tolerance + UInt m_numOriginalSplines = 0; ///< The original number of splines // Spline properties (first index is the spline number) - std::vector m_type; ///< Spline type - std::vector m_centralSplineIndex; ///< For each spline the index to its central - std::vector m_numCrossingSplines; ///< Number of crossing splines - std::vector> m_crossingSplinesIndices; ///< Indices for each cross spline, the indices of the center splines + std::vector m_type; ///< Spline type + std::vector m_centralSplineIndex; ///< For each spline the index to its central + std::vector m_numCrossingSplines; ///< Number of crossing splines + std::vector> m_crossingSplinesIndices; ///< Indices for each cross spline, the indices of the center splines std::vector> m_isLeftOriented; ///< isLeftOriented cross spline is left to right(.true.) or not (.false.) w.r.t.center spline std::vector> m_crossSplineCoordinates; ///< t center spline coordinates of cross splines std::vector> m_cosCrossingAngle; ///< cosPhi cosine of crossing angle std::vector>> m_crossSplineLeftHeights; ///< hL left - hand side grid heights at cross spline locations for each grid layer subinterval, hL(1, :) being the height of the first subinterval, etc. std::vector>> m_crossSplineRightHeights; ///< hR right - hand side grid heights at cross spline locations for each grid layer subinterval, hR(1, :) being the height of the first subinterval, etc. - std::vector> m_numCrossSplineLeftHeights; ///< NsubL number of subintervals of grid layers at cross spline locations at the left - hand side of the spline, each having their own exponential grow factor - std::vector> m_numCrossSplineRightHeights; ///< NsubR number of subintervals of grid layers at cross spline locations at the right - hand side of the spline, each having their own exponential grow factor - std::vector m_numMSplines; ///< mfac number of grid intervals on the spline - std::vector m_leftGridLineIndex; ///< iL index in the whole gridline array of the first grid point on the left - hand side of the spline - std::vector m_rightGridLineIndex; ///< iR index in the whole gridline array of the first grid point on the right - hand side of the spline + std::vector> m_numCrossSplineLeftHeights; ///< NsubL number of subintervals of grid layers at cross spline locations at the left - hand side of the spline, each having their own exponential grow factor + std::vector> m_numCrossSplineRightHeights; ///< NsubR number of subintervals of grid layers at cross spline locations at the right - hand side of the spline, each having their own exponential grow factor + std::vector m_numMSplines; ///< mfac number of grid intervals on the spline + std::vector m_leftGridLineIndex; ///< iL index in the whole gridline array of the first grid point on the left - hand side of the spline + std::vector m_rightGridLineIndex; ///< iR index in the whole gridline array of the first grid point on the right - hand side of the spline std::vector> m_gridHeights; ///< Heights of all grid elements - std::vector m_leftGridLineIndexOriginal; ///< Original index of the left grid line - std::vector m_rightGridLineIndexOriginal; ///< Original index of the right grid line - std::vector m_mfacOriginal; ///< Original mfac number + std::vector m_leftGridLineIndexOriginal; ///< Original index of the left grid line + std::vector m_rightGridLineIndexOriginal; ///< Original index of the right grid line + std::vector m_mfacOriginal; ///< Original mfac number std::vector m_maximumGridHeightsOriginal; ///< Original maximum transversal grid height std::vector m_originalTypes; ///< Original types // cache variables during iterations - std::vector m_edgeVelocities; ///< Edge velocities - std::vector m_validFrontNodes; ///< InternalValid front nodes - std::vector> m_gridPoints; ///< Grid points - double m_timeStep = 1.0; ///< Time step - std::vector m_subLayerGridPoints; ///< Sublayer grid points - std::vector> m_numPerpendicularFacesOnSubintervalAndEdge; ///< Perpendicular faces on subinterval and edge - std::vector> m_growFactorOnSubintervalAndEdge; ///< Grow factor on subinterval and edge + std::vector m_edgeVelocities; ///< Edge velocities + std::vector m_validFrontNodes; ///< InternalValid front nodes + std::vector> m_gridPoints; ///< Grid points + double m_timeStep = 1.0; ///< Time step + std::vector m_subLayerGridPoints; ///< Sublayer grid points + std::vector> m_numPerpendicularFacesOnSubintervalAndEdge; ///< Perpendicular faces on subinterval and edge + std::vector> m_growFactorOnSubintervalAndEdge; ///< Grow factor on subinterval and edge }; } // namespace meshkernel diff --git a/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridFromSplinesTransfinite.hpp b/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridFromSplinesTransfinite.hpp index 80f7d08f0..d00c66c4c 100644 --- a/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridFromSplinesTransfinite.hpp +++ b/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridFromSplinesTransfinite.hpp @@ -30,6 +30,7 @@ #include #include +#include #include namespace meshkernel @@ -65,17 +66,17 @@ namespace meshkernel /// @param[in] startSecond /// @param[in] endSecond /// @returns Boolean to indicate that procedure has to be repeated - [[nodiscard]] bool OrderSplines(size_t startFirst, - size_t endFirst, - size_t startSecond, - size_t endSecond); + [[nodiscard]] bool OrderSplines(UInt startFirst, + UInt endFirst, + UInt startSecond, + UInt endSecond); /// @brief Swap the rows of a two dimensional vector /// @param v The input vector /// @param firstRow The first row /// @param secondRow The second row template - void SwapRows(std::vector>& v, size_t firstRow, size_t secondRow) const; + void SwapRows(std::vector>& v, UInt firstRow, UInt secondRow) const; /// @brief Swap the columns of a two dimensional vector (MAKESR) /// @tparam T The input vector @@ -83,7 +84,7 @@ namespace meshkernel /// @param firstColumn The first column /// @param secondColumn The second column template - void SwapColumns(std::vector>& v, size_t firstColumn, size_t secondColumn) const; + void SwapColumns(std::vector>& v, UInt firstColumn, UInt secondColumn) const; /// Compute the distances following an exponential increase /// @param[in] factor @@ -101,19 +102,19 @@ namespace meshkernel /// @param[in] numDiscretizations /// @param[in] intersectionDistances /// @param[out] distances - void ComputeDiscretizations(size_t numIntersections, - size_t numPoints, - size_t numDiscretizations, + void ComputeDiscretizations(UInt numIntersections, + UInt numPoints, + UInt numDiscretizations, const std::vector& intersectionDistances, std::vector& distances) const; - std::vector m_splineType; ///< The spline types (1 horizontal, -1 vertical) - std::vector> m_splineIntersectionRatios; ///< For each spline, stores the intersections in terms of total spline length - std::vector> m_splineGroupIndexAndFromToIntersections; ///< For each spline: position in m or n group, from and to spline crossing indices (MN12) - size_t m_numMSplines = 0; ///< The index of the last m spline - size_t m_numNSplines = 0; ///< The index of the last m spline - size_t m_numM = 0; ///< Number of m columns - size_t m_numN = 0; ///< Number of n rows + std::vector m_splineType; ///< The spline types (1 horizontal, -1 vertical) + std::vector> m_splineIntersectionRatios; ///< For each spline, stores the intersections in terms of total spline length + std::vector> m_splineGroupIndexAndFromToIntersections; ///< For each spline: position in m or n group, from and to spline crossing indices (MN12) + UInt m_numMSplines = 0; ///< The index of the last m spline + UInt m_numNSplines = 0; ///< The index of the last m spline + UInt m_numM = 0; ///< Number of m columns + UInt m_numN = 0; ///< Number of n rows }; } // namespace meshkernel diff --git a/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridLine.hpp b/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridLine.hpp index a0399aab5..ce2c5cb46 100644 --- a/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridLine.hpp +++ b/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridLine.hpp @@ -29,6 +29,7 @@ #include +#include #include #include @@ -58,7 +59,7 @@ namespace meshkernel /// @brief Gets the indices of a node on the grid line /// @param[in] coordinate The one-dimensional coordinate along the grid line /// @return The node indices - [[nodiscard]] CurvilinearGridNodeIndices GetNodeIndexFromCoordinate(size_t const& coordinate) const; + [[nodiscard]] CurvilinearGridNodeIndices GetNodeIndexFromCoordinate(UInt const& coordinate) const; /// @brief Inquires if the grid line is an M grid line /// @return True if it is an M grid line @@ -70,9 +71,9 @@ namespace meshkernel CurvilinearGridNodeIndices m_startNode; ///< The start node of the grid line CurvilinearGridNodeIndices m_endNode; ///< The end node of the grid line - size_t m_startCoordinate; ///< The start coordinate. If it is an MDirection, the start m otherwise the start n - size_t m_endCoordinate; ///< The end coordinate. If it is an MDirection, the end m otherwise the end n - size_t m_constantCoordinate; ///< The constant coordinate. If it is an MDirection, the n coordinate, otherwise the m coordinate + UInt m_startCoordinate; ///< The start coordinate. If it is an MDirection, the start m otherwise the start n + UInt m_endCoordinate; ///< The end coordinate. If it is an MDirection, the end m otherwise the end n + UInt m_constantCoordinate; ///< The constant coordinate. If it is an MDirection, the n coordinate, otherwise the m coordinate GridLineDirection m_gridLineType; ///< The grid line type }; } // namespace meshkernel diff --git a/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridNodeIndices.hpp b/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridNodeIndices.hpp index 5d940d7aa..c263d728b 100644 --- a/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridNodeIndices.hpp +++ b/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridNodeIndices.hpp @@ -37,15 +37,15 @@ namespace meshkernel struct CurvilinearGridNodeIndices { /// @brief Default constructor sets the indices to invalid - CurvilinearGridNodeIndices() : m_m(constants::missing::sizetValue), m_n(constants::missing::sizetValue){}; + CurvilinearGridNodeIndices() : m_m(constants::missing::uintValue), m_n(constants::missing::uintValue){}; /// @brief Constructor sets indices from values /// @param[in] m The m index /// @param[in] n The n index - CurvilinearGridNodeIndices(size_t m, size_t n) : m_m(m), m_n(n){}; + CurvilinearGridNodeIndices(UInt m, UInt n) : m_m(m), m_n(n){}; /// @brief Determines if one of the indices equals to \p missingValue - [[nodiscard]] bool IsValid(const size_t missingValue = constants::missing::sizetValue) const + [[nodiscard]] bool IsValid(const UInt missingValue = constants::missing::uintValue) const { return m_m != missingValue && m_n != missingValue; } @@ -61,7 +61,7 @@ namespace meshkernel return m_m == rhs.m_m || m_n == rhs.m_n; } - size_t m_m; ///< Columns - size_t m_n; ///< Rows + UInt m_m; ///< Columns + UInt m_n; ///< Rows }; } // namespace meshkernel diff --git a/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridRefinement.hpp b/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridRefinement.hpp index 36f7c421f..dcac2acb6 100644 --- a/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridRefinement.hpp +++ b/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridRefinement.hpp @@ -45,13 +45,13 @@ namespace meshkernel /// \p firstPoint and \p secondPoint must lie on the same gridline /// @param[in] grid The input curvilinear grid /// @param[in] refinement The number of refinement lines between the points set by SetBlock() - CurvilinearGridRefinement(const std::shared_ptr& grid, size_t refinement); + CurvilinearGridRefinement(const std::shared_ptr& grid, UInt refinement); /// @brief Refine the curvilinear grid CurvilinearGrid Compute() override; private: - size_t m_refinement; ///< The selected number of refinement lines - Splines m_splines; ///< An instance of the spline class storing the individual grid lines as splines + UInt m_refinement; ///< The selected number of refinement lines + Splines m_splines; ///< An instance of the spline class storing the individual grid lines as splines }; } // namespace meshkernel diff --git a/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridSmoothing.hpp b/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridSmoothing.hpp index b92c8d218..c98638b50 100644 --- a/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridSmoothing.hpp +++ b/libs/MeshKernel/include/MeshKernel/CurvilinearGrid/CurvilinearGridSmoothing.hpp @@ -43,7 +43,7 @@ namespace meshkernel /// @brief Class constructor /// @param[in] grid The input curvilinear grid /// @param[in] smoothingIterations The number of smoothing iterations to perform - CurvilinearGridSmoothing(std::shared_ptr grid, size_t smoothingIterations); + CurvilinearGridSmoothing(std::shared_ptr grid, UInt smoothingIterations); /// @brief Compute curvilinear grid block smoothing (modifies the m_grid nodal values) /// @return The smoothed grid @@ -65,9 +65,9 @@ namespace meshkernel /// @param[in] point The point to project /// @param[in] m The current m coordinate on the boundary of the curvilinear grid /// @param[in] n The current n coordinate on the boundary of the curvilinear grid - void ProjectPointOnClosestGridBoundary(Point const& point, size_t m, size_t n); + void ProjectPointOnClosestGridBoundary(Point const& point, UInt m, UInt n); - size_t m_smoothingIterations; ///< The orthogonalization parameters + UInt m_smoothingIterations; ///< The orthogonalization parameters std::vector> m_gridNodesCache; ///< A cache for storing current iteration node positions }; } // namespace meshkernel diff --git a/libs/MeshKernel/include/MeshKernel/Definitions.hpp b/libs/MeshKernel/include/MeshKernel/Definitions.hpp new file mode 100644 index 000000000..d8819bdfe --- /dev/null +++ b/libs/MeshKernel/include/MeshKernel/Definitions.hpp @@ -0,0 +1,36 @@ +//---- GPL --------------------------------------------------------------------- +// +// Copyright (C) Stichting Deltares, 2011-2021. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation version 3. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// contact: delft3d.support@deltares.nl +// Stichting Deltares +// P.O. Box 177 +// 2600 MH Delft, The Netherlands +// +// All indications and logos of, and references to, "Delft3D" and "Deltares" +// are registered trademarks of Stichting Deltares, and remain the property of +// Stichting Deltares. All rights reserved. +// +//------------------------------------------------------------------------------ + +#pragma once + +#include + +namespace meshkernel +{ + /// @brief Integer type used when indexing mesh graph entities. + using UInt = std::uint32_t; +} // namespace meshkernel diff --git a/libs/MeshKernel/include/MeshKernel/Entities.hpp b/libs/MeshKernel/include/MeshKernel/Entities.hpp index 476c6354f..924504e0e 100644 --- a/libs/MeshKernel/include/MeshKernel/Entities.hpp +++ b/libs/MeshKernel/include/MeshKernel/Entities.hpp @@ -28,13 +28,13 @@ #pragma once #include -#include #include #include namespace meshkernel { + // to re-enable when compiling with c++20 support // template // concept IsCoordinate = requires(T t) @@ -159,13 +159,13 @@ namespace meshkernel }; /// @brief Describes an edge with two indices - using Edge = std::pair; + using Edge = std::pair; /// @brief Get the index of the node on the other node of the edge /// @param[in] edge The given edge /// @param[in] node The node where we want the other one /// @returns Node index of other node of the edge - size_t static OtherNodeOfEdge(const Edge& edge, size_t node) + UInt static OtherNodeOfEdge(const Edge& edge, UInt node) { return node == edge.first ? edge.second : edge.first; } @@ -205,7 +205,7 @@ namespace meshkernel { // Build the samples std::vector samples(numSamples); - for (size_t i = 0; i < samples.size(); ++i) + for (UInt i = 0; i < samples.size(); ++i) { samples[i].x = (*samplesXCoordinate)[i]; samples[i].y = (*samplesYCoordinate)[i]; @@ -269,21 +269,21 @@ namespace meshkernel } /// @brief Converts array of face centers to corresponding vector - static std::vector> ConvertToFaceNodesVector(int num_faces, - const int* const face_nodes, - const int* const nodes_per_face) + static std::vector> ConvertToFaceNodesVector(int num_faces, + const int* const face_nodes, + const int* const nodes_per_face) { - std::vector> result; + std::vector> result; result.reserve(num_faces); - std::vector nodes; - size_t index = 0; + std::vector nodes; + UInt index = 0; for (auto f = 0; f < num_faces; f++) { nodes.clear(); for (auto n = 0; n < nodes_per_face[f]; n++) { - nodes.emplace_back(face_nodes[index]); + nodes.emplace_back(static_cast(face_nodes[index])); index++; } result.emplace_back(nodes); diff --git a/libs/MeshKernel/include/MeshKernel/Exceptions.hpp b/libs/MeshKernel/include/MeshKernel/Exceptions.hpp index 9dbaf585c..5c3c43624 100644 --- a/libs/MeshKernel/include/MeshKernel/Exceptions.hpp +++ b/libs/MeshKernel/include/MeshKernel/Exceptions.hpp @@ -232,7 +232,7 @@ namespace meshkernel /// @param[in] source_location The source location. explicit MeshGeometryError(std::source_location const& source_location = std::source_location::current()) : MeshKernelError("", source_location), - m_invalid_index{constants::missing::sizetValue}, + m_invalid_index{constants::missing::uintValue}, m_mesh_location(Mesh::Location::Unknown) { } @@ -243,7 +243,7 @@ namespace meshkernel /// @param[in] mesh_location The location type. /// @param[in] source_location The source location. MeshGeometryError(VariadicErrorMessage const& message, - size_t invalid_index, + UInt invalid_index, Mesh::Location mesh_location, std::source_location const& source_location = std::source_location::current()) : MeshKernelError(message, source_location), @@ -258,7 +258,7 @@ namespace meshkernel /// @param[in] mesh_location The location type. /// @param[in] source_location The source location. MeshGeometryError(std::string_view message, - size_t invalid_index, + UInt invalid_index, Mesh::Location mesh_location, std::source_location const& source_location = std::source_location::current()) : MeshKernelError(message, source_location), @@ -269,7 +269,7 @@ namespace meshkernel /// @brief Returns the invalid index. /// @return The invalid index. - size_t InavlidIndex() const { return m_invalid_index; } + UInt InavlidIndex() const { return m_invalid_index; } /// @brief Returns the mesh location. /// @return The mesh location. @@ -280,8 +280,8 @@ namespace meshkernel /// @return The error category. std::string Category() const override { return "MeshGeometryError"; } - size_t m_invalid_index; ///< The invalid mesh location index. + UInt m_invalid_index; ///< The invalid mesh location index. Mesh::Location m_mesh_location; ///< The location type. }; -} // namespace meshkernel \ No newline at end of file +} // namespace meshkernel diff --git a/libs/MeshKernel/include/MeshKernel/FlipEdges.hpp b/libs/MeshKernel/include/MeshKernel/FlipEdges.hpp index 2fb015450..cb1441988 100644 --- a/libs/MeshKernel/include/MeshKernel/FlipEdges.hpp +++ b/libs/MeshKernel/include/MeshKernel/FlipEdges.hpp @@ -27,6 +27,8 @@ #pragma once +#include "MeshKernel/Constants.hpp" + namespace meshkernel { // Forward declarations @@ -61,24 +63,24 @@ namespace meshkernel /// @param[out] nodeLeft The node at the left side of the edge /// @param[out] nodeRight The node at the left side of the edge /// @return topologyFunctional The computed functional - int ComputeTopologyFunctional(size_t edge, - size_t& nodeLeft, - size_t& nodeRight) const; + int ComputeTopologyFunctional(UInt edge, + UInt& nodeLeft, + UInt& nodeRight) const; /// @brief Determine the optimal number of connected nodes for each node (nmk_opt) /// @param nodeIndex /// @returns Optimal number of connected nodes - [[nodiscard]] size_t OptimalNumberOfConnectedNodes(size_t nodeIndex) const; + [[nodiscard]] UInt OptimalNumberOfConnectedNodes(UInt nodeIndex) const; /// @brief Compute the difference with the optimal number of edges by counting the numbers of edges that /// connect nodes firstNode and secondNode, and are on the land boundary path (comp_nnow) /// @returns Difference form optimum - [[nodiscard]] int DifferenceFromOptimum(size_t nodeIndex, size_t firstNode, size_t secondNode) const; + [[nodiscard]] int DifferenceFromOptimum(UInt nodeIndex, UInt firstNode, UInt secondNode) const; /// @brief Remove a connected edge from a node /// @param[in] edgeIndex The index of the edge to remove /// @param[in] nodeIndex The index of the node to process - void DeleteEdgeFromNode(size_t edgeIndex, size_t nodeIndex) const; + void DeleteEdgeFromNode(UInt edgeIndex, UInt nodeIndex) const; std::shared_ptr m_mesh; ///< A pointer to the 2D mesh std::shared_ptr m_landBoundaries; ///< A pointer to the land boundaries diff --git a/libs/MeshKernel/include/MeshKernel/LandBoundaries.hpp b/libs/MeshKernel/include/MeshKernel/LandBoundaries.hpp index d04c520b5..dd17f96dc 100644 --- a/libs/MeshKernel/include/MeshKernel/LandBoundaries.hpp +++ b/libs/MeshKernel/include/MeshKernel/LandBoundaries.hpp @@ -86,7 +86,7 @@ namespace meshkernel /// @return The number of land boundary nodes. auto GetNumNodes() const { return m_nodes.size(); } - std::vector m_meshNodesLandBoundarySegments; ///< Mesh nodes to land boundary mapping (lanseg_map) + std::vector m_meshNodesLandBoundarySegments; ///< Mesh nodes to land boundary mapping (lanseg_map) private: /// @brief Build an additional boundary for not assigned nodes (connect_boundary_paths) @@ -94,29 +94,29 @@ namespace meshkernel /// @param[in] initialize /// @param[in] nodes /// @param[in] numNodes - void AssignLandBoundaryPolylineToMeshNodes(size_t edgeIndex, + void AssignLandBoundaryPolylineToMeshNodes(UInt edgeIndex, bool initialize, - std::vector& nodes, - size_t numNodes); + std::vector& nodes, + UInt numNodes); /// @brief Add new land boundary segment that connects two others (add_land) /// @param[in] nodesLoc /// @param[in] numNodesLoc /// @param[in] nodeIndex - void AddLandBoundary(const std::vector& nodesLoc, - size_t numNodesLoc, - size_t nodeIndex); + void AddLandBoundary(const std::vector& nodesLoc, + UInt numNodesLoc, + UInt nodeIndex); /// @brief Assigns to each mesh node a land boundary segment. /// /// This is done by modifying m_meshNodesLandBoundarySegments. /// @param[in] landBoundaryIndex The current landboundary segment /// @returns The number of mesh nodes and rejected nodes for this path - std::tuple MakePath(size_t landBoundaryIndex); + std::tuple MakePath(UInt landBoundaryIndex); /// @brief Mask the mesh nodes to be considered in the shortest path algorithm for the current land boundary polyline (masknodes). /// @param[in] landBoundaryIndex The land boundary polyline index - void ComputeMeshNodeMask(size_t landBoundaryIndex); + void ComputeMeshNodeMask(UInt landBoundaryIndex); /// @brief Mask the mesh nodes to be considered in the shortest path algorithm for the current segmentIndex. /// It is setting leftIndex, rightIndex, leftEdgeRatio, rightEdgeRatio (masknodes). @@ -129,25 +129,25 @@ namespace meshkernel /// @param[out] rightIndex /// @param[out] leftEdgeRatio /// @param[out] rightEdgeRatio - void ComputeMask(size_t segmentIndex, + void ComputeMask(UInt segmentIndex, bool meshBoundOnly, - size_t startLandBoundaryIndex, - size_t endLandBoundaryIndex, - size_t& leftIndex, - size_t& rightIndex, + UInt startLandBoundaryIndex, + UInt endLandBoundaryIndex, + UInt& leftIndex, + UInt& rightIndex, double& leftEdgeRatio, double& rightEdgeRatio); /// @brief Mask all face close to a land boundary, starting from a seed of others and growing from there (maskcells) /// @param[in] landBoundaryIndex The land boundary polyline index /// @param[in] initialFaces The initial face seeds - void MaskMeshFaceMask(size_t landBoundaryIndex, const std::vector& initialFaces); + void MaskMeshFaceMask(UInt landBoundaryIndex, const std::vector& initialFaces); /// @brief Check if a mesh edge is close to a land boundary segment (linkcrossedbyland) /// @param[in] landBoundaryIndex The land boundary polyline index /// @param[in] edge The mesh edge to inquire /// @return the closest land boundary node - [[nodiscard]] size_t IsMeshEdgeCloseToLandBoundaries(size_t landBoundaryIndex, size_t edge); + [[nodiscard]] UInt IsMeshEdgeCloseToLandBoundaries(UInt landBoundaryIndex, UInt edge); /// @brief Finds the start and the end mesh node indices which correspond to a landboundary polyline. /// These are the nodes that are on a edge close to the land boundary segment (get_kstartend2) @@ -155,39 +155,39 @@ namespace meshkernel /// \image html LandBoundaryDijkstra_step4.jpg "Compute the land boundary representation on the mesh using the Djikstra shortest path algorithm." /// @param[in] landBoundaryIndex The land boundary polyline index /// @returns the start and the end mesh nodes indices - std::tuple FindStartEndMeshNodesDijkstraAlgorithm(size_t landBoundaryIndex); + std::tuple FindStartEndMeshNodesDijkstraAlgorithm(UInt landBoundaryIndex); /// @brief Finds the edge nodes closest to a point /// /// \image html LandBoundaryStartEndNodes_step3.jpg "Find the start and end mesh nodes of the land boundary on the mesh." /// @param[in] edge The edge index /// @param[in] point The point to inquire - size_t FindStartEndMeshNodesFromEdges(size_t edge, Point point) const; + UInt FindStartEndMeshNodesFromEdges(UInt edge, Point point) const; /// @brief Connect mesh nodes close to the landBoundaryIndex using Dijkstra's algorithm /// @param[in] landBoundaryIndex The index of a valid landboundary /// @param[in] startMeshNode The starting point /// @returns A vector of connected edge indices for each node - std::vector ShortestPath(size_t landBoundaryIndex, size_t startMeshNode); + std::vector ShortestPath(UInt landBoundaryIndex, UInt startMeshNode); /// @brief Compute the nearest land boundary segment (toland) /// @param[in] landBoundaryIndex The land boundary index /// @param[in] node The node /// @returns A tuple containing the distance of the node from the land boundary, the projected node on the land boundary, /// the closest land boundary node and the length of the segment from the starting point to the projected point expressed as an edge ratio. - std::tuple NearestLandBoundarySegment(size_t landBoundaryIndex, const Point& node); - - std::shared_ptr m_mesh; ///< A pointer to mesh - std::shared_ptr m_polygons; ///< A pointer to polygons - std::vector m_nodes; ///< XLAN, YLAN - std::vector m_polygonNodesCache; ///< Array of points (e.g. points of a face) - std::vector> m_validLandBoundaries; ///< Start and end indices of valid land boundaries (lanseg_startend) - std::vector> m_nodesLand; ///< Node to land boundary segment mapping - std::vector m_nodeFaceIndices; ///< For each node, the indices of the faces including them - - std::vector m_nodeMask; ///< Node mask - std::vector m_faceMask; ///< Face mask - std::vector m_edgeMask; ///< Edge mask + std::tuple NearestLandBoundarySegment(UInt landBoundaryIndex, const Point& node); + + std::shared_ptr m_mesh; ///< A pointer to mesh + std::shared_ptr m_polygons; ///< A pointer to polygons + std::vector m_nodes; ///< XLAN, YLAN + std::vector m_polygonNodesCache; ///< Array of points (e.g. points of a face) + std::vector> m_validLandBoundaries; ///< Start and end indices of valid land boundaries (lanseg_startend) + std::vector> m_nodesLand; ///< Node to land boundary segment mapping + std::vector m_nodeFaceIndices; ///< For each node, the indices of the faces including them + + std::vector m_nodeMask; ///< Node mask + std::vector m_faceMask; ///< Face mask + std::vector m_edgeMask; ///< Edge mask bool m_landMask = true; ///< Land mask bool m_addLandboundaries = true; ///< Whether to add land boundaries diff --git a/libs/MeshKernel/include/MeshKernel/Mesh.hpp b/libs/MeshKernel/include/MeshKernel/Mesh.hpp index 8ab286b8c..79ec8a08d 100644 --- a/libs/MeshKernel/include/MeshKernel/Mesh.hpp +++ b/libs/MeshKernel/include/MeshKernel/Mesh.hpp @@ -105,9 +105,9 @@ namespace meshkernel int polylineSegmentIndex{constants::missing::intValue}; ///< The intersected segment index (a polyline can formed by several segments) double polylineDistance{constants::missing::doubleValue}; ///< The location of the intersection expressed as distance from the polyline start double adimensionalPolylineSegmentDistance{constants::missing::doubleValue}; ///< The location of the intersection expressed as an adimensional distance from the segment start - size_t edgeIndex{constants::missing::sizetValue}; ///< The first node of the edge is on the left (the virtual node) - size_t edgeFirstNode{constants::missing::sizetValue}; ///< The first node of the edge is on the left (the virtual node) - size_t edgeSecondNode{constants::missing::sizetValue}; ///< The second node of the edge is on the right (the inner node) + UInt edgeIndex{constants::missing::uintValue}; ///< The first node of the edge is on the left (the virtual node) + UInt edgeFirstNode{constants::missing::uintValue}; ///< The first node of the edge is on the left (the virtual node) + UInt edgeSecondNode{constants::missing::uintValue}; ///< The second node of the edge is on the right (the inner node) double edgeDistance{constants::missing::doubleValue}; ///< The location of the intersection expressed as an adimensional distance from the edge start }; @@ -115,9 +115,9 @@ namespace meshkernel struct FaceMeshPolylineIntersection { double polylineDistance{constants::missing::doubleValue}; ///< The location of the intersection expressed as an adimensional distance from the polyline start - size_t faceIndex{constants::missing::sizetValue}; ///< The face index - std::vector edgeIndexses; ///< The indexes of crossed edges - std::vector edgeNodes; ///< The indexes of the nodes defining the crossed edges + UInt faceIndex{constants::missing::uintValue}; ///< The face index + std::vector edgeIndexses; ///< The indexes of crossed edges + std::vector edgeNodes; ///< The indexes of the nodes defining the crossed edges }; /// @brief Default constructor @@ -138,44 +138,44 @@ namespace meshkernel /// @brief Inquire if a node is on boundary /// @param[in] node The node index /// @return If the node is on boundary - [[nodiscard]] bool IsNodeOnBoundary(size_t node) const { return m_nodesNumEdges[node] == 1; } + [[nodiscard]] bool IsNodeOnBoundary(UInt node) const { return m_nodesNumEdges[node] == 1; } /// @brief Get the number of valid nodes /// @return The number of valid node - [[nodiscard]] auto GetNumNodes() const { return m_nodes.size(); } + [[nodiscard]] auto GetNumNodes() const { return static_cast(m_nodes.size()); } /// @brief Get the number of valid edges /// @return The number of valid edges - [[nodiscard]] auto GetNumEdges() const { return m_edges.size(); } + [[nodiscard]] auto GetNumEdges() const { return static_cast(m_edges.size()); } /// @brief Get the number of valid faces /// @return The number of valid faces - [[nodiscard]] auto GetNumFaces() const { return m_facesNodes.size(); } + [[nodiscard]] auto GetNumFaces() const { return static_cast(m_facesNodes.size()); } /// @brief Get the number of edges for a face /// @param[in] faceIndex The face index /// @return The number of valid faces - [[nodiscard]] auto GetNumFaceEdges(size_t faceIndex) const { return m_numFacesNodes[faceIndex]; } + [[nodiscard]] auto GetNumFaceEdges(UInt faceIndex) const { return m_numFacesNodes[faceIndex]; } /// @brief Get the number of faces an edges shares /// @param[in] edgeIndex The edge index /// @return The number of faces an edges shares - [[nodiscard]] auto GetNumEdgesFaces(size_t edgeIndex) const { return m_edgesNumFaces[edgeIndex]; } + [[nodiscard]] auto GetNumEdgesFaces(UInt edgeIndex) const { return m_edgesNumFaces[edgeIndex]; } /// @brief Inquire if an edge is on boundary /// @param edge The edge index /// @return If the edge is on boundary - [[nodiscard]] bool IsEdgeOnBoundary(size_t edge) const { return m_edgesNumFaces[edge] == 1; } + [[nodiscard]] bool IsEdgeOnBoundary(UInt edge) const { return m_edgesNumFaces[edge] == 1; } /// @brief Inquire if a face is on boundary /// @param[in] face The face index /// @return If the face is on boundary - [[nodiscard]] bool IsFaceOnBoundary(size_t face) const; + [[nodiscard]] bool IsFaceOnBoundary(UInt face) const; /// @brief Merges two mesh nodes /// @param[in] startNode The index of the first node to be merged /// @param[in] endNode The second of the second node to be merged - void MergeTwoNodes(size_t startNode, size_t endNode); + void MergeTwoNodes(UInt startNode, UInt endNode); /// @brief Merge close mesh nodes inside a polygon (MERGENODESINPOLYGON) /// @param[in] polygons Polygon where to perform the merging @@ -186,55 +186,55 @@ namespace meshkernel /// @param[in] startNode The start node index /// @param[in] endNode The end node index /// @return The index of the new edge - size_t ConnectNodes(size_t startNode, size_t endNode); + UInt ConnectNodes(UInt startNode, UInt endNode); /// @brief Insert a new node in the mesh (setnewpoint) /// @param[in] newPoint The coordinate of the new point /// @return The index of the new node - size_t InsertNode(const Point& newPoint); + UInt InsertNode(const Point& newPoint); /// @brief Delete a node /// @param[in] node The index of the node to delete - void DeleteNode(size_t node); + void DeleteNode(UInt node); /// @brief Find the edge sharing two nodes /// @param[in] firstNodeIndex The index of the first node /// @param[in] secondNodeIndex The index of the second node /// @return The edge index - [[nodiscard]] size_t FindEdge(size_t firstNodeIndex, size_t secondNodeIndex) const; + [[nodiscard]] UInt FindEdge(UInt firstNodeIndex, UInt secondNodeIndex) const; /// @brief Move a node to a new location /// @param[in] newPoint The new location /// @param[in] nodeindex The index of the node to move - void MoveNode(Point newPoint, size_t nodeindex); + void MoveNode(Point newPoint, UInt nodeindex); /// @brief Get the index of a node close to a point /// @param[in] point The starting point from where to start the search /// @param[in] nodeMask The mask to apply to mesh nodes, if the mask value is false, the next closest node will be considered /// @returns The index of the closest node - [[nodiscard]] size_t FindNodeCloseToAPoint(Point point, const std::vector& nodeMask); + [[nodiscard]] UInt FindNodeCloseToAPoint(Point point, const std::vector& nodeMask); /// @brief Get the index of a node close to a point /// @param[in] point The starting point from where to start the search /// @param[in] searchRadius The search radius /// @returns The index of the closest node - [[nodiscard]] size_t FindNodeCloseToAPoint(Point const& point, double searchRadius); + [[nodiscard]] UInt FindNodeCloseToAPoint(Point const& point, double searchRadius); /// @brief Deletes an edge /// @param[in] edge The edge index - void DeleteEdge(size_t edge); + void DeleteEdge(UInt edge); /// Finds the closest edge close to a point /// @param[in] point The starting point from where to start the search /// @returns The index of the closest edge - [[nodiscard]] size_t FindEdgeCloseToAPoint(Point point); + [[nodiscard]] UInt FindEdgeCloseToAPoint(Point point); /// @brief Find the common node two edges share /// This method uses return parameters since the success is evaluated in a hot loop /// @param[in] firstEdgeIndex The index of the first edge /// @param[in] secondEdgeIndex The index of the second edge /// @return The shared node (constants::missing::sizetValue if no node is found) - [[nodiscard]] size_t FindCommonNode(size_t firstEdgeIndex, size_t secondEdgeIndex) const; + [[nodiscard]] UInt FindCommonNode(UInt firstEdgeIndex, UInt secondEdgeIndex) const; /// @brief Compute the lengths of all edges in one go void ComputeEdgesLengths(); @@ -254,12 +254,12 @@ namespace meshkernel /// @brief Sort mesh edges around a node in counterclockwise order (Sort_links_ccw) /// @param[in] startNode The first node index where to perform edge sorting. /// @param[in] endNode The last node index where to perform edge sorting. - void SortEdgesInCounterClockWiseOrder(size_t startNode, size_t endNode); + void SortEdgesInCounterClockWiseOrder(UInt startNode, UInt endNode); /// @brief Compute the max length of the edges connected to a node /// @param node The mesh node /// @return The max edge length - double ComputeMaxLengthSurroundingEdges(size_t node); + double ComputeMaxLengthSurroundingEdges(UInt node); /// @brief Build the rtree for the corresponding location /// @param[in] meshLocation The mesh location for which the RTree is build @@ -287,13 +287,13 @@ namespace meshkernel /// /// @param[in] meshLocation The mesh location (e.g. nodes, edge centers or face circumcenters). /// @return The number of found neighbors. - size_t GetNumLocations(Location meshLocation) const; + UInt GetNumLocations(Location meshLocation) const; /// @brief Gets the index of the location, sorted by proximity. To be used after SearchNearestLocation or SearchNearestLocation. /// @param[in] index The closest neighbor index (index 0 corresponds to the closest). /// @param[in] meshLocation The mesh location (e.g. nodes, edge centers or face circumcenters). /// @return The index of the closest location. - [[nodiscard]] size_t GetLocationsIndices(size_t index, Mesh::Location meshLocation); + [[nodiscard]] UInt GetLocationsIndices(UInt index, Mesh::Location meshLocation); /// @brief Computes a vector with the mesh locations coordinates (nodes, edges or faces coordinates). /// @@ -308,26 +308,26 @@ namespace meshkernel Mesh& operator+=(Mesh const& rhs); // nodes - std::vector m_nodes; ///< The mesh nodes (xk, yk) - std::vector> m_nodesEdges; ///< For each node, the indices of connected edges (nod%lin) - std::vector m_nodesNumEdges; ///< For each node, the number of connected edges (nmk) - std::vector> m_nodesNodes; ///< For each node, its neighbors - std::vector m_nodesTypes; ///< The node types (nb) + std::vector m_nodes; ///< The mesh nodes (xk, yk) + std::vector> m_nodesEdges; ///< For each node, the indices of connected edges (nod%lin) + std::vector m_nodesNumEdges; ///< For each node, the number of connected edges (nmk) + std::vector> m_nodesNodes; ///< For each node, its neighbors + std::vector m_nodesTypes; ///< The node types (nb) // edges - std::vector m_edges; ///< The edges, defined as first and second node(kn) - std::vector> m_edgesFaces; ///< For each edge, the shared face index (lne) - std::vector m_edgesNumFaces; ///< For each edge, the number of shared faces(lnn) - std::vector m_edgeLengths; ///< The edge lengths - std::vector m_edgesCenters; ///< The edges centers + std::vector m_edges; ///< The edges, defined as first and second node(kn) + std::vector> m_edgesFaces; ///< For each edge, the shared face index (lne) + std::vector m_edgesNumFaces; ///< For each edge, the number of shared faces(lnn) + std::vector m_edgeLengths; ///< The edge lengths + std::vector m_edgesCenters; ///< The edges centers // faces - std::vector> m_facesNodes; ///< The nodes composing the faces, in ccw order (netcell%Nod) - std::vector m_numFacesNodes; ///< The number of nodes composing the face (netcell%N) - std::vector> m_facesEdges; ///< The edge indices composing the face (netcell%lin) - std::vector m_facesCircumcenters; ///< The face circumcenters the face circumcenter (xz, yz) - std::vector m_facesMassCenters; ///< The faces centers of mass (xzw, yzw) - std::vector m_faceArea; ///< The face area + std::vector> m_facesNodes; ///< The nodes composing the faces, in ccw order (netcell%Nod) + std::vector m_numFacesNodes; ///< The number of nodes composing the face (netcell%N) + std::vector> m_facesEdges; ///< The edge indices composing the face (netcell%lin) + std::vector m_facesCircumcenters; ///< The face circumcenters the face circumcenter (xz, yz) + std::vector m_facesMassCenters; ///< The faces centers of mass (xzw, yzw) + std::vector m_faceArea; ///< The face area Projection m_projection; ///< The projection used @@ -339,12 +339,12 @@ namespace meshkernel RTree m_facesRTree; ///< Spatial R-Tree used to inquire face circumcenters // constants - static constexpr size_t m_maximumNumberOfEdgesPerNode = 12; ///< Maximum number of edges per node - static constexpr size_t m_maximumNumberOfEdgesPerFace = 6; ///< Maximum number of edges per face - static constexpr size_t m_maximumNumberOfNodesPerFace = 8; ///< Maximum number of nodes per face - static constexpr size_t m_maximumNumberOfConnectedNodes = m_maximumNumberOfEdgesPerNode * 4; ///< Maximum number of connected nodes - static constexpr size_t m_numNodesQuads = 4; ///< Number of nodes in a quadrilateral - static constexpr size_t m_numNodesInTriangle = 3; ///< Number of nodes in a triangle + static constexpr UInt m_maximumNumberOfEdgesPerNode = 12; ///< Maximum number of edges per node + static constexpr UInt m_maximumNumberOfEdgesPerFace = 6; ///< Maximum number of edges per face + static constexpr UInt m_maximumNumberOfNodesPerFace = 8; ///< Maximum number of nodes per face + static constexpr UInt m_maximumNumberOfConnectedNodes = m_maximumNumberOfEdgesPerNode * 4; ///< Maximum number of connected nodes + static constexpr UInt m_numNodesQuads = 4; ///< Number of nodes in a quadrilateral + static constexpr UInt m_numNodesInTriangle = 3; ///< Number of nodes in a triangle private: static double constexpr m_minimumDeltaCoordinate = 1e-14; ///< Minimum delta coordinate diff --git a/libs/MeshKernel/include/MeshKernel/Mesh1D.hpp b/libs/MeshKernel/include/MeshKernel/Mesh1D.hpp index 7541da824..3cd2d6bf7 100644 --- a/libs/MeshKernel/include/MeshKernel/Mesh1D.hpp +++ b/libs/MeshKernel/include/MeshKernel/Mesh1D.hpp @@ -66,13 +66,13 @@ namespace meshkernel /// @brief Inquire if a mesh 1d-node is on boundary /// @param[in] node The node index /// @return If the node is on boundary - [[nodiscard]] bool IsNodeOnBoundary(size_t node) const { return m_nodesNumEdges[node] == 1; } + [[nodiscard]] bool IsNodeOnBoundary(UInt node) const { return m_nodesNumEdges[node] == 1; } /// @brief Compute a projected node along a line normal to the edges connected to the node. /// @param node [in] The node /// @param distanceFactor [in] The distance factor /// @return The projected node - [[nodiscard]] Point ComputeProjectedNode(size_t node, double distanceFactor) const; + [[nodiscard]] Point ComputeProjectedNode(UInt node, double distanceFactor) const; }; } // namespace meshkernel diff --git a/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp b/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp index 8481764f2..d8dd722c1 100644 --- a/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp +++ b/libs/MeshKernel/include/MeshKernel/Mesh2D.hpp @@ -89,8 +89,8 @@ namespace meshkernel /// @param[in] projection The mesh projection Mesh2D(const std::vector& edges, const std::vector& nodes, - const std::vector>& faceNodes, - const std::vector& numFaceNodes, + const std::vector>& faceNodes, + const std::vector& numFaceNodes, Projection projection); /// @brief Create triangular grid from nodes (triangulatesamplestonetwork) @@ -118,22 +118,22 @@ namespace meshkernel /// @param[out] polygonNodesCache The node cache array filled with the nodes values /// @param[out] localNodeIndicesCache The consecutive node index in polygonNodesCache (0, 1, 2,...) /// @param[out] globalEdgeIndicesCache The edge cache array filled with the global edge indices - void ComputeFaceClosedPolygonWithLocalMappings(size_t faceIndex, + void ComputeFaceClosedPolygonWithLocalMappings(UInt faceIndex, std::vector& polygonNodesCache, - std::vector& localNodeIndicesCache, - std::vector& globalEdgeIndicesCache) const; + std::vector& localNodeIndicesCache, + std::vector& globalEdgeIndicesCache) const; /// @brief For a face create a closed polygon /// @param[in] faceIndex The face index /// @param[in,out] polygonNodesCache The cache array to be filled with the nodes values - void ComputeFaceClosedPolygon(size_t faceIndex, std::vector& polygonNodesCache) const; + void ComputeFaceClosedPolygon(UInt faceIndex, std::vector& polygonNodesCache) const; /// @brief For a closed polygon, compute the circumcenter of a face (getcircumcenter) /// @param[in,out] polygon Cache storing the face nodes /// @param[in] edgesNumFaces For meshes, the number of faces sharing the edges /// @returns The computed circumcenter [[nodiscard]] Point ComputeFaceCircumenter(std::vector& polygon, - const std::vector& edgesNumFaces) const; + const std::vector& edgesNumFaces) const; /// @brief Gets the mass centers of obtuse triangles /// @returns The center of obtuse triangles @@ -142,12 +142,12 @@ namespace meshkernel /// @brief Gets the edges crossing the small flow edges /// @param[in] smallFlowEdgesThreshold The configurable threshold for detecting the small flow edges /// @returns The indices of the edges crossing small flow edges - [[nodiscard]] std::vector GetEdgesCrossingSmallFlowEdges(double smallFlowEdgesThreshold); + [[nodiscard]] std::vector GetEdgesCrossingSmallFlowEdges(double smallFlowEdgesThreshold); /// @brief Gets the flow edges centers from the crossing edges /// @param[in] edges The crossing edges indices /// @returns The centers of the flow edges - [[nodiscard]] std::vector GetFlowEdgesCenters(const std::vector& edges) const; + [[nodiscard]] std::vector GetFlowEdgesCenters(const std::vector& edges) const; /// @brief Deletes small flow edges (removesmallflowlinks, part 1) /// @@ -220,12 +220,12 @@ namespace meshkernel /// @param[in] node The node index /// @param[in] enlargementFactor The factor by which the dual face is enlarged /// @param[out] dualFace The dual face to be calculated - void MakeDualFace(size_t node, double enlargementFactor, std::vector& dualFace); + void MakeDualFace(UInt node, double enlargementFactor, std::vector& dualFace); /// @brief Sorts the faces around a node, sorted in counter clock wise order /// @param[in] node The node index /// @return The face indexses - [[nodiscard]] std::vector SortedFacesAroundNode(size_t node) const; + [[nodiscard]] std::vector SortedFacesAroundNode(UInt node) const; /// @brief Convert all mesh boundaries to a vector of polygon nodes, including holes (copynetboundstopol) /// @param[in] polygon The polygon where the operation is performed @@ -239,12 +239,12 @@ namespace meshkernel /// @param[out] meshBoundaryPolygon The resulting polygon points void WalkBoundaryFromNode(const std::vector& polygonNodes, std::vector& isVisited, - size_t& currentNode, + UInt& currentNode, std::vector& meshBoundaryPolygon) const; /// @brief Gets the hanging edges /// @return A vector with the indices of the hanging edges - [[nodiscard]] std::vector GetHangingEdges() const; + [[nodiscard]] std::vector GetHangingEdges() const; /// @brief Deletes the hanging edges void DeleteHangingEdges(); @@ -252,7 +252,7 @@ namespace meshkernel /// @brief For a collection of points, compute the face indices including them. /// @param[in] points The input point vector. /// @return The face indices including the points. - [[nodiscard]] std::vector PointFaceIndices(const std::vector& points); + [[nodiscard]] std::vector PointFaceIndices(const std::vector& points); /// @brief Deletes a mesh in a polygon, using several options (delnet) /// @param[in] polygon The polygon where to perform the operation @@ -265,7 +265,7 @@ namespace meshkernel /// @param[in] firstPoint The first point of the segment /// @param[in] secondPoint The second point of the segment /// @return A tuple with the intersectedFace face index and intersected edge index - [[nodiscard]] std::tuple IsSegmentCrossingABoundaryEdge(const Point& firstPoint, const Point& secondPoint) const; + [[nodiscard]] std::tuple IsSegmentCrossingABoundaryEdge(const Point& firstPoint, const Point& secondPoint) const; /// @brief Gets the edges and faces intersected by a polyline, with additional information on the intersections /// @param[in] polyLine An input polyline, defined as a series of points @@ -292,7 +292,7 @@ namespace meshkernel /// @return The node mask [[nodiscard]] std::vector NodeMaskFromPolygon(const Polygons& polygons, bool inside) const; - size_t m_maxNumNeighbours = 0; ///< Maximum number of neighbours + UInt m_maxNumNeighbours = 0; ///< Maximum number of neighbours private: // orthogonalization @@ -311,21 +311,21 @@ namespace meshkernel /// @param[in,out] sortedEdges The caching array used for sorting the edges, used to inquire if an edge has been already visited /// @param[in,out] sortedNodes The caching array used for sorting the nodes, used to inquire if a node has been already visited /// @param[in,out] nodalValues The nodal values building a closed polygon - void FindFacesRecursive(size_t startNode, - size_t node, - size_t previousEdge, - size_t numClosingEdges, - std::vector& edges, - std::vector& nodes, - std::vector& sortedEdges, - std::vector& sortedNodes, + void FindFacesRecursive(UInt startNode, + UInt node, + UInt previousEdge, + UInt numClosingEdges, + std::vector& edges, + std::vector& nodes, + std::vector& sortedEdges, + std::vector& sortedNodes, std::vector& nodalValues); /// @brief Checks if a triangle has an acute angle (checktriangle) /// @param[in] faceNodes The face nodes composing the triangles /// @param[in] nodes The node coordinates /// @returns If triangle has an acute triangle - [[nodiscard]] bool HasTriangleNoAcuteAngles(const std::vector& faceNodes, const std::vector& nodes) const; + [[nodiscard]] bool HasTriangleNoAcuteAngles(const std::vector& faceNodes, const std::vector& nodes) const; /// @brief Resizes and initializes face vectors void ResizeAndInitializeFaceVectors() @@ -335,7 +335,7 @@ namespace meshkernel std::ranges::fill(m_edgesNumFaces, 0); m_edgesFaces.resize(m_edges.size()); - std::ranges::fill(m_edgesFaces, std::array{constants::missing::sizetValue, constants::missing::sizetValue}); + std::ranges::fill(m_edgesFaces, std::array{constants::missing::uintValue, constants::missing::uintValue}); m_facesMassCenters.clear(); m_faceArea.clear(); diff --git a/libs/MeshKernel/include/MeshKernel/MeshInterpolation.hpp b/libs/MeshKernel/include/MeshKernel/MeshInterpolation.hpp index ab733ff50..dc4a77442 100644 --- a/libs/MeshKernel/include/MeshKernel/MeshInterpolation.hpp +++ b/libs/MeshKernel/include/MeshKernel/MeshInterpolation.hpp @@ -27,6 +27,8 @@ #pragma once +#include "MeshKernel/Constants.hpp" + namespace meshkernel { /// @brief The interpolant types @@ -49,17 +51,17 @@ namespace meshkernel /// @brief Gets the interpolation value at a specific node /// @param[in] node The node index /// @return The interpolated value - [[nodiscard]] double GetNodeResult(size_t node) const { return m_nodeResults[node]; } + [[nodiscard]] double GetNodeResult(UInt node) const { return m_nodeResults[node]; } /// @brief Gets the interpolation value at a specific edge /// @param[in] edge The edge index /// @return The interpolated value - [[nodiscard]] double GetEdgeResult(size_t edge) const { return m_edgeResults[edge]; } + [[nodiscard]] double GetEdgeResult(UInt edge) const { return m_edgeResults[edge]; } /// @brief Gets the interpolation value at a specific face /// @param[in] face The face index /// @return The interpolated value - [[nodiscard]] double GetFaceResult(size_t face) const { return m_faceResults[face]; } + [[nodiscard]] double GetFaceResult(UInt face) const { return m_faceResults[face]; } /// @brief Gets all interpolated values at nodes /// @return The interpolated values diff --git a/libs/MeshKernel/include/MeshKernel/MeshRefinement.hpp b/libs/MeshKernel/include/MeshKernel/MeshRefinement.hpp index 242e5a0eb..9c7f2a487 100644 --- a/libs/MeshKernel/include/MeshKernel/MeshRefinement.hpp +++ b/libs/MeshKernel/include/MeshKernel/MeshRefinement.hpp @@ -145,7 +145,7 @@ namespace meshkernel /// @brief Computes refinement masks (compute_jarefine_poly) /// Face nodes, edge and edge lengths are stored in local caches. See Mesh2D.FaceClosedPolygon method /// @param face The face index - void ComputeRefinementMasksFromSamples(size_t face); + void ComputeRefinementMasksFromSamples(UInt face); /// Computes the edge refinement mask (comp_jalink) void ComputeEdgesRefinementMask(); @@ -153,24 +153,24 @@ namespace meshkernel /// @brief Finds the hanging nodes in a face (find_hangingnodes) /// @param[in] face The current face index /// @returns The number of hanging edges on the face, the number of hanging nodes and the number of edges to refine - void FindHangingNodes(size_t face); + void FindHangingNodes(UInt face); /// @brief Get the number of hanging nodes /// @returns The number of hanging nodes - size_t CountHangingNodes() const; + UInt CountHangingNodes() const; /// @brief Get the number of hanging nodes /// @returns The number of hanging nodes - size_t CountHangingEdges() const; + UInt CountHangingEdges() const; /// @brief Get the number of hanging nodes /// @param[in] face The current face index /// @returns The number of hanging nodes - size_t CountEdgesToRefine(size_t face) const; + UInt CountEdgesToRefine(UInt face) const; /// Deletes isolated hanging nodes(remove_isolated_hanging_nodes) /// @returns Number of deleted isolated hanging nodes - [[nodiscard]] size_t DeleteIsolatedHangingnodes(); + [[nodiscard]] UInt DeleteIsolatedHangingnodes(); /// @brief Connect the hanging nodes with triangles (connect_hanging_nodes) void ConnectHangingNodes(); @@ -183,37 +183,37 @@ namespace meshkernel /// @brief The refinement operation by splitting the face (refine_cells) /// @param[in] numEdgesBeforeRefinement Number of edges before the refinement - void RefineFacesBySplittingEdges(size_t numEdgesBeforeRefinement); + void RefineFacesBySplittingEdges(UInt numEdgesBeforeRefinement); /// @brief Compute if an edge must be refined based on the face location type and the Courant criteria /// @param edge The index of the edge to be refined /// @param faceLocationType The face location type /// @returns If the edge should be refined - bool IsEdgeToBeRefinedBasedFaceLocationTypeAndCourantCriteria(size_t edge, FaceLocation faceLocationType) const; + bool IsEdgeToBeRefinedBasedFaceLocationTypeAndCourantCriteria(UInt edge, FaceLocation faceLocationType) const; /// @brief Compute if an edge must be refined based on the face location type /// @param edge The index of the edge to be refined /// @param depthValues The depth value /// @returns If the edge should be refined based on Courant criteria - bool IsRefineNeededBasedOnCourantCriteria(size_t edge, double depthValues) const; + bool IsRefineNeededBasedOnCourantCriteria(UInt edge, double depthValues) const; /// @brief Compute the face location type based on the depths values on the nodes void ComputeFaceLocationTypes(); RTree m_samplesRTree; ///< The sample node RTree - std::vector m_faceMask; ///< Compute face without hanging nodes (1), refine face with hanging nodes (2), do not refine cell at all (0) or refine face outside polygon (-2) - std::vector m_edgeMask; ///< If 0, edge is not split - std::vector m_nodeMask; ///< The node mask used in the refinement process - std::vector m_brotherEdges; ///< The index of the brother edge for each edge + std::vector m_faceMask; ///< Compute face without hanging nodes (1), refine face with hanging nodes (2), do not refine cell at all (0) or refine face outside polygon (-2) + std::vector m_edgeMask; ///< If 0, edge is not split + std::vector m_nodeMask; ///< The node mask used in the refinement process + std::vector m_brotherEdges; ///< The index of the brother edge for each edge /// Local caches std::vector m_isHangingNodeCache; ///< Cache for maintaining if node is hanging std::vector m_isHangingEdgeCache; ///< Cache for maintaining if edge is hanging std::vector m_polygonNodesCache; ///< Cache for maintaining polygon nodes - std::vector m_localNodeIndicesCache; ///< Cache for maintaining local node indices - std::vector m_globalEdgeIndicesCache; ///< Cache for maintaining edge indices - std::vector m_refineEdgeCache; ///< Cache for the edges to be refined + std::vector m_localNodeIndicesCache; ///< Cache for maintaining local node indices + std::vector m_globalEdgeIndicesCache; ///< Cache for maintaining edge indices + std::vector m_refineEdgeCache; ///< Cache for the edges to be refined std::vector m_faceLocationType; ///< Cache for the face location types RefinementType m_refinementType = RefinementType::WaveCourant; ///< The type of refinement to use diff --git a/libs/MeshKernel/include/MeshKernel/Operations.hpp b/libs/MeshKernel/include/MeshKernel/Operations.hpp index 70ae0677e..1fdd4af3c 100644 --- a/libs/MeshKernel/include/MeshKernel/Operations.hpp +++ b/libs/MeshKernel/include/MeshKernel/Operations.hpp @@ -43,7 +43,7 @@ namespace meshkernel /// @param[in] fill Whatever fill or not fill the vector with missing values /// @param[in] fillValue The fill value template - void ResizeAndFill2DVector(std::vector>& v, size_t const& firstDimension, size_t const& secondDimension, bool fill = false, const T& fillValue = {}) + void ResizeAndFill2DVector(std::vector>& v, UInt const& firstDimension, UInt const& secondDimension, bool fill = false, const T& fillValue = {}) { v.resize(firstDimension); for (auto& e : v) @@ -65,7 +65,7 @@ namespace meshkernel /// @param[in] fill Whatever fill or not fill the vector with missing values /// @param[in] fillValue The fill value template - void ResizeAndFill3DVector(std::vector>>& v, size_t const& firstDimension, size_t const& secondDimension, size_t const& thirdDim, bool fill = false, const T& fillValue = {}) + void ResizeAndFill3DVector(std::vector>>& v, UInt const& firstDimension, UInt const& secondDimension, UInt const& thirdDim, bool fill = false, const T& fillValue = {}) { v.resize(firstDimension); for (auto& e : v) @@ -123,13 +123,13 @@ namespace meshkernel /// @param[in] el The element to search for /// @returns The index of element template - [[nodiscard]] size_t FindIndex(const std::vector& vec, T el) + [[nodiscard]] T FindIndex(const std::vector& vec, T el) { - for (size_t n = 0; n < vec.size(); n++) + for (UInt n = 0; n < vec.size(); n++) { if (vec[n] == el) { - return n; + return static_cast(n); } } @@ -142,17 +142,17 @@ namespace meshkernel /// @param[in] end The end of the range to search for /// @param[in] separator The value of the separator /// @returns Indices of elements - std::vector> FindIndices(const std::vector& vec, size_t start, size_t end, double separator); + std::vector> FindIndices(const std::vector& vec, UInt start, UInt end, double separator); /// @brief Sort a vector and return the sorted indices /// @param[in] v The vector to sort /// @returns The indices of elements template - [[nodiscard]] std::vector SortedIndices(const std::vector& v) + [[nodiscard]] std::vector SortedIndices(const std::vector& v) { - std::vector indices(v.size()); + std::vector indices(v.size()); iota(indices.begin(), indices.end(), 0); - std::ranges::stable_sort(indices.begin(), indices.end(), [&v](size_t i1, size_t i2) + std::ranges::stable_sort(indices.begin(), indices.end(), [&v](UInt i1, UInt i2) { return v[i1] < v[i2]; }); return indices; } @@ -162,7 +162,7 @@ namespace meshkernel /// @param[in] order The order to use /// @returns The reordered vector template - auto ReorderVector(const std::vector& v, const std::vector& order) + auto ReorderVector(const std::vector& v, const std::vector& order) { std::vector ordered; ordered.reserve(v.size()); @@ -232,13 +232,13 @@ namespace meshkernel /// @param[in] currentIndex The current index. /// @param[in] size The size of the vector. /// @returns The next forward index. - [[nodiscard]] size_t NextCircularForwardIndex(size_t currentIndex, size_t size); + [[nodiscard]] UInt NextCircularForwardIndex(UInt currentIndex, UInt size); /// @brief Get the next backward index. /// @param[in] currentIndex The current index. /// @param[in] size The size of the vector. /// @returns The next backward index. - [[nodiscard]] size_t NextCircularBackwardIndex(size_t currentIndex, size_t size); + [[nodiscard]] UInt NextCircularBackwardIndex(UInt currentIndex, UInt size); /// @brief Determines if a point is close to the poles (latitude close to 90 degrees). /// @param[in] point The current point. @@ -277,8 +277,8 @@ namespace meshkernel const std::vector& polygonNodes, const Projection& projection, Point polygonCenter = {constants::missing::doubleValue, constants::missing::doubleValue}, - size_t startNode = constants::missing::sizetValue, - size_t endNode = constants::missing::sizetValue); + UInt startNode = constants::missing::uintValue, + UInt endNode = constants::missing::uintValue); /// @brief Computes three base components void ComputeThreeBaseComponents(const Point& point, std::array& exxp, std::array& eyyp, std::array& ezzp); @@ -453,11 +453,11 @@ namespace meshkernel const auto coordinate = std::floor(pointAdimensionalCoordinate); if (pointAdimensionalCoordinate - coordinate < eps) { - return pointCoordinate = coordinates[static_cast(coordinate)]; + return pointCoordinate = coordinates[static_cast(coordinate)]; } - const size_t low = static_cast(coordinate); - const size_t high = low + 1; + const UInt low = static_cast(coordinate); + const UInt high = low + 1; const double a = high - pointAdimensionalCoordinate; const double b = pointAdimensionalCoordinate - low; @@ -473,7 +473,7 @@ namespace meshkernel template void SwapVectorElements(std::vector& v) { - for (size_t i = 0; i < v.size() / 2; ++i) + for (UInt i = 0; i < v.size() / 2; ++i) { const auto a = v[i]; v[i] = v[i + 1]; @@ -511,8 +511,8 @@ namespace meshkernel const std::vector& bottomDiscretization, const std::vector& upperDiscretization, const Projection& projection, - size_t numM, - size_t numN); + UInt numM, + UInt numN); /// @brief Computes the edge centers /// @param[in] nodes The vector of edge nodes. @@ -583,11 +583,11 @@ namespace meshkernel return {{minx, miny}, {maxx, maxy}}; } - /// @brief Calculates the absolute difference between to `size_t` numbers. + /// @brief Calculates the absolute difference between to `Index` numbers. /// /// @param[in] number_1 The first number /// @param[in] number_2 The second number - size_t AbsoluteDifference(size_t number_1, size_t number_2); + UInt AbsoluteDifference(UInt number_1, UInt number_2); /// @brief Computes the discretization points along a polyline /// @param polyline A polyline described by its nodes diff --git a/libs/MeshKernel/include/MeshKernel/OrthogonalizationAndSmoothing.hpp b/libs/MeshKernel/include/MeshKernel/OrthogonalizationAndSmoothing.hpp index ee8e7e208..a40bb5d31 100644 --- a/libs/MeshKernel/include/MeshKernel/OrthogonalizationAndSmoothing.hpp +++ b/libs/MeshKernel/include/MeshKernel/OrthogonalizationAndSmoothing.hpp @@ -124,14 +124,14 @@ namespace meshkernel /// @param[out] dx0 The computed x increment /// @param[out] dy0 The computed y increment /// @param[out] weightsSum The sum of the weights in x and y - void ComputeLocalIncrements(size_t nodeIndex, + void ComputeLocalIncrements(UInt nodeIndex, double& dx0, double& dy0, std::array& weightsSum); /// @brief Update the nodal coordinates based on the increments /// @param[in] nodeIndex - void UpdateNodeCoordinates(size_t nodeIndex); + void UpdateNodeCoordinates(UInt nodeIndex); /// @brief Allocate linear system vectors void AllocateLinearSystem(); @@ -147,19 +147,19 @@ namespace meshkernel LandBoundaries::ProjectToLandBoundaryOption m_projectToLandBoundaryOption; ///< The project to land boundary option OrthogonalizationParameters m_orthogonalizationParameters; ///< The orthogonalization parameters - std::vector m_localCoordinatesIndices; ///< Used in sphericalAccurate projection (iloc) - std::vector m_localCoordinates; ///< Used in sphericalAccurate projection (xloc,yloc) - std::vector m_orthogonalCoordinates; ///< A copy of the mesh node, orthogonalized - std::vector m_originalNodes; ///< The original mesh + std::vector m_localCoordinatesIndices; ///< Used in sphericalAccurate projection (iloc) + std::vector m_localCoordinates; ///< Used in sphericalAccurate projection (xloc,yloc) + std::vector m_orthogonalCoordinates; ///< A copy of the mesh node, orthogonalized + std::vector m_originalNodes; ///< The original mesh // Linear system terms - size_t m_nodeCacheSize = 0; ///< Node cache size - std::vector m_compressedEndNodeIndex; ///< Start index in m_compressedWeightX - std::vector m_compressedStartNodeIndex; ///< End index in m_compressedWeightY - std::vector m_compressedWeightX; ///< The computed weights X - std::vector m_compressedWeightY; ///< The computed weights Y - std::vector m_compressedRhs; ///< The right hand side - std::vector m_compressedNodesNodes; ///< The indices of the neighbouring nodes + UInt m_nodeCacheSize = 0; ///< Node cache size + std::vector m_compressedEndNodeIndex; ///< Start index in m_compressedWeightX + std::vector m_compressedStartNodeIndex; ///< End index in m_compressedWeightY + std::vector m_compressedWeightX; ///< The computed weights X + std::vector m_compressedWeightY; ///< The computed weights Y + std::vector m_compressedRhs; ///< The right hand side + std::vector m_compressedNodesNodes; ///< The indices of the neighbouring nodes // run-time parameters double m_mumax = 0.0; ///< Mumax stored for runtime diff --git a/libs/MeshKernel/include/MeshKernel/Orthogonalizer.hpp b/libs/MeshKernel/include/MeshKernel/Orthogonalizer.hpp index 05c46c72d..659ed013a 100644 --- a/libs/MeshKernel/include/MeshKernel/Orthogonalizer.hpp +++ b/libs/MeshKernel/include/MeshKernel/Orthogonalizer.hpp @@ -48,7 +48,7 @@ namespace meshkernel /// @brief node /// @brief connectedNode /// @returns The contribution of orthogonalizer to the left hand side, the linear system - [[nodiscard]] double GetWeight(size_t node, size_t connectedNode) + [[nodiscard]] double GetWeight(UInt node, UInt connectedNode) { return m_weights[node][connectedNode]; } @@ -57,7 +57,7 @@ namespace meshkernel /// @brief node /// @brief connectedNode /// @returns The contribution of orthogonalizer to the right hand size - [[nodiscard]] double GetRightHandSide(size_t node, size_t connectedNode) + [[nodiscard]] double GetRightHandSide(UInt node, UInt connectedNode) { return m_rhs[node][connectedNode]; } diff --git a/libs/MeshKernel/include/MeshKernel/Polygons.hpp b/libs/MeshKernel/include/MeshKernel/Polygons.hpp index f9ac97eb1..de9940540 100644 --- a/libs/MeshKernel/include/MeshKernel/Polygons.hpp +++ b/libs/MeshKernel/include/MeshKernel/Polygons.hpp @@ -54,7 +54,7 @@ namespace meshkernel /// @param[in] endIndex The end index /// @param[in] refinementDistance The chosen refinement distance /// @return refinedPolygon The computed polygon - [[nodiscard]] std::vector RefineFirstPolygon(size_t startIndex, size_t endIndex, double refinementDistance) const; + [[nodiscard]] std::vector RefineFirstPolygon(UInt startIndex, UInt endIndex, double refinementDistance) const; /// @brief Makes a new polygon from an existing one, by offsetting it by a distance (copypol) /// @param[in] distance The offset distance @@ -67,12 +67,12 @@ namespace meshkernel /// @param[in] point The point to check /// @param[in] polygonIndex The index of the polygon to account for /// @return True if it is included, false otherwise - [[nodiscard]] bool IsPointInPolygon(Point const& point, size_t polygonIndex) const; + [[nodiscard]] bool IsPointInPolygon(Point const& point, UInt polygonIndex) const; /// @brief Checks if a point is included in any of the polygons (dbpinpol_optinside_perpol) /// @param[in] point The point to check /// @return The index of a polygon where the point is included or if none has been found, constants::missing::sizetValue - [[nodiscard]] std::tuple IsPointInPolygons(Point point) const; + [[nodiscard]] std::tuple IsPointInPolygons(Point point) const; /// @brief For each point, compute the index of the polygon including it /// @param[in] point The vector of points @@ -85,7 +85,7 @@ namespace meshkernel /// @brief Gives the number of polygons /// @return Number of polygons - [[nodiscard]] size_t GetNumPolygons() const; + [[nodiscard]] UInt GetNumPolygons() const; /// @brief Gets the number of polygon nodes /// @return The number of polygon nodes @@ -98,7 +98,7 @@ namespace meshkernel /// @brief Gets the start-end indices of each outer polygon /// @param[in] i Outer polygon index /// @return Pair of start and end indices - [[nodiscard]] std::pair const& OuterIndices(size_t i) const + [[nodiscard]] std::pair const& OuterIndices(UInt i) const { return m_outer_polygons_indices[i]; } @@ -110,13 +110,13 @@ namespace meshkernel /// @brief Gets the coordinates of a node by index /// @param[in] i Node index /// @return Node coordinates - [[nodiscard]] Point const& Node(size_t i) const { return m_nodes[i]; } + [[nodiscard]] Point const& Node(UInt i) const { return m_nodes[i]; } private: - std::vector m_nodes; ///< The polygon nodes - Projection m_projection; ///< The current projection - std::vector> m_outer_polygons_indices; ///< Start-end indices of each outer polygon in m_nodes - std::unordered_map>> m_inner_polygons_indices; ///< For each outer polygon, the indices of each inner polygon + std::vector m_nodes; ///< The polygon nodes + Projection m_projection; ///< The current projection + std::vector> m_outer_polygons_indices; ///< Start-end indices of each outer polygon in m_nodes + std::unordered_map>> m_inner_polygons_indices; ///< For each outer polygon, the indices of each inner polygon /// @brief Computes the perimeter of a closed polygon /// @param[in] polygonNodes The polygon nodes to use in the computation diff --git a/libs/MeshKernel/include/MeshKernel/Smoother.hpp b/libs/MeshKernel/include/MeshKernel/Smoother.hpp index c803204fd..00f08f219 100644 --- a/libs/MeshKernel/include/MeshKernel/Smoother.hpp +++ b/libs/MeshKernel/include/MeshKernel/Smoother.hpp @@ -27,6 +27,8 @@ #pragma once +#include "MeshKernel/Constants.hpp" + namespace meshkernel { class Mesh2D; @@ -49,7 +51,7 @@ namespace meshkernel /// @brief node /// @brief connectedNode /// @returns - [[nodiscard]] auto GetWeight(size_t node, int connectedNode) + [[nodiscard]] auto GetWeight(UInt node, int connectedNode) { return m_weights[node][connectedNode]; } @@ -58,7 +60,7 @@ namespace meshkernel /// @brief node /// @brief connectedNode /// @returns - [[nodiscard]] auto GetConnectedNodeIndex(size_t node, int connectedNode) + [[nodiscard]] auto GetConnectedNodeIndex(UInt node, int connectedNode) { return m_connectedNodes[node][connectedNode]; } @@ -66,7 +68,7 @@ namespace meshkernel /// @brief Get number of connected nodes /// @brief node /// @returns - [[nodiscard]] auto GetNumConnectedNodes(size_t node) + [[nodiscard]] auto GetNumConnectedNodes(UInt node) { return m_numConnectedNodes[node]; } @@ -92,15 +94,15 @@ namespace meshkernel /// Computes operators of the elliptic smoother by node (orthonet_comp_operators) /// @param[in] currentNode - void ComputeOperatorsNode(size_t currentNode); + void ComputeOperatorsNode(UInt currentNode); /// @brief Computes m_faceNodeMappingCache, m_sharedFacesCache, m_connectedNodes for the current node, required before computing xi and eta /// @param[in] currentNode - void NodeAdministration(size_t currentNode); + void NodeAdministration(UInt currentNode); /// @brief Compute compute current node xi and eta (orthonet_assign_xieta) /// @param[in] currentNode - void ComputeNodeXiEta(size_t currentNode); + void ComputeNodeXiEta(UInt currentNode); /// @brief Compute optimal edge angle /// @brief numFaceNodes @@ -108,23 +110,23 @@ namespace meshkernel /// @brief theta2 /// @brief isBoundaryEdge /// @returns - [[nodiscard]] double OptimalEdgeAngle(size_t numFaceNodes, + [[nodiscard]] double OptimalEdgeAngle(UInt numFaceNodes, double theta1 = -1.0, double theta2 = -1.0, bool isBoundaryEdge = false) const; /// @brief Allocate smoother operators /// @param[in] topologyIndex - void AllocateNodeOperators(size_t topologyIndex); + void AllocateNodeOperators(UInt topologyIndex); /// @brief If it is a new topology, save it /// @param[in] currentNode - void SaveNodeTopologyIfNeeded(size_t currentNode); + void SaveNodeTopologyIfNeeded(UInt currentNode); /// @brief Computes local coordinates jacobian from the mapped jacobians m_Jxi and m_Jeta /// @param[in] currentNode /// @param[out] J - void ComputeJacobian(size_t currentNode, std::vector& J) const; + void ComputeJacobian(UInt currentNode, std::vector& J) const; // The mesh to smooth std::shared_ptr m_mesh; ///< Pointer to mesh @@ -143,33 +145,33 @@ namespace meshkernel std::vector> m_ww2; ///< weights // Smoother local caches - std::vector m_sharedFacesCache; ///< Cache for shared faces - std::vector m_connectedNodesCache; ///< Cache for connected nodes - std::vector> m_faceNodeMappingCache; ///< Cache for face node mapping - std::vector m_xiCache; ///< Cache for xi - std::vector m_etaCache; ///< Cache for eta - std::vector m_boundaryEdgesCache; ///< Cache for boundary edges - std::vector m_leftXFaceCenterCache; ///< Cache for left x face center - std::vector m_leftYFaceCenterCache; ///< Cache for left y face center - std::vector m_rightXFaceCenterCache; ///< Cache for right x face center - std::vector m_rightYFaceCenterCache; ///< Cache for right y face center - std::vector m_xisCache; ///< Cache for xis - std::vector m_etasCache; ///< Cache for etas + std::vector m_sharedFacesCache; ///< Cache for shared faces + std::vector m_connectedNodesCache; ///< Cache for connected nodes + std::vector> m_faceNodeMappingCache; ///< Cache for face node mapping + std::vector m_xiCache; ///< Cache for xi + std::vector m_etaCache; ///< Cache for eta + std::vector m_boundaryEdgesCache; ///< Cache for boundary edges + std::vector m_leftXFaceCenterCache; ///< Cache for left x face center + std::vector m_leftYFaceCenterCache; ///< Cache for left y face center + std::vector m_rightXFaceCenterCache; ///< Cache for right x face center + std::vector m_rightYFaceCenterCache; ///< Cache for right y face center + std::vector m_xisCache; ///< Cache for xis + std::vector m_etasCache; ///< Cache for etas // Smoother topologies - std::vector m_nodeTopologyMapping; ///< Node topology mapping - std::vector> m_topologyXi; ///< Topology xi - std::vector> m_topologyEta; ///< Topology eta - std::vector> m_topologySharedFaces; ///< Topology shared faces - std::vector>> m_topologyFaceNodeMapping; ///< Topology face node mapping - std::vector> m_topologyConnectedNodes; ///< Topology connected nodes + std::vector m_nodeTopologyMapping; ///< Node topology mapping + std::vector> m_topologyXi; ///< Topology xi + std::vector> m_topologyEta; ///< Topology eta + std::vector> m_topologySharedFaces; ///< Topology shared faces + std::vector>> m_topologyFaceNodeMapping; ///< Topology face node mapping + std::vector> m_topologyConnectedNodes; ///< Topology connected nodes - std::vector m_numConnectedNodes; ///< Number of connected nodes (nmk2) - std::vector> m_connectedNodes; ///< Connected nodes (kk2) + std::vector m_numConnectedNodes; ///< Number of connected nodes (nmk2) + std::vector> m_connectedNodes; ///< Connected nodes (kk2) // Class variables - size_t m_maximumNumConnectedNodes = 0; ///< Maximum number of connected nodes - size_t m_maximumNumSharedFaces = 0; ///< Maximum number of shared faces + UInt m_maximumNumConnectedNodes = 0; ///< Maximum number of connected nodes + UInt m_maximumNumSharedFaces = 0; ///< Maximum number of shared faces static constexpr int m_topologyInitialSize = 10; ///< Initial size of topology vectors static constexpr double m_thetaTolerance = 1e-4; ///< Tolerance diff --git a/libs/MeshKernel/include/MeshKernel/Splines.hpp b/libs/MeshKernel/include/MeshKernel/Splines.hpp index 5ce1e2093..0ad8a74ee 100644 --- a/libs/MeshKernel/include/MeshKernel/Splines.hpp +++ b/libs/MeshKernel/include/MeshKernel/Splines.hpp @@ -59,21 +59,21 @@ namespace meshkernel /// @param[in] splines The spline corner points /// @param[in] start The starting index in splines /// @param[in] size The end index splines - void AddSpline(const std::vector& splines, size_t start, size_t size); + void AddSpline(const std::vector& splines, UInt start, UInt size); /// @brief Second order derivative at spline corner points, from the start node to the end node of the spline (splint) /// @param[in] splines The spline corner points /// @param[in] startIndex The start spline node /// @param[in] endIndex The end spline node /// @returns coordinatesDerivatives The second order derivative at corner points - [[nodiscard]] static std::vector SecondOrderDerivative(const std::vector& splines, size_t startIndex, size_t endIndex); + [[nodiscard]] static std::vector SecondOrderDerivative(const std::vector& splines, UInt startIndex, UInt endIndex); /// @brief Second order derivative at spline corner point coordinates (splint) /// @param[in] coordinates The spline corner point coordinate (x or y) /// @param[in] startIndex The start spline node /// @param[in] endIndex The end spline node /// @returns coordinatesDerivatives The second order derivative at corner points (x derivative or y derivative) - [[nodiscard]] static std::vector SecondOrderDerivative(const std::vector& coordinates, size_t startIndex, size_t endIndex); + [[nodiscard]] static std::vector SecondOrderDerivative(const std::vector& coordinates, UInt startIndex, UInt endIndex); /// @brief Computes the intersection of two splines (sect3r) /// @param[in] first The index of the first spline @@ -83,8 +83,8 @@ namespace meshkernel /// @param[out] firstSplineRatio The ratio of the first spline length where the intersection occurs /// @param[out] secondSplineRatio The ratio of the second spline length where the intersection occurs /// @returns If a valid intersection is found - bool GetSplinesIntersection(size_t first, - size_t second, + bool GetSplinesIntersection(UInt first, + UInt second, double& crossProductIntersection, Point& intersectionPoint, double& firstSplineRatio, @@ -99,10 +99,10 @@ namespace meshkernel /// @param[in] height When accounting for curvature, the height to use /// @param[in] assignedDelta When larger than zero, the number of intervals the spline is divided when computing the length /// @returns The computed length - [[nodiscard]] double ComputeSplineLength(size_t index, + [[nodiscard]] double ComputeSplineLength(UInt index, double startAdimensionalCoordinate, double endAdimensionalCoordinate, - size_t numSamples = 100, + UInt numSamples = 100, bool accountForCurvature = false, double height = 1.0, double assignedDelta = -1.0) const; @@ -113,7 +113,7 @@ namespace meshkernel /// @param[in] isSpacingCurvatureAdapted Is spacing-curvature adapted /// @param[in] distances The dimensional distances of each point /// @returns The points along the splineand the adimensional distances of each point - std::tuple, std::vector> ComputePointOnSplineFromAdimensionalDistance(size_t index, + std::tuple, std::vector> ComputePointOnSplineFromAdimensionalDistance(UInt index, double maximumGridHeight, bool isSpacingCurvatureAdapted, const std::vector& distances); @@ -124,11 +124,11 @@ namespace meshkernel /// @param[in] endSplineSegment The end of the spline segment to consider /// @param[in] point The point to account for in the calculation /// @returns The point on a spline segment which is the closest to the input point - Point ComputeClosestPointOnSplineSegment(size_t index, double startSplineSegment, double endSplineSegment, Point point); + Point ComputeClosestPointOnSplineSegment(UInt index, double startSplineSegment, double endSplineSegment, Point point); /// @brief Get the number of splines /// @return the number of splines - auto GetNumSplines() const { return m_splineNodes.size(); } + auto GetNumSplines() const { return static_cast(m_splineNodes.size()); } std::vector> m_splineNodes; ///< The spline corner points std::vector> m_splineDerivatives; ///< The spline derivatives at the corner points @@ -139,18 +139,18 @@ namespace meshkernel /// @brief Adds a new corner point in an existing spline /// @param[in] splineIndex The spline index /// @param[in] point The point to add - void AddPointInExistingSpline(size_t splineIndex, const Point& point); + void AddPointInExistingSpline(UInt splineIndex, const Point& point); /// @brief Computes curvature in a spline point (comp_curv) /// @param[in] splineIndex the spline index /// @param[in] adimensionalPointCoordinate The adimensional coordinate of the point along the spline /// @returns The computed curvatureFactor, normal vector and tangential vector - std::tuple ComputeCurvatureOnSplinePoint(size_t splineIndex, + std::tuple ComputeCurvatureOnSplinePoint(UInt splineIndex, double adimensionalPointCoordinate) const; /// @brief Delete a spline /// @param[in] splineIndex The index of the spline to delete - void DeleteSpline(size_t splineIndex); + void DeleteSpline(UInt splineIndex); /// @brief Allocate spline properties vectors void AllocateSplinesProperties(); @@ -165,7 +165,7 @@ namespace meshkernel /// @param[in] isSpacingCurvatureAdapted Is spacing curvature adapted /// @param[in] h When accounting for curvature, the height to use FuncAdimensionalToDimensionalDistanceOnSpline(Splines* splines, - size_t splineIndex, + UInt splineIndex, bool isSpacingCurvatureAdapted, double h) : m_spline(splines), m_splineIndex(splineIndex), @@ -194,10 +194,10 @@ namespace meshkernel } Splines* m_spline = nullptr; ///< Pointer to splines - size_t m_splineIndex; ///< Spline index + UInt m_splineIndex; ///< Spline index bool m_isSpacingCurvatureAdapted; ///< Is spacing curvature adapted double m_h; ///< When accounting for curvature, the height to use - size_t m_numSamples = 10; ///< Number of samples + UInt m_numSamples = 10; ///< Number of samples double m_DimensionalDistance = 0.0; ///< Dimensional distance }; @@ -209,7 +209,7 @@ namespace meshkernel /// @param[in] splineIndex The index of the current spline /// @param[in] point The point from where the distance is calculated FuncDistanceFromAPoint(Splines* splines, - size_t splineIndex, + UInt splineIndex, Point point) : m_spline(splines), m_splineIndex(splineIndex), m_point(point) @@ -228,7 +228,7 @@ namespace meshkernel } Splines* m_spline; ///< Pointer to splines - size_t m_splineIndex; ///< Spline index + UInt m_splineIndex; ///< Spline index Point m_point; ///< The point from where the distance is calculated double m_DimensionalDistance = 0.0; ///< Dimensional distance }; diff --git a/libs/MeshKernel/include/MeshKernel/TriangulationWrapper.hpp b/libs/MeshKernel/include/MeshKernel/TriangulationWrapper.hpp index d8dacf71f..58023d43d 100644 --- a/libs/MeshKernel/include/MeshKernel/TriangulationWrapper.hpp +++ b/libs/MeshKernel/include/MeshKernel/TriangulationWrapper.hpp @@ -79,11 +79,11 @@ namespace meshkernel void Compute(const std::vector& inputNodes, TriangulationOptions triangulationOption, double averageTriangleArea, - size_t estimatedNumberOfTriangles) + UInt estimatedNumberOfTriangles) { std::vector xLocalPolygon(inputNodes.size()); std::vector yLocalPolygon(inputNodes.size()); - for (size_t i = 0; i < inputNodes.size(); ++i) + for (UInt i = 0; i < inputNodes.size(); ++i) { xLocalPolygon[i] = inputNodes[i].x; yLocalPolygon[i] = inputNodes[i].y; @@ -98,7 +98,7 @@ namespace meshkernel if (estimatedNumberOfTriangles == 0) { - estimatedNumberOfTriangles = inputNodes.size() * 6 + 10; + estimatedNumberOfTriangles = static_cast(inputNodes.size()) * 6 + 10; } // If the number of estimated triangles is not sufficient, triangulation must be repeated @@ -175,7 +175,7 @@ namespace meshkernel /// @brief Gets the nodes of a triangulated face /// @param faceIndex The face index /// @return The triangulated nodes - [[nodiscard]] const std::vector& GetFaceNodes(const size_t faceIndex) const + [[nodiscard]] const std::vector& GetFaceNodes(const UInt faceIndex) const { return m_faceNodes[faceIndex]; } @@ -184,7 +184,7 @@ namespace meshkernel /// @param faceIndex The index of the face to retrieve the node from /// @param nodeIndex The index of the node to retrieve /// @return const reference to the node with the specified index for the specified face - [[nodiscard]] size_t GetFaceNode(const size_t faceIndex, const size_t nodeIndex) const + [[nodiscard]] UInt GetFaceNode(const UInt faceIndex, const UInt nodeIndex) const { return m_faceNodes[faceIndex][nodeIndex]; } @@ -193,7 +193,7 @@ namespace meshkernel /// @param faceIndex The index of the face to retrieve the edge from /// @param edgeIndex The index of the edge to retrieve /// @return const reference to the edge with the specified index for the specified face - [[nodiscard]] size_t GetFaceEdge(const size_t faceIndex, const size_t edgeIndex) const + [[nodiscard]] UInt GetFaceEdge(const UInt faceIndex, const UInt edgeIndex) const { return m_faceEdges[faceIndex][edgeIndex]; } @@ -202,7 +202,7 @@ namespace meshkernel /// @param edgeIndex The index of the edge to retrieve the node from /// @param nodeIndex The index of the node to retrieve /// @return const reference to the node with the specified index for the specified face - [[nodiscard]] size_t GetEdgeNode(const size_t edgeIndex, const size_t nodeIndex) const + [[nodiscard]] UInt GetEdgeNode(const UInt edgeIndex, const UInt nodeIndex) const { return m_edgeNodes[edgeIndex][nodeIndex]; } @@ -211,7 +211,7 @@ namespace meshkernel /// @param edgeIndex The index of the edge to retrieve the node from /// @param faceIndex The index of the face to retrieve /// @return const reference to the edge with the specified index for the specified face - [[nodiscard]] size_t GetEdgeFace(const size_t edgeIndex, const size_t faceIndex) const + [[nodiscard]] UInt GetEdgeFace(const UInt edgeIndex, const UInt faceIndex) const { return m_edgesFaces[edgeIndex][faceIndex]; } @@ -219,7 +219,7 @@ namespace meshkernel /// @brief Retrieves the x coordinate of a triangulated node /// @param nodeIndex The index of the node to retrieve /// @return const reference to the x coordinate - [[nodiscard]] double GetXCoord(const size_t nodeIndex) const + [[nodiscard]] double GetXCoord(const UInt nodeIndex) const { return m_xCoordFlat[nodeIndex]; } @@ -227,7 +227,7 @@ namespace meshkernel /// @brief Retrieves the y coordinate of a triangulated node /// @param nodeIndex The index of the node to retrieve /// @return const reference to the y coordinate - [[nodiscard]] double GetYCoord(const size_t nodeIndex) const + [[nodiscard]] double GetYCoord(const UInt nodeIndex) const { return m_yCoordFlat[nodeIndex]; } @@ -242,11 +242,11 @@ namespace meshkernel int m_numEdges{0}; ///< Initial number of triangulated edges int m_numFaces{0}; ///< Initial number of triangulated faces - std::vector m_nodes; ///< Reconstructed vector of nodes - std::vector> m_faceNodes; ///< Reconstructed vector of face nodes - std::vector> m_faceEdges; ///< Reconstructed vector of face edges - std::vector> m_edgeNodes; ///< Reconstructed vector of edge nodes - std::vector> m_edgesFaces; ///< Reconstructed vector of edge faces + std::vector m_nodes; ///< Reconstructed vector of nodes + std::vector> m_faceNodes; ///< Reconstructed vector of face nodes + std::vector> m_faceEdges; ///< Reconstructed vector of face edges + std::vector> m_edgeNodes; ///< Reconstructed vector of edge nodes + std::vector> m_edgesFaces; ///< Reconstructed vector of edge faces }; } // namespace meshkernel diff --git a/libs/MeshKernel/include/MeshKernel/Utilities/RTree.hpp b/libs/MeshKernel/include/MeshKernel/Utilities/RTree.hpp index 884c6c9a0..4934abae8 100644 --- a/libs/MeshKernel/include/MeshKernel/Utilities/RTree.hpp +++ b/libs/MeshKernel/include/MeshKernel/Utilities/RTree.hpp @@ -69,7 +69,7 @@ namespace meshkernel m_points.clear(); m_rtree2D.clear(); - for (size_t n = 0; n < nodes.size(); ++n) + for (UInt n = 0; n < nodes.size(); ++n) { if (nodes[n].x != constants::missing::doubleValue && nodes[n].y != constants::missing::doubleValue) { @@ -95,19 +95,19 @@ namespace meshkernel /// @brief Deletes a node /// @param[in] position The index of the point to remove in m_points - void DeleteNode(size_t position); + void DeleteNode(UInt position); /// @brief Determines size of the RTree - [[nodiscard]] size_t Size() const { return m_rtree2D.size(); }; + [[nodiscard]] UInt Size() const { return static_cast(m_rtree2D.size()); }; /// @brief Determines if the RTree is empty [[nodiscard]] bool Empty() const { return m_rtree2D.empty(); } /// @brief Gets the size of the query - [[nodiscard]] size_t GetQueryResultSize() const { return m_queryCache.size(); } + [[nodiscard]] UInt GetQueryResultSize() const { return static_cast(m_queryCache.size()); } /// @brief Gets the index of a sample in the query - [[nodiscard]] size_t GetQueryResult(size_t index) const { return m_queryIndices[index]; } + [[nodiscard]] UInt GetQueryResult(UInt index) const { return m_queryIndices[index]; } /// @brief True if a query has results, false otherwise [[nodiscard]] bool HasQueryResults() const { return GetQueryResultSize() > 0; } @@ -115,14 +115,14 @@ namespace meshkernel private: using Point2D = bg::model::point; ///< Typedef for Point2D using Box2D = bg::model::box; ///< Typedef for box of Point2D - using Value2D = std::pair; ///< Typedef of pair of Point2D and size_t + using Value2D = std::pair; ///< Typedef of pair of Point2D and size_t using RTree2D = bgi::rtree>; ///< Typedef for a 2D RTree - RTree2D m_rtree2D; ///< The 2D RTree - std::vector> m_points; ///< The points - std::vector m_queryCache; ///< The query cache - std::vector m_queryIndices; ///< The query indices - int m_queryVectorCapacity = 100; ///< Capacity of the query vector + RTree2D m_rtree2D; ///< The 2D RTree + std::vector> m_points; ///< The points + std::vector m_queryCache; ///< The query cache + std::vector m_queryIndices; ///< The query indices + UInt m_queryVectorCapacity = 100; ///< Capacity of the query vector }; } // namespace meshkernel diff --git a/libs/MeshKernel/src/AveragingInterpolation.cpp b/libs/MeshKernel/src/AveragingInterpolation.cpp index 6e3f73ffc..b4aae5264 100644 --- a/libs/MeshKernel/src/AveragingInterpolation.cpp +++ b/libs/MeshKernel/src/AveragingInterpolation.cpp @@ -41,7 +41,7 @@ AveragingInterpolation::AveragingInterpolation(Mesh2D& mesh, double relativeSearchRadius, bool useClosestSampleIfNoneAvailable, bool transformSamples, - size_t minNumSamples) + UInt minNumSamples) : m_mesh(mesh), m_samples(samples), m_method(method), @@ -73,7 +73,7 @@ void AveragingInterpolation::Compute() m_mesh.ComputeEdgesCenters(); std::vector dualFacePolygon; - for (size_t n = 0; n < m_mesh.GetNumNodes(); ++n) + for (UInt n = 0; n < m_mesh.GetNumNodes(); ++n) { m_mesh.MakeDualFace(n, m_relativeSearchRadius, dualFacePolygon); const auto result = ComputeOnPolygon(dualFacePolygon, m_mesh.m_nodes[n]); @@ -87,7 +87,7 @@ void AveragingInterpolation::Compute() m_edgeResults.resize(m_mesh.GetNumEdges(), constants::missing::doubleValue); std::ranges::fill(m_edgeResults, constants::missing::doubleValue); - for (size_t e = 0; e < m_mesh.GetNumEdges(); ++e) + for (UInt e = 0; e < m_mesh.GetNumEdges(); ++e) { const auto& [first, second] = m_mesh.m_edges[e]; @@ -108,11 +108,11 @@ void AveragingInterpolation::Compute() std::vector polygonNodesCache(Mesh::m_maximumNumberOfNodesPerFace + 1); std::fill(m_visitedSamples.begin(), m_visitedSamples.end(), false); - for (size_t f = 0; f < m_mesh.GetNumFaces(); ++f) + for (UInt f = 0; f < m_mesh.GetNumFaces(); ++f) { polygonNodesCache.clear(); - for (size_t n = 0; n < m_mesh.GetNumFaceEdges(f); ++n) + for (UInt n = 0; n < m_mesh.GetNumFaceEdges(f); ++n) { polygonNodesCache.emplace_back(m_mesh.m_facesMassCenters[f] + (m_mesh.m_nodes[m_mesh.m_facesNodes[f][n]] - m_mesh.m_facesMassCenters[f]) * m_relativeSearchRadius); } @@ -124,7 +124,7 @@ void AveragingInterpolation::Compute() { // for certain algorithms we want to decrease the values of the samples (e.g. refinement) // it is difficult to do it otherwise without sharing or caching the query result - for (size_t i = 0; i < m_samplesRtree.GetQueryResultSize(); ++i) + for (UInt i = 0; i < m_samplesRtree.GetQueryResultSize(); ++i) { if (const auto sample = m_samplesRtree.GetQueryResult(i); !m_visitedSamples[sample]) { @@ -181,7 +181,7 @@ double AveragingInterpolation::GetSearchRadiusSquared(std::vector const& return result; } -double AveragingInterpolation::GetSampleValueFromRTree(size_t const index) +double AveragingInterpolation::GetSampleValueFromRTree(UInt const index) { auto const sample_index = m_samplesRtree.GetQueryResult(index); return m_samples[sample_index].value; @@ -191,7 +191,7 @@ double AveragingInterpolation::ComputeInterpolationResultFromNeighbors(std::uniq std::vector const& searchPolygon) { - for (size_t i = 0; i < m_samplesRtree.GetQueryResultSize(); ++i) + for (UInt i = 0; i < m_samplesRtree.GetQueryResultSize(); ++i) { auto const sampleIndex = m_samplesRtree.GetQueryResult(i); auto const sampleValue = m_samples[sampleIndex].value; diff --git a/libs/MeshKernel/src/BilinearInterpolationOnGriddedSamples.cpp b/libs/MeshKernel/src/BilinearInterpolationOnGriddedSamples.cpp index 85674d13c..7d1fede89 100644 --- a/libs/MeshKernel/src/BilinearInterpolationOnGriddedSamples.cpp +++ b/libs/MeshKernel/src/BilinearInterpolationOnGriddedSamples.cpp @@ -33,8 +33,8 @@ using namespace meshkernel; BilinearInterpolationOnGriddedSamples::BilinearInterpolationOnGriddedSamples(const Mesh2D& mesh, - size_t numXCoord, - size_t numYCoord, + UInt numXCoord, + UInt numYCoord, const Point& origin, double cellSize, const std::vector& values) : m_mesh(mesh), @@ -49,8 +49,8 @@ BilinearInterpolationOnGriddedSamples::BilinearInterpolationOnGriddedSamples(con const std::vector& xCoordinates, const std::vector& yCoordinates, const std::vector& values) : m_mesh(mesh), - m_numXCoord(xCoordinates.size()), - m_numYCoord(yCoordinates.size()), + m_numXCoord(static_cast(xCoordinates.size())), + m_numYCoord(static_cast(yCoordinates.size())), m_xCoordinates(xCoordinates), m_yCoordinates(yCoordinates), m_values(values), @@ -62,7 +62,7 @@ void BilinearInterpolationOnGriddedSamples::Compute() { m_nodeResults.resize(m_mesh.GetNumNodes()); std::ranges::fill(m_nodeResults, constants::missing::doubleValue); - for (size_t n = 0; n < m_mesh.GetNumNodes(); ++n) + for (UInt n = 0; n < m_mesh.GetNumNodes(); ++n) { const auto node = m_mesh.m_nodes[n]; m_nodeResults[n] = Interpolation(node); @@ -70,7 +70,7 @@ void BilinearInterpolationOnGriddedSamples::Compute() m_edgeResults.resize(m_mesh.GetNumEdges()); std::ranges::fill(m_edgeResults, constants::missing::doubleValue); - for (size_t e = 0; e < m_mesh.GetNumEdges(); ++e) + for (UInt e = 0; e < m_mesh.GetNumEdges(); ++e) { const auto& [first, second] = m_mesh.m_edges[e]; m_edgeResults[e] = 0.5 * (m_nodeResults[first] + m_nodeResults[second]); @@ -78,7 +78,7 @@ void BilinearInterpolationOnGriddedSamples::Compute() m_faceResults.resize(m_mesh.GetNumFaces(), constants::missing::doubleValue); std::ranges::fill(m_faceResults, constants::missing::doubleValue); - for (size_t f = 0; f < m_mesh.GetNumFaces(); ++f) + for (UInt f = 0; f < m_mesh.GetNumFaces(); ++f) { m_faceResults[f] = Interpolation(m_mesh.m_facesMassCenters[f]); } @@ -101,8 +101,8 @@ double BilinearInterpolationOnGriddedSamples::Interpolation(const Point& point) return constants::missing::doubleValue; } - size_t const columnIndex = static_cast(columnIndexTmp); - size_t const rowIndex = static_cast(rowIndexTmp); + UInt const columnIndex = static_cast(columnIndexTmp); + UInt const rowIndex = static_cast(rowIndexTmp); if (columnIndex + 1 >= m_numXCoord || rowIndex + 1 >= m_numYCoord) { @@ -127,7 +127,7 @@ double BilinearInterpolationOnGriddedSamples::Interpolation(const Point& point) { return result; } - for (size_t i = 0; i < m_xCoordinates.size() - 1; ++i) + for (UInt i = 0; i < m_xCoordinates.size() - 1; ++i) { if (point.x >= m_xCoordinates[i] && point.x < m_xCoordinates[i + 1]) @@ -153,7 +153,7 @@ double BilinearInterpolationOnGriddedSamples::GetFractionalNumberOfRows(const Po return result; } - for (size_t i = 0; i < m_yCoordinates.size() - 1; ++i) + for (UInt i = 0; i < m_yCoordinates.size() - 1; ++i) { if (point.y >= m_yCoordinates[i] && point.y < m_yCoordinates[i + 1]) diff --git a/libs/MeshKernel/src/Contacts.cpp b/libs/MeshKernel/src/Contacts.cpp index 8c15921ae..ee11d8ed1 100644 --- a/libs/MeshKernel/src/Contacts.cpp +++ b/libs/MeshKernel/src/Contacts.cpp @@ -35,7 +35,7 @@ void Contacts::ComputeSingleContacts(const std::vector& oneDNodeMask, const auto nodePolygonIndices = polygons.PointsInPolygons(m_mesh1d->m_nodes); - for (size_t n = 0; n < m_mesh1d->m_nodes.size(); ++n) + for (UInt n = 0; n < m_mesh1d->m_nodes.size(); ++n) { // connect only nodes included in the polygons if (!nodePolygonIndices[n]) @@ -50,7 +50,7 @@ void Contacts::ComputeSingleContacts(const std::vector& oneDNodeMask, } // if a node is inside a face, connect the 1d node with the face including the node. No more work to do - if (node1dFaceIndices[n] != constants::missing::sizetValue) + if (node1dFaceIndices[n] != constants::missing::uintValue) { m_mesh1dIndices.emplace_back(n); m_mesh2dIndices.emplace_back(node1dFaceIndices[n]); @@ -64,14 +64,14 @@ void Contacts::ComputeSingleContacts(const std::vector& oneDNodeMask, } } -void Contacts::Connect1dNodesWithCrossingFaces(size_t node, +void Contacts::Connect1dNodesWithCrossingFaces(UInt node, double projectionFactor) { const auto projectedNode = m_mesh1d->ComputeProjectedNode(node, projectionFactor); const auto [intersectedFace, intersectedEdge] = m_mesh2d->IsSegmentCrossingABoundaryEdge(m_mesh1d->m_nodes[node], projectedNode); - if (intersectedFace != constants::missing::sizetValue && - intersectedEdge != constants::missing::sizetValue && + if (intersectedFace != constants::missing::uintValue && + intersectedEdge != constants::missing::uintValue && !IsContactIntersectingMesh1d(node, intersectedFace) && !IsContactIntersectingContact(node, intersectedFace)) { @@ -80,10 +80,10 @@ void Contacts::Connect1dNodesWithCrossingFaces(size_t node, } } -bool Contacts::IsContactIntersectingMesh1d(size_t node, - size_t face) const +bool Contacts::IsContactIntersectingMesh1d(UInt node, + UInt face) const { - for (size_t e = 0; e < m_mesh1d->GetNumEdges(); ++e) + for (UInt e = 0; e < m_mesh1d->GetNumEdges(); ++e) { Point intersectionPoint; @@ -109,9 +109,9 @@ bool Contacts::IsContactIntersectingMesh1d(size_t node, return false; } -bool Contacts::IsContactIntersectingContact(size_t node, size_t face) const +bool Contacts::IsContactIntersectingContact(UInt node, UInt face) const { - for (size_t i = 0; i < m_mesh1dIndices.size(); ++i) + for (UInt i = 0; i < m_mesh1dIndices.size(); ++i) { Point intersectionPoint; double crossProduct; @@ -156,7 +156,7 @@ void Contacts::ComputeMultipleContacts(const std::vector& oneDNodeMask) std::vector isFaceAlreadyConnected(m_mesh2d->GetNumFaces(), false); // loop over 1d mesh edges - for (size_t e = 0; e < m_mesh1d->GetNumEdges(); ++e) + for (UInt e = 0; e < m_mesh1d->GetNumEdges(); ++e) { // get the mesh1d edge nodes const auto firstNode1dMeshEdge = m_mesh1d->m_edges[e].first; @@ -170,7 +170,7 @@ void Contacts::ComputeMultipleContacts(const std::vector& oneDNodeMask) // for each face determine if it is crossing the current 1d edge const auto numNeighbours = m_mesh2d->GetNumLocations(Mesh::Location::Faces); - for (size_t f = 0; f < numNeighbours; ++f) + for (UInt f = 0; f < numNeighbours; ++f) { const auto face = m_mesh2d->GetLocationsIndices(f, Mesh::Location::Faces); @@ -181,7 +181,7 @@ void Contacts::ComputeMultipleContacts(const std::vector& oneDNodeMask) } // determine which of the mesh2d edges is crossing the current 1d edge - for (size_t ee = 0; ee < m_mesh2d->m_numFacesNodes[face]; ++ee) + for (UInt ee = 0; ee < m_mesh2d->m_numFacesNodes[face]; ++ee) { Point intersectionPoint; double crossProduct; @@ -219,7 +219,7 @@ void Contacts::ComputeMultipleContacts(const std::vector& oneDNodeMask) } // the 1d mesh node to be connected needs to be included in the 2d mesh - if (node1dFaceIndices[nodeToConnect] == constants::missing::sizetValue) + if (node1dFaceIndices[nodeToConnect] == constants::missing::uintValue) { continue; } @@ -252,9 +252,9 @@ void Contacts::ComputeContactsWithPolygons(const std::vector& oneDNodeMask m_mesh1d->AdministrateNodesEdges(); // for each mesh2d face, store polygon index - std::vector facePolygonIndex(m_mesh2d->GetNumFaces(), constants::missing::sizetValue); + std::vector facePolygonIndex(m_mesh2d->GetNumFaces(), constants::missing::uintValue); std::vector faceInPolygon(m_mesh2d->GetNumFaces(), false); - for (size_t faceIndex = 0; faceIndex < m_mesh2d->GetNumFaces(); ++faceIndex) + for (UInt faceIndex = 0; faceIndex < m_mesh2d->GetNumFaces(); ++faceIndex) { auto [isInPolygon, polygonIndex] = polygons.IsPointInPolygons(m_mesh2d->m_facesMassCenters[faceIndex]); faceInPolygon[faceIndex] = isInPolygon; @@ -263,9 +263,9 @@ void Contacts::ComputeContactsWithPolygons(const std::vector& oneDNodeMask // for each polygon, find closest 1d node to any 2d mass center within the polygon std::vector minimalDistance(polygons.GetNumPolygons(), constants::missing::doubleValue); - std::vector closest1dNodeIndices(polygons.GetNumPolygons(), constants::missing::sizetValue); - std::vector closest2dNodeIndices(polygons.GetNumPolygons(), constants::missing::sizetValue); - for (size_t faceIndex = 0; faceIndex < m_mesh2d->GetNumFaces(); ++faceIndex) + std::vector closest1dNodeIndices(polygons.GetNumPolygons(), constants::missing::uintValue); + std::vector closest2dNodeIndices(polygons.GetNumPolygons(), constants::missing::uintValue); + for (UInt faceIndex = 0; faceIndex < m_mesh2d->GetNumFaces(); ++faceIndex) { // if face is not within a polygon, continue if (!faceInPolygon[faceIndex]) @@ -291,7 +291,7 @@ void Contacts::ComputeContactsWithPolygons(const std::vector& oneDNodeMask } // connect 1D nodes to closest 2d node in a polygon - for (size_t polygonIndex = 0; polygonIndex < polygons.GetNumPolygons(); ++polygonIndex) + for (UInt polygonIndex = 0; polygonIndex < polygons.GetNumPolygons(); ++polygonIndex) { m_mesh1dIndices.emplace_back(closest1dNodeIndices[polygonIndex]); m_mesh2dIndices.emplace_back(closest2dNodeIndices[polygonIndex]); @@ -314,10 +314,10 @@ void Contacts::ComputeContactsWithPoints(const std::vector& oneDNodeMask, const auto pointsFaceIndices = m_mesh2d->PointFaceIndices(points); // for each 1d node in the 2d mesh, find the closest 1d node. - for (size_t i = 0; i < points.size(); ++i) + for (UInt i = 0; i < points.size(); ++i) { // point not in the mesh - if (pointsFaceIndices[i] == constants::missing::sizetValue) + if (pointsFaceIndices[i] == constants::missing::uintValue) { continue; } @@ -367,8 +367,8 @@ void Contacts::ComputeBoundaryContacts(const std::vector& oneDNodeMask, // Loop over 1d edges std::vector isValidFace(m_mesh2d->GetNumFaces(), true); - std::vector faceTo1DNode(m_mesh2d->GetNumFaces(), constants::missing::sizetValue); - for (size_t n = 0; n < m_mesh1d->GetNumNodes(); ++n) + std::vector faceTo1DNode(m_mesh2d->GetNumFaces(), constants::missing::uintValue); + for (UInt n = 0; n < m_mesh1d->GetNumNodes(); ++n) { // Account for 1d node mask if present if (!oneDNodeMask.empty() && !oneDNodeMask[n]) @@ -384,7 +384,7 @@ void Contacts::ComputeBoundaryContacts(const std::vector& oneDNodeMask, // compute the nearest 2d face indices faceCircumcentersRTree.SearchPoints(m_mesh1d->m_nodes[n], localSearchRadius * localSearchRadius); - for (size_t f = 0; f < faceCircumcentersRTree.GetQueryResultSize(); ++f) + for (UInt f = 0; f < faceCircumcentersRTree.GetQueryResultSize(); ++f) { const auto face = faceCircumcentersRTree.GetQueryResult(f); @@ -409,7 +409,7 @@ void Contacts::ComputeBoundaryContacts(const std::vector& oneDNodeMask, } // a candidate contact does not exist - if (faceTo1DNode[face] == constants::missing::sizetValue) + if (faceTo1DNode[face] == constants::missing::uintValue) { faceTo1DNode[face] = n; continue; @@ -429,9 +429,9 @@ void Contacts::ComputeBoundaryContacts(const std::vector& oneDNodeMask, } } - for (size_t f = 0; f < m_mesh2d->GetNumFaces(); ++f) + for (UInt f = 0; f < m_mesh2d->GetNumFaces(); ++f) { - if (faceTo1DNode[f] != constants::missing::sizetValue && isValidFace[f]) + if (faceTo1DNode[f] != constants::missing::uintValue && isValidFace[f]) { m_mesh1dIndices.emplace_back(faceTo1DNode[f]); diff --git a/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGrid.cpp b/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGrid.cpp index 8fbc64efe..877947505 100644 --- a/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGrid.cpp +++ b/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGrid.cpp @@ -43,13 +43,13 @@ CurvilinearGrid::CurvilinearGrid(std::vector> const& grid, Pr } m_projection = projection; - m_numM = m_gridNodes.size(); - m_numN = m_gridNodes[0].size(); + m_numM = static_cast(m_gridNodes.size()); + m_numN = static_cast(m_gridNodes[0].size()); SetFlatCopies(); } -void CurvilinearGrid::Delete(std::shared_ptr polygons, size_t polygonIndex) +void CurvilinearGrid::Delete(std::shared_ptr polygons, UInt polygonIndex) { // no polygons available if (polygons->IsEmpty()) @@ -63,15 +63,15 @@ void CurvilinearGrid::Delete(std::shared_ptr polygons, size_t polygonI return; } - const auto numN = m_gridNodes.size(); - const auto numM = m_gridNodes[0].size(); + const auto numN = static_cast(m_gridNodes.size()); + const auto numM = static_cast(m_gridNodes[0].size()); std::vector> nodeBasedMask(numN, std::vector(numM, false)); std::vector> faceBasedMask(numN - 1, std::vector(numM - 1, true)); // Mark points inside a polygonIndex - for (size_t n = 0; n < numN; ++n) + for (UInt n = 0; n < numN; ++n) { - for (size_t m = 0; m < numM; ++m) + for (UInt m = 0; m < numM; ++m) { const auto isInPolygon = polygons->IsPointInPolygon(m_gridNodes[n][m], polygonIndex); if (isInPolygon) @@ -82,9 +82,9 @@ void CurvilinearGrid::Delete(std::shared_ptr polygons, size_t polygonI } // Mark faces when all nodes are inside - for (size_t n = 0; n < numN - 1; ++n) + for (UInt n = 0; n < numN - 1; ++n) { - for (size_t m = 0; m < numM - 1; ++m) + for (UInt m = 0; m < numM - 1; ++m) { if (!nodeBasedMask[n][m] || !nodeBasedMask[n + 1][m] || @@ -98,9 +98,9 @@ void CurvilinearGrid::Delete(std::shared_ptr polygons, size_t polygonI // Mark only the nodes of faces completely included in the polygonIndex std::fill(nodeBasedMask.begin(), nodeBasedMask.end(), std::vector(numM, false)); - for (size_t n = 0; n < numN - 1; ++n) + for (UInt n = 0; n < numN - 1; ++n) { - for (size_t m = 0; m < numM - 1; ++m) + for (UInt m = 0; m < numM - 1; ++m) { if (faceBasedMask[n][m]) { @@ -113,9 +113,9 @@ void CurvilinearGrid::Delete(std::shared_ptr polygons, size_t polygonI } // mark points inside a polygonIndex - for (size_t n = 0; n < numN; ++n) + for (UInt n = 0; n < numN; ++n) { - for (size_t m = 0; m < numM; ++m) + for (UInt m = 0; m < numM; ++m) { if (!nodeBasedMask[n][m]) { @@ -133,8 +133,8 @@ void CurvilinearGrid::SetFlatCopies() return; } - m_numM = m_gridNodes.size(); - m_numN = m_gridNodes[0].size(); + m_numM = static_cast(m_gridNodes.size()); + m_numN = static_cast(m_gridNodes[0].size()); const auto [nodes, edges, gridIndices] = ConvertCurvilinearToNodesAndEdges(); m_nodes = nodes; m_edges = edges; @@ -150,13 +150,13 @@ std::tuple, std::vector, std::v std::vector nodes(m_gridNodes.size() * m_gridNodes[0].size()); std::vector edges(m_gridNodes.size() * (m_gridNodes[0].size() - 1) + (m_gridNodes.size() - 1) * m_gridNodes[0].size()); - std::vector> nodeIndices(m_gridNodes.size(), std::vector(m_gridNodes[0].size(), constants::missing::sizetValue)); - std::vector gridIndices(nodes.size(), CurvilinearGridNodeIndices{constants::missing::sizetValue, constants::missing::sizetValue}); + std::vector> nodeIndices(m_gridNodes.size(), std::vector(m_gridNodes[0].size(), constants::missing::uintValue)); + std::vector gridIndices(nodes.size(), CurvilinearGridNodeIndices{constants::missing::uintValue, constants::missing::uintValue}); - size_t ind = 0; - for (size_t m = 0; m < m_gridNodes.size(); m++) + UInt ind = 0; + for (UInt m = 0; m < m_gridNodes.size(); m++) { - for (size_t n = 0; n < m_gridNodes[0].size(); n++) + for (UInt n = 0; n < m_gridNodes[0].size(); n++) { nodes[ind] = m_gridNodes[m][n]; nodeIndices[m][n] = ind; @@ -166,11 +166,11 @@ std::tuple, std::vector, std::v } ind = 0; - for (size_t m = 0; m < m_gridNodes.size() - 1; m++) + for (UInt m = 0; m < m_gridNodes.size() - 1; m++) { - for (size_t n = 0; n < m_gridNodes[0].size(); n++) + for (UInt n = 0; n < m_gridNodes[0].size(); n++) { - if (nodeIndices[m][n] != constants::missing::sizetValue && nodeIndices[m + 1][n] != constants::missing::sizetValue) + if (nodeIndices[m][n] != constants::missing::uintValue && nodeIndices[m + 1][n] != constants::missing::uintValue) { edges[ind].first = nodeIndices[m][n]; edges[ind].second = nodeIndices[m + 1][n]; @@ -179,11 +179,11 @@ std::tuple, std::vector, std::v } } - for (size_t m = 0; m < m_gridNodes.size(); m++) + for (UInt m = 0; m < m_gridNodes.size(); m++) { - for (size_t n = 0; n < m_gridNodes[0].size() - 1; n++) + for (UInt n = 0; n < m_gridNodes[0].size() - 1; n++) { - if (nodeIndices[m][n] != constants::missing::sizetValue && nodeIndices[m][n + 1] != constants::missing::sizetValue) + if (nodeIndices[m][n] != constants::missing::uintValue && nodeIndices[m][n + 1] != constants::missing::uintValue) { edges[ind].first = nodeIndices[m][n]; edges[ind].second = nodeIndices[m][n + 1]; @@ -223,7 +223,7 @@ CurvilinearGridNodeIndices CurvilinearGrid::GetNodeIndices(Point point) SearchNearestLocation(point, Mesh::Location::Nodes); if (GetNumLocations(Mesh::Location::Nodes) == 0) { - return {constants::missing::sizetValue, constants::missing::sizetValue}; + return {constants::missing::uintValue, constants::missing::uintValue}; } const auto nodeIndex = GetLocationsIndices(0, Mesh::Location::Nodes); @@ -245,7 +245,7 @@ std::tuple CurvilinearGr return {m_gridIndices[firstNode], m_gridIndices[secondNode]}; } -bool CurvilinearGrid::IsValidFace(size_t m, size_t n) const +bool CurvilinearGrid::IsValidFace(UInt m, UInt n) const { return m_gridNodes[m][n].IsValid() && m_gridNodes[m + 1][n].IsValid() && @@ -274,9 +274,9 @@ void CurvilinearGrid::ComputeGridFacesMask() { // Flag valid faces ResizeAndFill2DVector(m_gridFacesMask, m_numM - 1, m_numN - 1, true, false); - for (size_t m = 0; m < m_numM - 1; ++m) + for (UInt m = 0; m < m_numM - 1; ++m) { - for (size_t n = 0; n < m_numN - 1; ++n) + for (UInt n = 0; n < m_numN - 1; ++n) { // Only if all grid nodes of the face are valid, the face is valid if (!IsValidFace(m, n)) @@ -301,9 +301,9 @@ void CurvilinearGrid::RemoveInvalidNodes(bool invalidNodesToRemove) invalidNodesToRemove = false; // Flag nodes not connected to valid faces - for (size_t m = 1; m < m_numM - 1; ++m) + for (UInt m = 1; m < m_numM - 1; ++m) { - for (size_t n = 1; n < m_numN - 1; ++n) + for (UInt n = 1; n < m_numN - 1; ++n) { if (m_gridNodes[m][n].IsValid() && !m_gridFacesMask[m][n] && @@ -317,7 +317,7 @@ void CurvilinearGrid::RemoveInvalidNodes(bool invalidNodesToRemove) } } - for (size_t m = 1; m < m_numM - 1; ++m) + for (UInt m = 1; m < m_numM - 1; ++m) { if (m_gridNodes[m][0].IsValid() && !m_gridFacesMask[m - 1][0] && @@ -327,7 +327,7 @@ void CurvilinearGrid::RemoveInvalidNodes(bool invalidNodesToRemove) } } - for (size_t n = 1; n < m_numN - 1; ++n) + for (UInt n = 1; n < m_numN - 1; ++n) { if (m_gridNodes[0][n].IsValid() && !m_gridFacesMask[0][n - 1] && @@ -351,9 +351,9 @@ void CurvilinearGrid::ComputeGridNodeTypes() ResizeAndFill2DVector(m_gridNodesTypes, m_numM, m_numN, true, NodeType::Invalid); // Flag faces based on boundaries - for (size_t m = 0; m < m_numM; ++m) + for (UInt m = 0; m < m_numM; ++m) { - for (size_t n = 0; n < m_numN; ++n) + for (UInt n = 0; n < m_numN; ++n) { if (!m_gridNodes[m][n].IsValid()) diff --git a/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridCreateUniform.cpp b/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridCreateUniform.cpp index 4005f0362..e47271ccc 100644 --- a/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridCreateUniform.cpp +++ b/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridCreateUniform.cpp @@ -241,7 +241,7 @@ CurvilinearGrid CurvilinearGridCreateUniform::Compute(const double angle, const double blockSizeX, const double blockSizeY, std::shared_ptr polygons, - size_t polygonIndex) const + UInt polygonIndex) const { if (blockSizeX <= 0.0) { diff --git a/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridDeRefinement.cpp b/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridDeRefinement.cpp index a557da47b..ff521d9a7 100644 --- a/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridDeRefinement.cpp +++ b/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridDeRefinement.cpp @@ -51,10 +51,10 @@ CurvilinearGrid CurvilinearGridDeRefinement::Compute() std::vector> deRefinedGrid; deRefinedGrid.reserve(m_grid.m_numM); - size_t mIndexOriginalGrid = 0; + UInt mIndexOriginalGrid = 0; while (mIndexOriginalGrid < m_grid.m_numM) { - size_t localMDeRefinement = 1; + UInt localMDeRefinement = 1; if (mIndexOriginalGrid >= m_lowerLeft.m_m && mIndexOriginalGrid < m_upperRight.m_m) { localMDeRefinement = numMToDeRefine; @@ -62,10 +62,10 @@ CurvilinearGrid CurvilinearGridDeRefinement::Compute() deRefinedGrid.emplace_back(std::vector()); deRefinedGrid.back().reserve(m_grid.m_numN); - size_t nIndexOriginalGrid = 0; + UInt nIndexOriginalGrid = 0; while (nIndexOriginalGrid < m_grid.m_numN) { - size_t localNDeRefinement = 1; + UInt localNDeRefinement = 1; if (nIndexOriginalGrid >= m_lowerLeft.m_n && nIndexOriginalGrid < m_upperRight.m_n) { localNDeRefinement = numNToDeRefine; diff --git a/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridFromPolygon.cpp b/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridFromPolygon.cpp index eec2591e6..7e9dba67a 100644 --- a/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridFromPolygon.cpp +++ b/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridFromPolygon.cpp @@ -37,9 +37,9 @@ using meshkernel::CurvilinearGridFromPolygon; CurvilinearGridFromPolygon::CurvilinearGridFromPolygon(std::shared_ptr polygon) : m_polygon(polygon) {} -CurvilinearGrid CurvilinearGridFromPolygon::Compute(size_t firstNode, - size_t secondNode, - size_t thirdNode, +CurvilinearGrid CurvilinearGridFromPolygon::Compute(UInt firstNode, + UInt secondNode, + UInt thirdNode, bool useFourthSide) const { if (m_polygon->IsEmpty()) @@ -63,10 +63,10 @@ CurvilinearGrid CurvilinearGridFromPolygon::Compute(size_t firstNode, throw std::invalid_argument("CurvilinearGridFromPolygon::CurvilinearGridFromPolygon: Not enough points in polygon."); } - const size_t numPolygonNodes = end - start + 1; + const UInt numPolygonNodes = end - start + 1; // get rid of size and orientation first part - size_t diffForward; + UInt diffForward; if (firstNode > secondNode) { diffForward = secondNode + numPolygonNodes - firstNode; @@ -76,7 +76,7 @@ CurvilinearGrid CurvilinearGridFromPolygon::Compute(size_t firstNode, diffForward = secondNode - firstNode; } - size_t diffBackward; + UInt diffBackward; if (secondNode > firstNode) { diffBackward = firstNode + numPolygonNodes - secondNode; @@ -87,7 +87,7 @@ CurvilinearGrid CurvilinearGridFromPolygon::Compute(size_t firstNode, } int direction; - size_t numMNodes; + UInt numMNodes; if (diffForward <= diffBackward) { direction = 1; @@ -119,7 +119,7 @@ CurvilinearGrid CurvilinearGridFromPolygon::Compute(size_t firstNode, diffBackward = secondNode - thirdNode; } - size_t numNNodes; + UInt numNNodes; if (direction == 1) { numNNodes = diffForward + 1; @@ -140,7 +140,7 @@ CurvilinearGrid CurvilinearGridFromPolygon::Compute(size_t firstNode, fourthNode -= numPolygonNodes; } - size_t numRequiredPoints; + UInt numRequiredPoints; if (useFourthSide) { numRequiredPoints = 2 * (numMNodes - 1) + 2 * (numNNodes - 1); @@ -165,12 +165,12 @@ CurvilinearGrid CurvilinearGridFromPolygon::Compute(size_t firstNode, auto assignPolygonPointsToSegment = [&nodes = std::as_const(m_polygon->Nodes()), startIndex = start, endIndex = end, - numPolygonNodes](size_t nodeIndex, - size_t numPointsSide, + numPolygonNodes](UInt nodeIndex, + UInt numPointsSide, int direction, std::vector& sideToFill) { - for (size_t i = 0; i < numPointsSide; i++) + for (UInt i = 0; i < numPointsSide; i++) { sideToFill[i] = nodes[nodeIndex]; @@ -196,7 +196,7 @@ CurvilinearGrid CurvilinearGridFromPolygon::Compute(size_t firstNode, else { // Interpolate fourth side - for (size_t i = 0; i < numNNodes; i++) + for (UInt i = 0; i < numNNodes; i++) { const double fac = static_cast(i) / static_cast(numNNodes - 1); sideOne[i] = m_polygon->Node(firstNode) * (1.0 - fac) + @@ -215,9 +215,9 @@ CurvilinearGrid CurvilinearGridFromPolygon::Compute(size_t firstNode, // Assign the points to the curvilinear grid std::vector> gridNodes(numMNodes, std::vector(numNNodes)); - for (size_t i = 0; i < numMNodes; i++) + for (UInt i = 0; i < numMNodes; i++) { - for (size_t j = 0; j < numNNodes; j++) + for (UInt j = 0; j < numNNodes; j++) { gridNodes[i][j] = result[i][j]; } @@ -225,9 +225,9 @@ CurvilinearGrid CurvilinearGridFromPolygon::Compute(size_t firstNode, return CurvilinearGrid(std::move(gridNodes), polygonProjection); } -CurvilinearGrid CurvilinearGridFromPolygon::Compute(size_t firstNode, - size_t secondNode, - size_t thirdNode) const +CurvilinearGrid CurvilinearGridFromPolygon::Compute(UInt firstNode, + UInt secondNode, + UInt thirdNode) const { if (m_polygon->IsEmpty()) { @@ -254,7 +254,7 @@ CurvilinearGrid CurvilinearGridFromPolygon::Compute(size_t firstNode, const auto numPolygonNodes = end - start + 1; // get rid of size and orientation first part - size_t numPointsFirstSide; + UInt numPointsFirstSide; if (firstNode > secondNode) { numPointsFirstSide = secondNode + numPolygonNodes - firstNode; @@ -264,7 +264,7 @@ CurvilinearGrid CurvilinearGridFromPolygon::Compute(size_t firstNode, numPointsFirstSide = secondNode - firstNode; } - size_t numPointsSecondSide; + UInt numPointsSecondSide; if (secondNode > thirdNode) { numPointsSecondSide = thirdNode + numPolygonNodes - secondNode; @@ -275,7 +275,7 @@ CurvilinearGrid CurvilinearGridFromPolygon::Compute(size_t firstNode, } const auto numPointsThirdSide = numPolygonNodes - (numPointsFirstSide + numPointsSecondSide); - const auto blockSize = static_cast(static_cast(numPointsFirstSide + numPointsSecondSide + numPointsThirdSide) * 0.5); + const auto blockSize = static_cast(static_cast(numPointsFirstSide + numPointsSecondSide + numPointsThirdSide) * 0.5); if (numPointsThirdSide >= blockSize || numPointsSecondSide >= blockSize || numPointsFirstSide >= blockSize) { @@ -288,30 +288,30 @@ CurvilinearGrid CurvilinearGridFromPolygon::Compute(size_t firstNode, // compute the midpoint - size_t firstSideMiddlePoint = firstNode + n1; + UInt firstSideMiddlePoint = firstNode + n1; if (firstSideMiddlePoint >= numPolygonNodes) { firstSideMiddlePoint = firstSideMiddlePoint - numPolygonNodes; } - size_t secondSideMiddlePoint = secondNode + n3; + UInt secondSideMiddlePoint = secondNode + n3; if (secondSideMiddlePoint >= numPolygonNodes) { secondSideMiddlePoint = secondSideMiddlePoint - numPolygonNodes; } - size_t thirdSideMiddlePoint = thirdNode + n2; + UInt thirdSideMiddlePoint = thirdNode + n2; if (thirdSideMiddlePoint >= numPolygonNodes) { thirdSideMiddlePoint = thirdSideMiddlePoint - numPolygonNodes; } // set dimensions of blocks - std::vector numM{n1, n3, n2}; - std::vector numN{n3, n2, n1}; + std::vector numM{n1, n3, n2}; + std::vector numN{n3, n2, n1}; // set pointers of block corners - std::vector cornerPoints{firstNode, secondNode, thirdNode}; - std::vector iLeft{thirdSideMiddlePoint, firstSideMiddlePoint, secondSideMiddlePoint}; - std::vector iRight{firstSideMiddlePoint, secondSideMiddlePoint, thirdSideMiddlePoint}; + std::vector cornerPoints{firstNode, secondNode, thirdNode}; + std::vector iLeft{thirdSideMiddlePoint, firstSideMiddlePoint, secondSideMiddlePoint}; + std::vector iRight{firstSideMiddlePoint, secondSideMiddlePoint, thirdSideMiddlePoint}; // compute triangle middle point const auto xia = static_cast(n1) / static_cast(numPointsFirstSide); @@ -337,7 +337,7 @@ CurvilinearGrid CurvilinearGridFromPolygon::Compute(size_t firstNode, Projection const polygonProjection = m_polygon->GetProjection(); - for (size_t t = 0; t < Mesh::m_numNodesInTriangle; ++t) + for (UInt t = 0; t < Mesh::m_numNodesInTriangle; ++t) { std::ranges::fill(sideOne, Point()); std::ranges::fill(sideTwo, Point()); @@ -346,7 +346,7 @@ CurvilinearGrid CurvilinearGridFromPolygon::Compute(size_t firstNode, // backward auto cornerIndex = cornerPoints[t]; - for (size_t i = 0; i < numN[t] + 1; ++i) + for (UInt i = 0; i < numN[t] + 1; ++i) { sideOne[i] = polygonNodes[cornerIndex]; if (cornerIndex == 0 || cornerIndex < start) @@ -365,7 +365,7 @@ CurvilinearGrid CurvilinearGridFromPolygon::Compute(size_t firstNode, // forward cornerIndex = cornerPoints[t]; - for (size_t i = 0; i < numM[t] + 1; ++i) + for (UInt i = 0; i < numM[t] + 1; ++i) { sideThree[i] = polygonNodes[cornerIndex]; cornerIndex += 1; @@ -380,14 +380,14 @@ CurvilinearGrid CurvilinearGridFromPolygon::Compute(size_t firstNode, } // fill side four - for (size_t i = 0; i < numM[t] + 1; ++i) + for (UInt i = 0; i < numM[t] + 1; ++i) { double localXia = static_cast(i) / static_cast(numM[t]); sideFour[i] = polygonNodes[iLeft[t]] * (1.0 - localXia) + triangleCenter * localXia; } // fill side two - for (size_t i = 0; i < numN[t] + 1; ++i) + for (UInt i = 0; i < numN[t] + 1; ++i) { double localXia = static_cast(i) / static_cast(numN[t]); sideTwo[i] = polygonNodes[iRight[t]] * (1.0 - localXia) + triangleCenter * localXia; @@ -404,9 +404,9 @@ CurvilinearGrid CurvilinearGridFromPolygon::Compute(size_t firstNode, // add to grid if (t == 0) { - for (size_t i = 0; i < result.size(); ++i) + for (UInt i = 0; i < result.size(); ++i) { - for (size_t j = 0; j < result[0].size(); ++j) + for (UInt j = 0; j < result[0].size(); ++j) { gridNodes[i][j] = result[i][j]; } @@ -414,9 +414,9 @@ CurvilinearGrid CurvilinearGridFromPolygon::Compute(size_t firstNode, } if (t == 1) { - for (size_t i = 0; i < result.size(); ++i) + for (UInt i = 0; i < result.size(); ++i) { - for (size_t j = 0; j < result[0].size(); ++j) + for (UInt j = 0; j < result[0].size(); ++j) { const auto iIndex = n1 + n3 - i; const auto jIndex = n2 + n3 - j; @@ -426,9 +426,9 @@ CurvilinearGrid CurvilinearGridFromPolygon::Compute(size_t firstNode, } if (t == 2) { - for (size_t i = 0; i < result[0].size(); ++i) + for (UInt i = 0; i < result[0].size(); ++i) { - for (size_t j = 0; j < result.size(); ++j) + for (UInt j = 0; j < result.size(); ++j) { const auto jIndex = n2 + n3 - j; gridNodes[i][jIndex] = result[j][i]; diff --git a/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridFromSplines.cpp b/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridFromSplines.cpp index 2f0cf8fbb..d7631d377 100644 --- a/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridFromSplines.cpp +++ b/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridFromSplines.cpp @@ -70,7 +70,7 @@ void CurvilinearGridFromSplines::AllocateSplinesProperties() m_crossSplineRightHeights.resize(numSplines); m_numCrossSplineLeftHeights.resize(numSplines); m_numCrossSplineRightHeights.resize(numSplines); - for (size_t s = 0; s < numSplines; ++s) + for (UInt s = 0; s < numSplines; ++s) { m_crossingSplinesIndices[s].resize(numSplines); std::fill(m_crossingSplinesIndices[s].begin(), m_crossingSplinesIndices[s].end(), 0); @@ -100,9 +100,9 @@ void CurvilinearGridFromSplines::AllocateSplinesProperties() m_numMSplines.resize(numSplines); std::fill(m_numMSplines.begin(), m_numMSplines.end(), 0); m_leftGridLineIndex.resize(numSplines); - std::fill(m_leftGridLineIndex.begin(), m_leftGridLineIndex.end(), constants::missing::sizetValue); + std::fill(m_leftGridLineIndex.begin(), m_leftGridLineIndex.end(), constants::missing::uintValue); m_rightGridLineIndex.resize(numSplines); - std::fill(m_rightGridLineIndex.begin(), m_rightGridLineIndex.end(), constants::missing::sizetValue); + std::fill(m_rightGridLineIndex.begin(), m_rightGridLineIndex.end(), constants::missing::uintValue); } CurvilinearGrid CurvilinearGridFromSplines::Compute() @@ -126,18 +126,18 @@ CurvilinearGrid CurvilinearGridFromSplines::Compute() void CurvilinearGridFromSplines::DeleteSkinnyTriangles() { - const size_t numMaxIterations = 10; - const auto numN = m_gridPoints.size() - 2; + const UInt numMaxIterations = 10; + const auto numN = static_cast(m_gridPoints.size()) - 2; const double squaredDistanceTolerance = 1e-4; const double cosineTolerance = 1e-2; const double maxCosine = 0.93969; - for (size_t j = numN - 1; j >= 1; --j) + for (UInt j = numN - 1; j >= 1; --j) { - for (size_t iter = 0; iter < numMaxIterations; ++iter) + for (UInt iter = 0; iter < numMaxIterations; ++iter) { - size_t numChanged = 0; - size_t firstRightIndex = 0; - size_t i = 0; + UInt numChanged = 0; + UInt firstRightIndex = 0; + UInt i = 0; while (firstRightIndex != m_numM - 1 || i != m_numM - 1) { @@ -270,7 +270,7 @@ void CurvilinearGridFromSplines::Initialize() // Store original number of splines std::vector newCrossSpline(2); m_numOriginalSplines = m_splines->GetNumSplines(); - for (size_t s = 0; s < m_numOriginalSplines; ++s) + for (UInt s = 0; s < m_numOriginalSplines; ++s) { // mirror only center splines if (m_type[s] != SplineTypes::central) @@ -309,7 +309,7 @@ void CurvilinearGridFromSplines::Initialize() newCrossSpline[0] = {xs1, ys1}; newCrossSpline[1] = {xs2, ys2}; - m_splines->AddSpline(newCrossSpline, 0, newCrossSpline.size()); + m_splines->AddSpline(newCrossSpline, 0, static_cast(newCrossSpline.size())); // flag the cross spline as artificially added m_type.emplace_back(SplineTypes::artificial); } @@ -321,7 +321,7 @@ void CurvilinearGridFromSplines::Initialize() m_mfacOriginal.resize(m_numOriginalSplines); m_maximumGridHeightsOriginal.resize(m_numOriginalSplines); m_originalTypes.resize(m_numOriginalSplines); - for (size_t s = 0; s < m_numOriginalSplines; ++s) + for (UInt s = 0; s < m_numOriginalSplines; ++s) { m_leftGridLineIndexOriginal[s] = m_leftGridLineIndex[s]; m_rightGridLineIndexOriginal[s] = m_rightGridLineIndex[s]; @@ -335,7 +335,7 @@ void CurvilinearGridFromSplines::Initialize() // artificial cross spline: remove the last part of the sub-intervals (since it makes no sense, // as the artificial cross spline has an arbitrary, but sufficiently large, length) - for (size_t s = 0; s < m_numOriginalSplines; ++s) + for (UInt s = 0; s < m_numOriginalSplines; ++s) { // Remove the last part of the sub-intervals if (m_type[s] != SplineTypes::central) @@ -344,7 +344,7 @@ void CurvilinearGridFromSplines::Initialize() } // For number of intersecting splines - for (size_t i = 0; i < m_numCrossingSplines[s]; ++i) + for (UInt i = 0; i < m_numCrossingSplines[s]; ++i) { const auto crossingSplineIndex = m_crossingSplinesIndices[s][i]; if (m_type[crossingSplineIndex] == SplineTypes::artificial) @@ -365,15 +365,15 @@ void CurvilinearGridFromSplines::Initialize() m_validFrontNodes.resize(m_numM, 1); // Copy the first m point in m_gridPoints - for (size_t n = 0; n < m_numM; ++n) + for (UInt n = 0; n < m_numM; ++n) { m_gridPoints[0][n] = m_gridLine[n]; if (!m_gridLine[n].IsValid()) { m_validFrontNodes[n] = 0; } - size_t sumLeft = 0; - size_t sumRight = 0; + UInt sumLeft = 0; + UInt sumRight = 0; const auto leftColumn = n == 0 ? 0 : n - 1; const auto rightColumn = n <= m_numM - 2 ? n : m_numM - 2; @@ -391,7 +391,7 @@ void CurvilinearGridFromSplines::Initialize() // compute maximum mesh width and get dtolLR in the proper dimension double squaredMaximumGridWidth = 0.0; - for (size_t i = 0; i < m_gridPoints[0].size() - 1; i++) + for (UInt i = 0; i < m_gridPoints[0].size() - 1; i++) { if (!m_gridPoints[0][i].IsValid() || !m_gridPoints[0][i + 1].IsValid()) { @@ -404,11 +404,11 @@ void CurvilinearGridFromSplines::Initialize() m_subLayerGridPoints.resize(m_numPerpendicularFacesOnSubintervalAndEdge.size()); } -void CurvilinearGridFromSplines::Iterate(size_t layer) +void CurvilinearGridFromSplines::Iterate(UInt layer) { GrowLayer(layer); - for (size_t j = 0; j < m_subLayerGridPoints.size(); ++j) + for (UInt j = 0; j < m_subLayerGridPoints.size(); ++j) { m_subLayerGridPoints[j] = m_numPerpendicularFacesOnSubintervalAndEdge[j][0]; } @@ -416,11 +416,11 @@ void CurvilinearGridFromSplines::Iterate(size_t layer) auto results = ComputeGridLayerAndSubLayer(layer); auto subLayerRightIndex = std::get<1>(results); - for (size_t i = 0; i < m_numM; i++) + for (UInt i = 0; i < m_numM; i++) { const auto subLayerLeftIndex = subLayerRightIndex; - const auto minRight = std::min(static_cast(i), m_numPerpendicularFacesOnSubintervalAndEdge[0].size() - static_cast(1)); - for (size_t j = 0; j < m_subLayerGridPoints.size(); ++j) + const auto minRight = std::min(i, static_cast(m_numPerpendicularFacesOnSubintervalAndEdge[0].size()) - 1); + for (UInt j = 0; j < m_subLayerGridPoints.size(); ++j) { m_subLayerGridPoints[j] = m_numPerpendicularFacesOnSubintervalAndEdge[j][minRight]; } @@ -429,14 +429,14 @@ void CurvilinearGridFromSplines::Iterate(size_t layer) const auto gridLayer = std::get<0>(results); subLayerRightIndex = std::get<1>(results); - if (subLayerRightIndex != constants::missing::sizetValue && i < m_numM - 1 && gridLayer != constants::missing::sizetValue) + if (subLayerRightIndex != constants::missing::uintValue && i < m_numM - 1 && gridLayer != constants::missing::uintValue) { m_edgeVelocities[i] = m_growFactorOnSubintervalAndEdge[subLayerRightIndex][i] * m_edgeVelocities[i]; } - if (subLayerLeftIndex == constants::missing::sizetValue && subLayerRightIndex == constants::missing::sizetValue) + if (subLayerLeftIndex == constants::missing::uintValue && subLayerRightIndex == constants::missing::uintValue) { - m_validFrontNodes[i] = constants::missing::sizetValue; + m_validFrontNodes[i] = constants::missing::uintValue; } } @@ -451,16 +451,16 @@ CurvilinearGrid CurvilinearGridFromSplines::ComputeCurvilinearGridFromGridPoints const double squaredDistanceTolerance = 1e-12; // get the grid sizes in j-direction - for (size_t i = 0; i < m_gridPoints[0].size(); i++) + for (UInt i = 0; i < m_gridPoints[0].size(); i++) { - for (size_t j = 0; j < m_gridPoints.size(); j++) + for (UInt j = 0; j < m_gridPoints.size(); j++) { gridPointsNDirection[i][j] = m_gridPoints[j][i]; } } - size_t startIndex = 0; - size_t startGridLine = 0; + UInt startIndex = 0; + UInt startGridLine = 0; while (startIndex < m_gridPoints[0].size()) { auto mIndicesThisSide = FindIndices(m_gridPoints[0], startIndex, m_numM, constants::missing::doubleValue); @@ -472,19 +472,19 @@ CurvilinearGrid CurvilinearGridFromSplines::ComputeCurvilinearGridFromGridPoints bool isConnected = true; - size_t minN = m_curvilinearParameters.n_refinement; - size_t maxN = 0; - size_t minNOther = m_curvilinearParameters.n_refinement; - size_t maxNOther = 0; + UInt minN = m_curvilinearParameters.n_refinement; + UInt maxN = 0; + UInt minNOther = m_curvilinearParameters.n_refinement; + UInt maxNOther = 0; // check if this part is connected to another part for (auto i = mStartIndexThisSide; i < mEndIndexThisSide + 1; ++i) { - const auto nIndicesThisSide = FindIndices(gridPointsNDirection[i], 0, gridPointsNDirection[i].size(), constants::missing::doubleValue); + const auto nIndicesThisSide = FindIndices(gridPointsNDirection[i], 0, static_cast(gridPointsNDirection[i].size()), constants::missing::doubleValue); const auto& [nStartIndexThisSide, nEndIndexThisSide] = nIndicesThisSide[0]; minN = std::min(minN, nStartIndexThisSide); maxN = std::max(maxN, nEndIndexThisSide); - const size_t mOther = mEndIndexThisSide + 2 + (mEndIndexThisSide - i); + const UInt mOther = mEndIndexThisSide + 2 + (mEndIndexThisSide - i); if (mOther > m_numM - 1) { @@ -500,7 +500,7 @@ CurvilinearGrid CurvilinearGridFromSplines::ComputeCurvilinearGridFromGridPoints } else { - const auto nIndicesOtherSide = FindIndices(gridPointsNDirection[mOther], 0, gridPointsNDirection[mOther].size(), constants::missing::doubleValue); + const auto nIndicesOtherSide = FindIndices(gridPointsNDirection[mOther], 0, static_cast(gridPointsNDirection[mOther].size()), constants::missing::doubleValue); const auto& [nStartIndexOtherSide, nEndIndexOtherSide] = nIndicesOtherSide[0]; minNOther = std::min(minNOther, nStartIndexOtherSide); @@ -522,17 +522,17 @@ CurvilinearGrid CurvilinearGridFromSplines::ComputeCurvilinearGridFromGridPoints // increment points curvilinearMeshPoints.resize(endGridlineIndex + 1); - const auto NSize = std::max(curvilinearMeshPoints[0].size(), maxN + maxNOther + 1); + const auto NSize = std::max(static_cast(curvilinearMeshPoints[0].size()), maxN + maxNOther + 1); for (auto& element : curvilinearMeshPoints) { element.resize(NSize); } // fill first part - size_t columnIncrement = 0; + UInt columnIncrement = 0; for (auto i = startGridLine; i < endGridlineIndex + 1; ++i) { - for (size_t j = 0; j < maxN + 1; ++j) + for (UInt j = 0; j < maxN + 1; ++j) { curvilinearMeshPoints[i][j + maxNOther] = m_gridPoints[j][mStartIndexThisSide + columnIncrement]; } @@ -542,7 +542,7 @@ CurvilinearGrid CurvilinearGridFromSplines::ComputeCurvilinearGridFromGridPoints columnIncrement = 0; for (auto i = startGridLine; i < endGridlineIndex + 1; ++i) { - for (size_t j = 0; j < maxNOther + 1; ++j) + for (UInt j = 0; j < maxNOther + 1; ++j) { curvilinearMeshPoints[i][maxNOther - j] = m_gridPoints[j][mEndIndexOtherSide - columnIncrement]; } @@ -555,22 +555,22 @@ CurvilinearGrid CurvilinearGridFromSplines::ComputeCurvilinearGridFromGridPoints return CurvilinearGrid(std::move(curvilinearMeshPoints), m_splines->m_projection); } -std::tuple -CurvilinearGridFromSplines::ComputeGridLayerAndSubLayer(size_t layerIndex) +std::tuple +CurvilinearGridFromSplines::ComputeGridLayerAndSubLayer(UInt layerIndex) { if (layerIndex == 0) { - return {constants::missing::sizetValue, constants::missing::sizetValue}; + return {constants::missing::uintValue, constants::missing::uintValue}; } - size_t gridLayer = layerIndex - 1; - auto sum = std::accumulate(m_subLayerGridPoints.begin(), m_subLayerGridPoints.end(), size_t(0)); + UInt gridLayer = layerIndex - 1; + auto sum = std::accumulate(m_subLayerGridPoints.begin(), m_subLayerGridPoints.end(), UInt(0)); - size_t subLayerIndex; + UInt subLayerIndex; if (layerIndex >= sum) { - subLayerIndex = constants::missing::sizetValue; + subLayerIndex = constants::missing::uintValue; } else { @@ -587,12 +587,12 @@ CurvilinearGridFromSplines::ComputeGridLayerAndSubLayer(size_t layerIndex) return {gridLayer, subLayerIndex}; } -void CurvilinearGridFromSplines::GrowLayer(size_t layerIndex) +void CurvilinearGridFromSplines::GrowLayer(UInt layerIndex) { auto velocityVectorAtGridPoints = ComputeVelocitiesAtGridPoints(layerIndex - 1); std::vector activeLayerPoints(m_gridPoints[layerIndex - 1]); - for (size_t m = 0; m < velocityVectorAtGridPoints.size(); ++m) + for (UInt m = 0; m < velocityVectorAtGridPoints.size(); ++m) { if (!velocityVectorAtGridPoints[m].IsValid()) { @@ -607,17 +607,17 @@ void CurvilinearGridFromSplines::GrowLayer(size_t layerIndex) std::vector gridLine(m_gridPoints[layerIndex - 1]); double localTimeStep = 0.0; double otherTimeStep = std::numeric_limits::max(); - const auto numGridPoints = m_gridPoints.size() * m_gridPoints[0].size(); - std::vector newValidFrontNodes(numGridPoints); + const auto numGridPoints = static_cast(m_gridPoints.size() * m_gridPoints[0].size()); + std::vector newValidFrontNodes(numGridPoints); while (totalTimeStep < m_timeStep) { // Copy old front velocities newValidFrontNodes = m_validFrontNodes; - for (size_t i = 0; i < m_validFrontNodes.size(); ++i) + for (UInt i = 0; i < m_validFrontNodes.size(); ++i) { - if (m_validFrontNodes[i] == constants::missing::sizetValue) + if (m_validFrontNodes[i] == constants::missing::uintValue) { activeLayerPoints[i] = {constants::missing::doubleValue, constants::missing::doubleValue}; } @@ -644,7 +644,7 @@ void CurvilinearGridFromSplines::GrowLayer(size_t layerIndex) newValidFrontNodes[m_numM - 1] = 0; } - for (size_t i = 0; i < newValidFrontNodes.size() - 2; ++i) + for (UInt i = 0; i < newValidFrontNodes.size() - 2; ++i) { if (newValidFrontNodes[i + 1] == 1 && newValidFrontNodes[i] == 0 && newValidFrontNodes[i + 2] == 0) { @@ -654,7 +654,7 @@ void CurvilinearGridFromSplines::GrowLayer(size_t layerIndex) m_validFrontNodes = newValidFrontNodes; - for (size_t i = 0; i < velocityVectorAtGridPoints.size(); ++i) + for (UInt i = 0; i < velocityVectorAtGridPoints.size(); ++i) { if (m_validFrontNodes[i] == 1 && velocityVectorAtGridPoints[i].IsValid()) { @@ -678,7 +678,7 @@ void CurvilinearGridFromSplines::GrowLayer(size_t layerIndex) { velocityVectorAtGridPoints = ComputeVelocitiesAtGridPoints(layerIndex); - for (size_t i = 0; i < m_numM; ++i) + for (UInt i = 0; i < m_numM; ++i) { // Disable points that have no valid normal vector // Remove stationary points @@ -694,7 +694,7 @@ void CurvilinearGridFromSplines::GrowLayer(size_t layerIndex) auto [gridPointsIndices, frontGridPoints, numFrontPoints] = FindFront(); if (layerIndex >= 2) { - for (size_t i = 1; i < m_numM - 1; ++i) + for (UInt i = 1; i < m_numM - 1; ++i) { if (!activeLayerPoints[i].IsValid()) @@ -729,7 +729,7 @@ std::vector CurvilinearGridFromSplines::ComputeMaximumEdgeGrowTime(const std::vector edgeIncrement(coordinates.size() - 1); const double minEdgeWidth = 1e-8; const double dt = 1.0; - for (size_t i = 0; i < coordinates.size() - 1; ++i) + for (UInt i = 0; i < coordinates.size() - 1; ++i) { if (!coordinates[i].IsValid() || !coordinates[i + 1].IsValid()) { @@ -750,7 +750,7 @@ std::vector CurvilinearGridFromSplines::ComputeMaximumEdgeGrowTime(const edgeIncrement[i] = edgeIncrement[i] / dt; } - for (size_t i = 0; i < coordinates.size() - 1; ++i) + for (UInt i = 0; i < coordinates.size() - 1; ++i) { if (edgeIncrement[i] < 0.0) { @@ -761,14 +761,14 @@ std::vector CurvilinearGridFromSplines::ComputeMaximumEdgeGrowTime(const return maximumGridLayerGrowTime; } -std::vector CurvilinearGridFromSplines::CopyVelocitiesToFront(size_t layerIndex, +std::vector CurvilinearGridFromSplines::CopyVelocitiesToFront(UInt layerIndex, const std::vector& previousFrontVelocities) { const auto numGridPoints = m_gridPoints.size() * m_gridPoints[0].size(); std::vector velocities(numGridPoints, {0.0, 0.0}); - size_t numCornerNodes = 0; - size_t p = 0; + UInt numCornerNodes = 0; + UInt p = 0; auto [gridPointsIndices, frontGridPoints, numFrontPoints] = FindFront(); while (p < numFrontPoints) { @@ -789,11 +789,11 @@ std::vector CurvilinearGridFromSplines::CopyVelocitiesToFront // Check corner nodes bool ll = previousIndices[0] == gridPointsIndices[p][0] - 1 && previousIndices[1] == gridPointsIndices[p][1] && - m_validFrontNodes[previousIndices[0]] == constants::missing::sizetValue; + m_validFrontNodes[previousIndices[0]] == constants::missing::uintValue; bool lr = nextIndices[0] == gridPointsIndices[p][0] + 1 && nextIndices[1] == gridPointsIndices[p][1] && - m_validFrontNodes[nextIndices[0]] == constants::missing::sizetValue; + m_validFrontNodes[nextIndices[0]] == constants::missing::uintValue; ll = ll || (previousIndices[0] == gridPointsIndices[p][0] && previousIndices[1] < gridPointsIndices[p][1]); lr = lr || (nextIndices[0] == gridPointsIndices[p][0] && nextIndices[1] < gridPointsIndices[p][1]); @@ -829,18 +829,18 @@ std::vector CurvilinearGridFromSplines::CopyVelocitiesToFront return velocities; } -std::tuple>, std::vector, size_t> +std::tuple>, std::vector, meshkernel::UInt> CurvilinearGridFromSplines::FindFront() { - const auto numGridPoints = m_gridPoints.size() * m_gridPoints[0].size(); - std::vector> gridPointsIndices(numGridPoints, std::vector(2, constants::missing::sizetValue)); + const auto numGridPoints = static_cast(m_gridPoints.size() * m_gridPoints[0].size()); + std::vector> gridPointsIndices(numGridPoints, std::vector(2, constants::missing::uintValue)); std::vector frontGridPoints(numGridPoints, {0.0, 0.0}); - size_t numFrontPoints; + UInt numFrontPoints; std::vector frontPosition(m_gridPoints[0].size() - 2, static_cast(m_gridPoints.size())); - for (size_t m = 0; m < frontPosition.size(); ++m) + for (UInt m = 0; m < frontPosition.size(); ++m) { - for (size_t n = 0; n < m_gridPoints.size(); ++n) + for (UInt n = 0; n < m_gridPoints.size(); ++n) { if (!m_gridPoints[n][m].IsValid() || !m_gridPoints[n][m + 1].IsValid()) { @@ -871,7 +871,7 @@ CurvilinearGridFromSplines::FindFront() numFrontPoints++; } - for (size_t m = 0; m < m_gridPoints[0].size() - 2; ++m) + for (UInt m = 0; m < m_gridPoints[0].size() - 2; ++m) { const auto currentFrontPosition = frontPosition[m]; if (currentFrontPosition >= 0) @@ -915,7 +915,7 @@ CurvilinearGridFromSplines::FindFront() frontGridPoints[numFrontPoints] = {constants::missing::doubleValue, constants::missing::doubleValue}; gridPointsIndices[numFrontPoints][0] = m; - gridPointsIndices[numFrontPoints][1] = constants::missing::sizetValue; + gridPointsIndices[numFrontPoints][1] = constants::missing::uintValue; numFrontPoints++; } @@ -923,7 +923,7 @@ CurvilinearGridFromSplines::FindFront() } // add last j-edge, check for circular connectivity - const auto lastPoint = m_gridPoints[0].size() - 2; + const auto lastPoint = static_cast(m_gridPoints[0].size()) - 2; const auto [currentLeftIndex, currentRightIndex] = GetNeighbours(m_gridPoints[0], lastPoint); if (currentRightIndex == m_gridPoints[0].size() - 2) { @@ -940,7 +940,7 @@ CurvilinearGridFromSplines::FindFront() } std::vector -CurvilinearGridFromSplines::ComputeVelocitiesAtGridPoints(size_t layerIndex) +CurvilinearGridFromSplines::ComputeVelocitiesAtGridPoints(UInt layerIndex) { std::vector velocityVector(m_numM); std::fill(velocityVector.begin(), velocityVector.end(), Point()); @@ -948,7 +948,7 @@ CurvilinearGridFromSplines::ComputeVelocitiesAtGridPoints(size_t layerIndex) Point normalVectorRight; const double cosTolerance = 1e-8; const double eps = 1e-10; - for (size_t m = 0; m < velocityVector.size(); ++m) + for (UInt m = 0; m < velocityVector.size(); ++m) { if (!m_gridPoints[layerIndex][m].IsValid()) { @@ -1025,13 +1025,13 @@ CurvilinearGridFromSplines::ComputeVelocitiesAtGridPoints(size_t layerIndex) return velocityVector; } -std::tuple CurvilinearGridFromSplines::GetNeighbours(const std::vector& gridPoints, - size_t index) const +std::tuple CurvilinearGridFromSplines::GetNeighbours(const std::vector& gridPoints, + UInt index) const { if (gridPoints.empty()) { - return {constants::missing::sizetValue, constants::missing::sizetValue}; + return {constants::missing::uintValue, constants::missing::uintValue}; } bool circularConnection = false; @@ -1084,20 +1084,20 @@ std::tuple CurvilinearGridFromSplines::GetNeighbours(const std:: localRightIndex++; } - return {static_cast(localLeftIndex), static_cast(localRightIndex)}; + return {static_cast(localLeftIndex), static_cast(localRightIndex)}; } void CurvilinearGridFromSplines::ComputeEdgeVelocities() { m_edgeVelocities.resize(m_numM - 1, constants::missing::doubleValue); ResizeAndFill2DVector(m_growFactorOnSubintervalAndEdge, m_maxNumCenterSplineHeights, m_numM - 1, true, 1.0); - ResizeAndFill2DVector(m_numPerpendicularFacesOnSubintervalAndEdge, m_maxNumCenterSplineHeights, m_numM - 1, true, static_cast(0)); + ResizeAndFill2DVector(m_numPerpendicularFacesOnSubintervalAndEdge, m_maxNumCenterSplineHeights, m_numM - 1, true, static_cast(0)); ComputeGridHeights(); std::fill(m_numPerpendicularFacesOnSubintervalAndEdge[0].begin(), m_numPerpendicularFacesOnSubintervalAndEdge[0].end(), 1); - for (size_t s = 0; s < m_splines->GetNumSplines(); s++) + for (UInt s = 0; s < m_splines->GetNumSplines(); s++) { if (m_type[s] != SplineTypes::central) @@ -1108,8 +1108,8 @@ void CurvilinearGridFromSplines::ComputeEdgeVelocities() // Get true crossing splines heights auto numLeftHeights = m_maxNumCenterSplineHeights; auto numRightHeights = m_maxNumCenterSplineHeights; - size_t numTrueCrossings = 0; - for (size_t i = 0; i < m_numCrossingSplines[s]; ++i) + UInt numTrueCrossings = 0; + for (UInt i = 0; i < m_numCrossingSplines[s]; ++i) { if (m_type[m_crossingSplinesIndices[s][i]] != SplineTypes::crossing) { @@ -1135,7 +1135,7 @@ void CurvilinearGridFromSplines::ComputeEdgeVelocities() double hh0LeftMaxRatio; double hh0RightMaxRatio; - const size_t numIterations = 2; + const UInt numIterations = 2; double maxHeight = std::numeric_limits::lowest(); for (const auto& e : m_gridHeights[0]) @@ -1147,7 +1147,7 @@ void CurvilinearGridFromSplines::ComputeEdgeVelocities() } const double firstHeight = std::min(maxHeight, m_splinesToCurvilinearParameters.aspect_ratio * m_splinesToCurvilinearParameters.average_width); - for (size_t iter = 0; iter < numIterations; ++iter) + for (UInt iter = 0; iter < numIterations; ++iter) { ComputeVelocitiesSubIntervals(s, startGridLineLeft, endGridLineLeft, numLeftHeights, numRightHeights, firstHeight, m_leftGridLineIndex, m_rightGridLineIndex, m_numPerpendicularFacesOnSubintervalAndEdge, m_edgeVelocities, hh0LeftMaxRatio); @@ -1166,10 +1166,10 @@ void CurvilinearGridFromSplines::ComputeEdgeVelocities() } // left part - size_t numNLeftExponential = 0; + UInt numNLeftExponential = 0; if (m_splinesToCurvilinearParameters.grow_grid_outside == 1) { - numNLeftExponential = std::min(ComputeNumberExponentialLayers(hh0LeftMaxRatio), static_cast(m_curvilinearParameters.n_refinement)); + numNLeftExponential = std::min(ComputeNumberExponentialLayers(hh0LeftMaxRatio), static_cast(m_curvilinearParameters.n_refinement)); } for (auto i = startGridLineLeft; i < endGridLineLeft; ++i) { @@ -1177,10 +1177,10 @@ void CurvilinearGridFromSplines::ComputeEdgeVelocities() } // right part - size_t numNRightExponential = 0; + UInt numNRightExponential = 0; if (m_splinesToCurvilinearParameters.grow_grid_outside == 1) { - numNRightExponential = std::min(ComputeNumberExponentialLayers(hh0RightMaxRatio), static_cast(m_curvilinearParameters.n_refinement)); + numNRightExponential = std::min(ComputeNumberExponentialLayers(hh0RightMaxRatio), static_cast(m_curvilinearParameters.n_refinement)); } for (auto i = startGridLineRight; i < endGridLineRight; ++i) { @@ -1189,7 +1189,7 @@ void CurvilinearGridFromSplines::ComputeEdgeVelocities() } // compute local grow factors - for (size_t s = 0; s < m_splines->GetNumSplines(); s++) + for (UInt s = 0; s < m_splines->GetNumSplines(); s++) { if (m_numMSplines[s] < 1) { @@ -1207,7 +1207,7 @@ void CurvilinearGridFromSplines::ComputeEdgeVelocities() } } -double CurvilinearGridFromSplines::ComputeGrowFactor(size_t splineIndex) const +double CurvilinearGridFromSplines::ComputeGrowFactor(UInt splineIndex) const { // eheight m_gridHeights @@ -1219,14 +1219,14 @@ double CurvilinearGridFromSplines::ComputeGrowFactor(size_t splineIndex) const auto heightDifferenceIncremented = ComputeTotalExponentialHeight(aspectRatioGrowFactorIncremented, m_edgeVelocities[splineIndex], m_numPerpendicularFacesOnSubintervalAndEdge[1][splineIndex]) - m_gridHeights[1][splineIndex]; const double tolerance = 1e-8; - const size_t numIterations = 1000; + const UInt numIterations = 1000; const double relaxationFactor = 0.5; double oldAspectRatio; double oldHeightDifference = heightDifference; if (std::abs(heightDifferenceIncremented) > tolerance && std::abs(heightDifferenceIncremented - heightDifference) > tolerance) { - for (size_t i = 0; i < numIterations; ++i) + for (UInt i = 0; i < numIterations; ++i) { oldAspectRatio = aspectRatioGrowFactor; oldHeightDifference = heightDifference; @@ -1257,35 +1257,36 @@ double CurvilinearGridFromSplines::ComputeGrowFactor(size_t splineIndex) const return 1.0; } -double CurvilinearGridFromSplines::ComputeTotalExponentialHeight(double aspectRatio, double height, size_t numLayers) const +double CurvilinearGridFromSplines::ComputeTotalExponentialHeight(double aspectRatio, double height, UInt numLayers) const { - if (std::abs(aspectRatio - 1.0) > 1e-8) + const auto absAspectRatio = aspectRatio - 1.0; + if (absAspectRatio < -1e-8 || absAspectRatio > 1e-8) { - return (std::pow(aspectRatio, numLayers) - 1.0) / (aspectRatio - 1.0) * height; + return (std::pow(aspectRatio, static_cast(numLayers)) - 1.0) / absAspectRatio * height; } return height * static_cast(numLayers); } -size_t CurvilinearGridFromSplines::ComputeNumberExponentialLayers(const double heightRatio) const +meshkernel::UInt CurvilinearGridFromSplines::ComputeNumberExponentialLayers(const double heightRatio) const { if (m_splinesToCurvilinearParameters.aspect_ratio_grow_factor - 1.0 > 1e-8) { - return size_t(std::floor(std::log((m_splinesToCurvilinearParameters.aspect_ratio_grow_factor - 1.0) * heightRatio + 1.0) / - log(m_splinesToCurvilinearParameters.aspect_ratio_grow_factor))); + return UInt(std::floor(std::log((m_splinesToCurvilinearParameters.aspect_ratio_grow_factor - 1.0) * heightRatio + 1.0) / + log(m_splinesToCurvilinearParameters.aspect_ratio_grow_factor))); } - return size_t(std::floor(0.999 + heightRatio)); + return UInt(std::floor(0.999 + heightRatio)); } -void CurvilinearGridFromSplines::ComputeVelocitiesSubIntervals(size_t s, - size_t startGridLineIndex, - size_t endGridLineIndex, - size_t numHeights, - size_t numOtherSideHeights, +void CurvilinearGridFromSplines::ComputeVelocitiesSubIntervals(UInt s, + UInt startGridLineIndex, + UInt endGridLineIndex, + UInt numHeights, + UInt numOtherSideHeights, const double firstHeight, - const std::vector& gridLineIndex, - const std::vector& otherGridLineIndex, - std::vector>& numPerpendicularFacesOnSubintervalAndEdge, + const std::vector& gridLineIndex, + const std::vector& otherGridLineIndex, + std::vector>& numPerpendicularFacesOnSubintervalAndEdge, std::vector& edgeVelocities, double& hh0MaxRatio) { @@ -1294,7 +1295,7 @@ void CurvilinearGridFromSplines::ComputeVelocitiesSubIntervals(size_t s, { const auto maxHeight = *std::max_element(m_gridHeights[0].begin() + startGridLineIndex, m_gridHeights[0].begin() + endGridLineIndex); - auto numNUniformPart = static_cast(std::floor(maxHeight / firstHeight + 0.99999)); + auto numNUniformPart = static_cast(std::floor(maxHeight / firstHeight + 0.99999)); numNUniformPart = std::min(numNUniformPart, m_maxNUniformPart); for (auto i = startGridLineIndex; i < endGridLineIndex; ++i) @@ -1307,7 +1308,7 @@ void CurvilinearGridFromSplines::ComputeVelocitiesSubIntervals(size_t s, else { // only one subinterval: no uniform part - const size_t numNUniformPart = 0; + const UInt numNUniformPart = 0; for (auto i = startGridLineIndex; i < endGridLineIndex; ++i) { numPerpendicularFacesOnSubintervalAndEdge[0][i] = numNUniformPart; @@ -1328,7 +1329,7 @@ void CurvilinearGridFromSplines::ComputeVelocitiesSubIntervals(size_t s, } } - for (size_t j = 1; j < m_maxNumCenterSplineHeights; ++j) + for (UInt j = 1; j < m_maxNumCenterSplineHeights; ++j) { m_gridHeights[j][i] = m_gridHeights[j - 1][i]; } @@ -1352,9 +1353,9 @@ void CurvilinearGridFromSplines::ComputeGridHeights() std::vector edgesCenterPoints(m_numM, 0.0); std::vector crossingSplinesDimensionalCoordinates(numSplines, 0.0); std::vector localSplineDerivatives(numSplines, 0.0); - std::vector localValidSplineIndices(numSplines, 0); + std::vector localValidSplineIndices(numSplines, 0); - for (size_t s = 0; s < numSplines; s++) + for (UInt s = 0; s < numSplines; s++) { if (m_type[s] != SplineTypes::central) { @@ -1373,11 +1374,11 @@ void CurvilinearGridFromSplines::ComputeGridHeights() if (m_numCrossingSplines[s] == 1) { // only one crossing spline present: - for (size_t i = 0; i < minNumLeftIntervals; ++i) + for (UInt i = 0; i < minNumLeftIntervals; ++i) { std::fill(heightsLeft[i].begin(), heightsLeft[i].begin() + numM, m_crossSplineRightHeights[s][i][0]); } - for (size_t i = 0; i < minNumRightIntervals; ++i) + for (UInt i = 0; i < minNumRightIntervals; ++i) { std::fill(heightsRight[i].begin(), heightsRight[i].begin() + numM, m_crossSplineLeftHeights[s][i][0]); } @@ -1386,7 +1387,7 @@ void CurvilinearGridFromSplines::ComputeGridHeights() { const auto leftGridLineIndex = m_leftGridLineIndex[s]; edgesCenterPoints[0] = m_splines->ComputeSplineLength(s, 0, m_gridLineDimensionalCoordinates[leftGridLineIndex]); - for (size_t i = 0; i < numM; ++i) + for (UInt i = 0; i < numM; ++i) { edgesCenterPoints[i + 1] = edgesCenterPoints[i] + m_splines->ComputeSplineLength(s, @@ -1395,7 +1396,7 @@ void CurvilinearGridFromSplines::ComputeGridHeights() } // compute at edge center points - for (size_t i = 0; i < numM; ++i) + for (UInt i = 0; i < numM; ++i) { edgesCenterPoints[i] = 0.5 * (edgesCenterPoints[i] + edgesCenterPoints[i + 1]); } @@ -1403,13 +1404,13 @@ void CurvilinearGridFromSplines::ComputeGridHeights() // compute center spline path length of cross splines crossingSplinesDimensionalCoordinates[0] = m_splines->ComputeSplineLength(s, 0.0, m_crossSplineCoordinates[s][0]); - for (size_t i = 0; i < m_numCrossingSplines[s] - 1; ++i) + for (UInt i = 0; i < m_numCrossingSplines[s] - 1; ++i) { crossingSplinesDimensionalCoordinates[i + 1] = crossingSplinesDimensionalCoordinates[i] + m_splines->ComputeSplineLength(s, m_crossSplineCoordinates[s][i], m_crossSplineCoordinates[s][i + 1]); } - for (size_t j = 0; j < m_maxNumCenterSplineHeights; ++j) + for (UInt j = 0; j < m_maxNumCenterSplineHeights; ++j) { FindNearestCrossSplines(s, @@ -1435,9 +1436,9 @@ void CurvilinearGridFromSplines::ComputeGridHeights() } // store grid height - for (size_t j = 0; j < m_maxNumCenterSplineHeights; ++j) + for (UInt j = 0; j < m_maxNumCenterSplineHeights; ++j) { - for (size_t i = 0; i < m_numMSplines[s]; ++i) + for (UInt i = 0; i < m_numMSplines[s]; ++i) { m_gridHeights[j][m_leftGridLineIndex[s] + i] = heightsLeft[j][i]; m_gridHeights[j][m_rightGridLineIndex[s] + m_numMSplines[s] - i - 1] = heightsRight[j][i]; @@ -1446,18 +1447,18 @@ void CurvilinearGridFromSplines::ComputeGridHeights() } } -void CurvilinearGridFromSplines::FindNearestCrossSplines(size_t s, - size_t j, - const std::vector& numHeightsLeft, +void CurvilinearGridFromSplines::FindNearestCrossSplines(UInt s, + UInt j, + const std::vector& numHeightsLeft, const std::vector>& crossSplineLeftHeights, const std::vector& edgesCenterPoints, - std::vector& localValidSplineIndices, + std::vector& localValidSplineIndices, std::vector& localSplineDerivatives, std::vector& crossingSplinesDimensionalCoordinates, std::vector>& heights) { - size_t numValid = 0; - for (size_t i = 0; i < m_numCrossingSplines[s]; ++i) + UInt numValid = 0; + for (UInt i = 0; i < m_numCrossingSplines[s]; ++i) { if (numHeightsLeft[i] != 0) { @@ -1476,20 +1477,20 @@ void CurvilinearGridFromSplines::FindNearestCrossSplines(size_t s, std::vector localCornerPoints(numValid); // TODO: strided memory access - for (size_t i = 0; i < numValid; ++i) + for (UInt i = 0; i < numValid; ++i) { const auto index = localValidSplineIndices[i]; localCornerPoints[i] = crossSplineLeftHeights[index][j]; } - localSplineDerivatives = Splines::SecondOrderDerivative(localCornerPoints, 0, localCornerPoints.size() - 1); + localSplineDerivatives = Splines::SecondOrderDerivative(localCornerPoints, 0, static_cast(localCornerPoints.size()) - 1); crossingSplinesDimensionalCoordinates[0] = m_splines->ComputeSplineLength(s, 0.0, m_crossSplineCoordinates[s][0]); - for (size_t i = 0; i < numM; ++i) + for (UInt i = 0; i < numM; ++i) { - size_t leftIndex = 0; + UInt leftIndex = 0; double leftCoordinate = crossingSplinesDimensionalCoordinates[localValidSplineIndices[leftIndex]]; - auto rightIndex = std::min(size_t(1), numValid - 1); + auto rightIndex = std::min(UInt(1), numValid - 1); double rightCoordinate = crossingSplinesDimensionalCoordinates[localValidSplineIndices[rightIndex]]; // Find two nearest cross splines while (rightCoordinate < edgesCenterPoints[i] && rightIndex < numValid) @@ -1516,7 +1517,7 @@ void CurvilinearGridFromSplines::FindNearestCrossSplines(size_t s, } } -void CurvilinearGridFromSplines::GetSplineIntersections(size_t splineIndex) +void CurvilinearGridFromSplines::GetSplineIntersections(UInt splineIndex) { m_numCrossingSplines[splineIndex] = 0; const auto numSplines = m_splines->GetNumSplines(); @@ -1525,11 +1526,11 @@ void CurvilinearGridFromSplines::GetSplineIntersections(size_t splineIndex) std::fill(m_crossSplineCoordinates[splineIndex].begin(), m_crossSplineCoordinates[splineIndex].end(), std::numeric_limits::max()); std::fill(m_cosCrossingAngle[splineIndex].begin(), m_cosCrossingAngle[splineIndex].end(), constants::missing::doubleValue); - for (size_t s = 0; s < numSplines; ++s) + for (UInt s = 0; s < numSplines; ++s) { // a crossing is a spline with 2 nodes and another with more than 2 nodes - const auto numSplineNodesS = m_splines->m_splineNodes[s].size(); - const auto numSplineNodesI = m_splines->m_splineNodes[splineIndex].size(); + const auto numSplineNodesS = static_cast(m_splines->m_splineNodes[s].size()); + const auto numSplineNodesI = static_cast(m_splines->m_splineNodes[splineIndex].size()); if ((numSplineNodesS == 2 && numSplineNodesI == 2) || (numSplineNodesS > 2 && numSplineNodesI > 2)) { @@ -1569,8 +1570,8 @@ void CurvilinearGridFromSplines::GetSplineIntersections(size_t splineIndex) void CurvilinearGridFromSplines::MakeAllGridLines() { m_numM = 0; - size_t numCenterSplines = 0; - for (size_t s = 0; s < m_splines->GetNumSplines(); ++s) + UInt numCenterSplines = 0; + for (UInt s = 0; s < m_splines->GetNumSplines(); ++s) { // center splines only if (m_type[s] != SplineTypes::central) @@ -1585,8 +1586,8 @@ void CurvilinearGridFromSplines::MakeAllGridLines() throw std::invalid_argument("CurvilinearGridFromSplines::MakeAllGridLines: There are no center splines."); } - size_t gridLineIndex = 0; - for (size_t s = 0; s < m_splines->GetNumSplines(); ++s) + UInt gridLineIndex = 0; + for (UInt s = 0; s < m_splines->GetNumSplines(); ++s) { // center splines only if (m_type[s] != SplineTypes::central) @@ -1618,7 +1619,7 @@ void CurvilinearGridFromSplines::MakeAllGridLines() // add other side of gridline m_rightGridLineIndex[s] = gridLineIndex; auto rightIndex = m_rightGridLineIndex[s] - 1; - for (auto j = m_rightGridLineIndex[s] - 1; j >= m_leftGridLineIndex[s] && j != static_cast(0) - 1; --j) + for (auto j = m_rightGridLineIndex[s] - 1; j >= m_leftGridLineIndex[s] && j != static_cast(0) - 1; --j) { m_gridLine[rightIndex] = m_gridLine[j]; m_gridLineDimensionalCoordinates[rightIndex] = m_gridLineDimensionalCoordinates[j]; @@ -1632,12 +1633,12 @@ void CurvilinearGridFromSplines::MakeAllGridLines() } } -size_t CurvilinearGridFromSplines::MakeGridLine(size_t splineIndex, - size_t startingIndex) +meshkernel::UInt CurvilinearGridFromSplines::MakeGridLine(UInt splineIndex, + UInt startingIndex) { // first estimation of nodes along m - auto numM = 1 + static_cast(std::floor(m_splines->m_splinesLength[splineIndex] / m_splinesToCurvilinearParameters.average_width)); - numM = std::min(numM, static_cast(m_curvilinearParameters.m_refinement)); + auto numM = 1 + static_cast(std::floor(m_splines->m_splinesLength[splineIndex] / m_splinesToCurvilinearParameters.average_width)); + numM = std::min(numM, static_cast(m_curvilinearParameters.m_refinement)); const auto endSplineAdimensionalCoordinate = static_cast(m_splines->m_splineNodes[splineIndex].size()) - 1; const auto splineLength = m_splines->ComputeSplineLength(splineIndex, @@ -1654,7 +1655,7 @@ size_t CurvilinearGridFromSplines::MakeGridLine(size_t splineIndex, while (currentMaxWidth > m_splinesToCurvilinearParameters.average_width) { currentMaxWidth = 0.0; - for (size_t n = 0; n < numM; ++n) + for (UInt n = 0; n < numM; ++n) { distances[n] = splineLength * (n + 1.0) / static_cast(numM); } @@ -1664,7 +1665,7 @@ size_t CurvilinearGridFromSplines::MakeGridLine(size_t splineIndex, m_splinesToCurvilinearParameters.curvature_adapted_grid_spacing, distances); - for (size_t n = 0; n < numM; ++n) + for (UInt n = 0; n < numM; ++n) { const auto index = startingIndex + n + 1; m_gridLineDimensionalCoordinates[index] = adimensionalDistances[n]; @@ -1674,7 +1675,7 @@ size_t CurvilinearGridFromSplines::MakeGridLine(size_t splineIndex, // a gridline is computed if (currentMaxWidth < m_splinesToCurvilinearParameters.average_width || - numM == static_cast(m_curvilinearParameters.m_refinement)) + numM == static_cast(m_curvilinearParameters.m_refinement)) { break; } @@ -1682,9 +1683,9 @@ size_t CurvilinearGridFromSplines::MakeGridLine(size_t splineIndex, // room for sub-division if (currentMaxWidth > m_splinesToCurvilinearParameters.average_width) { - numM = std::min(std::max(static_cast(m_curvilinearParameters.m_refinement / m_maximumGridHeights[splineIndex] * static_cast(numM)), - numM + static_cast(1)), - static_cast(m_curvilinearParameters.m_refinement)); + numM = std::min(std::max(static_cast(m_curvilinearParameters.m_refinement / m_maximumGridHeights[splineIndex] * static_cast(numM)), + numM + static_cast(1)), + static_cast(m_curvilinearParameters.m_refinement)); distances.resize(numM); adimensionalDistances.resize(numM); @@ -1699,13 +1700,13 @@ void CurvilinearGridFromSplines::ComputeSplineProperties(const bool restoreOrigi { AllocateSplinesProperties(); - for (size_t s = 0; s < m_splines->GetNumSplines(); ++s) + for (UInt s = 0; s < m_splines->GetNumSplines(); ++s) { GetSplineIntersections(s); } // select all non-cross splines only - for (size_t s = 0; s < m_splines->GetNumSplines(); ++s) + for (UInt s = 0; s < m_splines->GetNumSplines(); ++s) { m_type[s] = SplineTypes::crossing; // if more than 2 nodes, the spline must be a central spline @@ -1715,7 +1716,7 @@ void CurvilinearGridFromSplines::ComputeSplineProperties(const bool restoreOrigi } } // check the cross splines. The center spline is the middle spline that crosses the cross spline - for (size_t s = 0; s < m_splines->GetNumSplines(); ++s) + for (UInt s = 0; s < m_splines->GetNumSplines(); ++s) { // only crossing splines with one or more central spline if (m_splines->m_splineNodes[s].size() != 2 || m_numCrossingSplines[s] < 1) @@ -1736,7 +1737,7 @@ void CurvilinearGridFromSplines::ComputeSplineProperties(const bool restoreOrigi if (m_type[crossingSplineIndex] == SplineTypes::central) { // associate bounding splines with the middle spline - for (size_t i = 0; i < middleCrossingSpline; ++i) + for (UInt i = 0; i < middleCrossingSpline; ++i) { const auto index = m_crossingSplinesIndices[s][i]; m_type[index] = SplineTypes::lateral; // lateral spline @@ -1754,7 +1755,7 @@ void CurvilinearGridFromSplines::ComputeSplineProperties(const bool restoreOrigi if (restoreOriginalProperties) { // restore original spline properties - for (size_t s = 0; s < m_numOriginalSplines; ++s) + for (UInt s = 0; s < m_numOriginalSplines; ++s) { m_leftGridLineIndex[s] = m_leftGridLineIndexOriginal[s]; m_rightGridLineIndex[s] = m_rightGridLineIndexOriginal[s]; @@ -1764,7 +1765,7 @@ void CurvilinearGridFromSplines::ComputeSplineProperties(const bool restoreOrigi } // mark new splines as artificial cross splines - for (size_t s = m_numOriginalSplines; s < m_splines->GetNumSplines(); ++s) + for (UInt s = m_numOriginalSplines; s < m_splines->GetNumSplines(); ++s) { m_type[s] = SplineTypes::artificial; } @@ -1775,21 +1776,21 @@ void CurvilinearGridFromSplines::ComputeSplineProperties(const bool restoreOrigi void CurvilinearGridFromSplines::ComputeHeights() { - for (size_t i = 0; i < m_splines->GetNumSplines(); ++i) + for (UInt i = 0; i < m_splines->GetNumSplines(); ++i) { // Heights should be computed only for center splines if (m_splines->m_splineNodes[i].size() <= 2) { continue; } - for (size_t j = 0; j < m_numCrossingSplines[i]; ++j) + for (UInt j = 0; j < m_numCrossingSplines[i]; ++j) { ComputeSubHeights(i, j); } } // compute m_maximumGridHeight - for (size_t s = 0; s < m_splines->GetNumSplines(); ++s) + for (UInt s = 0; s < m_splines->GetNumSplines(); ++s) { if (m_numCrossingSplines[s] == 0) { @@ -1797,15 +1798,15 @@ void CurvilinearGridFromSplines::ComputeHeights() continue; } double maximumHeight = 0.0; - for (size_t c = 0; c < m_numCrossingSplines[s]; ++c) + for (UInt c = 0; c < m_numCrossingSplines[s]; ++c) { double sumLeftHeights = 0.0; - for (size_t ss = 0; ss < m_numCrossSplineLeftHeights[s][c]; ++ss) + for (UInt ss = 0; ss < m_numCrossSplineLeftHeights[s][c]; ++ss) { sumLeftHeights += m_crossSplineLeftHeights[s][c][ss]; } double sumRightHeights = 0.0; - for (size_t ss = 0; ss < m_numCrossSplineRightHeights[s][c]; ++ss) + for (UInt ss = 0; ss < m_numCrossSplineRightHeights[s][c]; ++ss) { sumRightHeights += m_crossSplineRightHeights[s][c][ss]; } @@ -1816,12 +1817,12 @@ void CurvilinearGridFromSplines::ComputeHeights() } } -void CurvilinearGridFromSplines::ComputeSubHeights(size_t centerSplineIndex, size_t crossingSplineLocalIndex) +void CurvilinearGridFromSplines::ComputeSubHeights(UInt centerSplineIndex, UInt crossingSplineLocalIndex) { // find center spline index - size_t centerSplineLocalIndex = 0; + UInt centerSplineLocalIndex = 0; const auto crossingSplineIndex = m_crossingSplinesIndices[centerSplineIndex][crossingSplineLocalIndex]; // js - for (size_t s = 0; s < m_numCrossingSplines[crossingSplineIndex]; ++s) + for (UInt s = 0; s < m_numCrossingSplines[crossingSplineIndex]; ++s) { if (m_crossingSplinesIndices[crossingSplineIndex][s] == centerSplineIndex) { @@ -1831,9 +1832,9 @@ void CurvilinearGridFromSplines::ComputeSubHeights(size_t centerSplineIndex, siz } // right part - size_t numSubIntervalsRight = 0; - size_t rightCenterSplineIndex = centerSplineLocalIndex; - size_t leftCenterSplineIndex; + UInt numSubIntervalsRight = 0; + UInt rightCenterSplineIndex = centerSplineLocalIndex; + UInt leftCenterSplineIndex; m_crossSplineRightHeights[centerSplineIndex][crossingSplineLocalIndex].resize(m_maxNumCenterSplineHeights, 0); for (auto s = centerSplineLocalIndex; s < m_numCrossingSplines[crossingSplineIndex] - 1; ++s) { @@ -1854,7 +1855,7 @@ void CurvilinearGridFromSplines::ComputeSubHeights(size_t centerSplineIndex, siz numSubIntervalsRight++; } - const auto numSplineNodes = m_splines->m_splineNodes[crossingSplineIndex].size(); + const auto numSplineNodes = static_cast(m_splines->m_splineNodes[crossingSplineIndex].size()); m_crossSplineRightHeights[centerSplineIndex][crossingSplineLocalIndex][numSubIntervalsRight] = m_splines->ComputeSplineLength(crossingSplineIndex, m_crossSplineCoordinates[crossingSplineIndex][rightCenterSplineIndex], @@ -1866,7 +1867,7 @@ void CurvilinearGridFromSplines::ComputeSubHeights(size_t centerSplineIndex, siz m_numCrossSplineRightHeights[centerSplineIndex][crossingSplineLocalIndex] = numSubIntervalsRight; // left part - size_t numSubIntervalsLeft = 0; + UInt numSubIntervalsLeft = 0; leftCenterSplineIndex = centerSplineLocalIndex; m_crossSplineLeftHeights[centerSplineIndex][crossingSplineLocalIndex].resize(m_maxNumCenterSplineHeights, 0); for (auto s = centerSplineLocalIndex; s >= 1; --s) diff --git a/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridFromSplinesTransfinite.cpp b/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridFromSplinesTransfinite.cpp index e652e3f32..5d71ca12b 100644 --- a/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridFromSplinesTransfinite.cpp +++ b/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridFromSplinesTransfinite.cpp @@ -87,11 +87,11 @@ CurvilinearGrid CurvilinearGridFromSplinesTransfinite::Compute() const auto TotalNRows = (m_numMSplines - 1) * m_numN; std::vector> gridNodes(TotalMColumns + 1, std::vector(TotalNRows + 1)); - size_t numMSplines = 0; - size_t numNSplines = 0; - for (size_t splineIndex = 0; splineIndex < numSplines; splineIndex++) + UInt numMSplines = 0; + UInt numNSplines = 0; + for (UInt splineIndex = 0; splineIndex < numSplines; splineIndex++) { - size_t numIntersections = 0; + UInt numIntersections = 0; for (const auto& value : m_splineIntersectionRatios[splineIndex]) { @@ -107,11 +107,11 @@ CurvilinearGrid CurvilinearGridFromSplinesTransfinite::Compute() throw std::invalid_argument("CurvilinearGridFromSplinesTransfinite::Compute: The number of intersections are less than two."); } - size_t numPoints; - size_t numDiscretizations; - size_t position; - size_t from; - size_t to; + UInt numPoints; + UInt numDiscretizations; + UInt position; + UInt from; + UInt to; if (splineIndex < m_numMSplines) { numPoints = TotalMColumns + 1; @@ -147,7 +147,7 @@ CurvilinearGrid CurvilinearGridFromSplinesTransfinite::Compute() distances); // Start filling curvilinear grid - size_t index = 0; + UInt index = 0; for (auto i = from; i < to; i++) { if (splineIndex < m_numMSplines) @@ -166,14 +166,14 @@ CurvilinearGrid CurvilinearGridFromSplinesTransfinite::Compute() sideTwo.resize(numNPoints); sideThree.resize(numMPoints); sideFour.resize(numMPoints); - for (size_t i = 0; i < numMSplines - 1; i++) + for (UInt i = 0; i < numMSplines - 1; i++) { - for (size_t j = 0; j < numNSplines - 1; j++) + for (UInt j = 0; j < numNSplines - 1; j++) { // Fill each block of the interpolation plane - for (size_t k = 0; k < numMPoints; k++) + for (UInt k = 0; k < numMPoints; k++) { - for (size_t l = 0; l < numNPoints; l++) + for (UInt l = 0; l < numNPoints; l++) { const auto m = i * m_numM + k; const auto n = j * m_numN + l; @@ -213,9 +213,9 @@ CurvilinearGrid CurvilinearGridFromSplinesTransfinite::Compute() m_numN); // assign the points - for (size_t k = 0; k < numMPoints; k++) + for (UInt k = 0; k < numMPoints; k++) { - for (size_t l = 0; l < numNPoints; l++) + for (UInt l = 0; l < numNPoints; l++) { const auto m = i * m_numM + k; const auto n = j * m_numN + l; @@ -234,16 +234,16 @@ CurvilinearGrid CurvilinearGridFromSplinesTransfinite::Compute() return CurvilinearGrid(std::move(gridNodes), m_splines->m_projection); } -void CurvilinearGridFromSplinesTransfinite::ComputeDiscretizations(size_t numIntersections, - size_t numPoints, - size_t numDiscretizations, +void CurvilinearGridFromSplinesTransfinite::ComputeDiscretizations(UInt numIntersections, + UInt numPoints, + UInt numDiscretizations, const std::vector& intersectionDistances, std::vector& distances) const { if (numIntersections == 2) { - for (size_t i = 0; i < numPoints; i++) + for (UInt i = 0; i < numPoints; i++) { distances[i] = intersectionDistances[0] + (intersectionDistances[1] - intersectionDistances[0]) * i / static_cast(numDiscretizations); } @@ -251,7 +251,7 @@ void CurvilinearGridFromSplinesTransfinite::ComputeDiscretizations(size_t numInt if (numIntersections > 2) { std::vector ratioSegments(numIntersections, 0.0); - for (size_t i = 1; i < numIntersections - 1; i++) + for (UInt i = 1; i < numIntersections - 1; i++) { ratioSegments[i] = (intersectionDistances[i + 1] - intersectionDistances[i]) / (intersectionDistances[i] - intersectionDistances[i - 1]); } @@ -261,7 +261,7 @@ void CurvilinearGridFromSplinesTransfinite::ComputeDiscretizations(size_t numInt // the ratios std::vector leftDiscretization(numDiscretizations + 1, 0.0); std::vector rightDiscretization(numDiscretizations + 1, 0.0); - for (size_t i = 0; i < numIntersections - 1; i++) + for (UInt i = 0; i < numIntersections - 1; i++) { const double rightRatio = std::pow(ratioSegments[i + 1], 1.0 / static_cast(numDiscretizations)); ComputeExponentialDistances(rightRatio, @@ -275,7 +275,7 @@ void CurvilinearGridFromSplinesTransfinite::ComputeDiscretizations(size_t numInt intersectionDistances[i + 1], leftDiscretization); - for (size_t j = 0; j < numDiscretizations + 1; j++) + for (UInt j = 0; j < numDiscretizations + 1; j++) { double ar = double(j) / static_cast(numDiscretizations); @@ -300,7 +300,7 @@ void CurvilinearGridFromSplinesTransfinite::ComputeExponentialDistances(double f { distances[0] = 0.0; double incrementRatio = 1.0; - for (size_t i = 0; i < distances.size() - 1; i++) + for (UInt i = 0; i < distances.size() - 1; i++) { distances[i + 1] = distances[i] + incrementRatio; incrementRatio = incrementRatio * factor; @@ -326,9 +326,9 @@ void CurvilinearGridFromSplinesTransfinite::ComputeIntersections() m_splineIntersectionRatios.resize(numSplines); std::fill(m_splineIntersectionRatios.begin(), m_splineIntersectionRatios.end(), std::vector(numSplines, 0.0)); - for (size_t i = 0; i < numSplines; i++) + for (UInt i = 0; i < numSplines; i++) { - for (size_t j = i + 1; j < numSplines; j++) + for (UInt j = i + 1; j < numSplines; j++) { double crossProductIntersection; Point intersectionPoint; @@ -376,7 +376,7 @@ void CurvilinearGridFromSplinesTransfinite::ComputeIntersections() } } - for (size_t i = 0; i < numSplines; i++) + for (UInt i = 0; i < numSplines; i++) { if (m_splineType[i] == 0) { @@ -388,12 +388,12 @@ void CurvilinearGridFromSplinesTransfinite::ComputeIntersections() m_numMSplines = FindIndex(m_splineType, -1); m_numNSplines = numSplines - m_numMSplines; - const size_t maxExternalIterations = 10; - for (size_t i = 0; i < maxExternalIterations; i++) + const UInt maxExternalIterations = 10; + for (UInt i = 0; i < maxExternalIterations; i++) { // sort along m_m - const size_t maxInternalIterations = 100; - for (size_t j = 0; j < maxInternalIterations; j++) + const UInt maxInternalIterations = 100; + for (UInt j = 0; j < maxInternalIterations; j++) { const auto successful = OrderSplines(0, m_numMSplines, m_numMSplines, numSplines); if (successful) @@ -404,7 +404,7 @@ void CurvilinearGridFromSplinesTransfinite::ComputeIntersections() // sort along m_n bool nSplineSortingHasNotChanged = true; - for (size_t j = 0; j < maxInternalIterations; j++) + for (UInt j = 0; j < maxInternalIterations; j++) { const auto successful = OrderSplines(m_numMSplines, numSplines, 0, m_numMSplines); if (successful) @@ -424,16 +424,16 @@ void CurvilinearGridFromSplinesTransfinite::ComputeIntersections() } // Now determine the start and end spline corner points for each spline - ResizeAndFill2DVector(m_splineGroupIndexAndFromToIntersections, numSplines, 3, true, static_cast(0)); + ResizeAndFill2DVector(m_splineGroupIndexAndFromToIntersections, numSplines, 3, true, static_cast(0)); // m_n direction - for (size_t i = 0; i < m_numMSplines; i++) + for (UInt i = 0; i < m_numMSplines; i++) { for (auto j = m_numMSplines; j < numSplines; j++) { - size_t maxIndex = 0; - size_t lastIndex = 0; - for (size_t k = 0; k <= i; k++) + UInt maxIndex = 0; + UInt lastIndex = 0; + for (UInt k = 0; k <= i; k++) { if (std::abs(m_splineIntersectionRatios[j][k]) > 0.0) { @@ -443,7 +443,7 @@ void CurvilinearGridFromSplinesTransfinite::ComputeIntersections() } m_splineGroupIndexAndFromToIntersections[j][1] = maxIndex; } - size_t maxIndex = 0; + UInt maxIndex = 0; for (auto j = m_numMSplines; j < numSplines; j++) { if (std::abs(m_splineIntersectionRatios[j][i]) > 0.0) @@ -457,10 +457,10 @@ void CurvilinearGridFromSplinesTransfinite::ComputeIntersections() // m_m direction for (auto i = m_numMSplines; i < numSplines; i++) { - for (size_t j = 0; j < m_numMSplines; j++) + for (UInt j = 0; j < m_numMSplines; j++) { - size_t maxIndex = 0; - size_t lastIndex = m_numMSplines; + UInt maxIndex = 0; + UInt lastIndex = m_numMSplines; for (auto k = m_numMSplines; k <= i; k++) { if (std::abs(m_splineIntersectionRatios[j][k]) > 0.0) @@ -471,8 +471,8 @@ void CurvilinearGridFromSplinesTransfinite::ComputeIntersections() } m_splineGroupIndexAndFromToIntersections[j][2] = maxIndex; } - size_t maxIndex = 0; - for (size_t j = 0; j < m_numMSplines; j++) + UInt maxIndex = 0; + for (UInt j = 0; j < m_numMSplines; j++) { if (std::abs(m_splineIntersectionRatios[j][i]) > 0.0) { @@ -482,14 +482,14 @@ void CurvilinearGridFromSplinesTransfinite::ComputeIntersections() m_splineGroupIndexAndFromToIntersections[i][0] = maxIndex; } - for (size_t i = 0; i < numSplines; i++) + for (UInt i = 0; i < numSplines; i++) { m_splineGroupIndexAndFromToIntersections[i][1] = 0; m_splineGroupIndexAndFromToIntersections[i][2] = 0; } // m_n constant, spline start end end - for (size_t i = 0; i < m_numMSplines; i++) + for (UInt i = 0; i < m_numMSplines; i++) { for (auto j = m_numMSplines; j < numSplines; j++) { @@ -507,7 +507,7 @@ void CurvilinearGridFromSplinesTransfinite::ComputeIntersections() // m_m constant, spline start end end for (auto i = m_numMSplines; i < numSplines; i++) { - for (size_t j = 0; j < m_numMSplines; j++) + for (UInt j = 0; j < m_numMSplines; j++) { if (std::abs(m_splineIntersectionRatios[i][j]) > 0.0) { @@ -521,10 +521,10 @@ void CurvilinearGridFromSplinesTransfinite::ComputeIntersections() } } -bool CurvilinearGridFromSplinesTransfinite::OrderSplines(size_t startFirst, - size_t endFirst, - size_t startSecond, - size_t endSecond) +bool CurvilinearGridFromSplinesTransfinite::OrderSplines(UInt startFirst, + UInt endFirst, + UInt startSecond, + UInt endSecond) { for (auto i = startFirst; i < endFirst; i++) { @@ -560,21 +560,21 @@ bool CurvilinearGridFromSplinesTransfinite::OrderSplines(size_t startFirst, } template -void CurvilinearGridFromSplinesTransfinite::SwapRows(std::vector>& v, size_t firstRow, size_t secondRow) const +void CurvilinearGridFromSplinesTransfinite::SwapRows(std::vector>& v, UInt firstRow, UInt secondRow) const { - auto minSize = std::min(v[firstRow].size(), v[secondRow].size()); + auto minSize = std::min(static_cast(v[firstRow].size()), static_cast(v[secondRow].size())); minSize = std::min(minSize, m_splines->GetNumSplines()); - for (size_t i = 0; i < minSize; i++) + for (UInt i = 0; i < minSize; i++) { std::swap(v[firstRow][i], v[secondRow][i]); } } template -void CurvilinearGridFromSplinesTransfinite::SwapColumns(std::vector>& v, size_t firstColumn, size_t secondColumn) const +void CurvilinearGridFromSplinesTransfinite::SwapColumns(std::vector>& v, UInt firstColumn, UInt secondColumn) const { - for (size_t i = 0; i < m_splines->GetNumSplines(); i++) + for (UInt i = 0; i < m_splines->GetNumSplines(); i++) { if (firstColumn >= v[i].size() || secondColumn >= v[i].size()) { diff --git a/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridLine.cpp b/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridLine.cpp index fc1d3397d..f6da8d2d2 100644 --- a/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridLine.cpp +++ b/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridLine.cpp @@ -63,7 +63,7 @@ bool CurvilinearGridLine::IsNodeOnLine(CurvilinearGridNodeIndices const& node) c return false; } -CurvilinearGridNodeIndices CurvilinearGridLine::GetNodeIndexFromCoordinate(size_t const& coordinate) const +CurvilinearGridNodeIndices CurvilinearGridLine::GetNodeIndexFromCoordinate(UInt const& coordinate) const { auto const mCoordinate = IsMGridLine() ? coordinate : m_constantCoordinate; auto const nCoordinate = IsMGridLine() ? m_constantCoordinate : coordinate; diff --git a/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridLineShift.cpp b/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridLineShift.cpp index 0a1f80d2d..6b1deeea7 100644 --- a/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridLineShift.cpp +++ b/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridLineShift.cpp @@ -54,7 +54,7 @@ CurvilinearGrid CurvilinearGridLineShift::Compute() const double eps = 1e-5; auto previousCoordinate = m_lines[0].m_startCoordinate; - for (size_t i = 1; i <= m_lines[0].m_endCoordinate; ++i) + for (UInt i = 1; i <= m_lines[0].m_endCoordinate; ++i) { auto const currentNodeIndex = m_lines[0].GetNodeIndexFromCoordinate(i); @@ -69,7 +69,7 @@ CurvilinearGrid CurvilinearGridLineShift::Compute() /// On the original algorithm currentDelta is distributed on the nodes above the current i, /// except for the last node m_endCoordinate, where currentDelta is distributed on the entire grid line const auto currentLastCoordinate = i == m_lines[0].m_endCoordinate ? i : i - 1; - for (size_t j = previousCoordinate; j <= currentLastCoordinate; ++j) + for (UInt j = previousCoordinate; j <= currentLastCoordinate; ++j) { auto const nodeIndex = m_lines[0].GetNodeIndexFromCoordinate(j); diff --git a/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridOrthogonalization.cpp b/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridOrthogonalization.cpp index 3ecf9d360..2ed046c86 100644 --- a/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridOrthogonalization.cpp +++ b/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridOrthogonalization.cpp @@ -100,11 +100,11 @@ CurvilinearGrid CurvilinearGridOrthogonalization::Compute() void CurvilinearGridOrthogonalization::ProjectHorizontalBoundaryGridNodes() { // m grid lines (horizontal) - for (size_t n = 0; n < m_grid.m_numN; ++n) + for (UInt n = 0; n < m_grid.m_numN; ++n) { - size_t startM = constants::missing::sizetValue; + UInt startM = constants::missing::uintValue; int nextVertical = 0; - for (size_t m = 0; m < m_grid.m_numM; ++m) + for (UInt m = 0; m < m_grid.m_numM; ++m) { const auto nodeType = m_grid.m_gridNodesTypes[m][n]; if (nodeType == CurvilinearGrid::NodeType::BottomLeft || nodeType == CurvilinearGrid::NodeType::UpperLeft) @@ -125,7 +125,7 @@ void CurvilinearGridOrthogonalization::ProjectHorizontalBoundaryGridNodes() // Project the nodes at the boundary (Bottom and Up node types) if a valid interval has been found. // The interval ranges from startM to the next BottomRight or UpperRight node. - if (startM != constants::missing::sizetValue && + if (startM != constants::missing::uintValue && (nodeType == CurvilinearGrid::NodeType::BottomRight || nodeType == CurvilinearGrid::NodeType::UpperRight) && nextVertical != 0) { @@ -179,11 +179,11 @@ void CurvilinearGridOrthogonalization::ProjectHorizontalBoundaryGridNodes() void CurvilinearGridOrthogonalization::ProjectVerticalBoundariesGridNodes() { // m gridlines (vertical) - for (size_t m = 0; m < m_grid.m_numM; ++m) + for (UInt m = 0; m < m_grid.m_numM; ++m) { - size_t startN = constants::missing::sizetValue; + UInt startN = constants::missing::uintValue; int nextHorizontal = 0; - for (size_t n = 0; n < m_grid.m_numN; ++n) + for (UInt n = 0; n < m_grid.m_numN; ++n) { const auto nodeType = m_grid.m_gridNodesTypes[m][n]; if (nodeType == CurvilinearGrid::NodeType::BottomLeft || nodeType == CurvilinearGrid::NodeType::BottomRight) @@ -206,7 +206,7 @@ void CurvilinearGridOrthogonalization::ProjectVerticalBoundariesGridNodes() // The interval ranges from startN to the next UpperLeft or UpperRight node. if ((nodeType == CurvilinearGrid::NodeType::UpperLeft || nodeType == CurvilinearGrid::NodeType::UpperRight) && nextHorizontal != 0 && - startN != constants::missing::sizetValue) + startN != constants::missing::uintValue) { for (auto nn = startN + 1; nn < n; ++nn) { @@ -263,8 +263,8 @@ void CurvilinearGridOrthogonalization::Solve() const double factor = 0.9 * 0.9; // Only the internal nodes of the orthogonalization box - const auto minMInternal = std::max(static_cast(1), m_lowerLeft.m_m); - const auto minNInternal = std::max(static_cast(1), m_lowerLeft.m_n); + const auto minMInternal = std::max(static_cast(1), m_lowerLeft.m_m); + const auto minNInternal = std::max(static_cast(1), m_lowerLeft.m_n); const auto maxMInternal = std::min(m_upperRight.m_m, m_grid.m_numM - 1); const auto maxNInternal = std::min(m_upperRight.m_n, m_grid.m_numN - 1); @@ -408,7 +408,7 @@ void CurvilinearGridOrthogonalization::ComputeVerticalCoefficients() { const auto invalidBoundaryNodes = ComputeInvalidVerticalBoundaryNodes(); // Store the counter - std::vector> counter(m_grid.m_numM, std::vector(m_grid.m_numN, 0)); + std::vector> counter(m_grid.m_numM, std::vector(m_grid.m_numN, 0)); // Perform left sum for (auto n = m_lowerLeft.m_n; n < m_upperRight.m_n; ++n) @@ -461,7 +461,7 @@ void CurvilinearGridOrthogonalization::ComputeVerticalCoefficients() void CurvilinearGridOrthogonalization::ComputeHorizontalCoefficients() { const auto invalidBoundaryNodes = ComputeInvalidHorizontalBoundaryNodes(); - std::vector> counter(m_grid.m_numM, std::vector(m_grid.m_numN, 0)); + std::vector> counter(m_grid.m_numM, std::vector(m_grid.m_numN, 0)); // Perform bottom sum for (auto m = m_lowerLeft.m_m; m < m_upperRight.m_m; ++m) diff --git a/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridRefinement.cpp b/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridRefinement.cpp index caa4e73ec..14a342740 100644 --- a/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridRefinement.cpp +++ b/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridRefinement.cpp @@ -33,7 +33,7 @@ using meshkernel::CurvilinearGrid; using meshkernel::CurvilinearGridRefinement; -CurvilinearGridRefinement::CurvilinearGridRefinement(const std::shared_ptr& grid, size_t refinement) +CurvilinearGridRefinement::CurvilinearGridRefinement(const std::shared_ptr& grid, UInt refinement) : CurvilinearGridAlgorithm(grid), m_refinement(refinement) { @@ -58,8 +58,8 @@ CurvilinearGrid CurvilinearGridRefinement::Compute() // Estimate the dimension of the refined grid const auto numMToRefine = m_upperRight.m_m - m_lowerLeft.m_m; const auto numNToRefine = m_upperRight.m_n - m_lowerLeft.m_n; - const size_t maxM = m_grid.m_numM + numMToRefine * (m_refinement - 1); - const size_t maxN = m_grid.m_numN + numNToRefine * (m_refinement - 1); + const UInt maxM = m_grid.m_numM + numMToRefine * (m_refinement - 1); + const UInt maxN = m_grid.m_numN + numNToRefine * (m_refinement - 1); // Local vector for each curvilinear grid face std::vector bottomRefinement(m_refinement); @@ -70,20 +70,20 @@ CurvilinearGrid CurvilinearGridRefinement::Compute() // The refined grid std::vector> refinedGrid(maxM, std::vector(maxN)); - size_t refinedM = 0; - for (size_t currentM = 0; currentM < m_grid.m_numM - 1; ++currentM) + UInt refinedM = 0; + for (UInt currentM = 0; currentM < m_grid.m_numM - 1; ++currentM) { - size_t localMRefinement = 1; + UInt localMRefinement = 1; if (currentM >= m_lowerLeft.m_m && currentM < m_upperRight.m_m) { localMRefinement = m_refinement; } - size_t refinedN = 0; - for (size_t currentN = 0; currentN < m_grid.m_numN - 1; ++currentN) + UInt refinedN = 0; + for (UInt currentN = 0; currentN < m_grid.m_numN - 1; ++currentN) { - size_t localNRefinement = 1; + UInt localNRefinement = 1; if (currentN >= m_lowerLeft.m_n && currentN < m_upperRight.m_n) { localNRefinement = m_refinement; @@ -98,7 +98,7 @@ CurvilinearGrid CurvilinearGridRefinement::Compute() // Calculate m-direction spline points bottomRefinement.clear(); topRefinement.clear(); - for (size_t m = 0; m < localMRefinement + 1; ++m) + for (UInt m = 0; m < localMRefinement + 1; ++m) { const auto splineIndex = currentN; const auto interpolationPoint = static_cast(currentM) + static_cast(m) / static_cast(localMRefinement); @@ -109,7 +109,7 @@ CurvilinearGrid CurvilinearGridRefinement::Compute() // Calculate m-direction spline points leftRefinement.clear(); rightRefinement.clear(); - for (size_t n = 0; n < localNRefinement + 1; ++n) + for (UInt n = 0; n < localNRefinement + 1; ++n) { const auto splineIndex = m_grid.m_numN + currentM; const auto interpolationPoint = static_cast(currentN) + static_cast(n) / static_cast(localNRefinement); @@ -126,9 +126,9 @@ CurvilinearGrid CurvilinearGridRefinement::Compute() localMRefinement, localNRefinement); // Copy the local grid into the refined grid - for (size_t m = 0; m < localMRefinement + 1; ++m) + for (UInt m = 0; m < localMRefinement + 1; ++m) { - for (size_t n = 0; n < localNRefinement + 1; ++n) + for (UInt n = 0; n < localNRefinement + 1; ++n) { refinedGrid[refinedM + m][refinedN + n] = localGrid[m][n]; } diff --git a/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridSmoothing.cpp b/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridSmoothing.cpp index d8c9c264d..55a2fe007 100644 --- a/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridSmoothing.cpp +++ b/libs/MeshKernel/src/CurvilinearGrid/CurvilinearGridSmoothing.cpp @@ -34,11 +34,11 @@ using meshkernel::CurvilinearGrid; using meshkernel::CurvilinearGridSmoothing; -CurvilinearGridSmoothing::CurvilinearGridSmoothing(std::shared_ptr grid, size_t smoothingIterations) : CurvilinearGridAlgorithm(grid), m_smoothingIterations(smoothingIterations) +CurvilinearGridSmoothing::CurvilinearGridSmoothing(std::shared_ptr grid, UInt smoothingIterations) : CurvilinearGridAlgorithm(grid), m_smoothingIterations(smoothingIterations) { // Allocate cache for storing grid nodes values - ResizeAndFill2DVector(m_gridNodesCache, m_grid.m_gridNodes.size(), m_grid.m_gridNodes[0].size()); + ResizeAndFill2DVector(m_gridNodesCache, static_cast(m_grid.m_gridNodes.size()), static_cast(m_grid.m_gridNodes[0].size())); // Compute the grid node types m_grid.ComputeGridNodeTypes(); @@ -47,7 +47,7 @@ CurvilinearGridSmoothing::CurvilinearGridSmoothing(std::shared_ptrAdministrate(); } - const size_t MaxIter = 10; + const UInt MaxIter = 10; const auto numEdges = m_mesh->GetNumEdges(); - size_t numFlippedEdges = constants::missing::sizetValue; + UInt numFlippedEdges = constants::missing::uintValue; - for (size_t iteration = 0; iteration < MaxIter; ++iteration) + for (UInt iteration = 0; iteration < MaxIter; ++iteration) { if (numFlippedEdges == 0) { @@ -72,7 +72,7 @@ void FlipEdges::Compute() const } numFlippedEdges = 0; - for (size_t e = 0; e < numEdges; e++) + for (UInt e = 0; e < static_cast(numEdges); e++) { if (m_mesh->IsEdgeOnBoundary(e)) @@ -91,8 +91,8 @@ void FlipEdges::Compute() const return; } - size_t nodeLeft = constants::missing::sizetValue; - size_t nodeRight = constants::missing::sizetValue; + UInt nodeLeft = constants::missing::uintValue; + UInt nodeRight = constants::missing::uintValue; const auto topologyFunctional = ComputeTopologyFunctional(e, nodeLeft, nodeRight); if (topologyFunctional >= 0) @@ -133,11 +133,11 @@ void FlipEdges::Compute() const numFlippedEdges++; // Find the other edges - size_t firstEdgeLeftFace = constants::missing::sizetValue; - size_t firstEdgeRightFace = constants::missing::sizetValue; - size_t secondEdgeLeftFace = constants::missing::sizetValue; - size_t secondEdgeRightFace = constants::missing::sizetValue; - for (size_t i = 0; i < NumEdgesLeftFace; i++) + UInt firstEdgeLeftFace = constants::missing::uintValue; + UInt firstEdgeRightFace = constants::missing::uintValue; + UInt secondEdgeLeftFace = constants::missing::uintValue; + UInt secondEdgeRightFace = constants::missing::uintValue; + for (UInt i = 0; i < NumEdgesLeftFace; i++) { const auto edgeIndex = m_mesh->m_facesEdges[leftFace][i]; if (edgeIndex == e) @@ -157,7 +157,7 @@ void FlipEdges::Compute() const } } - for (size_t i = 0; i < NumEdgesRightFace; i++) + for (UInt i = 0; i < NumEdgesRightFace; i++) { const auto edgeIndex = m_mesh->m_facesEdges[rightFace][i]; if (edgeIndex == e) @@ -244,10 +244,10 @@ void FlipEdges::Compute() const m_mesh->Administrate(); } -void FlipEdges::DeleteEdgeFromNode(size_t edge, size_t firstNode) const +void FlipEdges::DeleteEdgeFromNode(UInt edge, UInt firstNode) const { // Update node, delete edge from m_mesh->m_nodesEdges[firstNode] - size_t kk = 0; + UInt kk = 0; while (m_mesh->m_nodesEdges[firstNode][kk] != edge && kk < m_mesh->m_nodesNumEdges[firstNode]) { kk = kk + 1; @@ -257,8 +257,8 @@ void FlipEdges::DeleteEdgeFromNode(size_t edge, size_t firstNode) const throw std::invalid_argument("FlipEdges::DeleteEdgeFromNode: The edge does not match the given node."); } - size_t count = 0; - for (size_t i = 0; i < m_mesh->m_nodesNumEdges[firstNode] + 1; i++) + UInt count = 0; + for (UInt i = 0; i < m_mesh->m_nodesNumEdges[firstNode] + 1; i++) { if (i + 1 <= kk || i > kk) { @@ -270,9 +270,9 @@ void FlipEdges::DeleteEdgeFromNode(size_t edge, size_t firstNode) const m_mesh->m_nodesEdges[firstNode].resize(m_mesh->m_nodesNumEdges[firstNode]); } -int FlipEdges::ComputeTopologyFunctional(size_t edge, - size_t& nodeLeft, - size_t& nodeRight) const +int FlipEdges::ComputeTopologyFunctional(UInt edge, + UInt& nodeLeft, + UInt& nodeRight) const { const int largeTopologyFunctionalValue = 1000; @@ -294,8 +294,8 @@ int FlipEdges::ComputeTopologyFunctional(size_t edge, } // Find the nodes that are connected to both k1 and k - size_t sumIndicesLeftFace = 0; - size_t sumIndicesRightFace = 0; + UInt sumIndicesLeftFace = 0; + UInt sumIndicesRightFace = 0; for (auto i = 0; i < 3; i++) { sumIndicesLeftFace += m_mesh->m_facesNodes[faceL][i]; @@ -305,14 +305,14 @@ int FlipEdges::ComputeTopologyFunctional(size_t edge, nodeLeft = sumIndicesLeftFace - firstNode - secondNode; nodeRight = sumIndicesRightFace - firstNode - secondNode; - if (nodeLeft == constants::missing::sizetValue || nodeRight == constants::missing::sizetValue) + if (nodeLeft == constants::missing::uintValue || nodeRight == constants::missing::uintValue) { return largeTopologyFunctionalValue; } // Check that kl is part of faceL bool nodeFound = false; - for (size_t i = 0; i < NumEdgesLeftFace; i++) + for (UInt i = 0; i < NumEdgesLeftFace; i++) { if (m_mesh->m_facesNodes[faceL][i] == nodeLeft) { @@ -328,7 +328,7 @@ int FlipEdges::ComputeTopologyFunctional(size_t edge, // Check that kr is part of faceR nodeFound = false; - for (size_t i = 0; i < NumEdgesRightFace; i++) + for (UInt i = 0; i < NumEdgesRightFace; i++) { if (m_mesh->m_facesNodes[faceR][i] == nodeRight) { @@ -350,7 +350,7 @@ int FlipEdges::ComputeTopologyFunctional(size_t edge, if (m_projectToLandBoundary && m_landBoundaries->GetNumNodes() > 0) { - if (m_landBoundaries->m_meshNodesLandBoundarySegments[firstNode] != constants::missing::sizetValue && m_landBoundaries->m_meshNodesLandBoundarySegments[secondNode] != constants::missing::sizetValue) + if (m_landBoundaries->m_meshNodesLandBoundarySegments[firstNode] != constants::missing::uintValue && m_landBoundaries->m_meshNodesLandBoundarySegments[secondNode] != constants::missing::uintValue) { // Edge is associated with a land boundary -> keep the edge return largeTopologyFunctionalValue; @@ -383,9 +383,9 @@ int FlipEdges::ComputeTopologyFunctional(size_t edge, return topologyFunctional; } -int FlipEdges::DifferenceFromOptimum(size_t nodeIndex, size_t firstNode, size_t secondNode) const +int FlipEdges::DifferenceFromOptimum(UInt nodeIndex, UInt firstNode, UInt secondNode) const { - if (m_landBoundaries->m_meshNodesLandBoundarySegments[nodeIndex] == constants::missing::sizetValue) + if (m_landBoundaries->m_meshNodesLandBoundarySegments[nodeIndex] == constants::missing::uintValue) { return static_cast(m_mesh->m_nodesNumEdges[nodeIndex]) - static_cast(OptimalNumberOfConnectedNodes(nodeIndex)); } @@ -401,8 +401,8 @@ int FlipEdges::DifferenceFromOptimum(size_t nodeIndex, size_t firstNode, size_t } // Find the first edge connecting firstNode - size_t edgeIndexConnectingFirstNode = constants::missing::sizetValue; - for (size_t i = 0; i < m_mesh->m_nodesNumEdges[nodeIndex]; i++) + UInt edgeIndexConnectingFirstNode = constants::missing::uintValue; + for (UInt i = 0; i < m_mesh->m_nodesNumEdges[nodeIndex]; i++) { const auto edgeIndex = m_mesh->m_nodesEdges[nodeIndex][i]; @@ -413,14 +413,14 @@ int FlipEdges::DifferenceFromOptimum(size_t nodeIndex, size_t firstNode, size_t } } - if (edgeIndexConnectingFirstNode == constants::missing::sizetValue) + if (edgeIndexConnectingFirstNode == constants::missing::uintValue) { return 0; } // Find the first edge connecting secondNode - size_t edgeIndexConnectingSecondNode = constants::missing::sizetValue; - for (size_t i = 0; i < m_mesh->m_nodesNumEdges[nodeIndex]; i++) + UInt edgeIndexConnectingSecondNode = constants::missing::uintValue; + for (UInt i = 0; i < m_mesh->m_nodesNumEdges[nodeIndex]; i++) { const auto edgeIndex = m_mesh->m_nodesEdges[nodeIndex][i]; @@ -431,7 +431,7 @@ int FlipEdges::DifferenceFromOptimum(size_t nodeIndex, size_t firstNode, size_t } } - if (edgeIndexConnectingSecondNode == constants::missing::sizetValue) + if (edgeIndexConnectingSecondNode == constants::missing::uintValue) { return 0; } @@ -442,8 +442,8 @@ int FlipEdges::DifferenceFromOptimum(size_t nodeIndex, size_t firstNode, size_t auto edgeIndex = m_mesh->m_nodesEdges[nodeIndex][currentEdgeIndexInNodeEdges]; auto otherNode = OtherNodeOfEdge(m_mesh->m_edges[edgeIndex], nodeIndex); - size_t num = 1; - while (m_landBoundaries->m_meshNodesLandBoundarySegments[otherNode] == constants::missing::sizetValue && + UInt num = 1; + while (m_landBoundaries->m_meshNodesLandBoundarySegments[otherNode] == constants::missing::uintValue && !m_mesh->IsEdgeOnBoundary(edgeIndex) && currentEdgeIndexInNodeEdges != edgeIndexConnectingSecondNode) { @@ -453,22 +453,22 @@ int FlipEdges::DifferenceFromOptimum(size_t nodeIndex, size_t firstNode, size_t num++; } - size_t firstEdgeInPathIndex = constants::missing::sizetValue; - if (m_landBoundaries->m_meshNodesLandBoundarySegments[otherNode] != constants::missing::sizetValue || + UInt firstEdgeInPathIndex = constants::missing::uintValue; + if (m_landBoundaries->m_meshNodesLandBoundarySegments[otherNode] != constants::missing::uintValue || m_mesh->IsEdgeOnBoundary(edgeIndex)) { firstEdgeInPathIndex = edgeIndex; } // If not all edges are visited, count counterclockwise from the one connecting indexSecondNode - size_t secondEdgeInPathIndex = constants::missing::sizetValue; + UInt secondEdgeInPathIndex = constants::missing::uintValue; if (currentEdgeIndexInNodeEdges != edgeIndexConnectingSecondNode) { currentEdgeIndexInNodeEdges = edgeIndexConnectingSecondNode; edgeIndex = m_mesh->m_nodesEdges[nodeIndex][currentEdgeIndexInNodeEdges]; otherNode = OtherNodeOfEdge(m_mesh->m_edges[edgeIndex], nodeIndex); num = num + 1; - while (m_landBoundaries->m_meshNodesLandBoundarySegments[otherNode] == constants::missing::sizetValue && + while (m_landBoundaries->m_meshNodesLandBoundarySegments[otherNode] == constants::missing::uintValue && !m_mesh->IsEdgeOnBoundary(edgeIndex) && currentEdgeIndexInNodeEdges != edgeIndexConnectingFirstNode && edgeIndex != firstEdgeInPathIndex) @@ -483,7 +483,7 @@ int FlipEdges::DifferenceFromOptimum(size_t nodeIndex, size_t firstNode, size_t } } - if ((m_landBoundaries->m_meshNodesLandBoundarySegments[otherNode] != constants::missing::sizetValue || + if ((m_landBoundaries->m_meshNodesLandBoundarySegments[otherNode] != constants::missing::uintValue || m_mesh->IsEdgeOnBoundary(edgeIndex)) && edgeIndex != firstEdgeInPathIndex) { @@ -497,7 +497,7 @@ int FlipEdges::DifferenceFromOptimum(size_t nodeIndex, size_t firstNode, size_t return 0; } - if (firstEdgeInPathIndex != constants::missing::sizetValue && secondEdgeInPathIndex != constants::missing::sizetValue) + if (firstEdgeInPathIndex != constants::missing::uintValue && secondEdgeInPathIndex != constants::missing::uintValue) { // Internal boundary return 4; @@ -506,9 +506,9 @@ int FlipEdges::DifferenceFromOptimum(size_t nodeIndex, size_t firstNode, size_t return 6; } -size_t FlipEdges::OptimalNumberOfConnectedNodes(size_t index) const +meshkernel::UInt FlipEdges::OptimalNumberOfConnectedNodes(UInt index) const { - size_t optimalNumber = 6; + UInt optimalNumber = 6; if (m_mesh->m_nodesTypes[index] == 2) { optimalNumber = 4; diff --git a/libs/MeshKernel/src/LandBoundaries.cpp b/libs/MeshKernel/src/LandBoundaries.cpp index 187525c7f..931116345 100644 --- a/libs/MeshKernel/src/LandBoundaries.cpp +++ b/libs/MeshKernel/src/LandBoundaries.cpp @@ -43,7 +43,7 @@ LandBoundaries::LandBoundaries(const std::vector& landBoundary, { if (!landBoundary.empty()) { - size_t const nodeVectorPreallocation = 10000; + UInt const nodeVectorPreallocation = 10000; m_nodes.reserve(nodeVectorPreallocation); std::copy(landBoundary.begin(), landBoundary.end(), std::back_inserter(m_nodes)); m_polygonNodesCache.resize(Mesh::m_maximumNumberOfNodesPerFace); @@ -62,7 +62,7 @@ void LandBoundaries::Administrate() // Do not consider the landboundary nodes outside the polygon std::vector nodeMask(m_nodes.size(), false); - for (size_t n = 0; n < m_nodes.size() - 1; n++) + for (UInt n = 0; n < m_nodes.size() - 1; n++) { if (!m_nodes[n].IsValid() || !m_nodes[n + 1].IsValid()) { @@ -80,7 +80,7 @@ void LandBoundaries::Administrate() const auto meshBoundaryPolygon = m_mesh->MeshBoundaryToPolygon(polygonNodes); // Find the start/end node of the land boundaries - const auto landBoundaryIndices = FindIndices(m_nodes, 0, m_nodes.size(), constants::missing::doubleValue); + const auto landBoundaryIndices = FindIndices(m_nodes, 0, static_cast(m_nodes.size()), constants::missing::doubleValue); // Emplace start/end node of the land boundaries back in m_validLandBoundaries, // if the land boundary segment is close to a mesh node @@ -98,8 +98,8 @@ void LandBoundaries::Administrate() // Split every land boundary in order to get rid of closed land boundaries // (some pieces of software cannot handle closed polygons, only polylines) - const auto numSegmentIndicesBeforeSplitting = m_validLandBoundaries.size(); - for (size_t i = 0; i < numSegmentIndicesBeforeSplitting; ++i) + const auto numSegmentIndicesBeforeSplitting = static_cast(m_validLandBoundaries.size()); + for (UInt i = 0; i < numSegmentIndicesBeforeSplitting; ++i) { const auto [startSegmentIndex, endSegmentIndex] = m_validLandBoundaries[i]; if (endSegmentIndex - startSegmentIndex > 1) @@ -126,14 +126,14 @@ void LandBoundaries::FindNearestMeshBoundary(ProjectToLandBoundaryOption project Administrate(); - m_nodeMask.resize(m_mesh->GetNumNodes(), constants::missing::sizetValue); + m_nodeMask.resize(m_mesh->GetNumNodes(), constants::missing::uintValue); m_faceMask.resize(m_mesh->GetNumFaces(), false); - m_edgeMask.resize(m_mesh->GetNumEdges(), constants::missing::sizetValue); - m_meshNodesLandBoundarySegments.resize(m_mesh->GetNumNodes(), constants::missing::sizetValue); + m_edgeMask.resize(m_mesh->GetNumEdges(), constants::missing::uintValue); + m_meshNodesLandBoundarySegments.resize(m_mesh->GetNumNodes(), constants::missing::uintValue); m_nodesMinDistances.resize(m_mesh->GetNumNodes(), constants::missing::doubleValue); // Loop over the segments of the land boundary and assign each node to the land boundary segment index - for (size_t landBoundarySegment = 0; landBoundarySegment < m_validLandBoundaries.size(); ++landBoundarySegment) + for (UInt landBoundarySegment = 0; landBoundarySegment < m_validLandBoundaries.size(); ++landBoundarySegment) { const auto [_, numRejectedPaths] = MakePath(landBoundarySegment); @@ -148,8 +148,8 @@ void LandBoundaries::FindNearestMeshBoundary(ProjectToLandBoundaryOption project // Connect the m_mesh nodes if (m_findOnlyOuterMeshBoundary) { - std::vector connectedNodes; - for (size_t e = 0; e < m_mesh->GetNumEdges(); ++e) + std::vector connectedNodes; + for (UInt e = 0; e < m_mesh->GetNumEdges(); ++e) { if (!m_mesh->IsEdgeOnBoundary(e)) { @@ -161,38 +161,38 @@ void LandBoundaries::FindNearestMeshBoundary(ProjectToLandBoundaryOption project } } -void LandBoundaries::AssignLandBoundaryPolylineToMeshNodes(size_t edgeIndex, bool initialize, std::vector& nodes, size_t numNodes) +void LandBoundaries::AssignLandBoundaryPolylineToMeshNodes(UInt edgeIndex, bool initialize, std::vector& nodes, UInt numNodes) { if (m_nodes.empty()) { return; } - std::vector nodesLoc; - size_t numNodesLoc; + std::vector nodesLoc; + UInt numNodesLoc; if (initialize) { - if (!m_mesh->IsEdgeOnBoundary(edgeIndex) || m_mesh->m_edges[edgeIndex].first == constants::missing::sizetValue || m_mesh->m_edges[edgeIndex].second == constants::missing::sizetValue) + if (!m_mesh->IsEdgeOnBoundary(edgeIndex) || m_mesh->m_edges[edgeIndex].first == constants::missing::uintValue || m_mesh->m_edges[edgeIndex].second == constants::missing::uintValue) throw std::invalid_argument("LandBoundaries::AssignLandBoundaryPolylineToMeshNodes: Cannot not assign segment to mesh nodes."); const auto firstMeshNode = m_mesh->m_edges[edgeIndex].first; const auto secondMeshNode = m_mesh->m_edges[edgeIndex].second; - if (m_meshNodesLandBoundarySegments[firstMeshNode] != constants::missing::sizetValue && - m_meshNodesLandBoundarySegments[secondMeshNode] == constants::missing::sizetValue && - m_nodeMask[firstMeshNode] != constants::missing::sizetValue && - m_nodeMask[secondMeshNode] != constants::missing::sizetValue) + if (m_meshNodesLandBoundarySegments[firstMeshNode] != constants::missing::uintValue && + m_meshNodesLandBoundarySegments[secondMeshNode] == constants::missing::uintValue && + m_nodeMask[firstMeshNode] != constants::missing::uintValue && + m_nodeMask[secondMeshNode] != constants::missing::uintValue) { nodesLoc.resize(3); nodesLoc[0] = firstMeshNode; nodesLoc[1] = secondMeshNode; numNodesLoc = 2; } - else if (m_meshNodesLandBoundarySegments[firstMeshNode] == constants::missing::sizetValue && - m_meshNodesLandBoundarySegments[secondMeshNode] != constants::missing::sizetValue && - m_nodeMask[firstMeshNode] != constants::missing::sizetValue && - m_nodeMask[secondMeshNode] != constants::missing::sizetValue) + else if (m_meshNodesLandBoundarySegments[firstMeshNode] == constants::missing::uintValue && + m_meshNodesLandBoundarySegments[secondMeshNode] != constants::missing::uintValue && + m_nodeMask[firstMeshNode] != constants::missing::uintValue && + m_nodeMask[secondMeshNode] != constants::missing::uintValue) { nodesLoc.resize(3); nodesLoc[0] = secondMeshNode; @@ -220,7 +220,7 @@ void LandBoundaries::AssignLandBoundaryPolylineToMeshNodes(size_t edgeIndex, boo const auto lastVisitedNode = nodesLoc[numNodesLoc - 1]; - for (size_t e = 0; e < m_mesh->m_nodesNumEdges[lastVisitedNode]; e++) + for (UInt e = 0; e < m_mesh->m_nodesNumEdges[lastVisitedNode]; e++) { const auto edge = m_mesh->m_nodesEdges[lastVisitedNode][e]; @@ -230,7 +230,7 @@ void LandBoundaries::AssignLandBoundaryPolylineToMeshNodes(size_t edgeIndex, boo const auto otherNode = OtherNodeOfEdge(m_mesh->m_edges[edge], lastVisitedNode); // path stopped - if (m_nodeMask[otherNode] == constants::missing::sizetValue) + if (m_nodeMask[otherNode] == constants::missing::uintValue) break; // TODO: C++ 20 for(auto& i : views::reverse(vec)) @@ -249,20 +249,20 @@ void LandBoundaries::AssignLandBoundaryPolylineToMeshNodes(size_t edgeIndex, boo nodesLoc[numNodesLoc] = otherNode; - if (m_meshNodesLandBoundarySegments[otherNode] != constants::missing::sizetValue) + if (m_meshNodesLandBoundarySegments[otherNode] != constants::missing::uintValue) { // Now check landboundary for otherNode - for (size_t n = 1; n < numNodesLoc; n++) + for (UInt n = 1; n < numNodesLoc; n++) { const auto meshNode = nodesLoc[n]; const auto [minimumDistance, pointOnLandBoundary, nearestLandBoundaryNodeIndex, - edgeRatio] = NearestLandBoundarySegment(constants::missing::sizetValue, m_mesh->m_nodes[meshNode]); + edgeRatio] = NearestLandBoundarySegment(constants::missing::uintValue, m_mesh->m_nodes[meshNode]); // find the segment index of the found point - size_t landboundarySegmentIndex = std::numeric_limits::max(); - for (size_t s = 0; s < m_validLandBoundaries.size(); s++) + UInt landboundarySegmentIndex = std::numeric_limits::max(); + for (UInt s = 0; s < m_validLandBoundaries.size(); s++) { const auto& [startIndex, endIndex] = m_validLandBoundaries[s]; if (nearestLandBoundaryNodeIndex >= startIndex && nearestLandBoundaryNodeIndex < endIndex) @@ -272,7 +272,7 @@ void LandBoundaries::AssignLandBoundaryPolylineToMeshNodes(size_t edgeIndex, boo } } - if (landboundarySegmentIndex == std::numeric_limits::max()) + if (landboundarySegmentIndex == std::numeric_limits::max()) { throw AlgorithmError("LandBoundaries::AssignLandBoundaryPolylineToMeshNodes: No segment index found: cannot assign segment to mesh nodes."); } @@ -284,7 +284,7 @@ void LandBoundaries::AssignLandBoundaryPolylineToMeshNodes(size_t edgeIndex, boo if (m_addLandboundaries) { AddLandBoundary(nodesLoc, numNodesLoc, lastVisitedNode); - m_meshNodesLandBoundarySegments[meshNode] = m_validLandBoundaries.size() - 1; // last added ;and boundary + m_meshNodesLandBoundarySegments[meshNode] = static_cast(m_validLandBoundaries.size()) - 1; // last added ;and boundary } } else @@ -300,7 +300,7 @@ void LandBoundaries::AssignLandBoundaryPolylineToMeshNodes(size_t edgeIndex, boo } } -void LandBoundaries::AddLandBoundary(const std::vector& nodesLoc, size_t numNodesLoc, size_t nodeIndex) +void LandBoundaries::AddLandBoundary(const std::vector& nodesLoc, UInt numNodesLoc, UInt nodeIndex) { if (m_nodes.empty()) { @@ -310,8 +310,8 @@ void LandBoundaries::AddLandBoundary(const std::vector& nodesLoc, size_t const auto startSegmentIndex = m_meshNodesLandBoundarySegments[nodesLoc[0]]; const auto endSegmentIndex = m_meshNodesLandBoundarySegments[nodesLoc[numNodesLoc]]; - if (startSegmentIndex == constants::missing::sizetValue || startSegmentIndex >= m_validLandBoundaries.size() || - endSegmentIndex == constants::missing::sizetValue || endSegmentIndex >= m_validLandBoundaries.size()) + if (startSegmentIndex == constants::missing::uintValue || startSegmentIndex >= m_validLandBoundaries.size() || + endSegmentIndex == constants::missing::uintValue || endSegmentIndex >= m_validLandBoundaries.size()) { throw std::invalid_argument("LandBoundaries::AddLandBoundary: Invalid segment index."); } @@ -356,10 +356,10 @@ void LandBoundaries::AddLandBoundary(const std::vector& nodesLoc, size_t m_nodes.emplace_back(Point()); // Update segment indices - m_validLandBoundaries.emplace_back(std::make_pair(m_nodes.size() - 3, m_nodes.size() - 2)); + m_validLandBoundaries.emplace_back(std::make_pair(static_cast(m_nodes.size()) - 3, static_cast(m_nodes.size()) - 2)); } -std::tuple LandBoundaries::MakePath(size_t landBoundaryIndex) +std::tuple LandBoundaries::MakePath(UInt landBoundaryIndex) { if (m_nodes.empty()) { @@ -377,24 +377,24 @@ std::tuple LandBoundaries::MakePath(size_t landBoundaryIndex) auto [startMeshNode, endMeshNode] = FindStartEndMeshNodesDijkstraAlgorithm(landBoundaryIndex); - if (startMeshNode == constants::missing::sizetValue || endMeshNode == constants::missing::sizetValue || startMeshNode == endMeshNode) + if (startMeshNode == constants::missing::uintValue || endMeshNode == constants::missing::uintValue || startMeshNode == endMeshNode) { throw AlgorithmError("LandBoundaries::MakePath: Cannot not find valid mesh nodes."); } const auto connectedNodeEdges = ShortestPath(landBoundaryIndex, startMeshNode); auto lastSegment = m_meshNodesLandBoundarySegments[endMeshNode]; - size_t lastNode = constants::missing::sizetValue; + UInt lastNode = constants::missing::uintValue; auto currentNode = endMeshNode; - size_t numConnectedNodes = 0; - size_t numNodesInPath = 0; - size_t numRejectedNodesInPath = 0; + UInt numConnectedNodes = 0; + UInt numNodesInPath = 0; + UInt numRejectedNodesInPath = 0; while (true) { bool stopPathSearch = true; - if (m_meshNodesLandBoundarySegments[currentNode] != constants::missing::sizetValue) + if (m_meshNodesLandBoundarySegments[currentNode] != constants::missing::uintValue) { // Multiple boundary segments: take the nearest const auto previousLandBoundarySegment = m_meshNodesLandBoundarySegments[currentNode]; @@ -424,7 +424,7 @@ std::tuple LandBoundaries::MakePath(size_t landBoundaryIndex) const auto [minDinstanceFromLandBoundary, nodeOnLandBoundary, currentNodeLandBoundaryNodeIndex, - currentNodeEdgeRatio] = NearestLandBoundarySegment(constants::missing::sizetValue, m_mesh->m_nodes[currentNode]); + currentNodeEdgeRatio] = NearestLandBoundarySegment(constants::missing::uintValue, m_mesh->m_nodes[currentNode]); m_nodesMinDistances[currentNode] = minDinstanceFromLandBoundary; } @@ -443,7 +443,7 @@ std::tuple LandBoundaries::MakePath(size_t landBoundaryIndex) if (stopPathSearch) { - if (numConnectedNodes == 1 && lastSegment != constants::missing::sizetValue) + if (numConnectedNodes == 1 && lastSegment != constants::missing::uintValue) { m_meshNodesLandBoundarySegments[lastNode] = lastSegment; } @@ -467,14 +467,14 @@ std::tuple LandBoundaries::MakePath(size_t landBoundaryIndex) } const auto nextEdgeIndex = connectedNodeEdges[currentNode]; - if (nextEdgeIndex == constants::missing::sizetValue || nextEdgeIndex >= m_mesh->GetNumEdges()) + if (nextEdgeIndex == constants::missing::uintValue || nextEdgeIndex >= m_mesh->GetNumEdges()) { break; } currentNode = OtherNodeOfEdge(m_mesh->m_edges[nextEdgeIndex], currentNode); - if (currentNode == constants::missing::sizetValue || currentNode >= m_mesh->GetNumNodes()) + if (currentNode == constants::missing::uintValue || currentNode >= m_mesh->GetNumNodes()) { break; } @@ -488,7 +488,7 @@ std::tuple LandBoundaries::MakePath(size_t landBoundaryIndex) return {numNodesInPath, numRejectedNodesInPath}; } -void LandBoundaries::ComputeMeshNodeMask(size_t landBoundaryIndex) +void LandBoundaries::ComputeMeshNodeMask(UInt landBoundaryIndex) { if (m_nodes.empty()) { @@ -500,43 +500,43 @@ void LandBoundaries::ComputeMeshNodeMask(size_t landBoundaryIndex) // Try to find a face crossed by the current land boundary polyline: // 1. One of the land boundary nodes is inside a face // 2. Or one of the land boundary segments is crossing a boundary mesh edge - size_t crossedFaceIndex = constants::missing::sizetValue; + UInt crossedFaceIndex = constants::missing::uintValue; for (auto i = startLandBoundaryIndex; i < endLandBoundaryIndex; i++) { crossedFaceIndex = m_nodeFaceIndices[i]; - if (crossedFaceIndex != constants::missing::sizetValue) + if (crossedFaceIndex != constants::missing::uintValue) { break; } auto [face, edge] = m_mesh->IsSegmentCrossingABoundaryEdge(m_nodes[i], m_nodes[i + 1]); crossedFaceIndex = face; - if (crossedFaceIndex != constants::missing::sizetValue) + if (crossedFaceIndex != constants::missing::uintValue) { break; } } - std::fill(m_nodeMask.begin(), m_nodeMask.end(), constants::missing::sizetValue); + std::fill(m_nodeMask.begin(), m_nodeMask.end(), constants::missing::uintValue); if (m_landMask) { std::fill(m_faceMask.begin(), m_faceMask.end(), false); - std::fill(m_edgeMask.begin(), m_edgeMask.end(), constants::missing::sizetValue); + std::fill(m_edgeMask.begin(), m_edgeMask.end(), constants::missing::uintValue); // m_faceMask assumes crossedFace has already been done. - if (crossedFaceIndex != constants::missing::sizetValue) + if (crossedFaceIndex != constants::missing::uintValue) { m_faceMask[crossedFaceIndex] = true; } - std::vector landBoundaryFaces{crossedFaceIndex}; + std::vector landBoundaryFaces{crossedFaceIndex}; MaskMeshFaceMask(landBoundaryIndex, landBoundaryFaces); // Mask all nodes of the masked faces - for (size_t f = 0; f < m_mesh->GetNumFaces(); f++) + for (UInt f = 0; f < m_mesh->GetNumFaces(); f++) { if (m_faceMask[f]) { - for (size_t n = 0; n < m_mesh->GetNumFaceEdges(f); n++) + for (UInt n = 0; n < m_mesh->GetNumFaceEdges(f); n++) { m_nodeMask[m_mesh->m_facesNodes[f][n]] = landBoundaryIndex; } @@ -551,35 +551,35 @@ void LandBoundaries::ComputeMeshNodeMask(size_t landBoundaryIndex) } } - for (size_t n = 0; n < m_mesh->GetNumNodes(); n++) + for (UInt n = 0; n < m_mesh->GetNumNodes(); n++) { - if (m_nodeMask[n] != constants::missing::sizetValue) + if (m_nodeMask[n] != constants::missing::uintValue) { const bool inPolygon = m_polygons->IsPointInPolygon(m_mesh->m_nodes[n], 0); if (!inPolygon) { - m_nodeMask[n] = constants::missing::sizetValue; + m_nodeMask[n] = constants::missing::uintValue; } } } } -void LandBoundaries::MaskMeshFaceMask(size_t landBoundaryIndex, const std::vector& initialFaces) +void LandBoundaries::MaskMeshFaceMask(UInt landBoundaryIndex, const std::vector& initialFaces) { if (m_nodes.empty()) { return; } - std::vector nextFaces; + std::vector nextFaces; nextFaces.reserve(initialFaces.size()); for (const auto& face : initialFaces) { // No face was crossed by the land boundary: mask boundary faces only // These are the faces that are close (up to a certain tolerance) by a land boundary - if (face == constants::missing::sizetValue) + if (face == constants::missing::uintValue) { - for (size_t e = 0; e < m_mesh->GetNumEdges(); e++) + for (UInt e = 0; e < m_mesh->GetNumEdges(); e++) { // only boundary edges are considered if (!m_mesh->IsEdgeOnBoundary(e)) @@ -597,7 +597,7 @@ void LandBoundaries::MaskMeshFaceMask(size_t landBoundaryIndex, const std::vecto for (const auto& edge : m_mesh->m_facesEdges[face]) { const auto landBoundaryNode = IsMeshEdgeCloseToLandBoundaries(landBoundaryIndex, edge); - if (landBoundaryNode != constants::missing::sizetValue) + if (landBoundaryNode != constants::missing::uintValue) { m_faceMask[face] = true; break; @@ -648,7 +648,7 @@ void LandBoundaries::MaskMeshFaceMask(size_t landBoundaryIndex, const std::vecto m_edgeMask[edge] = 0; const auto landBoundaryNode = IsMeshEdgeCloseToLandBoundaries(landBoundaryIndex, edge); - if (landBoundaryNode != constants::missing::sizetValue) + if (landBoundaryNode != constants::missing::uintValue) { m_edgeMask[edge] = 1; isFaceFound = true; @@ -670,9 +670,9 @@ void LandBoundaries::MaskMeshFaceMask(size_t landBoundaryIndex, const std::vecto } } -size_t LandBoundaries::IsMeshEdgeCloseToLandBoundaries(size_t landBoundaryIndex, size_t edge) +meshkernel::UInt LandBoundaries::IsMeshEdgeCloseToLandBoundaries(UInt landBoundaryIndex, UInt edge) { - size_t landBoundaryNode = constants::missing::sizetValue; + UInt landBoundaryNode = constants::missing::uintValue; if (m_nodes.empty()) { return landBoundaryNode; @@ -680,8 +680,8 @@ size_t LandBoundaries::IsMeshEdgeCloseToLandBoundaries(size_t landBoundaryIndex, const auto& [startLandBoundaryIndex, endLandBoundaryIndex] = m_validLandBoundaries[landBoundaryIndex]; - const auto startNode = std::max(std::min(static_cast(0), endLandBoundaryIndex - 1), startLandBoundaryIndex); - if (m_mesh->m_edges[edge].first == constants::missing::sizetValue || m_mesh->m_edges[edge].second == constants::missing::sizetValue) + const auto startNode = std::max(std::min(static_cast(0), endLandBoundaryIndex - 1), startLandBoundaryIndex); + if (m_mesh->m_edges[edge].first == constants::missing::uintValue || m_mesh->m_edges[edge].second == constants::missing::uintValue) { return landBoundaryNode; } @@ -696,9 +696,9 @@ size_t LandBoundaries::IsMeshEdgeCloseToLandBoundaries(size_t landBoundaryIndex, // Now search over the land boundaries auto currentNode = startNode; - size_t searchIterations = 0; + UInt searchIterations = 0; int stepNode = 0; - const size_t maximumNumberOfIterations = 3; + const UInt maximumNumberOfIterations = 3; while (searchIterations < maximumNumberOfIterations) { const double landBoundaryLength = ComputeSquaredDistance(m_nodes[currentNode], m_nodes[currentNode + 1], m_mesh->m_projection); @@ -760,11 +760,11 @@ size_t LandBoundaries::IsMeshEdgeCloseToLandBoundaries(size_t landBoundaryIndex, return landBoundaryNode; } -std::tuple LandBoundaries::FindStartEndMeshNodesDijkstraAlgorithm(size_t landBoundaryIndex) +std::tuple LandBoundaries::FindStartEndMeshNodesDijkstraAlgorithm(UInt landBoundaryIndex) { if (m_nodes.empty()) { - return {constants::missing::sizetValue, constants::missing::sizetValue}; + return {constants::missing::uintValue, constants::missing::uintValue}; } const auto& [startLandBoundaryIndex, endLandBoundaryIndex] = m_validLandBoundaries[landBoundaryIndex]; @@ -780,19 +780,19 @@ std::tuple LandBoundaries::FindStartEndMeshNodesDijkstraAlgorith // Get the edges that are closest the land boundary auto minDistStart = std::numeric_limits::max(); auto minDistEnd = std::numeric_limits::max(); - size_t startEdge = constants::missing::sizetValue; - size_t endEdge = constants::missing::sizetValue; + UInt startEdge = constants::missing::uintValue; + UInt endEdge = constants::missing::uintValue; - for (size_t e = 0; e < m_mesh->GetNumEdges(); e++) + for (UInt e = 0; e < m_mesh->GetNumEdges(); e++) { // If the edge has an invalid node, continue - if (m_mesh->m_edges[e].first == constants::missing::sizetValue || m_mesh->m_edges[e].second == constants::missing::sizetValue) + if (m_mesh->m_edges[e].first == constants::missing::uintValue || m_mesh->m_edges[e].second == constants::missing::uintValue) { continue; } // Use only edges with both nodes masked - if (m_nodeMask[m_mesh->m_edges[e].first] == constants::missing::sizetValue || m_nodeMask[m_mesh->m_edges[e].second] == constants::missing::sizetValue) + if (m_nodeMask[m_mesh->m_edges[e].first] == constants::missing::uintValue || m_nodeMask[m_mesh->m_edges[e].second] == constants::missing::uintValue) { continue; } @@ -819,7 +819,7 @@ std::tuple LandBoundaries::FindStartEndMeshNodesDijkstraAlgorith } } - if (startEdge == constants::missing::sizetValue || endEdge == constants::missing::sizetValue) + if (startEdge == constants::missing::uintValue || endEdge == constants::missing::uintValue) { throw std::invalid_argument("LandBoundaries::FindStartEndMeshNodesDijkstraAlgorithm: Cannot find startMeshNode or endMeshNode."); } @@ -830,11 +830,11 @@ std::tuple LandBoundaries::FindStartEndMeshNodesDijkstraAlgorith return {startMeshNode, endMeshNode}; } -size_t LandBoundaries::FindStartEndMeshNodesFromEdges(size_t edge, Point point) const +meshkernel::UInt LandBoundaries::FindStartEndMeshNodesFromEdges(UInt edge, Point point) const { if (m_nodes.empty()) { - return constants::missing::sizetValue; + return constants::missing::uintValue; } const auto firstMeshNodeIndex = m_mesh->m_edges[edge].first; @@ -849,17 +849,17 @@ size_t LandBoundaries::FindStartEndMeshNodesFromEdges(size_t edge, Point point) return secondMeshNodeIndex; } -std::vector LandBoundaries::ShortestPath(size_t landBoundaryIndex, - size_t startMeshNode) +std::vector LandBoundaries::ShortestPath(UInt landBoundaryIndex, + UInt startMeshNode) { - std::vector connectedNodeEdges; + std::vector connectedNodeEdges; if (m_nodes.empty()) { return connectedNodeEdges; } - connectedNodeEdges.resize(m_mesh->GetNumNodes(), constants::missing::sizetValue); - std::fill(connectedNodeEdges.begin(), connectedNodeEdges.end(), constants::missing::sizetValue); + connectedNodeEdges.resize(m_mesh->GetNumNodes(), constants::missing::uintValue); + std::fill(connectedNodeEdges.begin(), connectedNodeEdges.end(), constants::missing::uintValue); // Infinite distance for all nodes std::vector nodeDistances(m_mesh->GetNumNodes(), std::numeric_limits::max()); @@ -877,14 +877,14 @@ std::vector LandBoundaries::ShortestPath(size_t landBoundaryIndex, currentNodeLandBoundaryNodeIndex, currentNodeEdgeRatio] = NearestLandBoundarySegment(landBoundaryIndex, currentNode); - if (currentNodeLandBoundaryNodeIndex == constants::missing::sizetValue) + if (currentNodeLandBoundaryNodeIndex == constants::missing::uintValue) { throw AlgorithmError("LandBoundaries::ShortestPath: Cannot compute the nearest node on the land boundary."); } for (const auto& edgeIndex : m_mesh->m_nodesEdges[currentNodeIndex]) { - if (m_mesh->m_edges[edgeIndex].first == constants::missing::sizetValue || m_mesh->m_edges[edgeIndex].second == constants::missing::sizetValue) + if (m_mesh->m_edges[edgeIndex].first == constants::missing::uintValue || m_mesh->m_edges[edgeIndex].second == constants::missing::uintValue) { continue; } @@ -947,7 +947,7 @@ std::vector LandBoundaries::ShortestPath(size_t landBoundaryIndex, // Linear search with masking currentNodeIndex = 0; double minValue = std::numeric_limits::max(); - for (size_t n = 0; n < m_mesh->GetNumNodes(); n++) + for (UInt n = 0; n < m_mesh->GetNumNodes(); n++) { if (m_nodeMask[n] == landBoundaryIndex && !isVisited[n] && nodeDistances[n] < minValue) { @@ -967,11 +967,11 @@ std::vector LandBoundaries::ShortestPath(size_t landBoundaryIndex, return connectedNodeEdges; } -std::tuple LandBoundaries::NearestLandBoundarySegment(size_t segmentIndex, const Point& node) +std::tuple LandBoundaries::NearestLandBoundarySegment(UInt segmentIndex, const Point& node) { double minimumDistance = std::numeric_limits::max(); Point pointOnLandBoundary = node; - size_t nearestLandBoundaryNodeIndex = constants::missing::sizetValue; + UInt nearestLandBoundaryNodeIndex = constants::missing::uintValue; double edgeRatio = -1.0; if (m_nodes.empty()) @@ -979,8 +979,8 @@ std::tuple LandBoundaries::NearestLan return {minimumDistance, pointOnLandBoundary, nearestLandBoundaryNodeIndex, edgeRatio}; } - const auto startLandBoundaryIndex = segmentIndex == constants::missing::sizetValue ? 0 : m_validLandBoundaries[segmentIndex].first; - const auto endLandBoundaryIndex = segmentIndex == constants::missing::sizetValue ? m_nodes.size() : m_validLandBoundaries[segmentIndex].second; + const auto startLandBoundaryIndex = segmentIndex == constants::missing::uintValue ? 0 : m_validLandBoundaries[segmentIndex].first; + const auto endLandBoundaryIndex = segmentIndex == constants::missing::uintValue ? static_cast(m_nodes.size()) : m_validLandBoundaries[segmentIndex].second; for (auto n = startLandBoundaryIndex; n < endLandBoundaryIndex; n++) { @@ -1011,12 +1011,12 @@ void LandBoundaries::SnapMeshToLandBoundaries() } const auto numNodes = m_mesh->GetNumNodes(); - for (size_t n = 0; n < numNodes; ++n) + for (UInt n = 0; n < numNodes; ++n) { if (m_mesh->m_nodesTypes[n] == 1 || m_mesh->m_nodesTypes[n] == 2 || m_mesh->m_nodesTypes[n] == 3) { const auto meshNodeToLandBoundarySegment = m_meshNodesLandBoundarySegments[n]; - if (meshNodeToLandBoundarySegment == constants::missing::sizetValue) + if (meshNodeToLandBoundarySegment == constants::missing::uintValue) { continue; } diff --git a/libs/MeshKernel/src/Mesh.cpp b/libs/MeshKernel/src/Mesh.cpp index 1dd362312..545da7b8c 100644 --- a/libs/MeshKernel/src/Mesh.cpp +++ b/libs/MeshKernel/src/Mesh.cpp @@ -43,12 +43,12 @@ Mesh::Mesh(const std::vector& edges, void Mesh::NodeAdministration() { // assume no duplicated links - for (size_t e = 0; e < GetNumEdges(); e++) + for (UInt e = 0; e < static_cast(GetNumEdges()); e++) { const auto firstNode = m_edges[e].first; const auto secondNode = m_edges[e].second; - if (firstNode == constants::missing::sizetValue || secondNode == constants::missing::sizetValue) + if (firstNode == constants::missing::uintValue || secondNode == constants::missing::uintValue) { continue; } @@ -60,7 +60,7 @@ void Mesh::NodeAdministration() // Search for previously connected edges auto alreadyAddedEdge = false; - for (size_t i = 0; i < m_nodesNumEdges[firstNode]; ++i) + for (UInt i = 0; i < m_nodesNumEdges[firstNode]; ++i) { if (const auto currentEdge = m_edges[m_nodesEdges[firstNode][i]]; currentEdge.first == secondNode || currentEdge.second == secondNode) { @@ -76,7 +76,7 @@ void Mesh::NodeAdministration() // Search for previously connected edges alreadyAddedEdge = false; - for (size_t i = 0; i < m_nodesNumEdges[secondNode]; ++i) + for (UInt i = 0; i < m_nodesNumEdges[secondNode]; ++i) { if (const auto currentEdge = m_edges[m_nodesEdges[secondNode][i]]; currentEdge.first == firstNode || currentEdge.second == firstNode) { @@ -92,7 +92,7 @@ void Mesh::NodeAdministration() } // resize - for (size_t n = 0; n < GetNumNodes(); n++) + for (UInt n = 0; n < GetNumNodes(); n++) { m_nodesEdges[n].resize(m_nodesNumEdges[n]); } @@ -103,11 +103,11 @@ void Mesh::DeleteInvalidNodesAndEdges() // Mask nodes connected to valid edges std::vector connectedNodes(m_nodes.size(), false); - size_t numInvalidEdges = 0; + UInt numInvalidEdges = 0; for (const auto& [firstNode, secondNode] : m_edges) { - if (firstNode == constants::missing::sizetValue || secondNode == constants::missing::sizetValue) + if (firstNode == constants::missing::uintValue || secondNode == constants::missing::uintValue) { numInvalidEdges++; continue; @@ -117,8 +117,8 @@ void Mesh::DeleteInvalidNodesAndEdges() } // Count all invalid nodes (note: there might be nodes that are not connected to an edge) - size_t numInvalidNodes = 0; - for (size_t n = 0; n < m_nodes.size(); ++n) + UInt numInvalidNodes = 0; + for (UInt n = 0; n < m_nodes.size(); ++n) { // invalidate nodes that are not connected if (!connectedNodes[n]) @@ -139,10 +139,10 @@ void Mesh::DeleteInvalidNodesAndEdges() } // Flag invalid nodes - std::vector validNodesIndices(m_nodes.size()); - std::ranges::fill(validNodesIndices, constants::missing::sizetValue); - size_t validIndex = 0; - for (size_t n = 0; n < m_nodes.size(); ++n) + std::vector validNodesIndices(m_nodes.size()); + std::ranges::fill(validNodesIndices, constants::missing::uintValue); + UInt validIndex = 0; + for (UInt n = 0; n < m_nodes.size(); ++n) { if (m_nodes[n].IsValid()) { @@ -154,15 +154,15 @@ void Mesh::DeleteInvalidNodesAndEdges() // Flag invalid edges for (auto& [firstNode, secondNode] : m_edges) { - if (firstNode != constants::missing::sizetValue && secondNode != constants::missing::sizetValue && validNodesIndices[firstNode] != constants::missing::sizetValue && validNodesIndices[secondNode] != constants::missing::sizetValue) + if (firstNode != constants::missing::uintValue && secondNode != constants::missing::uintValue && validNodesIndices[firstNode] != constants::missing::uintValue && validNodesIndices[secondNode] != constants::missing::uintValue) { firstNode = validNodesIndices[firstNode]; secondNode = validNodesIndices[secondNode]; continue; } - firstNode = constants::missing::sizetValue; - secondNode = constants::missing::sizetValue; + firstNode = constants::missing::uintValue; + secondNode = constants::missing::uintValue; } // Remove invalid nodes, without reducing capacity @@ -172,11 +172,11 @@ void Mesh::DeleteInvalidNodesAndEdges() // Remove invalid edges, without reducing capacity const auto endEdgeVector = std::remove_if(m_edges.begin(), m_edges.end(), [](const Edge& e) - { return e.first == constants::missing::sizetValue || e.second == constants::missing::sizetValue; }); + { return e.first == constants::missing::uintValue || e.second == constants::missing::uintValue; }); m_edges.erase(endEdgeVector, m_edges.end()); } -void Mesh::MergeTwoNodes(size_t firstNodeIndex, size_t secondNodeIndex) +void Mesh::MergeTwoNodes(UInt firstNodeIndex, UInt secondNodeIndex) { if (firstNodeIndex >= GetNumNodes() || secondNodeIndex >= GetNumNodes()) { @@ -184,41 +184,41 @@ void Mesh::MergeTwoNodes(size_t firstNodeIndex, size_t secondNodeIndex) } auto edgeIndex = FindEdge(firstNodeIndex, secondNodeIndex); - if (edgeIndex != constants::missing::sizetValue) + if (edgeIndex != constants::missing::uintValue) { - m_edges[edgeIndex].first = constants::missing::sizetValue; - m_edges[edgeIndex].second = constants::missing::sizetValue; + m_edges[edgeIndex].first = constants::missing::uintValue; + m_edges[edgeIndex].second = constants::missing::uintValue; } // check if there is another edge starting at firstEdgeOtherNode and ending at secondNode - for (size_t n = 0; n < m_nodesNumEdges[firstNodeIndex]; n++) + for (UInt n = 0; n < m_nodesNumEdges[firstNodeIndex]; n++) { const auto firstEdgeIndex = m_nodesEdges[firstNodeIndex][n]; const auto& firstEdge = m_edges[firstEdgeIndex]; const auto firstEdgeOtherNode = OtherNodeOfEdge(firstEdge, firstNodeIndex); - if (firstEdgeOtherNode != constants::missing::sizetValue && firstEdgeOtherNode != secondNodeIndex) + if (firstEdgeOtherNode != constants::missing::uintValue && firstEdgeOtherNode != secondNodeIndex) { - for (size_t nn = 0; nn < m_nodesNumEdges[firstEdgeOtherNode]; nn++) + for (UInt nn = 0; nn < m_nodesNumEdges[firstEdgeOtherNode]; nn++) { const auto secondEdgeIndex = m_nodesEdges[firstEdgeOtherNode][nn]; auto secondEdge = m_edges[secondEdgeIndex]; const auto secondNodeSecondEdge = OtherNodeOfEdge(secondEdge, firstEdgeOtherNode); if (secondNodeSecondEdge == secondNodeIndex) { - m_edges[secondEdgeIndex].first = constants::missing::sizetValue; - m_edges[secondEdgeIndex].second = constants::missing::sizetValue; + m_edges[secondEdgeIndex].first = constants::missing::uintValue; + m_edges[secondEdgeIndex].second = constants::missing::uintValue; } } } } // add all valid edges starting at secondNode - std::vector secondNodeEdges(Mesh::m_maximumNumberOfEdgesPerNode, constants::missing::sizetValue); - size_t numSecondNodeEdges = 0; - for (size_t n = 0; n < m_nodesNumEdges[secondNodeIndex]; n++) + std::vector secondNodeEdges(Mesh::m_maximumNumberOfEdgesPerNode, constants::missing::uintValue); + UInt numSecondNodeEdges = 0; + for (UInt n = 0; n < m_nodesNumEdges[secondNodeIndex]; n++) { edgeIndex = m_nodesEdges[secondNodeIndex][n]; - if (m_edges[edgeIndex].first != constants::missing::sizetValue) + if (m_edges[edgeIndex].first != constants::missing::uintValue) { secondNodeEdges[numSecondNodeEdges] = edgeIndex; numSecondNodeEdges++; @@ -226,10 +226,10 @@ void Mesh::MergeTwoNodes(size_t firstNodeIndex, size_t secondNodeIndex) } // add all valid edges starting at firstNode are assigned to the second node - for (size_t n = 0; n < m_nodesNumEdges[firstNodeIndex]; n++) + for (UInt n = 0; n < m_nodesNumEdges[firstNodeIndex]; n++) { edgeIndex = m_nodesEdges[firstNodeIndex][n]; - if (m_edges[edgeIndex].first != constants::missing::sizetValue) + if (m_edges[edgeIndex].first != constants::missing::uintValue) { secondNodeEdges[numSecondNodeEdges] = edgeIndex; if (m_edges[edgeIndex].first == firstNodeIndex) @@ -245,11 +245,11 @@ void Mesh::MergeTwoNodes(size_t firstNodeIndex, size_t secondNodeIndex) } // re-assign edges to second node - m_nodesEdges[secondNodeIndex] = std::vector(secondNodeEdges.begin(), secondNodeEdges.begin() + numSecondNodeEdges); + m_nodesEdges[secondNodeIndex] = std::vector(secondNodeEdges.begin(), secondNodeEdges.begin() + numSecondNodeEdges); m_nodesNumEdges[secondNodeIndex] = numSecondNodeEdges; // remove edges to first node - m_nodesEdges[firstNodeIndex] = std::vector(0); + m_nodesEdges[firstNodeIndex] = std::vector(0); m_nodesNumEdges[firstNodeIndex] = 0; m_nodes[firstNodeIndex] = {constants::missing::doubleValue, constants::missing::doubleValue}; @@ -261,9 +261,9 @@ void Mesh::MergeNodesInPolygon(const Polygons& polygon, double mergingDistance) { // first filter the nodes in polygon std::vector filteredNodes(GetNumNodes()); - std::vector originalNodeIndices(GetNumNodes(), constants::missing::sizetValue); - size_t index = 0; - for (size_t i = 0; i < GetNumNodes(); ++i) + std::vector originalNodeIndices(GetNumNodes(), constants::missing::uintValue); + UInt index = 0; + for (UInt i = 0; i < static_cast(GetNumNodes()); ++i) { const bool inPolygon = polygon.IsPointInPolygon(m_nodes[i], 0); if (inPolygon) @@ -281,14 +281,14 @@ void Mesh::MergeNodesInPolygon(const Polygons& polygon, double mergingDistance) // merge the closest nodes auto const mergingDistanceSquared = mergingDistance * mergingDistance; - for (size_t i = 0; i < filteredNodes.size(); ++i) + for (UInt i = 0; i < filteredNodes.size(); ++i) { nodesRtree.SearchPoints(filteredNodes[i], mergingDistanceSquared); const auto resultSize = nodesRtree.GetQueryResultSize(); if (resultSize > 1) { - for (size_t j = 0; j < nodesRtree.GetQueryResultSize(); j++) + for (UInt j = 0; j < nodesRtree.GetQueryResultSize(); j++) { const auto nodeIndexInFilteredNodes = nodesRtree.GetQueryResult(j); if (nodeIndexInFilteredNodes != i) @@ -303,13 +303,13 @@ void Mesh::MergeNodesInPolygon(const Polygons& polygon, double mergingDistance) AdministrateNodesEdges(); } -size_t Mesh::ConnectNodes(size_t startNode, size_t endNode) +meshkernel::UInt Mesh::ConnectNodes(UInt startNode, UInt endNode) { const auto edgeIndex = FindEdge(startNode, endNode); // The nodes are already connected - if (edgeIndex != constants::missing::sizetValue) - return constants::missing::sizetValue; + if (edgeIndex != constants::missing::uintValue) + return constants::missing::uintValue; // increment the edges container const auto newEdgeIndex = GetNumEdges(); @@ -322,7 +322,7 @@ size_t Mesh::ConnectNodes(size_t startNode, size_t endNode) return newEdgeIndex; } -size_t Mesh::InsertNode(const Point& newPoint) +meshkernel::UInt Mesh::InsertNode(const Point& newPoint) { const auto newSize = GetNumNodes() + 1; const auto newNodeIndex = GetNumNodes(); @@ -339,14 +339,14 @@ size_t Mesh::InsertNode(const Point& newPoint) return newNodeIndex; } -void Mesh::DeleteNode(size_t node) +void Mesh::DeleteNode(UInt node) { if (node >= GetNumNodes()) { throw std::invalid_argument("Mesh::DeleteNode: The index of the node to be deleted does not exist."); } - for (size_t e = 0; e < m_nodesNumEdges[node]; e++) + for (UInt e = 0; e < m_nodesNumEdges[node]; e++) { const auto edgeIndex = m_nodesEdges[node][e]; DeleteEdge(edgeIndex); @@ -356,15 +356,15 @@ void Mesh::DeleteNode(size_t node) m_nodesRTreeRequiresUpdate = true; } -void Mesh::DeleteEdge(size_t edge) +void Mesh::DeleteEdge(UInt edge) { - if (edge == constants::missing::sizetValue) + if (edge == constants::missing::uintValue) { throw std::invalid_argument("Mesh::DeleteEdge: The index of the edge to be deleted does not exist."); } - m_edges[edge].first = constants::missing::sizetValue; - m_edges[edge].second = constants::missing::sizetValue; + m_edges[edge].first = constants::missing::uintValue; + m_edges[edge].second = constants::missing::uintValue; m_edgesRTreeRequiresUpdate = true; } @@ -373,7 +373,7 @@ void Mesh::ComputeEdgesLengths() { auto const numEdges = GetNumEdges(); m_edgeLengths.resize(numEdges, constants::missing::doubleValue); - for (size_t e = 0; e < numEdges; e++) + for (UInt e = 0; e < numEdges; e++) { auto const first = m_edges[e].first; auto const second = m_edges[e].second; @@ -386,7 +386,7 @@ void Mesh::ComputeEdgesCenters() m_edgesCenters = ComputeEdgeCenters(m_nodes, m_edges); } -size_t Mesh::FindCommonNode(size_t firstEdgeIndex, size_t secondEdgeIndex) const +meshkernel::UInt Mesh::FindCommonNode(UInt firstEdgeIndex, UInt secondEdgeIndex) const { const auto firstEdgeFirstNode = m_edges[firstEdgeIndex].first; const auto firstEdgeEdgeSecondNode = m_edges[firstEdgeIndex].second; @@ -394,7 +394,7 @@ size_t Mesh::FindCommonNode(size_t firstEdgeIndex, size_t secondEdgeIndex) const const auto secondEdgeFirstNode = m_edges[secondEdgeIndex].first; const auto secondEdgeSecondNode = m_edges[secondEdgeIndex].second; - if (firstEdgeFirstNode == constants::missing::sizetValue || firstEdgeEdgeSecondNode == constants::missing::sizetValue || secondEdgeFirstNode == constants::missing::sizetValue || secondEdgeSecondNode == constants::missing::sizetValue) + if (firstEdgeFirstNode == constants::missing::uintValue || firstEdgeEdgeSecondNode == constants::missing::uintValue || secondEdgeFirstNode == constants::missing::uintValue || secondEdgeSecondNode == constants::missing::uintValue) { throw std::invalid_argument("Mesh::FindCommonNode: At least one of the given edges is invalid."); } @@ -407,18 +407,18 @@ size_t Mesh::FindCommonNode(size_t firstEdgeIndex, size_t secondEdgeIndex) const { return firstEdgeEdgeSecondNode; } - return constants::missing::sizetValue; + return constants::missing::uintValue; } -size_t Mesh::FindEdge(size_t firstNodeIndex, size_t secondNodeIndex) const +meshkernel::UInt Mesh::FindEdge(UInt firstNodeIndex, UInt secondNodeIndex) const { - if (firstNodeIndex == constants::missing::sizetValue || secondNodeIndex == constants::missing::sizetValue) + if (firstNodeIndex == constants::missing::uintValue || secondNodeIndex == constants::missing::uintValue) { throw std::invalid_argument("Mesh::FindEdge: Invalid node index."); } - size_t edgeIndex = constants::missing::sizetValue; - for (size_t n = 0; n < m_nodesNumEdges[firstNodeIndex]; n++) + UInt edgeIndex = constants::missing::uintValue; + for (UInt n = 0; n < m_nodesNumEdges[firstNodeIndex]; n++) { const auto localEdgeIndex = m_nodesEdges[firstNodeIndex][n]; const auto firstEdgeOtherNode = OtherNodeOfEdge(m_edges[localEdgeIndex], firstNodeIndex); @@ -431,7 +431,7 @@ size_t Mesh::FindEdge(size_t firstNodeIndex, size_t secondNodeIndex) const return edgeIndex; } -size_t Mesh::FindNodeCloseToAPoint(Point const& point, double searchRadius) +meshkernel::UInt Mesh::FindNodeCloseToAPoint(Point const& point, double searchRadius) { if (GetNumNodes() <= 0) { @@ -448,7 +448,7 @@ size_t Mesh::FindNodeCloseToAPoint(Point const& point, double searchRadius) throw AlgorithmError("Mesh::FindNodeCloseToAPoint: Could not find the node index close to a point."); } -size_t Mesh::FindNodeCloseToAPoint(Point point, const std::vector& oneDNodeMask) +meshkernel::UInt Mesh::FindNodeCloseToAPoint(Point point, const std::vector& oneDNodeMask) { if (GetNumNodes() <= 0) { @@ -478,7 +478,7 @@ size_t Mesh::FindNodeCloseToAPoint(Point point, const std::vector& oneDNod } // resultSize > 0, a mask is applied - for (size_t index = 0; index < resultSize; ++index) + for (UInt index = 0; index < resultSize; ++index) { const auto nodeIndex = m_nodesRTree.GetQueryResult(index); if (oneDNodeMask[nodeIndex]) @@ -490,7 +490,7 @@ size_t Mesh::FindNodeCloseToAPoint(Point point, const std::vector& oneDNod throw AlgorithmError("Mesh::FindNodeCloseToAPoint: Could not find the node index close to a point."); } -size_t Mesh::FindEdgeCloseToAPoint(Point point) +meshkernel::UInt Mesh::FindEdgeCloseToAPoint(Point point) { if (GetNumEdges() == 0) { @@ -507,7 +507,7 @@ size_t Mesh::FindEdgeCloseToAPoint(Point point) throw AlgorithmError("Mesh::FindEdgeCloseToAPoint: Could not find the closest edge to a point."); } -void Mesh::MoveNode(Point newPoint, size_t nodeindex) +void Mesh::MoveNode(Point newPoint, UInt nodeindex) { const Point nodeToMove = m_nodes.at(nodeindex); @@ -515,7 +515,7 @@ void Mesh::MoveNode(Point newPoint, size_t nodeindex) const auto dy = GetDy(nodeToMove, newPoint, m_projection); const auto distanceNodeToMoveFromNewPoint = std::sqrt(dx * dx + dy * dy); - for (size_t n = 0; n < GetNumNodes(); ++n) + for (UInt n = 0; n < GetNumNodes(); ++n) { const auto nodeDx = GetDx(m_nodes[n], nodeToMove, m_projection); const auto nodeDy = GetDy(m_nodes[n], nodeToMove, m_projection); @@ -531,12 +531,12 @@ void Mesh::MoveNode(Point newPoint, size_t nodeindex) m_edgesRTreeRequiresUpdate = true; } -bool Mesh::IsFaceOnBoundary(size_t face) const +bool Mesh::IsFaceOnBoundary(UInt face) const { bool isFaceOnBoundary = false; - for (size_t e = 0; e < GetNumFaceEdges(face); ++e) + for (UInt e = 0; e < GetNumFaceEdges(face); ++e) { const auto edge = m_facesEdges[face][e]; if (IsEdgeOnBoundary(edge)) @@ -548,13 +548,13 @@ bool Mesh::IsFaceOnBoundary(size_t face) const return isFaceOnBoundary; } -void Mesh::SortEdgesInCounterClockWiseOrder(size_t startNode, size_t endNode) +void Mesh::SortEdgesInCounterClockWiseOrder(UInt startNode, UInt endNode) { std::vector edgeAngles(Mesh::m_maximumNumberOfEdgesPerNode); - std::vector indices(Mesh::m_maximumNumberOfEdgesPerNode); - std::vector edgeNodeCopy(Mesh::m_maximumNumberOfEdgesPerNode); - for (auto n = startNode; n <= endNode; n++) + std::vector indices(Mesh::m_maximumNumberOfEdgesPerNode); + std::vector edgeNodeCopy(Mesh::m_maximumNumberOfEdgesPerNode); + for (UInt n = startNode; n <= endNode; n++) { if (!m_nodes[n].IsValid()) { @@ -564,12 +564,12 @@ void Mesh::SortEdgesInCounterClockWiseOrder(size_t startNode, size_t endNode) double phi0 = 0.0; double phi; std::ranges::fill(edgeAngles, 0.0); - for (size_t edgeIndex = 0; edgeIndex < m_nodesNumEdges[n]; edgeIndex++) + for (UInt edgeIndex = 0; edgeIndex < m_nodesNumEdges[n]; edgeIndex++) { auto firstNode = m_edges[m_nodesEdges[n][edgeIndex]].first; auto secondNode = m_edges[m_nodesEdges[n][edgeIndex]].second; - if (firstNode == constants::missing::sizetValue || secondNode == constants::missing::sizetValue) + if (firstNode == constants::missing::uintValue || secondNode == constants::missing::uintValue) { continue; } @@ -615,10 +615,10 @@ void Mesh::SortEdgesInCounterClockWiseOrder(size_t startNode, size_t endNode) edgeNodeCopy.clear(); std::copy(m_nodesEdges[n].begin(), m_nodesEdges[n].end(), std::back_inserter(edgeNodeCopy)); iota(indices.begin(), indices.end(), 0); - sort(indices.begin(), indices.end(), [&](std::size_t const& i1, std::size_t const& i2) + sort(indices.begin(), indices.end(), [&](UInt const& i1, UInt const& i2) { return edgeAngles[i1] < edgeAngles[i2]; }); - for (std::size_t edgeIndex = 0; edgeIndex < m_nodesNumEdges[n]; edgeIndex++) + for (UInt edgeIndex = 0; edgeIndex < m_nodesNumEdges[n]; edgeIndex++) { m_nodesEdges[n][edgeIndex] = edgeNodeCopy[indices[edgeIndex]]; } @@ -706,7 +706,7 @@ void Mesh::SearchLocations(Point point, double squaredRadius, Location meshLocat } } -size_t Mesh::GetNumLocations(Location meshLocation) const +meshkernel::UInt Mesh::GetNumLocations(Location meshLocation) const { switch (meshLocation) { @@ -718,11 +718,11 @@ size_t Mesh::GetNumLocations(Location meshLocation) const return m_edgesRTree.GetQueryResultSize(); case Location::Unknown: default: - return constants::missing::sizetValue; + return constants::missing::uintValue; } } -size_t Mesh::GetLocationsIndices(size_t index, Location meshLocation) +meshkernel::UInt Mesh::GetLocationsIndices(UInt index, Location meshLocation) { switch (meshLocation) { @@ -734,7 +734,7 @@ size_t Mesh::GetLocationsIndices(size_t index, Location meshLocation) return m_edgesRTree.GetQueryResult(index); case Location::Unknown: default: - return constants::missing::sizetValue; + return constants::missing::uintValue; } } @@ -762,7 +762,7 @@ void Mesh::AdministrateNodesEdges() } m_nodesEdges.resize(m_nodes.size()); - std::ranges::fill(m_nodesEdges, std::vector(m_maximumNumberOfEdgesPerNode, constants::missing::sizetValue)); + std::ranges::fill(m_nodesEdges, std::vector(m_maximumNumberOfEdgesPerNode, constants::missing::uintValue)); m_nodesNumEdges.resize(m_nodes.size()); std::ranges::fill(m_nodesNumEdges, 0); @@ -772,7 +772,7 @@ void Mesh::AdministrateNodesEdges() SortEdgesInCounterClockWiseOrder(0, GetNumNodes() - 1); } -double Mesh::ComputeMaxLengthSurroundingEdges(size_t node) +double Mesh::ComputeMaxLengthSurroundingEdges(UInt node) { if (m_edgeLengths.empty()) @@ -781,7 +781,7 @@ double Mesh::ComputeMaxLengthSurroundingEdges(size_t node) } auto maxEdgeLength = std::numeric_limits::lowest(); - for (size_t ee = 0; ee < m_nodesNumEdges[node]; ++ee) + for (UInt ee = 0; ee < m_nodesNumEdges[node]; ++ee) { const auto edge = m_nodesEdges[node][ee]; maxEdgeLength = std::max(maxEdgeLength, m_edgeLengths[edge]); @@ -807,7 +807,7 @@ std::vector Mesh::ComputeLocations(Location location) const for (const auto& [firstNode, secondNode] : m_edges) { - if (firstNode != constants::missing::sizetValue && secondNode != constants::missing::sizetValue) + if (firstNode != constants::missing::uintValue && secondNode != constants::missing::uintValue) { result.emplace_back((m_nodes[firstNode] + m_nodes[secondNode]) * 0.5); } diff --git a/libs/MeshKernel/src/Mesh1D.cpp b/libs/MeshKernel/src/Mesh1D.cpp index 5da60edd6..302da3150 100644 --- a/libs/MeshKernel/src/Mesh1D.cpp +++ b/libs/MeshKernel/src/Mesh1D.cpp @@ -43,7 +43,7 @@ Mesh1D::Mesh1D(Network1D& network1d, double minFaceSize) { std::vector edges; std::vector nodes; - size_t numNodes = 0; + UInt numNodes = 0; // Compute 1d mesh discretization auto const discretizations = network1d.ComputeDiscretizationsFromChainages(); @@ -62,7 +62,7 @@ Mesh1D::Mesh1D(Network1D& network1d, double minFaceSize) edges.emplace_back(i, i + 1); } // Poly lines are separated. If the end of one polyline coincides with the start of another, the two nodes will be merged later on. - numNodes = numNodes + nodes.size(); + numNodes = numNodes + static_cast(nodes.size()); } // Sets the edges, nodes and projections @@ -78,7 +78,7 @@ Mesh1D::Mesh1D(Network1D& network1d, double minFaceSize) MergeNodesInPolygon(polygon, minFaceSize); } -Point Mesh1D::ComputeProjectedNode(size_t node, double distanceFactor) const +Point Mesh1D::ComputeProjectedNode(UInt node, double distanceFactor) const { if (m_nodesNumEdges[node] <= 0) diff --git a/libs/MeshKernel/src/Mesh2D.cpp b/libs/MeshKernel/src/Mesh2D.cpp index de176e7fa..f3a89e10d 100644 --- a/libs/MeshKernel/src/Mesh2D.cpp +++ b/libs/MeshKernel/src/Mesh2D.cpp @@ -48,8 +48,8 @@ Mesh2D::Mesh2D(const std::vector& edges, Mesh2D::Mesh2D(const std::vector& edges, const std::vector& nodes, - const std::vector>& faceNodes, - const std::vector& numFaceNodes, + const std::vector>& faceNodes, + const std::vector& numFaceNodes, Projection projection) : Mesh(edges, nodes, projection) { @@ -61,10 +61,10 @@ Mesh2D::Mesh2D(const std::vector& edges, m_facesNodes = faceNodes; m_numFacesNodes = numFaceNodes; - std::vector local_edges; + std::vector local_edges; std::vector local_nodes; - std::vector local_node_indices; - for (size_t f = 0; f < m_facesNodes.size(); ++f) + std::vector local_node_indices; + for (UInt f = 0; f < m_facesNodes.size(); ++f) { local_edges.clear(); local_nodes.clear(); @@ -73,7 +73,7 @@ Mesh2D::Mesh2D(const std::vector& edges, auto node = m_facesNodes[f][0]; local_nodes.emplace_back(m_nodes[node]); local_node_indices.emplace_back(node); - size_t index = 0; + UInt index = 0; while (index < m_nodesEdges[node].size()) { const auto edge = m_nodesEdges[node][index]; @@ -148,7 +148,7 @@ Mesh2D::Mesh2D(const std::vector& inputNodes, const Polygons& polygons, P m_projection = projection; // compute triangulation TriangulationWrapper triangulationWrapper; - const auto numberOfTriangles = inputNodes.size() * 6 + 10; + const auto numberOfTriangles = static_cast(inputNodes.size()) * 6 + 10; triangulationWrapper.Compute(inputNodes, TriangulationWrapper::TriangulationOptions::TriangulatePointsAndGenerateFaces, 0.0, @@ -178,7 +178,7 @@ Mesh2D::Mesh2D(const std::vector& inputNodes, const Polygons& polygons, P } // mark all edges of this triangle as good ones - for (size_t j = 0; j < m_numNodesInTriangle; ++j) + for (UInt j = 0; j < m_numNodesInTriangle; ++j) { edgeNodesFlag[triangulationWrapper.GetFaceEdge(i, j)] = true; } @@ -186,7 +186,7 @@ Mesh2D::Mesh2D(const std::vector& inputNodes, const Polygons& polygons, P // now add all points and all valid edges m_nodes = inputNodes; - size_t validEdgesCount = 0; + UInt validEdgesCount = 0; for (auto i = 0; i < triangulationWrapper.GetNumEdges(); ++i) { if (!edgeNodesFlag[i]) @@ -212,7 +212,7 @@ Mesh2D::Mesh2D(const std::vector& inputNodes, const Polygons& polygons, P *this = Mesh2D(edges, inputNodes, projection); } -bool Mesh2D::HasTriangleNoAcuteAngles(const std::vector& faceNodes, const std::vector& nodes) const +bool Mesh2D::HasTriangleNoAcuteAngles(const std::vector& faceNodes, const std::vector& nodes) const { // Used for triangular grids constexpr double triangleMinimumAngle = 5.0; @@ -221,9 +221,9 @@ bool Mesh2D::HasTriangleNoAcuteAngles(const std::vector& faceNodes, cons double phiMin = 1e3; double phiMax = 0.0; - static std::array, 3> nodePermutations{{{2, 0, 1}, {0, 1, 2}, {1, 2, 0}}}; + static std::array, 3> nodePermutations{{{2, 0, 1}, {0, 1, 2}, {1, 2, 0}}}; - for (size_t i = 0; i < faceNodes.size(); ++i) + for (UInt i = 0; i < faceNodes.size(); ++i) { Point x0 = nodes[faceNodes[nodePermutations[i][0]]]; Point x1 = nodes[faceNodes[nodePermutations[i][1]]]; @@ -246,9 +246,9 @@ void Mesh2D::DeleteDegeneratedTriangles() Administrate(); // assume the max amount of degenerated triangles is 10% of the actual faces - std::vector degeneratedTriangles; - degeneratedTriangles.reserve(static_cast(static_cast(GetNumFaces()) * 0.1)); - for (size_t f = 0; f < GetNumFaces(); ++f) + std::vector degeneratedTriangles; + degeneratedTriangles.reserve(static_cast(static_cast(GetNumFaces()) * 0.1)); + for (UInt f = 0; f < GetNumFaces(); ++f) { const auto numFaceNodes = m_numFacesNodes[f]; if (numFaceNodes != m_numNodesInTriangle) @@ -279,10 +279,10 @@ void Mesh2D::DeleteDegeneratedTriangles() if (IsEqual(den, 0.0)) { // Flag edges to remove - for (size_t e = 0; e < m_numNodesInTriangle; ++e) + for (UInt e = 0; e < m_numNodesInTriangle; ++e) { const auto edge = m_facesEdges[f][e]; - m_edges[edge] = {constants::missing::sizetValue, constants::missing::sizetValue}; + m_edges[edge] = {constants::missing::uintValue, constants::missing::uintValue}; } // save degenerated face index degeneratedTriangles.emplace_back(f); @@ -304,21 +304,21 @@ void Mesh2D::DeleteDegeneratedTriangles() Administrate(); } -void Mesh2D::FindFacesRecursive(size_t startNode, - size_t node, - size_t previousEdge, - size_t numClosingEdges, - std::vector& edges, - std::vector& nodes, - std::vector& sortedEdgesFaces, - std::vector& sortedNodes, +void Mesh2D::FindFacesRecursive(UInt startNode, + UInt node, + UInt previousEdge, + UInt numClosingEdges, + std::vector& edges, + std::vector& nodes, + std::vector& sortedEdgesFaces, + std::vector& sortedNodes, std::vector& nodalValues) { // The selected edge does not exist. if (nodes.size() >= numClosingEdges) return; - if (m_edges[previousEdge].first == constants::missing::sizetValue || m_edges[previousEdge].second == constants::missing::sizetValue) + if (m_edges[previousEdge].first == constants::missing::uintValue || m_edges[previousEdge].second == constants::missing::uintValue) throw std::invalid_argument("Mesh2D::FindFacesRecursive: The selected edge is invalid. This should not happen since all invalid edges should have been cleaned up."); // Check if the faces are already found @@ -338,7 +338,7 @@ void Mesh2D::FindFacesRecursive(size_t startNode, sortedNodes.reserve(nodes.size()); std::copy(nodes.begin(), nodes.end(), std::back_inserter(sortedNodes)); std::sort(sortedNodes.begin(), sortedNodes.end()); - for (size_t n = 0; n < sortedNodes.size() - 1; n++) + for (UInt n = 0; n < sortedNodes.size() - 1; n++) { if (sortedNodes[n + 1] == sortedNodes[n]) { @@ -363,14 +363,14 @@ void Mesh2D::FindFacesRecursive(size_t startNode, sortedEdgesFaces.clear(); sortedEdgesFaces.reserve(edges.size()); // is an internal face only if all edges have a different face - for (size_t ee = 0; ee < edges.size(); ee++) + for (UInt ee = 0; ee < edges.size(); ee++) { sortedEdgesFaces.push_back(m_edgesFaces[edges[ee]][0]); } std::sort(sortedEdgesFaces.begin(), sortedEdgesFaces.end()); - for (size_t n = 0; n < sortedEdgesFaces.size() - 1; n++) + for (UInt n = 0; n < sortedEdgesFaces.size() - 1; n++) { if (sortedEdgesFaces[n + 1] == sortedEdgesFaces[n]) return; @@ -406,13 +406,13 @@ void Mesh2D::FindFacesRecursive(size_t startNode, m_facesEdges.emplace_back(edges); m_faceArea.emplace_back(area); m_facesMassCenters.emplace_back(center_of_mass); - m_numFacesNodes.emplace_back(nodes.size()); + m_numFacesNodes.emplace_back(static_cast(nodes.size())); return; } - size_t edgeIndexOtherNode = 0; - for (size_t e = 0; e < m_nodesNumEdges[otherNode]; e++) + UInt edgeIndexOtherNode = 0; + for (UInt e = 0; e < m_nodesNumEdges[otherNode]; e++) { if (m_nodesEdges[otherNode][e] == previousEdge) { @@ -440,22 +440,22 @@ void Mesh2D::FindFacesRecursive(size_t startNode, void Mesh2D::FindFaces() { - std::vector sortedEdgesFaces(m_maximumNumberOfEdgesPerFace); - std::vector sortedNodes(m_maximumNumberOfEdgesPerFace); + std::vector sortedEdgesFaces(m_maximumNumberOfEdgesPerFace); + std::vector sortedNodes(m_maximumNumberOfEdgesPerFace); std::vector nodalValues(m_maximumNumberOfEdgesPerFace); - std::vector edges(m_maximumNumberOfEdgesPerFace); - std::vector nodes(m_maximumNumberOfEdgesPerFace); + std::vector edges(m_maximumNumberOfEdgesPerFace); + std::vector nodes(m_maximumNumberOfEdgesPerFace); - for (size_t numEdgesPerFace = 3; numEdgesPerFace <= m_maximumNumberOfEdgesPerFace; numEdgesPerFace++) + for (UInt numEdgesPerFace = 3; numEdgesPerFace <= m_maximumNumberOfEdgesPerFace; numEdgesPerFace++) { - for (size_t n = 0; n < GetNumNodes(); n++) + for (UInt n = 0; n < GetNumNodes(); n++) { if (!m_nodes[n].IsValid()) { continue; } - for (size_t e = 0; e < m_nodesNumEdges[n]; e++) + for (UInt e = 0; e < m_nodesNumEdges[n]; e++) { nodes.clear(); edges.clear(); @@ -473,7 +473,7 @@ void Mesh2D::ComputeCircumcentersMassCentersAndFaceAreas(bool computeMassCenters m_faceArea.resize(numFaces); m_facesMassCenters.resize(numFaces); - std::vector numEdgeFacesCache; + std::vector numEdgeFacesCache; numEdgeFacesCache.reserve(m_maximumNumberOfEdgesPerFace); std::vector polygonNodesCache; #pragma omp parallel for private(numEdgeFacesCache, polygonNodesCache) @@ -489,7 +489,7 @@ void Mesh2D::ComputeCircumcentersMassCentersAndFaceAreas(bool computeMassCenters m_facesMassCenters[f] = centerOfMass; } - size_t numberOfInteriorEdges = 0; + UInt numberOfInteriorEdges = 0; const auto numberOfFaceNodes = static_cast(GetNumFaceEdges(f)); for (int n = 0; n < numberOfFaceNodes; n++) { @@ -518,12 +518,12 @@ void Mesh2D::ClassifyNodes() m_nodesTypes.resize(GetNumNodes(), 0); std::ranges::fill(m_nodesTypes, 0); - for (size_t e = 0; e < GetNumEdges(); e++) + for (UInt e = 0; e < GetNumEdges(); e++) { const auto firstNode = m_edges[e].first; const auto secondNode = m_edges[e].second; - if (firstNode == constants::missing::sizetValue || secondNode == constants::missing::sizetValue) + if (firstNode == constants::missing::uintValue || secondNode == constants::missing::uintValue) { continue; } @@ -545,7 +545,7 @@ void Mesh2D::ClassifyNodes() } } - for (size_t n = 0; n < GetNumNodes(); n++) + for (UInt n = 0; n < GetNumNodes(); n++) { if (m_nodesTypes[n] == 1 || m_nodesTypes[n] == 2) { @@ -556,9 +556,9 @@ void Mesh2D::ClassifyNodes() } else { - size_t firstNode = constants::missing::sizetValue; - size_t secondNode = constants::missing::sizetValue; - for (size_t i = 0; i < m_nodesNumEdges[n]; ++i) + UInt firstNode = constants::missing::uintValue; + UInt secondNode = constants::missing::uintValue; + for (UInt i = 0; i < m_nodesNumEdges[n]; ++i) { const auto edgeIndex = m_nodesEdges[n][i]; if (!IsEdgeOnBoundary(edgeIndex)) @@ -578,7 +578,7 @@ void Mesh2D::ClassifyNodes() // point at the border m_nodesTypes[n] = 2; - if (firstNode != constants::missing::sizetValue && secondNode != constants::missing::sizetValue) + if (firstNode != constants::missing::uintValue && secondNode != constants::missing::uintValue) { const double cosPhi = NormalizedInnerProductTwoSegments(m_nodes[n], m_nodes[firstNode], m_nodes[n], m_nodes[secondNode], m_projection); @@ -610,10 +610,10 @@ void Mesh2D::ClassifyNodes() } } -void Mesh2D::ComputeFaceClosedPolygonWithLocalMappings(size_t faceIndex, +void Mesh2D::ComputeFaceClosedPolygonWithLocalMappings(UInt faceIndex, std::vector& polygonNodesCache, - std::vector& localNodeIndicesCache, - std::vector& globalEdgeIndicesCache) const + std::vector& localNodeIndicesCache, + std::vector& globalEdgeIndicesCache) const { const auto numFaceNodes = GetNumFaceEdges(faceIndex); polygonNodesCache.reserve(numFaceNodes + 1); @@ -623,7 +623,7 @@ void Mesh2D::ComputeFaceClosedPolygonWithLocalMappings(size_t faceIndex, globalEdgeIndicesCache.reserve(numFaceNodes + 1); globalEdgeIndicesCache.clear(); - for (size_t n = 0; n < numFaceNodes; n++) + for (UInt n = 0; n < numFaceNodes; n++) { polygonNodesCache.emplace_back(m_nodes[m_facesNodes[faceIndex][n]]); localNodeIndicesCache.emplace_back(n); @@ -634,13 +634,13 @@ void Mesh2D::ComputeFaceClosedPolygonWithLocalMappings(size_t faceIndex, globalEdgeIndicesCache.emplace_back(globalEdgeIndicesCache.front()); } -void Mesh2D::ComputeFaceClosedPolygon(size_t faceIndex, std::vector& polygonNodesCache) const +void Mesh2D::ComputeFaceClosedPolygon(UInt faceIndex, std::vector& polygonNodesCache) const { const auto numFaceNodes = GetNumFaceEdges(faceIndex); polygonNodesCache.clear(); polygonNodesCache.reserve(numFaceNodes + 1); - for (size_t n = 0; n < numFaceNodes; n++) + for (UInt n = 0; n < numFaceNodes; n++) { polygonNodesCache.push_back(m_nodes[m_facesNodes[faceIndex][n]]); } @@ -652,7 +652,7 @@ void Mesh2D::OffsetSphericalCoordinates(double minx, double maxx) { if (m_projection == Projection::spherical && maxx - minx > 180.0) { - for (size_t n = 0; n < GetNumNodes(); ++n) + for (UInt n = 0; n < GetNumNodes(); ++n) { if (m_nodes[n].x - 360.0 >= minx) { @@ -668,19 +668,19 @@ void Mesh2D::OffsetSphericalCoordinates(double minx, double maxx) } meshkernel::Point Mesh2D::ComputeFaceCircumenter(std::vector& polygon, - const std::vector& edgesNumFaces) const + const std::vector& edgesNumFaces) const { - const size_t maximumNumberCircumcenterIterations = 100; + const UInt maximumNumberCircumcenterIterations = 100; const double eps = m_projection == Projection::cartesian ? 1e-3 : 9e-10; // 111km = 0-e digit. std::array middlePoints; std::array normals; - size_t pointCount = 0; + UInt pointCount = 0; - const auto numNodes = polygon.size() - 1; + const auto numNodes = static_cast(polygon.size()) - 1; Point centerOfMass{0.0, 0.0}; - for (size_t n = 0; n < numNodes; n++) + for (UInt n = 0; n < numNodes; n++) { centerOfMass.x += polygon[n].x; centerOfMass.y += polygon[n].y; @@ -695,8 +695,8 @@ meshkernel::Point Mesh2D::ComputeFaceCircumenter(std::vector& polygon, } else if (!edgesNumFaces.empty()) { - size_t numValidEdges = 0; - for (size_t n = 0; n < numNodes; ++n) + UInt numValidEdges = 0; + for (UInt n = 0; n < numNodes; ++n) { if (edgesNumFaces[n] == 2) { @@ -706,7 +706,7 @@ meshkernel::Point Mesh2D::ComputeFaceCircumenter(std::vector& polygon, if (numValidEdges > 1) { - for (size_t n = 0; n < numNodes; n++) + for (UInt n = 0; n < numNodes; n++) { if (edgesNumFaces[n] != 2) { @@ -720,10 +720,10 @@ meshkernel::Point Mesh2D::ComputeFaceCircumenter(std::vector& polygon, } Point estimatedCircumCenter = centerOfMass; - for (size_t iter = 0; iter < maximumNumberCircumcenterIterations; ++iter) + for (UInt iter = 0; iter < maximumNumberCircumcenterIterations; ++iter) { const Point previousCircumCenter = estimatedCircumCenter; - for (size_t n = 0; n < pointCount; n++) + for (UInt n = 0; n < pointCount; n++) { const auto dx = GetDx(middlePoints[n], estimatedCircumCenter, m_projection); const auto dy = GetDy(middlePoints[n], estimatedCircumCenter, m_projection); @@ -741,7 +741,7 @@ meshkernel::Point Mesh2D::ComputeFaceCircumenter(std::vector& polygon, } } - for (size_t n = 0; n < numNodes; n++) + for (UInt n = 0; n < numNodes; n++) { polygon[n].x = m_weightCircumCenter * polygon[n].x + (1.0 - m_weightCircumCenter) * centerOfMass.x; polygon[n].y = m_weightCircumCenter * polygon[n].y + (1.0 - m_weightCircumCenter) * centerOfMass.y; @@ -755,7 +755,7 @@ meshkernel::Point Mesh2D::ComputeFaceCircumenter(std::vector& polygon, // If the circumcenter is not included in the face, // the circumcenter will be placed at the intersection between an edge and the segment connecting the mass center with the circumcentre. - for (size_t n = 0; n < numNodes; n++) + for (UInt n = 0; n < numNodes; n++) { const auto nextNode = NextCircularForwardIndex(n, numNodes); Point intersection; @@ -778,7 +778,7 @@ std::vector Mesh2D::GetObtuseTrianglesCenters() Administrate(); std::vector result; result.reserve(GetNumFaces()); - for (size_t f = 0; f < GetNumFaces(); ++f) + for (UInt f = 0; f < GetNumFaces(); ++f) { // a triangle if (m_numFacesNodes[f] == 3) @@ -802,17 +802,17 @@ std::vector Mesh2D::GetObtuseTrianglesCenters() return result; } -std::vector Mesh2D::GetEdgesCrossingSmallFlowEdges(double smallFlowEdgesThreshold) +std::vector Mesh2D::GetEdgesCrossingSmallFlowEdges(double smallFlowEdgesThreshold) { Administrate(); - std::vector result; + std::vector result; result.reserve(GetNumEdges()); - for (size_t e = 0; e < GetNumEdges(); ++e) + for (UInt e = 0; e < GetNumEdges(); ++e) { const auto firstFace = m_edgesFaces[e][0]; const auto secondFace = m_edgesFaces[e][1]; - if (firstFace != constants::missing::sizetValue && secondFace != constants::missing::sizetValue) + if (firstFace != constants::missing::uintValue && secondFace != constants::missing::uintValue) { const auto flowEdgeLength = ComputeDistance(m_facesCircumcenters[firstFace], m_facesCircumcenters[secondFace], m_projection); const double cutOffDistance = smallFlowEdgesThreshold * 0.5 * (std::sqrt(m_faceArea[firstFace]) + std::sqrt(m_faceArea[secondFace])); @@ -826,7 +826,7 @@ std::vector Mesh2D::GetEdgesCrossingSmallFlowEdges(double smallFlowEdges return result; } -std::vector Mesh2D::GetFlowEdgesCenters(const std::vector& edges) const +std::vector Mesh2D::GetFlowEdgesCenters(const std::vector& edges) const { std::vector result; result.reserve(GetNumEdges()); @@ -850,7 +850,7 @@ void Mesh2D::DeleteSmallFlowEdges(double smallFlowEdgesThreshold) // invalidate the edges for (const auto& e : edges) { - m_edges[e] = {constants::missing::sizetValue, constants::missing::sizetValue}; + m_edges[e] = {constants::missing::uintValue, constants::missing::uintValue}; } Administrate(); } @@ -859,8 +859,8 @@ void Mesh2D::DeleteSmallFlowEdges(double smallFlowEdgesThreshold) void Mesh2D::DeleteSmallTrianglesAtBoundaries(double minFractionalAreaTriangles) { // On the second part, the small triangles at the boundaries are checked - std::vector> smallTrianglesNodes; - for (size_t face = 0; face < GetNumFaces(); ++face) + std::vector> smallTrianglesNodes; + for (UInt face = 0; face < GetNumFaces(); ++face) { if (m_numFacesNodes[face] != m_numNodesInTriangle || m_faceArea[face] <= 0.0 || !IsFaceOnBoundary(face)) { @@ -869,8 +869,8 @@ void Mesh2D::DeleteSmallTrianglesAtBoundaries(double minFractionalAreaTriangles) // compute the average area of neighboring faces double averageOtherFacesArea = 0.0; - size_t numNonBoundaryFaces = 0; - for (size_t e = 0; e < m_numNodesInTriangle; ++e) + UInt numNonBoundaryFaces = 0; + for (UInt e = 0; e < m_numNodesInTriangle; ++e) { // the edge must not be at the boundary, otherwise there is no "other" face const auto edge = m_facesEdges[face][e]; @@ -893,11 +893,11 @@ void Mesh2D::DeleteSmallTrianglesAtBoundaries(double minFractionalAreaTriangles) } double minCosPhiSmallTriangle = 1.0; - size_t nodeToPreserve = constants::missing::sizetValue; - size_t firstNodeToMerge = constants::missing::sizetValue; - size_t secondNodeToMerge = constants::missing::sizetValue; - size_t thirdEdgeSmallTriangle = constants::missing::sizetValue; - for (size_t e = 0; e < m_numNodesInTriangle; ++e) + UInt nodeToPreserve = constants::missing::uintValue; + UInt firstNodeToMerge = constants::missing::uintValue; + UInt secondNodeToMerge = constants::missing::uintValue; + UInt thirdEdgeSmallTriangle = constants::missing::uintValue; + for (UInt e = 0; e < m_numNodesInTriangle; ++e) { const auto previousEdge = NextCircularBackwardIndex(e, m_numNodesInTriangle); const auto nextEdge = NextCircularForwardIndex(e, m_numNodesInTriangle); @@ -919,9 +919,9 @@ void Mesh2D::DeleteSmallTrianglesAtBoundaries(double minFractionalAreaTriangles) } } - if (thirdEdgeSmallTriangle != constants::missing::sizetValue && IsEdgeOnBoundary(thirdEdgeSmallTriangle)) + if (thirdEdgeSmallTriangle != constants::missing::uintValue && IsEdgeOnBoundary(thirdEdgeSmallTriangle)) { - smallTrianglesNodes.emplace_back(std::initializer_list{nodeToPreserve, firstNodeToMerge, secondNodeToMerge}); + smallTrianglesNodes.emplace_back(std::initializer_list{nodeToPreserve, firstNodeToMerge, secondNodeToMerge}); } } @@ -933,8 +933,8 @@ void Mesh2D::DeleteSmallTrianglesAtBoundaries(double minFractionalAreaTriangles) const auto secondNodeToMerge = triangleNodes[2]; // only - size_t numInternalEdges = 0; - for (size_t e = 0; e < m_nodesNumEdges[firstNodeToMerge]; ++e) + UInt numInternalEdges = 0; + for (UInt e = 0; e < m_nodesNumEdges[firstNodeToMerge]; ++e) { if (!IsEdgeOnBoundary(m_nodesEdges[firstNodeToMerge][e])) { @@ -950,7 +950,7 @@ void Mesh2D::DeleteSmallTrianglesAtBoundaries(double minFractionalAreaTriangles) // corner point of a triangle numInternalEdges = 0; - for (size_t e = 0; e < m_nodesNumEdges[secondNodeToMerge]; ++e) + for (UInt e = 0; e < m_nodesNumEdges[secondNodeToMerge]; ++e) { if (!IsEdgeOnBoundary(m_nodesEdges[secondNodeToMerge][e])) { @@ -976,11 +976,11 @@ void Mesh2D::ComputeNodeNeighbours() m_maxNumNeighbours = *(std::max_element(m_nodesNumEdges.begin(), m_nodesNumEdges.end())); m_maxNumNeighbours += 1; - ResizeAndFill2DVector(m_nodesNodes, GetNumNodes(), m_maxNumNeighbours, true, constants::missing::sizetValue); + ResizeAndFill2DVector(m_nodesNodes, GetNumNodes(), m_maxNumNeighbours, true, constants::missing::uintValue); // for each node, determine the neighboring nodes - for (size_t n = 0; n < GetNumNodes(); n++) + for (UInt n = 0; n < GetNumNodes(); n++) { - for (size_t nn = 0; nn < m_nodesNumEdges[n]; nn++) + for (UInt nn = 0; nn < m_nodesNumEdges[n]; nn++) { const auto edge = m_edges[m_nodesEdges[n][nn]]; m_nodesNodes[n][nn] = OtherNodeOfEdge(edge, n); @@ -992,13 +992,13 @@ std::vector Mesh2D::GetOrthogonality() { std::vector result; result.reserve(GetNumEdges()); - for (size_t e = 0; e < GetNumEdges(); e++) + for (UInt e = 0; e < GetNumEdges(); e++) { auto val = constants::missing::doubleValue; const auto firstNode = m_edges[e].first; const auto secondNode = m_edges[e].second; - if (firstNode != constants::missing::sizetValue && secondNode != constants::missing::sizetValue && !IsEdgeOnBoundary(e)) + if (firstNode != constants::missing::uintValue && secondNode != constants::missing::uintValue && !IsEdgeOnBoundary(e)) { val = NormalizedInnerProductTwoSegments(m_nodes[firstNode], m_nodes[secondNode], @@ -1019,13 +1019,13 @@ std::vector Mesh2D::GetSmoothness() { std::vector result; result.reserve(GetNumEdges()); - for (size_t e = 0; e < GetNumEdges(); e++) + for (UInt e = 0; e < GetNumEdges(); e++) { auto val = constants::missing::doubleValue; const auto firstNode = m_edges[e].first; const auto secondNode = m_edges[e].second; - if (firstNode != constants::missing::sizetValue && secondNode != constants::missing::sizetValue && !IsEdgeOnBoundary(e)) + if (firstNode != constants::missing::uintValue && secondNode != constants::missing::uintValue && !IsEdgeOnBoundary(e)) { const auto leftFace = m_edgesFaces[e][0]; const auto rightFace = m_edgesFaces[e][1]; @@ -1054,7 +1054,7 @@ void Mesh2D::ComputeAspectRatios(std::vector& aspectRatios) std::vector edgesLength(GetNumEdges(), 0.0); aspectRatios.resize(GetNumEdges(), 0.0); - for (size_t e = 0; e < GetNumEdges(); e++) + for (UInt e = 0; e < GetNumEdges(); e++) { const auto first = m_edges[e].first; const auto second = m_edges[e].second; @@ -1096,13 +1096,13 @@ void Mesh2D::ComputeAspectRatios(std::vector& aspectRatios) } // Compute normal length - for (size_t f = 0; f < GetNumFaces(); f++) + for (UInt f = 0; f < GetNumFaces(); f++) { const auto numberOfFaceNodes = GetNumFaceEdges(f); if (numberOfFaceNodes < m_numNodesInTriangle) continue; - for (size_t n = 0; n < numberOfFaceNodes; n++) + for (UInt n = 0; n < numberOfFaceNodes; n++) { if (numberOfFaceNodes != m_numNodesQuads) curvilinearGridIndicator[m_facesNodes[f][n]] = false; @@ -1122,7 +1122,7 @@ void Mesh2D::ComputeAspectRatios(std::vector& aspectRatios) // quads if (numberOfFaceNodes == m_numNodesQuads) { - size_t kkp2 = n + 2; + UInt kkp2 = n + 2; if (kkp2 >= numberOfFaceNodes) { kkp2 = kkp2 - numberOfFaceNodes; @@ -1146,12 +1146,12 @@ void Mesh2D::ComputeAspectRatios(std::vector& aspectRatios) if (m_curvilinearToOrthogonalRatio == 1.0) return; - for (size_t e = 0; e < GetNumEdges(); e++) + for (UInt e = 0; e < GetNumEdges(); e++) { const auto first = m_edges[e].first; const auto second = m_edges[e].second; - if (first == constants::missing::sizetValue || second == constants::missing::sizetValue) + if (first == constants::missing::uintValue || second == constants::missing::uintValue) continue; if (m_edgesNumFaces[e] == 0) continue; @@ -1183,7 +1183,7 @@ void Mesh2D::ComputeAspectRatios(std::vector& aspectRatios) void Mesh2D::TriangulateFaces() { - for (size_t i = 0; i < GetNumFaces(); ++i) + for (UInt i = 0; i < GetNumFaces(); ++i) { const auto NumEdges = GetNumFaceEdges(i); @@ -1193,7 +1193,7 @@ void Mesh2D::TriangulateFaces() } const auto indexFirstNode = m_facesNodes[i][0]; - for (size_t j = 2; j < NumEdges - 1; j++) + for (UInt j = 2; j < NumEdges - 1; j++) { const auto nodeIndex = m_facesNodes[i][j]; ConnectNodes(indexFirstNode, nodeIndex); @@ -1203,14 +1203,14 @@ void Mesh2D::TriangulateFaces() m_edgesRTreeRequiresUpdate = true; } -void Mesh2D::MakeDualFace(size_t node, double enlargementFactor, std::vector& dualFace) +void Mesh2D::MakeDualFace(UInt node, double enlargementFactor, std::vector& dualFace) { const auto sortedFacesIndices = SortedFacesAroundNode(node); const auto numEdges = m_nodesNumEdges[node]; dualFace.reserve(m_maximumNumberOfEdgesPerNode); dualFace.clear(); - for (size_t e = 0; e < numEdges; ++e) + for (UInt e = 0; e < numEdges; ++e) { const auto edgeIndex = m_nodesEdges[node][e]; auto edgeCenter = m_edgesCenters[edgeIndex]; @@ -1220,7 +1220,7 @@ void Mesh2D::MakeDualFace(size_t node, double enlargementFactor, std::vector Mesh2D::SortedFacesAroundNode(size_t node) const +std::vector Mesh2D::SortedFacesAroundNode(UInt node) const { const auto numEdges = m_nodesNumEdges[node]; - std::vector result; - for (size_t e = 0; e < numEdges; ++e) + std::vector result; + for (UInt e = 0; e < numEdges; ++e) { const auto firstEdge = m_nodesEdges[node][e]; @@ -1288,15 +1288,15 @@ std::vector Mesh2D::SortedFacesAroundNode(size_t node) const const auto secondEdge = m_nodesEdges[node][ee]; const auto firstFace = m_edgesFaces[firstEdge][0]; - size_t secondFace = constants::missing::sizetValue; + UInt secondFace = constants::missing::uintValue; if (m_edgesNumFaces[firstEdge] > 1) { secondFace = m_edgesFaces[firstEdge][1]; } // check if the first face contains the first edge - size_t firstEdgeIndexInFirstFace = 0; - for (size_t n = 0; n < m_numFacesNodes[firstFace]; ++n) + UInt firstEdgeIndexInFirstFace = 0; + for (UInt n = 0; n < m_numFacesNodes[firstFace]; ++n) { if (m_facesEdges[firstFace][n] == firstEdge) { @@ -1330,7 +1330,7 @@ std::vector Mesh2D::MeshBoundaryToPolygon(const std::vector

meshBoundaryPolygon; meshBoundaryPolygon.reserve(GetNumNodes()); - for (size_t e = 0; e < GetNumEdges(); e++) + for (UInt e = 0; e < GetNumEdges(); e++) { if (isVisited[e] || !IsEdgeOnBoundary(e)) { @@ -1357,7 +1357,7 @@ std::vector Mesh2D::MeshBoundaryToPolygon(const std::vector

(meshBoundaryPolygon.size()); meshBoundaryPolygon.emplace_back(firstNode); meshBoundaryPolygon.emplace_back(secondNode); isVisited[e] = true; @@ -1366,7 +1366,7 @@ std::vector Mesh2D::MeshBoundaryToPolygon(const std::vector

(meshBoundaryPolygon.size()); // if the boundary polygon is not closed if (currentNode != firstNodeIndex) @@ -1379,7 +1379,7 @@ std::vector Mesh2D::MeshBoundaryToPolygon(const std::vector

numNodesFirstTail) { - const auto start = startPolygonEdges + static_cast(std::ceil((numNodesFirstTail - startPolygonEdges + static_cast(1)) * 0.5)); + const auto start = startPolygonEdges + static_cast(std::ceil((numNodesFirstTail - startPolygonEdges + static_cast(1)) * 0.5)); for (auto n = start; n < numNodesFirstTail; n++) { const auto backupPoint = meshBoundaryPolygon[n]; @@ -1394,10 +1394,10 @@ std::vector Mesh2D::MeshBoundaryToPolygon(const std::vector

& polygonNodes, std::vector& isVisited, - size_t& currentNode, + UInt& currentNode, std::vector& meshBoundaryPolygon) const { - size_t e = 0; + UInt e = 0; bool currentNodeInPolygon = false; while (e < m_nodesNumEdges[currentNode]) { @@ -1427,15 +1427,15 @@ void Mesh2D::WalkBoundaryFromNode(const std::vector& polygonNodes, } } -std::vector Mesh2D::GetHangingEdges() const +std::vector Mesh2D::GetHangingEdges() const { - std::vector result; - for (size_t e = 0; e < GetNumEdges(); e++) + std::vector result; + for (UInt e = 0; e < GetNumEdges(); e++) { const auto firstNode = m_edges[e].first; const auto secondNode = m_edges[e].second; - if (firstNode != constants::missing::sizetValue && secondNode != constants::missing::sizetValue) + if (firstNode != constants::missing::uintValue && secondNode != constants::missing::uintValue) { // if one of the nodes has no other attached edges, the current edge is an hanging edge if (m_nodesNumEdges[firstNode] > 1 && m_nodesNumEdges[secondNode] > 1) @@ -1453,7 +1453,7 @@ void Mesh2D::DeleteMesh(const Polygons& polygon, int deletionOption, bool invert { if (deletionOption == AllNodesInside) { - for (size_t n = 0; n < GetNumNodes(); ++n) + for (UInt n = 0; n < GetNumNodes(); ++n) { auto [isInPolygon, polygonIndex] = polygon.IsPointInPolygons(m_nodes[n]); if (invertDeletion) @@ -1471,14 +1471,14 @@ void Mesh2D::DeleteMesh(const Polygons& polygon, int deletionOption, bool invert { Administrate(); - for (size_t e = 0; e < GetNumEdges(); ++e) + for (UInt e = 0; e < GetNumEdges(); ++e) { bool allFaceCircumcentersInPolygon = true; - for (size_t f = 0; f < GetNumEdgesFaces(e); ++f) + for (UInt f = 0; f < GetNumEdgesFaces(e); ++f) { const auto faceIndex = m_edgesFaces[e][f]; - if (faceIndex == constants::missing::sizetValue) + if (faceIndex == constants::missing::uintValue) { continue; } @@ -1501,7 +1501,7 @@ void Mesh2D::DeleteMesh(const Polygons& polygon, int deletionOption, bool invert const auto firstNodeIndex = m_edges[e].first; const auto secondNodeIndex = m_edges[e].second; - if (firstNodeIndex == constants::missing::sizetValue || secondNodeIndex == constants::missing::sizetValue) + if (firstNodeIndex == constants::missing::uintValue || secondNodeIndex == constants::missing::uintValue) { continue; } @@ -1518,8 +1518,8 @@ void Mesh2D::DeleteMesh(const Polygons& polygon, int deletionOption, bool invert if (allFaceCircumcentersInPolygon) { - m_edges[e].first = constants::missing::sizetValue; - m_edges[e].second = constants::missing::sizetValue; + m_edges[e].first = constants::missing::uintValue; + m_edges[e].second = constants::missing::uintValue; } } } @@ -1530,12 +1530,12 @@ void Mesh2D::DeleteMesh(const Polygons& polygon, int deletionOption, bool invert const auto edgeMask = EdgesMaskOfFacesInPolygons(polygon, invertDeletion, false); // mark the edges for deletion - for (size_t e = 0; e < GetNumEdges(); ++e) + for (UInt e = 0; e < GetNumEdges(); ++e) { if (edgeMask[e] == 1) { - m_edges[e].first = constants::missing::sizetValue; - m_edges[e].second = constants::missing::sizetValue; + m_edges[e].first = constants::missing::uintValue; + m_edges[e].second = constants::missing::uintValue; } } } @@ -1555,24 +1555,24 @@ void Mesh2D::DeleteHangingEdges() } } -std::vector Mesh2D::PointFaceIndices(const std::vector& points) +std::vector Mesh2D::PointFaceIndices(const std::vector& points) { - const auto numPoints = points.size(); - std::vector result; - result.resize(numPoints, constants::missing::sizetValue); + const auto numPoints = static_cast(points.size()); + std::vector result; + result.resize(numPoints, constants::missing::uintValue); std::vector polygonNodesCache; - for (size_t i = 0; i < numPoints; ++i) + for (UInt i = 0; i < numPoints; ++i) { const auto edgeIndex = FindEdgeCloseToAPoint(points[i]); - if (edgeIndex == constants::missing::sizetValue) + if (edgeIndex == constants::missing::uintValue) { - result[i] = constants::missing::sizetValue; + result[i] = constants::missing::uintValue; continue; } - for (size_t e = 0; e < m_edgesNumFaces[edgeIndex]; ++e) + for (UInt e = 0; e < m_edgesNumFaces[edgeIndex]; ++e) { const auto faceIndex = m_edgesFaces[edgeIndex][e]; ComputeFaceClosedPolygon(faceIndex, polygonNodesCache); @@ -1587,13 +1587,13 @@ std::vector Mesh2D::PointFaceIndices(const std::vector& points) return result; } -std::tuple Mesh2D::IsSegmentCrossingABoundaryEdge(const Point& firstPoint, - const Point& secondPoint) const +std::tuple Mesh2D::IsSegmentCrossingABoundaryEdge(const Point& firstPoint, + const Point& secondPoint) const { double intersectionRatio = std::numeric_limits::max(); - size_t intersectedFace = constants::missing::sizetValue; - size_t intersectedEdge = constants::missing::sizetValue; - for (size_t e = 0; e < GetNumEdges(); ++e) + UInt intersectedFace = constants::missing::uintValue; + UInt intersectedEdge = constants::missing::uintValue; + for (UInt e = 0; e < GetNumEdges(); ++e) { if (!IsEdgeOnBoundary(e)) { @@ -1639,19 +1639,19 @@ Mesh2D::GetPolylineIntersections(const std::vector& polyLine) std::vector facesIntersections(GetNumFaces()); std::vector cumulativeLength(polyLine.size(), 0.0); - for (size_t i = 1; i < polyLine.size(); ++i) + for (UInt i = 1; i < polyLine.size(); ++i) { cumulativeLength[i] = cumulativeLength[i - 1] + ComputeDistance(polyLine[i], polyLine[i - 1], m_projection); } - for (size_t segmentIndex = 0; segmentIndex < polyLine.size() - 1; ++segmentIndex) + for (UInt segmentIndex = 0; segmentIndex < polyLine.size() - 1; ++segmentIndex) { std::ranges::fill(edgesIntersections, EdgeMeshPolylineIntersection()); std::ranges::fill(facesIntersections, FaceMeshPolylineIntersection()); - for (size_t faceIndex = 0; faceIndex < GetNumFaces(); ++faceIndex) + for (UInt faceIndex = 0; faceIndex < GetNumFaces(); ++faceIndex) { - for (size_t e = 0; e < m_numFacesNodes[faceIndex]; ++e) + for (UInt e = 0; e < m_numFacesNodes[faceIndex]; ++e) { const auto edgeIndex = m_facesEdges[faceIndex][e]; @@ -1739,7 +1739,7 @@ Mesh2D::GetPolylineIntersections(const std::vector& polyLine) } // push back the face intersection edge nodes - for (size_t e = 0; e < facesIntersection.edgeIndexses.size(); ++e) + for (UInt e = 0; e < facesIntersection.edgeIndexses.size(); ++e) { const auto edgeIndex = facesIntersection.edgeIndexses[e]; facesIntersection.edgeNodes.emplace_back(edgesIntersections[edgeIndex].edgeFirstNode); @@ -1748,7 +1748,7 @@ Mesh2D::GetPolylineIntersections(const std::vector& polyLine) } // edge intersections are unique - for (size_t e = 0; e < GetNumEdges(); ++e) + for (UInt e = 0; e < GetNumEdges(); ++e) { if (edgesIntersectionsResult[e].polylineDistance < 0) { @@ -1757,7 +1757,7 @@ Mesh2D::GetPolylineIntersections(const std::vector& polyLine) } // face intersections are not unique and a face could have been intersected already - for (size_t f = 0; f < GetNumFaces(); ++f) + for (UInt f = 0; f < GetNumFaces(); ++f) { if (!faceIntersectionsResult[f].edgeNodes.empty() && !facesIntersections[f].edgeNodes.empty()) { @@ -1793,7 +1793,7 @@ std::vector Mesh2D::EdgesMaskOfFacesInPolygons(const Polygons& polygons, bo { // mark all nodes in polygon with 1 std::vector nodeMask(GetNumNodes(), 0); - for (size_t n = 0; n < GetNumNodes(); ++n) + for (UInt n = 0; n < GetNumNodes(); ++n) { const auto [isInPolygon, polygonIndex] = polygons.IsPointInPolygons(m_nodes[n]); if (isInPolygon) @@ -1804,7 +1804,7 @@ std::vector Mesh2D::EdgesMaskOfFacesInPolygons(const Polygons& polygons, bo // mark all edges with both start end end nodes included with 1 std::vector edgeMask(m_edges.size(), 0); - for (size_t e = 0; e < GetNumEdges(); ++e) + for (UInt e = 0; e < GetNumEdges(); ++e) { const auto firstNodeIndex = m_edges[e].first; const auto secondNodeIndex = m_edges[e].second; @@ -1812,15 +1812,15 @@ std::vector Mesh2D::EdgesMaskOfFacesInPolygons(const Polygons& polygons, bo int isEdgeIncluded; if (includeIntersected) { - isEdgeIncluded = ((firstNodeIndex != constants::missing::sizetValue && nodeMask[firstNodeIndex] == 1) || - (secondNodeIndex != constants::missing::sizetValue && nodeMask[secondNodeIndex] == 1)) + isEdgeIncluded = ((firstNodeIndex != constants::missing::uintValue && nodeMask[firstNodeIndex] == 1) || + (secondNodeIndex != constants::missing::uintValue && nodeMask[secondNodeIndex] == 1)) ? 1 : 0; } else { - isEdgeIncluded = (firstNodeIndex != constants::missing::sizetValue && nodeMask[firstNodeIndex] == 1 && - secondNodeIndex != constants::missing::sizetValue && nodeMask[secondNodeIndex] == 1) + isEdgeIncluded = (firstNodeIndex != constants::missing::uintValue && nodeMask[firstNodeIndex] == 1 && + secondNodeIndex != constants::missing::uintValue && nodeMask[secondNodeIndex] == 1) ? 1 : 0; } @@ -1832,13 +1832,13 @@ std::vector Mesh2D::EdgesMaskOfFacesInPolygons(const Polygons& polygons, bo auto secondEdgeMask = edgeMask; if (!includeIntersected) { - for (size_t f = 0; f < GetNumFaces(); ++f) + for (UInt f = 0; f < GetNumFaces(); ++f) { bool isOneEdgeNotIncluded = false; - for (size_t n = 0; n < GetNumFaceEdges(f); ++n) + for (UInt n = 0; n < GetNumFaceEdges(f); ++n) { const auto edgeIndex = m_facesEdges[f][n]; - if (edgeIndex != constants::missing::sizetValue && edgeMask[edgeIndex] == 0) + if (edgeIndex != constants::missing::uintValue && edgeMask[edgeIndex] == 0) { isOneEdgeNotIncluded = true; break; @@ -1847,10 +1847,10 @@ std::vector Mesh2D::EdgesMaskOfFacesInPolygons(const Polygons& polygons, bo if (isOneEdgeNotIncluded) { - for (size_t n = 0; n < GetNumFaceEdges(f); ++n) + for (UInt n = 0; n < GetNumFaceEdges(f); ++n) { const auto edgeIndex = m_facesEdges[f][n]; - if (edgeIndex != constants::missing::sizetValue) + if (edgeIndex != constants::missing::uintValue) { secondEdgeMask[edgeIndex] = 0; } @@ -1862,7 +1862,7 @@ std::vector Mesh2D::EdgesMaskOfFacesInPolygons(const Polygons& polygons, bo // if the selection is inverted, do not delete the edges of included faces if (invertSelection) { - for (size_t e = 0; e < GetNumEdges(); ++e) + for (UInt e = 0; e < GetNumEdges(); ++e) { if (secondEdgeMask[e] == 0) { @@ -1890,7 +1890,7 @@ std::vector Mesh2D::NodeMaskFromEdgeMask(std::vector const& edgeMask) std::vector nodeMask(GetNumNodes(), 0); // compute node mask from edge mask - for (size_t e = 0; e < GetNumEdges(); ++e) + for (UInt e = 0; e < GetNumEdges(); ++e) { if (edgeMask[e] != 1) continue; @@ -1898,11 +1898,11 @@ std::vector Mesh2D::NodeMaskFromEdgeMask(std::vector const& edgeMask) const auto firstNodeIndex = m_edges[e].first; const auto secondNodeIndex = m_edges[e].second; - if (firstNodeIndex != constants::missing::sizetValue) + if (firstNodeIndex != constants::missing::uintValue) { nodeMask[firstNodeIndex] = 1; } - if (secondNodeIndex != constants::missing::sizetValue) + if (secondNodeIndex != constants::missing::uintValue) { nodeMask[secondNodeIndex] = 1; } @@ -1915,7 +1915,7 @@ std::vector Mesh2D::NodeMaskFromPolygon(const Polygons& polygon, bool insid std::vector nodeMask(GetNumNodes(), 0); const auto nodePolygonIndices = polygon.PointsInPolygons(m_nodes); - for (size_t i = 0; i < nodeMask.size(); ++i) + for (UInt i = 0; i < nodeMask.size(); ++i) { auto isInPolygon = nodePolygonIndices[i]; if (!inside) diff --git a/libs/MeshKernel/src/MeshRefinement.cpp b/libs/MeshKernel/src/MeshRefinement.cpp index 6e0558a94..83c2d1682 100644 --- a/libs/MeshKernel/src/MeshRefinement.cpp +++ b/libs/MeshKernel/src/MeshRefinement.cpp @@ -131,10 +131,10 @@ void MeshRefinement::Compute() if (level == 0) { // if one face node is in polygon enable face refinement - for (size_t f = 0; f < m_mesh->GetNumFaces(); ++f) + for (UInt f = 0; f < m_mesh->GetNumFaces(); ++f) { bool activeNodeFound = false; - for (size_t n = 0; n < m_mesh->GetNumFaceEdges(f); ++n) + for (UInt n = 0; n < m_mesh->GetNumFaceEdges(f); ++n) { const auto nodeIndex = m_mesh->m_facesNodes[f][n]; if (m_nodeMask[nodeIndex] != 0 && m_nodeMask[nodeIndex] != -2) @@ -152,9 +152,9 @@ void MeshRefinement::Compute() if (level > 0) { // if one face node is not in polygon disable refinement - for (size_t f = 0; f < m_mesh->GetNumFaces(); f++) + for (UInt f = 0; f < m_mesh->GetNumFaces(); f++) { - for (size_t n = 0; n < m_mesh->GetNumFaceEdges(f); n++) + for (UInt n = 0; n < m_mesh->GetNumFaceEdges(f); n++) { const auto nodeIndex = m_mesh->m_facesNodes[f][n]; if (m_nodeMask[nodeIndex] != 1) @@ -170,8 +170,8 @@ void MeshRefinement::Compute() ComputeIfFaceShouldBeSplit(); - size_t numFacesToRefine = 0; - for (size_t f = 0; f < m_mesh->GetNumFaces(); f++) + UInt numFacesToRefine = 0; + for (UInt f = 0; f < m_mesh->GetNumFaces(); f++) { if (m_faceMask[f] != 0) { @@ -205,39 +205,39 @@ void MeshRefinement::Compute() } } -size_t MeshRefinement::DeleteIsolatedHangingnodes() +meshkernel::UInt MeshRefinement::DeleteIsolatedHangingnodes() { - size_t numRemovedIsolatedHangingNodes = 0; - for (size_t e = 0; e < m_mesh->GetNumEdges(); ++e) + UInt numRemovedIsolatedHangingNodes = 0; + for (UInt e = 0; e < m_mesh->GetNumEdges(); ++e) { const auto brotherEdgeIndex = m_brotherEdges[e]; - if (brotherEdgeIndex == constants::missing::sizetValue) + if (brotherEdgeIndex == constants::missing::uintValue) { continue; } const auto commonNode = m_mesh->FindCommonNode(e, brotherEdgeIndex); - if (commonNode == constants::missing::sizetValue) + if (commonNode == constants::missing::uintValue) { continue; } if (commonNode > 0 && m_mesh->m_nodesNumEdges[commonNode] == 2) { - for (size_t f = 0; f < m_mesh->m_edgesNumFaces[e]; ++f) + for (UInt f = 0; f < m_mesh->m_edgesNumFaces[e]; ++f) { const auto faceIndex = m_mesh->m_edgesFaces[e][f]; if (faceIndex != m_mesh->m_edgesFaces[brotherEdgeIndex][0] && - faceIndex != m_mesh->m_edgesFaces[brotherEdgeIndex][std::min(m_mesh->m_edgesNumFaces[brotherEdgeIndex], static_cast(1))]) + faceIndex != m_mesh->m_edgesFaces[brotherEdgeIndex][std::min(m_mesh->m_edgesNumFaces[brotherEdgeIndex], static_cast(1))]) { throw AlgorithmError("MeshRefinement::DeleteIsolatedHangingnodes: Algorithm error."); } - size_t ee = 0; - size_t nn = 0; - for (size_t n = 0; n < m_mesh->GetNumFaceEdges(faceIndex); ++n) + UInt ee = 0; + UInt nn = 0; + for (UInt n = 0; n < m_mesh->GetNumFaceEdges(faceIndex); ++n) { const auto edgeIndex = m_mesh->m_facesEdges[faceIndex][n]; if (edgeIndex != brotherEdgeIndex) @@ -275,7 +275,7 @@ size_t MeshRefinement::DeleteIsolatedHangingnodes() } // change nod adm of other node - for (size_t ee = 0; ee < m_mesh->m_nodesNumEdges[otherNodeIndex]; ++ee) + for (UInt ee = 0; ee < m_mesh->m_nodesNumEdges[otherNodeIndex]; ++ee) { if (m_mesh->m_nodesEdges[otherNodeIndex][ee] == brotherEdgeIndex) { @@ -289,7 +289,7 @@ size_t MeshRefinement::DeleteIsolatedHangingnodes() m_mesh->DeleteEdge(brotherEdgeIndex); - m_brotherEdges[brotherEdgeIndex] = constants::missing::sizetValue; + m_brotherEdges[brotherEdgeIndex] = constants::missing::uintValue; numRemovedIsolatedHangingNodes++; } @@ -299,21 +299,21 @@ size_t MeshRefinement::DeleteIsolatedHangingnodes() void MeshRefinement::ConnectHangingNodes() { - std::vector edgeEndNodeCache(Mesh::m_maximumNumberOfNodesPerFace, constants::missing::sizetValue); - std::vector hangingNodeCache(Mesh::m_maximumNumberOfNodesPerFace, constants::missing::sizetValue); + std::vector edgeEndNodeCache(Mesh::m_maximumNumberOfNodesPerFace, constants::missing::uintValue); + std::vector hangingNodeCache(Mesh::m_maximumNumberOfNodesPerFace, constants::missing::uintValue); - for (size_t f = 0; f < m_mesh->GetNumFaces(); ++f) + for (UInt f = 0; f < m_mesh->GetNumFaces(); ++f) { - std::ranges::fill(edgeEndNodeCache, constants::missing::sizetValue); - std::ranges::fill(hangingNodeCache, constants::missing::sizetValue); + std::ranges::fill(edgeEndNodeCache, constants::missing::uintValue); + std::ranges::fill(hangingNodeCache, constants::missing::uintValue); const auto numEdges = m_mesh->GetNumFaceEdges(f); if (numEdges > Mesh::m_maximumNumberOfNodesPerFace) { continue; } - size_t numNonHangingNodes = 0; - for (size_t n = 0; n < numEdges; ++n) + UInt numNonHangingNodes = 0; + for (UInt n = 0; n < numEdges; ++n) { const auto e = NextCircularBackwardIndex(n, numEdges); const auto ee = NextCircularForwardIndex(n, numEdges); @@ -332,7 +332,7 @@ void MeshRefinement::ConnectHangingNodes() } edgeEndNodeCache[numNonHangingNodes] = m_mesh->FindCommonNode(edgeIndex, secondEdgeIndex); - if (edgeEndNodeCache[numNonHangingNodes] == constants::missing::sizetValue) + if (edgeEndNodeCache[numNonHangingNodes] == constants::missing::uintValue) { throw AlgorithmError("MeshRefinement::connect_hanging_nodes: Could not find common node."); } @@ -340,7 +340,7 @@ void MeshRefinement::ConnectHangingNodes() if (m_brotherEdges[edgeIndex] == firstEdgeIndex) { hangingNodeCache[numNonHangingNodes] = m_mesh->FindCommonNode(edgeIndex, firstEdgeIndex); - if (hangingNodeCache[numNonHangingNodes] == constants::missing::sizetValue) + if (hangingNodeCache[numNonHangingNodes] == constants::missing::uintValue) { throw AlgorithmError("MeshRefinement::connect_hanging_nodes: Could not find common node."); } @@ -358,9 +358,9 @@ void MeshRefinement::ConnectHangingNodes() switch (numHangingNodes) { case 1: // one hanging node - for (size_t n = 0; n < numNonHangingNodes; ++n) + for (UInt n = 0; n < numNonHangingNodes; ++n) { - if (hangingNodeCache[n] == constants::missing::sizetValue) + if (hangingNodeCache[n] == constants::missing::uintValue) { continue; } @@ -375,9 +375,9 @@ void MeshRefinement::ConnectHangingNodes() } break; case 2: // two hanging node - for (size_t n = 0; n < numNonHangingNodes; ++n) + for (UInt n = 0; n < numNonHangingNodes; ++n) { - if (hangingNodeCache[n] == constants::missing::sizetValue) + if (hangingNodeCache[n] == constants::missing::uintValue) { continue; } @@ -385,19 +385,19 @@ void MeshRefinement::ConnectHangingNodes() const auto e = NextCircularBackwardIndex(n, numNonHangingNodes); const auto ee = NextCircularForwardIndex(n, numNonHangingNodes); const auto eee = NextCircularForwardIndex(n + 1, numNonHangingNodes); - if (hangingNodeCache[e] != constants::missing::sizetValue) // left neighbor + if (hangingNodeCache[e] != constants::missing::uintValue) // left neighbor { m_mesh->ConnectNodes(hangingNodeCache[e], hangingNodeCache[n]); m_mesh->ConnectNodes(hangingNodeCache[n], edgeEndNodeCache[ee]); m_mesh->ConnectNodes(edgeEndNodeCache[ee], hangingNodeCache[e]); } - else if (hangingNodeCache[ee] != constants::missing::sizetValue) // right neighbor + else if (hangingNodeCache[ee] != constants::missing::uintValue) // right neighbor { m_mesh->ConnectNodes(hangingNodeCache[n], hangingNodeCache[ee]); m_mesh->ConnectNodes(hangingNodeCache[ee], edgeEndNodeCache[eee]); m_mesh->ConnectNodes(edgeEndNodeCache[eee], hangingNodeCache[n]); } - else if (hangingNodeCache[eee] != constants::missing::sizetValue) // hanging nodes must be opposing + else if (hangingNodeCache[eee] != constants::missing::uintValue) // hanging nodes must be opposing { m_mesh->ConnectNodes(hangingNodeCache[n], hangingNodeCache[eee]); } @@ -413,9 +413,9 @@ void MeshRefinement::ConnectHangingNodes() switch (numHangingNodes) { case 1: // one hanging node - for (size_t n = 0; n < numNonHangingNodes; ++n) + for (UInt n = 0; n < numNonHangingNodes; ++n) { - if (hangingNodeCache[n] == constants::missing::sizetValue) + if (hangingNodeCache[n] == constants::missing::uintValue) { continue; } @@ -425,15 +425,15 @@ void MeshRefinement::ConnectHangingNodes() } break; case 2: // two hanging node - for (size_t n = 0; n < numNonHangingNodes; ++n) + for (UInt n = 0; n < numNonHangingNodes; ++n) { - if (hangingNodeCache[n] == constants::missing::sizetValue) + if (hangingNodeCache[n] == constants::missing::uintValue) { continue; } const auto e = NextCircularBackwardIndex(n, numNonHangingNodes); const auto ee = NextCircularForwardIndex(n, numNonHangingNodes); - if (hangingNodeCache[e] != constants::missing::sizetValue) // left neighbor + if (hangingNodeCache[e] != constants::missing::uintValue) // left neighbor { m_mesh->ConnectNodes(hangingNodeCache[n], hangingNodeCache[e]); } @@ -455,20 +455,20 @@ void MeshRefinement::ConnectHangingNodes() } } -void MeshRefinement::RefineFacesBySplittingEdges(size_t numEdgesBeforeRefinement) +void MeshRefinement::RefineFacesBySplittingEdges(UInt numEdgesBeforeRefinement) { // Add new nodes where required - std::vector notHangingFaceNodes; + std::vector notHangingFaceNodes; notHangingFaceNodes.reserve(Mesh::m_maximumNumberOfNodesPerFace); - std::vector nonHangingEdges; + std::vector nonHangingEdges; nonHangingEdges.reserve(Mesh::m_maximumNumberOfNodesPerFace); std::vector facePolygonWithoutHangingNodes; facePolygonWithoutHangingNodes.reserve(Mesh::m_maximumNumberOfNodesPerFace); - std::vector localEdgesNumFaces; + std::vector localEdgesNumFaces; localEdgesNumFaces.reserve(Mesh::m_maximumNumberOfEdgesPerFace); - for (size_t e = 0; e < m_mesh->GetNumEdges(); e++) + for (UInt e = 0; e < m_mesh->GetNumEdges(); e++) { if (m_edgeMask[e] == 0) { @@ -523,7 +523,7 @@ void MeshRefinement::RefineFacesBySplittingEdges(size_t numEdgesBeforeRefinement } } - for (size_t f = 0; f < m_mesh->GetNumFaces(); f++) + for (UInt f = 0; f < m_mesh->GetNumFaces(); f++) { if (m_faceMask[f] == 0) { @@ -533,7 +533,7 @@ void MeshRefinement::RefineFacesBySplittingEdges(size_t numEdgesBeforeRefinement const auto numEdges = m_mesh->GetNumFaceEdges(f); // check if the parent face is crossed by the enclosing polygon bool isParentCrossed = false; - for (size_t e = 0; e < numEdges; ++e) + for (UInt e = 0; e < numEdges; ++e) { const auto n = m_mesh->m_facesNodes[f][e]; if (m_nodeMask[n] != 1) @@ -545,11 +545,11 @@ void MeshRefinement::RefineFacesBySplittingEdges(size_t numEdgesBeforeRefinement m_mesh->ComputeFaceClosedPolygonWithLocalMappings(f, m_polygonNodesCache, m_localNodeIndicesCache, m_globalEdgeIndicesCache); - size_t numBrotherEdges = 0; + UInt numBrotherEdges = 0; notHangingFaceNodes.clear(); nonHangingEdges.clear(); - for (size_t e = 0; e < numEdges; e++) + for (UInt e = 0; e < numEdges; e++) { const auto firstEdge = NextCircularBackwardIndex(e, numEdges); const auto secondEdge = NextCircularForwardIndex(e, numEdges); @@ -563,23 +563,23 @@ void MeshRefinement::RefineFacesBySplittingEdges(size_t numEdgesBeforeRefinement mappedEdge = m_localNodeIndicesCache[secondEdge]; const auto secondEdgeIndex = m_mesh->m_facesEdges[f][mappedEdge]; - if (edgeIndex == constants::missing::sizetValue) + if (edgeIndex == constants::missing::uintValue) { continue; } - if (m_brotherEdges[edgeIndex] == secondEdgeIndex && secondEdgeIndex != constants::missing::sizetValue) + if (m_brotherEdges[edgeIndex] == secondEdgeIndex && secondEdgeIndex != constants::missing::uintValue) { numBrotherEdges++; const auto newNode = m_mesh->FindCommonNode(edgeIndex, m_brotherEdges[edgeIndex]); - if (newNode == constants::missing::sizetValue) + if (newNode == constants::missing::uintValue) { throw AlgorithmError("MeshRefinement::RefineFacesBySplittingEdges: Could not find common node."); } notHangingFaceNodes.emplace_back(newNode); } - else if ((m_brotherEdges[edgeIndex] != firstEdgeIndex || m_brotherEdges[edgeIndex] == constants::missing::sizetValue) && m_edgeMask[edgeIndex] != 0) + else if ((m_brotherEdges[edgeIndex] != firstEdgeIndex || m_brotherEdges[edgeIndex] == constants::missing::uintValue) && m_edgeMask[edgeIndex] != 0) { notHangingFaceNodes.emplace_back(m_edgeMask[edgeIndex]); } @@ -590,7 +590,7 @@ void MeshRefinement::RefineFacesBySplittingEdges(size_t numEdgesBeforeRefinement } // check if start of this link is hanging - if (m_brotherEdges[edgeIndex] != firstEdgeIndex || firstEdgeIndex != constants::missing::sizetValue) + if (m_brotherEdges[edgeIndex] != firstEdgeIndex || firstEdgeIndex != constants::missing::uintValue) { nonHangingEdges.emplace_back(e); } @@ -605,7 +605,7 @@ void MeshRefinement::RefineFacesBySplittingEdges(size_t numEdgesBeforeRefinement const auto mappedEdge = m_localNodeIndicesCache[edge]; const auto edgeIndex = m_mesh->m_facesEdges[f][mappedEdge]; - if (edgeIndex != constants::missing::sizetValue) + if (edgeIndex != constants::missing::uintValue) { localEdgesNumFaces.emplace_back(m_mesh->m_edgesNumFaces[edgeIndex]); } @@ -670,16 +670,16 @@ void MeshRefinement::RefineFacesBySplittingEdges(size_t numEdgesBeforeRefinement } else { - for (size_t n = 0; n < notHangingFaceNodes.size(); ++n) + for (UInt n = 0; n < notHangingFaceNodes.size(); ++n) { - const auto nn = NextCircularForwardIndex(n, notHangingFaceNodes.size()); + const auto nn = NextCircularForwardIndex(n, static_cast(notHangingFaceNodes.size())); m_mesh->ConnectNodes(notHangingFaceNodes[n], notHangingFaceNodes[nn]); } } } // Split original edges - for (size_t e = 0; e < numEdgesBeforeRefinement; ++e) + for (UInt e = 0; e < numEdgesBeforeRefinement; ++e) { if (m_edgeMask[e] > 0) { @@ -694,11 +694,11 @@ void MeshRefinement::RefineFacesBySplittingEdges(size_t numEdgesBeforeRefinement void MeshRefinement::ComputeNodeMaskAtPolygonPerimeter() { - for (size_t f = 0; f < m_mesh->GetNumFaces(); f++) + for (UInt f = 0; f < m_mesh->GetNumFaces(); f++) { bool crossing = false; const auto numnodes = m_mesh->GetNumFaceEdges(f); - for (size_t n = 0; n < numnodes; n++) + for (UInt n = 0; n < numnodes; n++) { const auto nodeIndex = m_mesh->m_facesNodes[f][n]; if (m_nodeMask[nodeIndex] == 0) @@ -711,7 +711,7 @@ void MeshRefinement::ComputeNodeMaskAtPolygonPerimeter() if (crossing) { m_faceMask[f] = 0; - for (size_t n = 0; n < numnodes; n++) + for (UInt n = 0; n < numnodes; n++) { const auto nodeIndex = m_mesh->m_facesNodes[f][n]; if (m_nodeMask[nodeIndex] == 1) @@ -729,14 +729,14 @@ void MeshRefinement::ComputeRefinementMasksFromSamples() std::ranges::fill(m_faceMask, 0); m_polygonNodesCache.resize(Mesh::m_maximumNumberOfNodesPerFace + 1); - m_localNodeIndicesCache.resize(Mesh::m_maximumNumberOfNodesPerFace + 1, constants::missing::sizetValue); - m_globalEdgeIndicesCache.resize(Mesh::m_maximumNumberOfEdgesPerFace + 1, constants::missing::sizetValue); + m_localNodeIndicesCache.resize(Mesh::m_maximumNumberOfNodesPerFace + 1, constants::missing::uintValue); + m_globalEdgeIndicesCache.resize(Mesh::m_maximumNumberOfEdgesPerFace + 1, constants::missing::uintValue); m_refineEdgeCache.resize(Mesh::m_maximumNumberOfEdgesPerFace, 0); // Compute all interpolated values m_interpolant->Compute(); - for (size_t f = 0; f < m_mesh->GetNumFaces(); f++) + for (UInt f = 0; f < m_mesh->GetNumFaces(); f++) { FindHangingNodes(f); @@ -744,7 +744,7 @@ void MeshRefinement::ComputeRefinementMasksFromSamples() } } -void MeshRefinement::FindHangingNodes(size_t face) +void MeshRefinement::FindHangingNodes(UInt face) { const auto numFaceNodes = m_mesh->GetNumFaceEdges(face); @@ -759,23 +759,23 @@ void MeshRefinement::FindHangingNodes(size_t face) std::fill(m_isHangingEdgeCache.begin(), m_isHangingEdgeCache.end(), false); auto kknod = numFaceNodes; - for (size_t n = 0; n < numFaceNodes; n++) + for (UInt n = 0; n < numFaceNodes; n++) { const auto edgeIndex = m_mesh->m_facesEdges[face][n]; // check if the parent edge is in the cell - if (m_brotherEdges[edgeIndex] != constants::missing::sizetValue) + if (m_brotherEdges[edgeIndex] != constants::missing::uintValue) { const auto e = NextCircularBackwardIndex(n, numFaceNodes); const auto ee = NextCircularForwardIndex(n, numFaceNodes); const auto firstEdgeIndex = m_mesh->m_facesEdges[face][e]; const auto secondEdgeIndex = m_mesh->m_facesEdges[face][ee]; - size_t commonNode = constants::missing::sizetValue; + UInt commonNode = constants::missing::uintValue; if (m_brotherEdges[edgeIndex] == firstEdgeIndex) { commonNode = m_mesh->FindCommonNode(edgeIndex, firstEdgeIndex); - if (commonNode == constants::missing::sizetValue) + if (commonNode == constants::missing::uintValue) { throw AlgorithmError("MeshRefinement::FindHangingNodes: Could not find common node."); } @@ -783,16 +783,16 @@ void MeshRefinement::FindHangingNodes(size_t face) else if (m_brotherEdges[edgeIndex] == secondEdgeIndex) { commonNode = m_mesh->FindCommonNode(edgeIndex, secondEdgeIndex); - if (commonNode == constants::missing::sizetValue) + if (commonNode == constants::missing::uintValue) { throw AlgorithmError("MeshRefinement::FindHangingNodes: Could not find common node."); } } - if (commonNode != constants::missing::sizetValue) + if (commonNode != constants::missing::uintValue) { m_isHangingEdgeCache[n] = true; - for (size_t nn = 0; nn < numFaceNodes; nn++) + for (UInt nn = 0; nn < numFaceNodes; nn++) { kknod = NextCircularForwardIndex(kknod, numFaceNodes); @@ -807,9 +807,9 @@ void MeshRefinement::FindHangingNodes(size_t face) } } -size_t MeshRefinement::CountHangingNodes() const +meshkernel::UInt MeshRefinement::CountHangingNodes() const { - size_t result = 0; + meshkernel::UInt result = 0; for (const auto& v : m_isHangingNodeCache) { if (v) @@ -820,9 +820,9 @@ size_t MeshRefinement::CountHangingNodes() const return result; } -size_t MeshRefinement::CountHangingEdges() const +meshkernel::UInt MeshRefinement::CountHangingEdges() const { - size_t result = 0; + meshkernel::UInt result = 0; for (const auto& v : m_isHangingEdgeCache) { if (v) @@ -833,13 +833,13 @@ size_t MeshRefinement::CountHangingEdges() const return result; } -size_t MeshRefinement::CountEdgesToRefine(size_t face) const +meshkernel::UInt MeshRefinement::CountEdgesToRefine(UInt face) const { const auto numFaceNodes = m_mesh->GetNumFaceEdges(face); - size_t result = 0; + UInt result = 0; - for (size_t n = 0; n < numFaceNodes; n++) + for (UInt n = 0; n < numFaceNodes; n++) { const auto edgeIndex = m_mesh->m_facesEdges[face][n]; if (m_edgeMask[edgeIndex] != 0) @@ -850,7 +850,7 @@ size_t MeshRefinement::CountEdgesToRefine(size_t face) const return result; } -void MeshRefinement::ComputeRefinementMasksFromSamples(size_t face) +void MeshRefinement::ComputeRefinementMasksFromSamples(UInt face) { if (IsEqual(m_interpolant->GetFaceResult(face), constants::missing::doubleValue)) @@ -868,7 +868,7 @@ void MeshRefinement::ComputeRefinementMasksFromSamples(size_t face) { return; } - for (size_t i = 0; i < m_mesh->GetNumFaceEdges(face); i++) + for (UInt i = 0; i < m_mesh->GetNumFaceEdges(face); i++) { numEdgesToBeRefined++; m_refineEdgeCache[i] = 1; @@ -922,7 +922,7 @@ void MeshRefinement::ComputeRefinementMasksFromSamples(size_t face) if (numEdgesToBeRefined > 0) { numEdgesToBeRefined = 0; - for (size_t i = 0; i < m_mesh->GetNumFaceEdges(face); i++) + for (UInt i = 0; i < m_mesh->GetNumFaceEdges(face); i++) { if (m_refineEdgeCache[i] == 1 || m_isHangingNodeCache[i]) { @@ -935,7 +935,7 @@ void MeshRefinement::ComputeRefinementMasksFromSamples(size_t face) { if (numEdgesToBeRefined == m_mesh->GetNumFaceEdges(face)) { - for (size_t i = 0; i < m_mesh->GetNumFaceEdges(face); i++) + for (UInt i = 0; i < m_mesh->GetNumFaceEdges(face); i++) { if (!m_isHangingNodeCache[i]) { @@ -964,7 +964,7 @@ void MeshRefinement::ComputeRefinementMasksFromSamples(size_t face) if (m_refineEdgeCache[n] == 1) { const auto edgeIndex = m_mesh->m_facesEdges[face][n]; - if (edgeIndex != constants::missing::sizetValue) + if (edgeIndex != constants::missing::uintValue) { m_edgeMask[edgeIndex] = 1; } @@ -977,11 +977,11 @@ void MeshRefinement::ComputeFaceLocationTypes() { m_faceLocationType.resize(m_mesh->GetNumFaces()); std::ranges::fill(m_faceLocationType, FaceLocation::Water); - for (size_t face = 0; face < m_mesh->GetNumFaces(); face++) + for (UInt face = 0; face < m_mesh->GetNumFaces(); face++) { double maxVal = -std::numeric_limits::max(); double minVal = std::numeric_limits::max(); - for (size_t e = 0; e < m_mesh->GetNumFaceEdges(face); ++e) + for (UInt e = 0; e < m_mesh->GetNumFaceEdges(face); ++e) { const auto node = m_mesh->m_facesNodes[face][e]; const auto val = m_interpolant->GetNodeResult(node); @@ -1000,7 +1000,7 @@ void MeshRefinement::ComputeFaceLocationTypes() } } -bool MeshRefinement::IsRefineNeededBasedOnCourantCriteria(size_t edge, double depthValues) const +bool MeshRefinement::IsRefineNeededBasedOnCourantCriteria(UInt edge, double depthValues) const { const double maxDtCourant = 120.0; const double newEdgeLength = 0.5 * m_mesh->m_edgeLengths[edge]; @@ -1013,17 +1013,17 @@ bool MeshRefinement::IsRefineNeededBasedOnCourantCriteria(size_t edge, double de void MeshRefinement::ComputeEdgesRefinementMask() { bool repeat = true; - size_t iter = 0; - const size_t numMaxIterations = 6; + UInt iter = 0; + const UInt numMaxIterations = 6; std::vector isQuadEdge(Mesh::m_numNodesQuads); - std::vector numOfEdges(Mesh::m_maximumNumberOfEdgesPerFace); + std::vector numOfEdges(Mesh::m_maximumNumberOfEdgesPerFace); while (repeat && iter < numMaxIterations) { repeat = false; iter++; - for (size_t f = 0; f < m_mesh->GetNumFaces(); f++) + for (UInt f = 0; f < m_mesh->GetNumFaces(); f++) { if (m_faceMask[f] == 0) { @@ -1038,7 +1038,7 @@ void MeshRefinement::ComputeEdgesRefinementMask() const auto numNodesEffective = numFaceNodes - numHangingNodes; if (numNodesEffective != Mesh::m_numNodesQuads) { - for (size_t n = 0; n < numFaceNodes; n++) + for (UInt n = 0; n < numFaceNodes; n++) { const auto e = NextCircularBackwardIndex(n, numFaceNodes); const auto ee = NextCircularForwardIndex(n, numFaceNodes); @@ -1058,8 +1058,8 @@ void MeshRefinement::ComputeEdgesRefinementMask() if (numNodesEffective == Mesh::m_numNodesQuads) { // number the links in the cell, links that share a hanging node will have the same number - size_t num = 0; - for (size_t n = 0; n < numFaceNodes; n++) + UInt num = 0; + for (UInt n = 0; n < numFaceNodes; n++) { const auto edgeIndex = m_mesh->m_facesEdges[f][n]; numOfEdges[n] = num; @@ -1088,10 +1088,10 @@ void MeshRefinement::ComputeEdgesRefinementMask() throw AlgorithmError("MeshRefinement::ComputeEdgesRefinementMask: The number the links in the cell is not equals 3."); } - size_t numEdgesToRefine = 0; - size_t firstEdgeIndex = 0; - size_t secondEdgeIndex = 0; - for (size_t i = 0; i < Mesh::m_numNodesQuads; i++) + UInt numEdgesToRefine = 0; + UInt firstEdgeIndex = 0; + UInt secondEdgeIndex = 0; + for (UInt i = 0; i < Mesh::m_numNodesQuads; i++) { if (isQuadEdge[i] != 0) { @@ -1115,7 +1115,7 @@ void MeshRefinement::ComputeEdgesRefinementMask() refineAllEdges = true; } - for (size_t n = 0; n < numFaceNodes; n++) + for (UInt n = 0; n < numFaceNodes; n++) { const auto edgeIndex = m_mesh->m_facesEdges[f][n]; if (m_edgeMask[edgeIndex] > 0) @@ -1157,9 +1157,9 @@ void MeshRefinement::ComputeEdgesRefinementMask() void MeshRefinement::ComputeIfFaceShouldBeSplit() { - const size_t maxiter = 1000; - size_t num = 1; - size_t iter = 0; + const UInt maxiter = 1000; + UInt num = 1; + UInt iter = 0; while (num != 0) { iter++; @@ -1169,7 +1169,7 @@ void MeshRefinement::ComputeIfFaceShouldBeSplit() } num = 0; - for (size_t f = 0; f < m_mesh->GetNumFaces(); f++) + for (UInt f = 0; f < m_mesh->GetNumFaces(); f++) { if (m_faceMask[f] != 0 && m_faceMask[f] != -1) { @@ -1192,7 +1192,7 @@ void MeshRefinement::ComputeIfFaceShouldBeSplit() return; } - for (size_t n = 0; n < numFaceNodes; n++) + for (UInt n = 0; n < numFaceNodes; n++) { const auto edgeIndex = m_mesh->m_facesEdges[f][n]; if (m_isHangingEdgeCache[n] && m_edgeMask[edgeIndex] > 0) @@ -1202,7 +1202,7 @@ void MeshRefinement::ComputeIfFaceShouldBeSplit() } // compute the effective face type - const auto numNodesEffective = numFaceNodes - static_cast(static_cast(numHangingEdges) / 2.0); + const auto numNodesEffective = numFaceNodes - static_cast(static_cast(numHangingEdges) / 2.0); if (2 * (numFaceNodes - numNodesEffective) != numHangingEdges) { // uneven number of brotherlinks @@ -1227,7 +1227,7 @@ void MeshRefinement::ComputeIfFaceShouldBeSplit() m_faceMask[f] = -2; } - for (size_t n = 0; n < numFaceNodes; n++) + for (UInt n = 0; n < numFaceNodes; n++) { const auto edgeIndex = m_mesh->m_facesEdges[f][n]; if (!m_isHangingEdgeCache[n] && m_edgeMask[edgeIndex] == 0) @@ -1248,12 +1248,12 @@ void MeshRefinement::ComputeIfFaceShouldBeSplit() void MeshRefinement::FindBrotherEdges() { m_brotherEdges.resize(m_mesh->GetNumEdges()); - std::ranges::fill(m_brotherEdges, constants::missing::sizetValue); + std::ranges::fill(m_brotherEdges, constants::missing::uintValue); - for (size_t n = 0; n < m_mesh->GetNumNodes(); n++) + for (UInt n = 0; n < m_mesh->GetNumNodes(); n++) { const auto numEdgesNodes = m_mesh->m_nodesNumEdges[n]; - for (size_t e = 0; e < numEdgesNodes; e++) + for (UInt e = 0; e < numEdgesNodes; e++) { const auto firstEdgeIndex = m_mesh->m_nodesEdges[n][e]; @@ -1321,7 +1321,7 @@ void MeshRefinement::SmoothRefinementMasks() { std::fill(splitEdge.begin(), splitEdge.end(), false); - for (size_t f = 0; f < m_mesh->GetNumFaces(); ++f) + for (UInt f = 0; f < m_mesh->GetNumFaces(); ++f) { if (m_faceMask[f] != 1) { @@ -1330,7 +1330,7 @@ void MeshRefinement::SmoothRefinementMasks() const auto numEdges = m_mesh->GetNumFaceEdges(f); - for (size_t e = 0; e < numEdges; ++e) + for (UInt e = 0; e < numEdges; ++e) { const auto edgeIndex = m_mesh->m_facesEdges[f][e]; const auto nextEdgeIndex = NextCircularForwardIndex(e, numEdges); @@ -1346,11 +1346,11 @@ void MeshRefinement::SmoothRefinementMasks() } // update face refinement mask - for (size_t f = 0; f < m_mesh->GetNumFaces(); ++f) + for (UInt f = 0; f < m_mesh->GetNumFaces(); ++f) { const auto numEdges = m_mesh->GetNumFaceEdges(f); - for (size_t e = 0; e < numEdges; ++e) + for (UInt e = 0; e < numEdges; ++e) { const auto edgeIndex = m_mesh->m_facesEdges[f][e]; if (splitEdge[edgeIndex]) @@ -1361,7 +1361,7 @@ void MeshRefinement::SmoothRefinementMasks() } // update edge refinement mask - for (size_t f = 0; f < m_mesh->GetNumFaces(); ++f) + for (UInt f = 0; f < m_mesh->GetNumFaces(); ++f) { if (m_faceMask[f] != 1) { @@ -1370,7 +1370,7 @@ void MeshRefinement::SmoothRefinementMasks() const auto numEdges = m_mesh->GetNumFaceEdges(f); - for (size_t e = 0; e < numEdges; ++e) + for (UInt e = 0; e < numEdges; ++e) { const auto edgeIndex = m_mesh->m_facesEdges[f][e]; const auto nextEdgeIndex = NextCircularForwardIndex(e, numEdges); diff --git a/libs/MeshKernel/src/Network1D.cpp b/libs/MeshKernel/src/Network1D.cpp index 8969f4845..d7004947a 100644 --- a/libs/MeshKernel/src/Network1D.cpp +++ b/libs/MeshKernel/src/Network1D.cpp @@ -39,7 +39,7 @@ Network1D::Network1D(std::vector> const& polyLines, m_chainages.resize(m_polyLines.size()); // start and end polyline chainages should always be accounted for - for (size_t i = 0; i < m_polyLines.size(); ++i) + for (UInt i = 0; i < m_polyLines.size(); ++i) { auto const nodalChainages = ComputePolyLineNodalChainages(m_polyLines[i], projection); m_chainages[i].push_back(nodalChainages.front()); @@ -57,7 +57,7 @@ void Network1D::ComputeFixedChainages(std::vector> const& fi throw std::invalid_argument("Network1D::ComputeFixedChainages: The polyline vector and the fixed chainages vector size must be the same"); } - for (size_t p = 0; p < m_polyLines.size(); ++p) + for (UInt p = 0; p < m_polyLines.size(); ++p) { if (fixedChainagesByPolyline[p].empty()) { @@ -102,20 +102,20 @@ void Network1D::ComputeFixedChainages(std::vector> const& fi void Network1D::ComputeOffsettedChainages(double offset) { - for (size_t p = 0; p < m_polyLines.size(); ++p) + for (UInt p = 0; p < m_polyLines.size(); ++p) { // Sort whatever is there std::sort(m_chainages[p].begin(), m_chainages[p].end()); std::vector chainagesAtInterval; - for (size_t i = 1; i < m_chainages[p].size(); ++i) + for (UInt i = 1; i < m_chainages[p].size(); ++i) { double const segmentLength = m_chainages[p][i] - m_chainages[p][i - 1]; if (segmentLength < offset) { continue; } - auto const numberOfNewSegments = static_cast(std::ceil(segmentLength / offset)); - for (size_t j = 1; j < numberOfNewSegments; j++) + auto const numberOfNewSegments = static_cast(std::ceil(segmentLength / offset)); + for (UInt j = 1; j < numberOfNewSegments; j++) { chainagesAtInterval.push_back(m_chainages[p][i - 1] + j * (segmentLength / static_cast(numberOfNewSegments))); } @@ -129,7 +129,7 @@ void Network1D::ComputeOffsettedChainages(double offset) std::vector> Network1D::ComputeDiscretizationsFromChainages() { std::vector> result; - for (size_t p = 0; p < m_polyLines.size(); ++p) + for (UInt p = 0; p < m_polyLines.size(); ++p) { result.emplace_back(ComputePolyLineDiscretization(m_polyLines[p], m_chainages[p], m_projection)); } diff --git a/libs/MeshKernel/src/Operations.cpp b/libs/MeshKernel/src/Operations.cpp index 419485706..a964d7242 100644 --- a/libs/MeshKernel/src/Operations.cpp +++ b/libs/MeshKernel/src/Operations.cpp @@ -46,12 +46,12 @@ namespace meshkernel return a.x * b.x + a.y * b.y + a.z * b.z; } - std::vector> FindIndices(const std::vector& vec, - size_t start, - size_t end, - double separator) + std::vector> FindIndices(const std::vector& vec, + UInt start, + UInt end, + double separator) { - std::vector> result; + std::vector> result; if (vec.empty()) { @@ -65,7 +65,7 @@ namespace meshkernel } bool inRange = false; - size_t startRange; + UInt startRange; for (auto n = start; n < end; n++) { @@ -84,15 +84,15 @@ namespace meshkernel // in case no separator was found if (inRange) { - result.emplace_back(startRange, vec.size() - 1); + result.emplace_back(startRange, static_cast(vec.size() - 1)); } return result; } - size_t NextCircularForwardIndex(size_t currentIndex, size_t size) + UInt NextCircularForwardIndex(UInt currentIndex, UInt size) { - size_t index = currentIndex + 1; + UInt index = currentIndex + 1; if (index >= size) { index = index - size; @@ -100,7 +100,7 @@ namespace meshkernel return index; } - size_t NextCircularBackwardIndex(size_t currentIndex, size_t size) + UInt NextCircularBackwardIndex(UInt currentIndex, UInt size) { if (currentIndex == 0) { @@ -146,18 +146,18 @@ namespace meshkernel const std::vector& polygonNodes, const Projection& projection, Point polygonCenter, - size_t startNode, - size_t endNode) + UInt startNode, + UInt endNode) { if (polygonNodes.empty()) { return true; } - if (startNode == constants::missing::sizetValue && endNode == constants::missing::sizetValue) + if (startNode == constants::missing::uintValue && endNode == constants::missing::uintValue) { startNode = 0; - endNode = polygonNodes.size() - 1; // closed polygon + endNode = static_cast(polygonNodes.size()) - 1; // closed polygon } if (endNode <= startNode) @@ -224,7 +224,7 @@ namespace meshkernel // get 3D polygon coordinates std::vector cartesian3DPoints; cartesian3DPoints.reserve(currentPolygonSize); - for (size_t i = 0; i < currentPolygonSize; ++i) + for (UInt i = 0; i < currentPolygonSize; ++i) { cartesian3DPoints.emplace_back(SphericalToCartesian3D(polygonNodes[startNode + i])); } @@ -232,7 +232,7 @@ namespace meshkernel // enlarge around polygon const double enlargementFactor = 1.000001; const Cartesian3DPoint polygonCenterCartesian3D{SphericalToCartesian3D(polygonCenter)}; - for (size_t i = 0; i < currentPolygonSize; ++i) + for (UInt i = 0; i < currentPolygonSize; ++i) { cartesian3DPoints[i].x = polygonCenterCartesian3D.x + enlargementFactor * (cartesian3DPoints[i].x - polygonCenterCartesian3D.x); cartesian3DPoints[i].y = polygonCenterCartesian3D.y + enlargementFactor * (cartesian3DPoints[i].y - polygonCenterCartesian3D.y); @@ -248,7 +248,7 @@ namespace meshkernel int inside = 0; // loop over the polygon nodes - for (size_t i = 0; i < currentPolygonSize - 1; ++i) + for (UInt i = 0; i < currentPolygonSize - 1; ++i) { const auto nextNode = NextCircularForwardIndex(i, currentPolygonSize); const auto xiXxip1 = VectorProduct(cartesian3DPoints[i], cartesian3DPoints[nextNode]); @@ -740,8 +740,8 @@ namespace meshkernel { auto minX = std::numeric_limits::max(); auto minY = std::numeric_limits::max(); - const auto numPoints = polygon.size(); - for (size_t i = 0; i < numPoints; ++i) + const auto numPoints = static_cast(polygon.size()); + for (UInt i = 0; i < numPoints; ++i) { minX = std::min(polygon[i].x, minX); if (abs(polygon[i].y) < abs(minY)) @@ -753,7 +753,7 @@ namespace meshkernel if (projection == Projection::spherical) { double maxX = std::numeric_limits::lowest(); - for (size_t i = 0; i < numPoints; ++i) + for (UInt i = 0; i < numPoints; ++i) { maxX = std::max(polygon[i].x, maxX); } @@ -761,7 +761,7 @@ namespace meshkernel if (maxX - minX > 180.0) { const double deltaX = maxX - 180.0; - for (size_t i = 0; i < numPoints; ++i) + for (UInt i = 0; i < numPoints; ++i) { if (polygon[i].x < deltaX) { @@ -1170,8 +1170,8 @@ namespace meshkernel double yCenterOfMass = 0.0; const double minArea = 1e-8; const Point reference = ReferencePoint(polygon, projection); - const auto numberOfPointsOpenedPolygon = polygon.size() - 1; - for (size_t n = 0; n < numberOfPointsOpenedPolygon; n++) + const auto numberOfPointsOpenedPolygon = static_cast(polygon.size()) - 1; + for (UInt n = 0; n < numberOfPointsOpenedPolygon; n++) { const auto nextNode = NextCircularForwardIndex(n, numberOfPointsOpenedPolygon); double dx0 = GetDx(reference, polygon[n], projection); @@ -1219,7 +1219,7 @@ namespace meshkernel std::vector result(v.size()); result[0] = 0; - for (size_t i = 1; i < v.size(); ++i) + for (UInt i = 1; i < v.size(); ++i) { result[i] = result[i - 1] + ComputeDistance(v[i - 1], v[i], projection); } @@ -1229,7 +1229,7 @@ namespace meshkernel return {result, totalDistance}; } const double inverseTotalDistance = 1.0 / totalDistance; - for (size_t i = 1; i < v.size(); ++i) + for (UInt i = 1; i < v.size(); ++i) { result[i] = result[i] * inverseTotalDistance; } @@ -1242,8 +1242,8 @@ namespace meshkernel const std::vector& bottomDiscretization, const std::vector& upperDiscretization, const Projection& projection, - size_t numM, - size_t numN) + UInt numM, + UInt numN) { const auto [sideOneAdimensional, totalLengthOne] = ComputeAdimensionalDistancesFromPointSerie(leftDiscretization, projection); const auto [sideTwoAdimensional, totalLengthTwo] = ComputeAdimensionalDistancesFromPointSerie(rightDiscretization, projection); @@ -1256,9 +1256,9 @@ namespace meshkernel std::vector> iWeightFactor(numMPoints, std::vector(numNPoints)); std::vector> jWeightFactor(numMPoints, std::vector(numNPoints)); - for (size_t m = 0; m < numMPoints; m++) + for (UInt m = 0; m < numMPoints; m++) { - for (size_t n = 0; n < numNPoints; n++) + for (UInt n = 0; n < numNPoints; n++) { const double mWeight = double(m) / double(numM); const double nWeight = double(n) / double(numN); @@ -1272,9 +1272,9 @@ namespace meshkernel std::vector> weightTwo(numMPoints, std::vector(numNPoints)); std::vector> weightThree(numMPoints, std::vector(numNPoints)); std::vector> weightFour(numMPoints, std::vector(numNPoints)); - for (size_t m = 0; m < numMPoints; m++) + for (UInt m = 0; m < numMPoints; m++) { - for (size_t n = 0; n < numNPoints; n++) + for (UInt n = 0; n < numNPoints; n++) { weightOne[m][n] = (1.0 - jWeightFactor[m][n]) * totalLengthThree + jWeightFactor[m][n] * totalLengthFour; @@ -1289,21 +1289,21 @@ namespace meshkernel // border points std::vector> result(numMPoints, std::vector(numNPoints)); - for (size_t m = 0; m < numMPoints; m++) + for (UInt m = 0; m < numMPoints; m++) { result[m][0] = bottomDiscretization[m]; result[m][numN] = upperDiscretization[m]; } - for (size_t n = 0; n < numNPoints; n++) + for (UInt n = 0; n < numNPoints; n++) { result[0][n] = leftDiscretization[n]; result[numM][n] = rightDiscretization[n]; } // first interpolation - for (size_t m = 1; m < numM; m++) + for (UInt m = 1; m < numM; m++) { - for (size_t n = 1; n < numN; n++) + for (UInt n = 1; n < numN; n++) { result[m][n].x = (leftDiscretization[n].x * (1.0 - iWeightFactor[m][n]) + rightDiscretization[n].x * iWeightFactor[m][n]) * weightOne[m][n] + @@ -1315,9 +1315,9 @@ namespace meshkernel } // update weights - for (size_t m = 0; m < numMPoints; m++) + for (UInt m = 0; m < numMPoints; m++) { - for (size_t n = 0; n < numNPoints; n++) + for (UInt n = 0; n < numNPoints; n++) { weightOne[m][n] = (1.0 - jWeightFactor[m][n]) * sideThreeAdimensional[m] * totalLengthThree + jWeightFactor[m][n] * sideFourAdimensional[m] * totalLengthFour; @@ -1326,55 +1326,55 @@ namespace meshkernel } } - for (size_t m = 1; m < numMPoints; m++) + for (UInt m = 1; m < numMPoints; m++) { - for (size_t n = 0; n < numNPoints; n++) + for (UInt n = 0; n < numNPoints; n++) { weightThree[m][n] = weightOne[m][n] - weightOne[m - 1][n]; } } - for (size_t m = 0; m < numMPoints; m++) + for (UInt m = 0; m < numMPoints; m++) { - for (size_t n = 1; n < numNPoints; n++) + for (UInt n = 1; n < numNPoints; n++) { weightFour[m][n] = weightTwo[m][n] - weightTwo[m][n - 1]; } } - for (size_t m = 1; m < numMPoints; m++) + for (UInt m = 1; m < numMPoints; m++) { - for (size_t n = 1; n < numNPoints - 1; n++) + for (UInt n = 1; n < numNPoints - 1; n++) { weightOne[m][n] = 0.25 * (weightFour[m][n] + weightFour[m][n + 1] + weightFour[m - 1][n] + weightFour[m - 1][n + 1]) / weightThree[m][n]; } } - for (size_t m = 1; m < numMPoints - 1; m++) + for (UInt m = 1; m < numMPoints - 1; m++) { - for (size_t n = 1; n < numNPoints; n++) + for (UInt n = 1; n < numNPoints; n++) { weightTwo[m][n] = 0.25 * (weightThree[m][n] + weightThree[m][n - 1] + weightThree[m + 1][n] + weightThree[m + 1][n - 1]) / weightFour[m][n]; } } // Iterate several times over - const size_t numIterations = 25; - for (size_t iter = 0; iter < numIterations; iter++) + const UInt numIterations = 25; + for (UInt iter = 0; iter < numIterations; iter++) { // re-assign the weights - for (size_t m = 0; m < numMPoints; m++) + for (UInt m = 0; m < numMPoints; m++) { - for (size_t n = 0; n < numNPoints; n++) + for (UInt n = 0; n < numNPoints; n++) { weightThree[m][n] = result[m][n].x; weightFour[m][n] = result[m][n].y; } } - for (size_t m = 1; m < numM; m++) + for (UInt m = 1; m < numM; m++) { - for (size_t n = 1; n < numN; n++) + for (UInt n = 1; n < numN; n++) { const double wa = 1.0 / (weightOne[m][n] + weightOne[m + 1][n] + weightTwo[m][n] + weightTwo[m][n + 1]); @@ -1400,11 +1400,10 @@ namespace meshkernel { auto const first = edge.first; auto const second = edge.second; - if (first == constants::missing::sizetValue || second == constants::missing::sizetValue) + if (first == constants::missing::uintValue || second == constants::missing::uintValue) { continue; } - edgesCenters.emplace_back((nodes[first] + nodes[second]) * 0.5); } return edgesCenters; @@ -1493,7 +1492,7 @@ namespace meshkernel std::vector edgeLengths; edgeLengths.reserve(polyline.size()); - for (size_t p = 0; p < polyline.size() - 1; ++p) + for (UInt p = 0; p < polyline.size() - 1; ++p) { const auto firstNode = p; auto secondNode = p + 1; @@ -1508,7 +1507,7 @@ namespace meshkernel auto const edgeLengths = ComputePolyLineEdgesLengths(polyline, projection); std::vector chainages(polyline.size()); chainages[0] = 0.0; - for (size_t i = 0; i < edgeLengths.size(); ++i) + for (UInt i = 0; i < edgeLengths.size(); ++i) { chainages[i + 1] = chainages[i] + edgeLengths[i]; } @@ -1528,7 +1527,7 @@ namespace meshkernel std::vector discretization; discretization.reserve(chainages.size()); - size_t curentNodalIndex = 0; + UInt curentNodalIndex = 0; std::sort(chainages.begin(), chainages.end()); for (auto const& chainage : chainages) { diff --git a/libs/MeshKernel/src/OrthogonalizationAndSmoothing.cpp b/libs/MeshKernel/src/OrthogonalizationAndSmoothing.cpp index 4f4710b3d..b108de1e0 100644 --- a/libs/MeshKernel/src/OrthogonalizationAndSmoothing.cpp +++ b/libs/MeshKernel/src/OrthogonalizationAndSmoothing.cpp @@ -62,7 +62,7 @@ void OrthogonalizationAndSmoothing::Initialize() const auto nodeMask = m_mesh->NodeMaskFromPolygon(*m_polygons, true); // Flag nodes outside the polygon as corner points - for (size_t n = 0; n < nodeMask.size(); n++) + for (UInt n = 0; n < nodeMask.size(); n++) { if (nodeMask[n] == 0) { @@ -91,7 +91,7 @@ void OrthogonalizationAndSmoothing::Initialize() m_localCoordinatesIndices.resize(m_mesh->GetNumNodes() + 1); m_localCoordinatesIndices[0] = 1; - for (size_t n = 0; n < m_mesh->GetNumNodes(); ++n) + for (UInt n = 0; n < m_mesh->GetNumNodes(); ++n) { m_localCoordinatesIndices[n + 1] = m_localCoordinatesIndices[n] + std::max(m_mesh->m_nodesNumEdges[n] + 1, m_smoother->GetNumConnectedNodes(n)); } @@ -148,7 +148,7 @@ void OrthogonalizationAndSmoothing::AllocateLinearSystem() m_compressedStartNodeIndex.resize(m_mesh->GetNumNodes()); std::fill(m_compressedStartNodeIndex.begin(), m_compressedStartNodeIndex.end(), 0); - for (size_t n = 0; n < m_mesh->GetNumNodes(); n++) + for (UInt n = 0; n < m_mesh->GetNumNodes(); n++) { m_compressedEndNodeIndex[n] = m_nodeCacheSize; m_nodeCacheSize += std::max(m_mesh->m_nodesNumEdges[n] + 1, m_smoother->GetNumConnectedNodes(n)); @@ -210,7 +210,7 @@ void OrthogonalizationAndSmoothing::ComputeLinearSystemTerms() m_compressedWeightY[cacheIndex] = wwy; cacheIndex++; } - const size_t firstCacheIndex = n * 2; + const UInt firstCacheIndex = n * 2; m_compressedRhs[firstCacheIndex] = atpfLoc * m_orthogonalizer->GetRightHandSide(n, 0); m_compressedRhs[firstCacheIndex + 1] = atpfLoc * m_orthogonalizer->GetRightHandSide(n, 1); } @@ -240,10 +240,10 @@ void OrthogonalizationAndSmoothing::Solve() void OrthogonalizationAndSmoothing::SnapMeshToOriginalMeshBoundary() { // in this case the nearest point is the point itself - std::vector nearestPoints(m_mesh->GetNumNodes(), 0); + std::vector nearestPoints(m_mesh->GetNumNodes(), 0); std::iota(nearestPoints.begin(), nearestPoints.end(), 0); - for (size_t n = 0; n < m_mesh->GetNumNodes(); n++) + for (UInt n = 0; n < m_mesh->GetNumNodes(); n++) { const auto nearestPointIndex = nearestPoints[n]; if (m_mesh->m_nodesTypes[n] == 2 && m_mesh->m_nodesNumEdges[n] > 0 && m_mesh->m_nodesNumEdges[nearestPointIndex] > 0) @@ -255,12 +255,12 @@ void OrthogonalizationAndSmoothing::SnapMeshToOriginalMeshBoundary() } const auto numEdges = m_mesh->m_nodesNumEdges[nearestPointIndex]; - size_t numNodes = 0; - size_t leftNode = constants::missing::sizetValue; - size_t rightNode = constants::missing::sizetValue; + UInt numNodes = 0; + UInt leftNode = constants::missing::uintValue; + UInt rightNode = constants::missing::uintValue; Point secondPoint{constants::missing::doubleValue, constants::missing::doubleValue}; Point thirdPoint{constants::missing::doubleValue, constants::missing::doubleValue}; - for (size_t nn = 0; nn < numEdges; nn++) + for (UInt nn = 0; nn < numEdges; nn++) { const auto edgeIndex = m_mesh->m_nodesEdges[nearestPointIndex][nn]; if (m_mesh->IsEdgeOnBoundary(edgeIndex)) @@ -269,7 +269,7 @@ void OrthogonalizationAndSmoothing::SnapMeshToOriginalMeshBoundary() if (numNodes == 1) { leftNode = m_mesh->m_nodesNodes[n][nn]; - if (leftNode == constants::missing::sizetValue) + if (leftNode == constants::missing::uintValue) { throw AlgorithmError("OrthogonalizationAndSmoothing::SnapMeshToOriginalMeshBoundary: The left node is invalid."); } @@ -278,7 +278,7 @@ void OrthogonalizationAndSmoothing::SnapMeshToOriginalMeshBoundary() else if (numNodes == 2) { rightNode = m_mesh->m_nodesNodes[n][nn]; - if (rightNode == constants::missing::sizetValue) + if (rightNode == constants::missing::uintValue) { throw AlgorithmError("OrthogonalizationAndSmoothing::SnapMeshToOriginalMeshBoundary: The right node is invalid."); } @@ -328,7 +328,7 @@ void OrthogonalizationAndSmoothing::ComputeCoordinates() const throw AlgorithmError("OrthogonalizationAndSmoothing::ComputeCoordinates: This functionality is not implemented yet."); } -void OrthogonalizationAndSmoothing::UpdateNodeCoordinates(size_t nodeIndex) +void OrthogonalizationAndSmoothing::UpdateNodeCoordinates(UInt nodeIndex) { double dx0 = 0.0; @@ -377,11 +377,11 @@ void OrthogonalizationAndSmoothing::UpdateNodeCoordinates(size_t nodeIndex) } } -void OrthogonalizationAndSmoothing::ComputeLocalIncrements(size_t nodeIndex, double& dx0, double& dy0, std::array& weightsSum) +void OrthogonalizationAndSmoothing::ComputeLocalIncrements(UInt nodeIndex, double& dx0, double& dy0, std::array& weightsSum) { const auto numConnectedNodes = m_compressedStartNodeIndex[nodeIndex] - m_compressedEndNodeIndex[nodeIndex]; auto cacheIndex = m_compressedEndNodeIndex[nodeIndex]; - for (size_t nn = 1; nn < numConnectedNodes; nn++) + for (UInt nn = 1; nn < numConnectedNodes; nn++) { const auto wwx = m_compressedWeightX[cacheIndex]; const auto wwy = m_compressedWeightY[cacheIndex]; diff --git a/libs/MeshKernel/src/Orthogonalizer.cpp b/libs/MeshKernel/src/Orthogonalizer.cpp index a12976e8c..1392e2a57 100644 --- a/libs/MeshKernel/src/Orthogonalizer.cpp +++ b/libs/MeshKernel/src/Orthogonalizer.cpp @@ -47,14 +47,14 @@ void Orthogonalizer::Compute() // Compute mesh aspect ratios m_mesh->ComputeAspectRatios(m_aspectRatios); - for (size_t n = 0; n < m_mesh->GetNumNodes(); n++) + for (UInt n = 0; n < m_mesh->GetNumNodes(); n++) { if (m_mesh->m_nodesTypes[n] != 1 && m_mesh->m_nodesTypes[n] != 2) { continue; } - for (size_t nn = 0; nn < m_mesh->m_nodesNumEdges[n]; nn++) + for (UInt nn = 0; nn < m_mesh->m_nodesNumEdges[n]; nn++) { const auto edgeIndex = m_mesh->m_nodesEdges[n][nn]; diff --git a/libs/MeshKernel/src/Polygons.cpp b/libs/MeshKernel/src/Polygons.cpp index 99bd648fd..ad9145616 100644 --- a/libs/MeshKernel/src/Polygons.cpp +++ b/libs/MeshKernel/src/Polygons.cpp @@ -36,10 +36,10 @@ using meshkernel::Polygons; Polygons::Polygons(const std::vector& polygon, Projection projection) : m_nodes(polygon), m_projection(projection) { // Find the polygons in the current list of points - m_outer_polygons_indices = FindIndices(polygon, 0, polygon.size(), constants::missing::doubleValue); - for (size_t i = 0; i < m_outer_polygons_indices.size(); ++i) + m_outer_polygons_indices = FindIndices(polygon, 0, static_cast(polygon.size()), constants::missing::doubleValue); + for (UInt i = 0; i < m_outer_polygons_indices.size(); ++i) { - m_inner_polygons_indices[i] = std::vector>{}; + m_inner_polygons_indices[i] = std::vector>{}; const auto& [outer_start, outer_end] = m_outer_polygons_indices[i]; @@ -56,8 +56,8 @@ Polygons::Polygons(const std::vector& polygon, Projection projection) : m const auto inner_start = inner_polygons_indices[1].first; // store inner polygons for this outer polygon - auto inner_polygons = std::vector>{}; - for (size_t j = 1; j < inner_polygons_indices.size(); ++j) + auto inner_polygons = std::vector>{}; + for (UInt j = 1; j < inner_polygons_indices.size(); ++j) { inner_polygons.emplace_back(inner_polygons_indices[j]); } @@ -76,7 +76,7 @@ std::vector> Polygons::ComputePointsInPolygons() std::vector localPolygon(GetNumNodes()); TriangulationWrapper triangulationWrapper; - for (size_t polygonIndex = 0; polygonIndex < m_outer_polygons_indices.size(); ++polygonIndex) + for (UInt polygonIndex = 0; polygonIndex < m_outer_polygons_indices.size(); ++polygonIndex) { const auto& [outerStart, outerEnd] = m_outer_polygons_indices[polygonIndex]; @@ -87,7 +87,7 @@ std::vector> Polygons::ComputePointsInPolygons() } // not a closed polygon - const auto numLocalPoints = localPolygon.size(); + const auto numLocalPoints = static_cast(localPolygon.size()); if (localPolygon[numLocalPoints - 1] != localPolygon[0] || localPolygon.size() < 4) { continue; @@ -102,8 +102,8 @@ std::vector> Polygons::ComputePointsInPolygons() const double averageTriangleArea = 0.25 * constants::numeric::squareRootOfThree * averageEdgeLength * averageEdgeLength; // estimated number of triangles - constexpr size_t SafetySize = 11; - const auto numberOfTriangles = static_cast(SafetySize * localPolygonArea / averageTriangleArea); + constexpr UInt SafetySize = 11; + const auto numberOfTriangles = static_cast(SafetySize * localPolygonArea / averageTriangleArea); if (numberOfTriangles == 0) { throw AlgorithmError("Polygons::ComputePointsInPolygons: The number of triangles is <= 0."); @@ -127,8 +127,8 @@ std::vector> Polygons::ComputePointsInPolygons() return generatedPoints; } -std::vector Polygons::RefineFirstPolygon(size_t startIndex, - size_t endIndex, +std::vector Polygons::RefineFirstPolygon(UInt startIndex, + UInt endIndex, double refinementDistance) const { if (m_outer_polygons_indices.empty()) @@ -149,8 +149,8 @@ std::vector Polygons::RefineFirstPolygon(size_t startIndex, } bool areIndicesValid = false; - size_t polygonIndex; - for (size_t i = 0; i < GetNumPolygons(); ++i) + UInt polygonIndex; + for (UInt i = 0; i < GetNumPolygons(); ++i) { const auto& [outerStart, outerEnd] = m_outer_polygons_indices[i]; if (startIndex >= outerStart && endIndex <= outerEnd) @@ -169,12 +169,12 @@ std::vector Polygons::RefineFirstPolygon(size_t startIndex, const auto edgeLengths = PolygonEdgeLengths(m_nodes); std::vector nodeLengthCoordinate(edgeLengths.size()); nodeLengthCoordinate[0] = 0.0; - for (size_t i = 1; i < edgeLengths.size(); ++i) + for (UInt i = 1; i < edgeLengths.size(); ++i) { nodeLengthCoordinate[i] = nodeLengthCoordinate[i - 1] + edgeLengths[i - 1]; } - const auto numNodesRefinedPart = size_t(std::ceil((nodeLengthCoordinate[endIndex] - nodeLengthCoordinate[startIndex]) / refinementDistance) + (double(endIndex) - double(startIndex))); + const auto numNodesRefinedPart = UInt(std::ceil((nodeLengthCoordinate[endIndex] - nodeLengthCoordinate[startIndex]) / refinementDistance) + (double(endIndex) - double(startIndex))); const auto& [outerStart, outerEnd] = m_outer_polygons_indices[polygonIndex]; const auto numNodesNotRefinedPart = startIndex - outerStart + outerEnd - endIndex; const auto totalNumNodes = numNodesRefinedPart + numNodesNotRefinedPart; @@ -265,7 +265,7 @@ Polygons Polygons::OffsetCopy(double distance, bool innerAndOuter) const double dyNormalPreviousEdge = 0.0; double dxNormal = 0.0; double dyNormal = 0.0; - for (size_t n = 0; n < GetNumNodes(); n++) + for (UInt n = 0; n < GetNumNodes(); n++) { if (n < GetNumNodes() - 1) { @@ -303,7 +303,7 @@ Polygons Polygons::OffsetCopy(double distance, bool innerAndOuter) const } std::vector newPolygonPoints(sizenewPolygon, {constants::missing::doubleValue, constants::missing::doubleValue}); - for (size_t i = 0; i < GetNumNodes(); ++i) + for (UInt i = 0; i < GetNumNodes(); ++i) { auto dx = normalVectors[i].x * distance; const auto dy = normalVectors[i].y * distance; @@ -326,7 +326,7 @@ Polygons Polygons::OffsetCopy(double distance, bool innerAndOuter) const return newPolygon; } -bool Polygons::IsPointInPolygon(Point const& point, size_t polygonIndex) const +bool Polygons::IsPointInPolygon(Point const& point, UInt polygonIndex) const { if (IsEmpty()) { @@ -342,21 +342,21 @@ bool Polygons::IsPointInPolygon(Point const& point, size_t polygonIndex) const return inPolygon; } -size_t Polygons::GetNumPolygons() const +meshkernel::UInt Polygons::GetNumPolygons() const { - return m_outer_polygons_indices.size(); + return static_cast(m_outer_polygons_indices.size()); } -std::tuple Polygons::IsPointInPolygons(Point point) const +std::tuple Polygons::IsPointInPolygons(Point point) const { // empty polygon means everything is included if (m_outer_polygons_indices.empty()) { - return {true, constants::missing::sizetValue}; + return {true, constants::missing::uintValue}; } bool inPolygon = false; - for (size_t polygonIndex = 0; polygonIndex < GetNumPolygons(); ++polygonIndex) + for (UInt polygonIndex = 0; polygonIndex < GetNumPolygons(); ++polygonIndex) { const auto& [polygonStartIndex, polygonEndIndex] = m_outer_polygons_indices[polygonIndex]; @@ -385,20 +385,20 @@ std::tuple Polygons::IsPointInPolygons(Point point) const { if (IsPointInPolygonNodes(point, m_nodes, m_projection, Point(), startInner, endInner)) { - return {false, constants::missing::sizetValue}; + return {false, constants::missing::uintValue}; } } return {true, polygonIndex}; } } - return {false, constants::missing::sizetValue}; + return {false, constants::missing::uintValue}; } std::vector Polygons::PointsInPolygons(const std::vector& points) const { std::vector result(points.size(), false); - for (size_t i = 0; i < points.size(); ++i) + for (UInt i = 0; i < points.size(); ++i) { const auto [isInPolygon, polygonIndex] = IsPointInPolygons(points[i]); result[i] = isInPolygon; @@ -427,7 +427,7 @@ std::vector Polygons::PolygonEdgeLengths(const std::vector& polyg std::vector edgeLengths; edgeLengths.reserve(polygonNodes.size()); - for (size_t p = 0; p < polygonNodes.size(); ++p) + for (UInt p = 0; p < polygonNodes.size(); ++p) { const auto firstNode = p; auto secondNode = p + 1; @@ -449,7 +449,7 @@ double Polygons::MaximumEdgeLength(const std::vector& polygonNodes) const } auto maximumEdgeLength = std::numeric_limits::lowest(); - for (size_t p = 0; p < polygonNodes.size() - 1; ++p) + for (UInt p = 0; p < polygonNodes.size() - 1; ++p) { double edgeLength = ComputeDistance(m_nodes[p], m_nodes[p + 1], m_projection); maximumEdgeLength = std::max(maximumEdgeLength, edgeLength); diff --git a/libs/MeshKernel/src/Smoother.cpp b/libs/MeshKernel/src/Smoother.cpp index 3d786fd1d..6f4271fd0 100644 --- a/libs/MeshKernel/src/Smoother.cpp +++ b/libs/MeshKernel/src/Smoother.cpp @@ -55,7 +55,7 @@ void Smoother::ComputeTopologies() { Initialize(); - for (size_t n = 0; n < m_mesh->GetNumNodes(); n++) + for (UInt n = 0; n < m_mesh->GetNumNodes(); n++) { NodeAdministration(n); @@ -63,8 +63,8 @@ void Smoother::ComputeTopologies() SaveNodeTopologyIfNeeded(n); - m_maximumNumConnectedNodes = std::max(m_maximumNumConnectedNodes, m_connectedNodesCache.size()); - m_maximumNumSharedFaces = std::max(m_maximumNumSharedFaces, m_sharedFacesCache.size()); + m_maximumNumConnectedNodes = std::max(m_maximumNumConnectedNodes, static_cast(m_connectedNodesCache.size())); + m_maximumNumSharedFaces = std::max(m_maximumNumSharedFaces, static_cast(m_sharedFacesCache.size())); } } @@ -81,7 +81,7 @@ void Smoother::ComputeOperators() m_ww2.resize(m_topologyConnectedNodes.size()); // allocate caches - m_boundaryEdgesCache.resize(2, constants::missing::sizetValue); + m_boundaryEdgesCache.resize(2, constants::missing::uintValue); m_leftXFaceCenterCache.resize(Mesh::m_maximumNumberOfEdgesPerNode, 0.0); m_leftYFaceCenterCache.resize(Mesh::m_maximumNumberOfEdgesPerNode, 0.0); m_rightXFaceCenterCache.resize(Mesh::m_maximumNumberOfEdgesPerNode, 0.0); @@ -91,7 +91,7 @@ void Smoother::ComputeOperators() std::vector isNewTopology(m_topologyConnectedNodes.size(), true); - for (size_t n = 0; n < m_mesh->GetNumNodes(); n++) + for (UInt n = 0; n < m_mesh->GetNumNodes(); n++) { if (m_mesh->m_nodesTypes[n] != 1 && m_mesh->m_nodesTypes[n] != 2 && m_mesh->m_nodesTypes[n] != 3 && m_mesh->m_nodesTypes[n] != 4) { @@ -118,7 +118,7 @@ void Smoother::ComputeWeights() std::vector> J(m_mesh->GetNumNodes(), std::vector(4, 0)); // Jacobian std::vector> Ginv(m_mesh->GetNumNodes(), std::vector(4, 0)); // Mesh2D monitor matrices - for (size_t n = 0; n < m_mesh->GetNumNodes(); n++) + for (UInt n = 0; n < m_mesh->GetNumNodes(); n++) { if (m_mesh->m_nodesTypes[n] != 1 && m_mesh->m_nodesTypes[n] != 2 && m_mesh->m_nodesTypes[n] != 4) { @@ -128,7 +128,7 @@ void Smoother::ComputeWeights() } // TODO: Account for samples: call orthonet_comp_Ginv(u, ops, J, Ginv) - for (size_t n = 0; n < m_mesh->GetNumNodes(); n++) + for (UInt n = 0; n < m_mesh->GetNumNodes(); n++) { Ginv[n][0] = 1.0; Ginv[n][1] = 0.0; @@ -148,7 +148,7 @@ void Smoother::ComputeWeights() std::vector GxiByDiveta(m_maximumNumConnectedNodes, 0.0); std::vector GetaByDivxi(m_maximumNumConnectedNodes, 0.0); std::vector GetaByDiveta(m_maximumNumConnectedNodes, 0.0); - for (size_t n = 0; n < m_mesh->GetNumNodes(); n++) + for (UInt n = 0; n < m_mesh->GetNumNodes(); n++) { if (m_mesh->m_nodesNumEdges[n] < 2) @@ -175,7 +175,7 @@ void Smoother::ComputeWeights() std::fill(DGinvDxi.begin(), DGinvDxi.end(), 0.0); std::fill(DGinvDeta.begin(), DGinvDeta.end(), 0.0); - for (size_t i = 0; i < m_topologyConnectedNodes[currentTopology].size(); i++) + for (UInt i = 0; i < m_topologyConnectedNodes[currentTopology].size(); i++) { DGinvDxi[0] += Ginv[m_topologyConnectedNodes[currentTopology][i]][0] * m_Jxi[currentTopology][i]; DGinvDxi[1] += Ginv[m_topologyConnectedNodes[currentTopology][i]][1] * m_Jxi[currentTopology][i]; @@ -199,9 +199,9 @@ void Smoother::ComputeWeights() std::fill(GxiByDiveta.begin(), GxiByDiveta.end(), 0.0); std::fill(GetaByDivxi.begin(), GetaByDivxi.end(), 0.0); std::fill(GetaByDiveta.begin(), GetaByDiveta.end(), 0.0); - for (size_t i = 0; i < m_topologyConnectedNodes[currentTopology].size(); i++) + for (UInt i = 0; i < m_topologyConnectedNodes[currentTopology].size(); i++) { - for (size_t j = 0; j < m_Divxi[currentTopology].size(); j++) + for (UInt j = 0; j < m_Divxi[currentTopology].size(); j++) { GxiByDivxi[i] += m_Gxi[currentTopology][j][i] * m_Divxi[currentTopology][j]; GxiByDiveta[i] += m_Gxi[currentTopology][j][i] * m_Diveta[currentTopology][j]; @@ -210,7 +210,7 @@ void Smoother::ComputeWeights() } } - for (size_t i = 0; i < m_topologyConnectedNodes[currentTopology].size(); i++) + for (UInt i = 0; i < m_topologyConnectedNodes[currentTopology].size(); i++) { m_weights[n][i] -= MatrixNorm(a1, a1, DGinvDxi) * m_Jxi[currentTopology][i] + MatrixNorm(a1, a2, DGinvDeta) * m_Jxi[currentTopology][i] + @@ -223,19 +223,19 @@ void Smoother::ComputeWeights() } double alpha = 0.0; - for (size_t i = 1; i < m_topologyConnectedNodes[currentTopology].size(); i++) + for (UInt i = 1; i < m_topologyConnectedNodes[currentTopology].size(); i++) { alpha = std::max(alpha, -m_weights[n][i]) / std::max(1.0, m_ww2[currentTopology][i]); } double sumValues = 0.0; - for (size_t i = 1; i < m_topologyConnectedNodes[currentTopology].size(); i++) + for (UInt i = 1; i < m_topologyConnectedNodes[currentTopology].size(); i++) { m_weights[n][i] = m_weights[n][i] + alpha * std::max(1.0, m_ww2[currentTopology][i]); sumValues += m_weights[n][i]; } m_weights[n][0] = -sumValues; - for (size_t i = 0; i < m_topologyConnectedNodes[currentTopology].size(); i++) + for (UInt i = 0; i < m_topologyConnectedNodes[currentTopology].size(); i++) { m_weights[n][i] = -m_weights[n][i] / (-sumValues + 1e-8); } @@ -243,23 +243,23 @@ void Smoother::ComputeWeights() } } -void Smoother::ComputeOperatorsNode(size_t currentNode) +void Smoother::ComputeOperatorsNode(UInt currentNode) { // the current topology index const auto currentTopology = m_nodeTopologyMapping[currentNode]; - for (size_t f = 0; f < m_topologySharedFaces[currentTopology].size(); f++) + for (UInt f = 0; f < m_topologySharedFaces[currentTopology].size(); f++) { - if (m_topologySharedFaces[currentTopology][f] == constants::missing::sizetValue || m_mesh->m_nodesTypes[currentNode] == 3) + if (m_topologySharedFaces[currentTopology][f] == constants::missing::uintValue || m_mesh->m_nodesTypes[currentNode] == 3) { continue; } - size_t edgeLeft = f + 1; - size_t edgeRight = edgeLeft + 1; + UInt edgeLeft = f + 1; + UInt edgeRight = edgeLeft + 1; if (edgeRight > m_topologySharedFaces[currentTopology].size()) { - edgeRight -= m_topologySharedFaces[currentTopology].size(); + edgeRight -= static_cast(m_topologySharedFaces[currentTopology].size()); } const auto xiLeft = m_topologyXi[currentTopology][edgeLeft]; @@ -276,7 +276,7 @@ void Smoother::ComputeOperatorsNode(size_t currentNode) if (numFaceNodes == 3) { // for triangular faces - const auto nodeIndex = FindIndex(m_mesh->m_facesNodes[m_topologySharedFaces[currentTopology][f]], currentNode); + const auto nodeIndex = FindIndex(m_mesh->m_facesNodes[m_topologySharedFaces[currentTopology][f]], static_cast(currentNode)); const auto nodeLeft = NextCircularBackwardIndex(nodeIndex, numFaceNodes); const auto nodeRight = NextCircularForwardIndex(nodeIndex, numFaceNodes); @@ -291,7 +291,7 @@ void Smoother::ComputeOperatorsNode(size_t currentNode) else { // for non-triangular faces - for (size_t i = 0; i < numFaceNodes; ++i) + for (UInt i = 0; i < numFaceNodes; ++i) { const auto element = m_topologyFaceNodeMapping[currentTopology][f][i]; m_Az[currentTopology][f][element] = 1.0 / static_cast(numFaceNodes); @@ -300,7 +300,7 @@ void Smoother::ComputeOperatorsNode(size_t currentNode) } // Initialize caches - std::fill(m_boundaryEdgesCache.begin(), m_boundaryEdgesCache.end(), constants::missing::sizetValue); + std::fill(m_boundaryEdgesCache.begin(), m_boundaryEdgesCache.end(), constants::missing::uintValue); std::fill(m_leftXFaceCenterCache.begin(), m_leftXFaceCenterCache.end(), 0.0); std::fill(m_leftYFaceCenterCache.begin(), m_leftYFaceCenterCache.end(), 0.0); std::fill(m_rightXFaceCenterCache.begin(), m_rightXFaceCenterCache.end(), 0.0); @@ -308,12 +308,12 @@ void Smoother::ComputeOperatorsNode(size_t currentNode) std::fill(m_xisCache.begin(), m_xisCache.end(), 0.0); std::fill(m_etasCache.begin(), m_etasCache.end(), 0.0); - size_t faceRightIndex = 0; - size_t faceLeftIndex = 0; + UInt faceRightIndex = 0; + UInt faceLeftIndex = 0; double xiBoundary = 0.0; double etaBoundary = 0.0; - for (size_t f = 0; f < m_topologySharedFaces[currentTopology].size(); f++) + for (UInt f = 0; f < m_topologySharedFaces[currentTopology].size(); f++) { auto edgeIndex = m_mesh->m_nodesEdges[currentNode][f]; auto otherNode = OtherNodeOfEdge(m_mesh->m_edges[edgeIndex], currentNode); @@ -339,7 +339,7 @@ void Smoother::ComputeOperatorsNode(size_t currentNode) if (m_mesh->IsEdgeOnBoundary(edgeIndex)) { // Boundary face - if (m_boundaryEdgesCache[0] == constants::missing::sizetValue) + if (m_boundaryEdgesCache[0] == constants::missing::uintValue) { m_boundaryEdgesCache[0] = f; } @@ -355,7 +355,7 @@ void Smoother::ComputeOperatorsNode(size_t currentNode) } // Compute the face circumcenter - for (size_t i = 0; i < m_topologyConnectedNodes[currentTopology].size(); i++) + for (UInt i = 0; i < m_topologyConnectedNodes[currentTopology].size(); i++) { leftXi += m_topologyXi[currentTopology][i] * m_Az[currentTopology][faceLeftIndex][i]; leftEta += m_topologyEta[currentTopology][i] * m_Az[currentTopology][faceLeftIndex][i]; @@ -381,9 +381,9 @@ void Smoother::ComputeOperatorsNode(size_t currentNode) else { faceLeftIndex = f; - faceRightIndex = NextCircularBackwardIndex(faceLeftIndex, m_topologySharedFaces[currentTopology].size()); + faceRightIndex = NextCircularBackwardIndex(faceLeftIndex, static_cast(m_topologySharedFaces[currentTopology].size())); - if (faceRightIndex == constants::missing::sizetValue) + if (faceRightIndex == constants::missing::uintValue) { continue; } @@ -397,7 +397,7 @@ void Smoother::ComputeOperatorsNode(size_t currentNode) throw std::invalid_argument("Smoother::ComputeOperatorsNode: Invalid argument."); } - for (size_t i = 0; i < m_topologyConnectedNodes[currentTopology].size(); i++) + for (UInt i = 0; i < m_topologyConnectedNodes[currentTopology].size(); i++) { leftXi += m_topologyXi[currentTopology][i] * m_Az[currentTopology][faceLeftIndex][i]; leftEta += m_topologyEta[currentTopology][i] * m_Az[currentTopology][faceLeftIndex][i]; @@ -442,9 +442,9 @@ void Smoother::ComputeOperatorsNode(size_t currentNode) facetaL = 2.0 * facetaL; } - size_t node1 = f + 1; - size_t node0 = 0; - for (size_t i = 0; i < m_topologyConnectedNodes[currentTopology].size(); i++) + UInt node1 = f + 1; + UInt node0 = 0; + for (UInt i = 0; i < m_topologyConnectedNodes[currentTopology].size(); i++) { m_Gxi[currentTopology][f][i] = facxiL * m_Az[currentTopology][faceLeftIndex][i]; m_Geta[currentTopology][f][i] = facetaL * m_Az[currentTopology][faceLeftIndex][i]; @@ -474,7 +474,7 @@ void Smoother::ComputeOperatorsNode(size_t currentNode) } double volxi = 0.0; - for (size_t i = 0; i < m_mesh->m_nodesNumEdges[currentNode]; i++) + for (UInt i = 0; i < m_mesh->m_nodesNumEdges[currentNode]; i++) { volxi += 0.5 * (m_Divxi[currentTopology][i] * m_xisCache[i] + m_Diveta[currentTopology][i] * m_etasCache[i]); } @@ -483,19 +483,19 @@ void Smoother::ComputeOperatorsNode(size_t currentNode) volxi = 1.0; } - for (size_t i = 0; i < m_mesh->m_nodesNumEdges[currentNode]; i++) + for (UInt i = 0; i < m_mesh->m_nodesNumEdges[currentNode]; i++) { m_Divxi[currentTopology][i] = m_Divxi[currentTopology][i] / volxi; m_Diveta[currentTopology][i] = m_Diveta[currentTopology][i] / volxi; } // compute the node-to-node gradients - for (size_t f = 0; f < m_topologySharedFaces[currentTopology].size(); f++) + for (UInt f = 0; f < m_topologySharedFaces[currentTopology].size(); f++) { // internal edge if (!m_mesh->IsEdgeOnBoundary(m_mesh->m_nodesEdges[currentNode][f])) { - size_t rightNode; + UInt rightNode; if (f == 0) { rightNode = f + m_mesh->m_nodesNumEdges[currentNode] - 1; @@ -505,7 +505,7 @@ void Smoother::ComputeOperatorsNode(size_t currentNode) rightNode = f - 1; } - for (size_t i = 0; i < m_topologyConnectedNodes[currentTopology].size(); i++) + for (UInt i = 0; i < m_topologyConnectedNodes[currentTopology].size(); i++) { m_Jxi[currentTopology][i] += m_Divxi[currentTopology][f] * 0.5 * (m_Az[currentTopology][f][i] + m_Az[currentTopology][rightNode][i]); m_Jeta[currentTopology][i] += m_Diveta[currentTopology][f] * 0.5 * (m_Az[currentTopology][f][i] + m_Az[currentTopology][rightNode][i]); @@ -522,31 +522,31 @@ void Smoother::ComputeOperatorsNode(size_t currentNode) // compute the weights in the Laplacian smoother std::fill(m_ww2[currentTopology].begin(), m_ww2[currentTopology].end(), 0.0); - for (size_t n = 0; n < m_mesh->m_nodesNumEdges[currentNode]; n++) + for (UInt n = 0; n < m_mesh->m_nodesNumEdges[currentNode]; n++) { - for (size_t i = 0; i < m_topologyConnectedNodes[currentTopology].size(); i++) + for (UInt i = 0; i < m_topologyConnectedNodes[currentTopology].size(); i++) { m_ww2[currentTopology][i] += m_Divxi[currentTopology][n] * m_Gxi[currentTopology][n][i] + m_Diveta[currentTopology][n] * m_Geta[currentTopology][n][i]; } } } -void Smoother::ComputeNodeXiEta(size_t currentNode) +void Smoother::ComputeNodeXiEta(UInt currentNode) { // set caches to 0 std::fill(m_xiCache.begin(), m_xiCache.end(), 0.0); std::fill(m_etaCache.begin(), m_etaCache.end(), 0.0); - const auto numSharedFaces = m_sharedFacesCache.size(); + const auto numSharedFaces = static_cast(m_sharedFacesCache.size()); // the angles for the squared nodes connected to the stencil nodes, first the ones directly connected, then the others std::vector thetaSquare(m_connectedNodesCache.size(), constants::missing::doubleValue); // for each shared face, a boolean indicating if it is squared or not std::vector isSquareFace(numSharedFaces, false); - size_t numNonStencilQuad = 0; + UInt numNonStencilQuad = 0; // loop over the connected edges - for (size_t f = 0; f < numSharedFaces; f++) + for (UInt f = 0; f < numSharedFaces; f++) { auto edgeIndex = m_mesh->m_nodesEdges[currentNode][f]; auto nextNode = m_connectedNodesCache[f + 1]; // the first entry is always the stencil node @@ -560,10 +560,10 @@ void Smoother::ComputeNodeXiEta(size_t currentNode) // check if it is a rectangular node (not currentNode itself) bool isSquare = true; - for (size_t e = 0; e < m_mesh->m_nodesNumEdges[nextNode]; e++) + for (UInt e = 0; e < m_mesh->m_nodesNumEdges[nextNode]; e++) { auto edge = m_mesh->m_nodesEdges[nextNode][e]; - for (size_t ff = 0; ff < m_mesh->m_edgesNumFaces[edge]; ff++) + for (UInt ff = 0; ff < m_mesh->m_edgesNumFaces[edge]; ff++) { auto face = m_mesh->m_edgesFaces[edge][ff]; if (face != faceLeft && face != faceRight) @@ -578,14 +578,14 @@ void Smoother::ComputeNodeXiEta(size_t currentNode) } // Compute optimal angle thetaSquare based on the node type - size_t leftFaceIndex; + UInt leftFaceIndex; if (f == 0) { - leftFaceIndex = f + numSharedFaces - static_cast(1); + leftFaceIndex = f + numSharedFaces - static_cast(1); } else { - leftFaceIndex = f - static_cast(1); + leftFaceIndex = f - static_cast(1); } if (isSquare) @@ -608,11 +608,11 @@ void Smoother::ComputeNodeXiEta(size_t currentNode) thetaSquare[f + 1] = 0.5 * M_PI; } - if (m_sharedFacesCache[f] != constants::missing::sizetValue && m_sharedFacesCache[f] > 1 && m_mesh->GetNumFaceEdges(m_sharedFacesCache[f]) == 4) + if (m_sharedFacesCache[f] != constants::missing::uintValue && m_sharedFacesCache[f] > 1 && m_mesh->GetNumFaceEdges(m_sharedFacesCache[f]) == 4) { numNonStencilQuad += 1; } - if (m_sharedFacesCache[leftFaceIndex] != constants::missing::sizetValue && m_sharedFacesCache[leftFaceIndex] > 1 && m_mesh->GetNumFaceEdges(m_sharedFacesCache[leftFaceIndex]) == 4) + if (m_sharedFacesCache[leftFaceIndex] != constants::missing::uintValue && m_sharedFacesCache[leftFaceIndex] > 1 && m_mesh->GetNumFaceEdges(m_sharedFacesCache[leftFaceIndex]) == 4) { numNonStencilQuad += 1; } @@ -626,16 +626,16 @@ void Smoother::ComputeNodeXiEta(size_t currentNode) isSquareFace[leftFaceIndex] = isSquareFace[leftFaceIndex] || isSquare; } - for (size_t f = 0; f < numSharedFaces; f++) + for (UInt f = 0; f < numSharedFaces; f++) { // boundary face - if (m_sharedFacesCache[f] == constants::missing::sizetValue) + if (m_sharedFacesCache[f] == constants::missing::uintValue) continue; // non boundary face if (m_mesh->GetNumFaceEdges(m_sharedFacesCache[f]) == 4) { - for (size_t n = 0; n < m_mesh->GetNumFaceEdges(m_sharedFacesCache[f]); n++) + for (UInt n = 0; n < m_mesh->GetNumFaceEdges(m_sharedFacesCache[f]); n++) { if (m_faceNodeMappingCache[f][n] <= numSharedFaces) { @@ -647,17 +647,17 @@ void Smoother::ComputeNodeXiEta(size_t currentNode) } // Compute internal angle - size_t numSquaredTriangles = 0; - size_t numTriangles = 0; + UInt numSquaredTriangles = 0; + UInt numTriangles = 0; double phiSquaredTriangles = 0.0; double phiQuads = 0.0; double phiTriangles = 0.0; double phiTot = 0.0; numNonStencilQuad = 0; - for (size_t f = 0; f < numSharedFaces; f++) + for (UInt f = 0; f < numSharedFaces; f++) { // boundary face - if (m_sharedFacesCache[f] == constants::missing::sizetValue) + if (m_sharedFacesCache[f] == constants::missing::uintValue) { continue; } @@ -667,7 +667,7 @@ void Smoother::ComputeNodeXiEta(size_t currentNode) if (isSquareFace[f] || numFaceNodes == 4) { - size_t nextNode = static_cast(f) + static_cast(2); + UInt nextNode = static_cast(f) + static_cast(2); if (nextNode > numSharedFaces) { nextNode = nextNode - numSharedFaces; @@ -731,10 +731,10 @@ void Smoother::ComputeNodeXiEta(size_t currentNode) double dPhi0 = 0.0; double dPhi = 0.0; double dTheta = 0.0; - for (size_t f = 0; f < numSharedFaces; f++) + for (UInt f = 0; f < numSharedFaces; f++) { phi0 = phi0 + 0.5 * dPhi; - if (m_sharedFacesCache[f] == constants::missing::sizetValue) + if (m_sharedFacesCache[f] == constants::missing::uintValue) { if (m_mesh->m_nodesTypes[currentNode] == 2) { @@ -761,7 +761,7 @@ void Smoother::ComputeNodeXiEta(size_t currentNode) dPhi0 = OptimalEdgeAngle(numFaceNodes); if (isSquareFace[f]) { - auto nextNode = f + static_cast(2); + auto nextNode = f + static_cast(2); if (nextNode > numSharedFaces) { nextNode = nextNode - numSharedFaces; @@ -782,7 +782,7 @@ void Smoother::ComputeNodeXiEta(size_t currentNode) phi0 = phi0 + 0.5 * dPhi; // determine the index of the current stencil node - const auto nodeIndex = FindIndex(m_mesh->m_facesNodes[m_sharedFacesCache[f]], currentNode); + const UInt nodeIndex = FindIndex(m_mesh->m_facesNodes[m_sharedFacesCache[f]], static_cast(currentNode)); // optimal angle dTheta = 2.0 * M_PI / static_cast(numFaceNodes); @@ -800,7 +800,7 @@ void Smoother::ComputeNodeXiEta(size_t currentNode) double aspectRatio = (1.0 - std::cos(dTheta)) / std::sin(std::abs(dTheta)) * std::tan(0.5 * dPhi); double radius = std::cos(0.5 * dPhi) / (1.0 - cos(dTheta)); - for (size_t n = 0; n < numFaceNodes; n++) + for (UInt n = 0; n < numFaceNodes; n++) { double theta = dTheta * (static_cast(n) - static_cast(nodeIndex)); double xip = radius - radius * std::cos(theta); @@ -812,7 +812,7 @@ void Smoother::ComputeNodeXiEta(size_t currentNode) } } -void Smoother::NodeAdministration(size_t currentNode) +void Smoother::NodeAdministration(UInt currentNode) { m_sharedFacesCache.clear(); m_connectedNodesCache.clear(); @@ -824,12 +824,12 @@ void Smoother::NodeAdministration(size_t currentNode) } // For the currentNode, find the shared faces - size_t newFaceIndex = constants::missing::sizetValue; - for (size_t e = 0; e < m_mesh->m_nodesNumEdges[currentNode]; e++) + UInt newFaceIndex = constants::missing::uintValue; + for (UInt e = 0; e < m_mesh->m_nodesNumEdges[currentNode]; e++) { const auto firstEdge = m_mesh->m_nodesEdges[currentNode][e]; - size_t secondEdgeIndex = e + 1; + UInt secondEdgeIndex = e + 1; if (secondEdgeIndex >= m_mesh->m_nodesNumEdges[currentNode]) { secondEdgeIndex = 0; @@ -842,8 +842,8 @@ void Smoother::NodeAdministration(size_t currentNode) } // find the face shared by the two edges - const auto firstFace = std::max(std::min(m_mesh->m_edgesNumFaces[firstEdge], size_t(2)), size_t(1)) - 1; - const auto secondFace = std::max(std::min(m_mesh->m_edgesNumFaces[secondEdge], size_t(2)), size_t(1)) - 1; + const auto firstFace = std::max(std::min(m_mesh->m_edgesNumFaces[firstEdge], 2U), 1U) - 1U; + const auto secondFace = std::max(std::min(m_mesh->m_edgesNumFaces[secondEdge], static_cast(2)), static_cast(1)) - 1; if (m_mesh->m_edgesFaces[firstEdge][0] != newFaceIndex && (m_mesh->m_edgesFaces[firstEdge][0] == m_mesh->m_edgesFaces[secondEdge][0] || @@ -859,7 +859,7 @@ void Smoother::NodeAdministration(size_t currentNode) } else { - newFaceIndex = constants::missing::sizetValue; + newFaceIndex = constants::missing::uintValue; } // corner face (already found in the first iteration) @@ -869,7 +869,7 @@ void Smoother::NodeAdministration(size_t currentNode) !m_sharedFacesCache.empty() && m_sharedFacesCache[0] == newFaceIndex) { - newFaceIndex = constants::missing::sizetValue; + newFaceIndex = constants::missing::uintValue; } m_sharedFacesCache.emplace_back(newFaceIndex); } @@ -884,7 +884,7 @@ void Smoother::NodeAdministration(size_t currentNode) m_connectedNodesCache.emplace_back(currentNode); // edge connected nodes - for (size_t e = 0; e < m_mesh->m_nodesNumEdges[currentNode]; e++) + for (UInt e = 0; e < m_mesh->m_nodesNumEdges[currentNode]; e++) { const auto edgeIndex = m_mesh->m_nodesEdges[currentNode][e]; const auto node = OtherNodeOfEdge(m_mesh->m_edges[edgeIndex], currentNode); @@ -895,20 +895,20 @@ void Smoother::NodeAdministration(size_t currentNode) // for each face store the positions of the its nodes in the connectedNodes (compressed array) if (m_faceNodeMappingCache.size() < m_sharedFacesCache.size()) { - ResizeAndFill2DVector(m_faceNodeMappingCache, m_sharedFacesCache.size(), Mesh::m_maximumNumberOfNodesPerFace); + ResizeAndFill2DVector(m_faceNodeMappingCache, static_cast(m_sharedFacesCache.size()), Mesh::m_maximumNumberOfNodesPerFace); } - for (size_t f = 0; f < m_sharedFacesCache.size(); f++) + for (UInt f = 0; f < m_sharedFacesCache.size(); f++) { const auto faceIndex = m_sharedFacesCache[f]; - if (faceIndex == constants::missing::sizetValue) + if (faceIndex == constants::missing::uintValue) { continue; } // find the stencil node position in the current face - size_t faceNodeIndex = 0; + UInt faceNodeIndex = 0; const auto numFaceNodes = m_mesh->GetNumFaceEdges(faceIndex); - for (size_t n = 0; n < numFaceNodes; n++) + for (UInt n = 0; n < numFaceNodes; n++) { if (m_mesh->m_facesNodes[faceIndex][n] == currentNode) { @@ -917,7 +917,7 @@ void Smoother::NodeAdministration(size_t currentNode) } } - for (size_t n = 0; n < numFaceNodes; n++) + for (UInt n = 0; n < numFaceNodes; n++) { if (faceNodeIndex >= numFaceNodes) @@ -928,12 +928,12 @@ void Smoother::NodeAdministration(size_t currentNode) const auto node = m_mesh->m_facesNodes[faceIndex][faceNodeIndex]; bool isNewNode = true; - for (size_t i = 0; i < m_connectedNodesCache.size(); i++) + for (UInt i = 0; i < m_connectedNodesCache.size(); i++) { if (node == m_connectedNodesCache[i]) { isNewNode = false; - m_faceNodeMappingCache[f][faceNodeIndex] = i; + m_faceNodeMappingCache[f][faceNodeIndex] = static_cast(i); break; } } @@ -941,7 +941,7 @@ void Smoother::NodeAdministration(size_t currentNode) if (isNewNode) { m_connectedNodesCache.emplace_back(node); - m_faceNodeMappingCache[f][faceNodeIndex] = m_connectedNodesCache.size() - 1; + m_faceNodeMappingCache[f][faceNodeIndex] = static_cast(m_connectedNodesCache.size() - 1); m_connectedNodes[currentNode].emplace_back(node); } @@ -951,10 +951,10 @@ void Smoother::NodeAdministration(size_t currentNode) } // update connected nodes (kkc) - m_numConnectedNodes[currentNode] = m_connectedNodesCache.size(); + m_numConnectedNodes[currentNode] = static_cast(m_connectedNodesCache.size()); } -double Smoother::OptimalEdgeAngle(size_t numFaceNodes, double theta1, double theta2, bool isBoundaryEdge) const +double Smoother::OptimalEdgeAngle(UInt numFaceNodes, double theta1, double theta2, bool isBoundaryEdge) const { double angle = M_PI * (1.0 - 2.0 / static_cast(numFaceNodes)); @@ -978,14 +978,14 @@ void Smoother::Initialize() std::fill(m_numConnectedNodes.begin(), m_numConnectedNodes.end(), 0); m_connectedNodes.resize(m_mesh->GetNumNodes()); - std::fill(m_connectedNodes.begin(), m_connectedNodes.end(), std::vector(Mesh::m_maximumNumberOfConnectedNodes, 0)); + std::fill(m_connectedNodes.begin(), m_connectedNodes.end(), std::vector(Mesh::m_maximumNumberOfConnectedNodes, 0)); m_sharedFacesCache.reserve(Mesh::m_maximumNumberOfEdgesPerNode); m_connectedNodesCache.reserve(Mesh::m_maximumNumberOfConnectedNodes); m_faceNodeMappingCache.resize(Mesh::m_maximumNumberOfConnectedNodes); - std::fill(m_faceNodeMappingCache.begin(), m_faceNodeMappingCache.end(), std::vector(Mesh::m_maximumNumberOfNodesPerFace, 0)); + std::fill(m_faceNodeMappingCache.begin(), m_faceNodeMappingCache.end(), std::vector(Mesh::m_maximumNumberOfNodesPerFace, 0)); m_xiCache.resize(Mesh::m_maximumNumberOfConnectedNodes, 0.0); std::fill(m_xiCache.begin(), m_xiCache.end(), 0.0); @@ -994,13 +994,13 @@ void Smoother::Initialize() std::fill(m_etaCache.begin(), m_etaCache.end(), 0.0); m_nodeTopologyMapping.resize(m_mesh->GetNumNodes()); - std::fill(m_nodeTopologyMapping.begin(), m_nodeTopologyMapping.end(), constants::missing::sizetValue); + std::fill(m_nodeTopologyMapping.begin(), m_nodeTopologyMapping.end(), constants::missing::uintValue); } -void Smoother::AllocateNodeOperators(size_t topologyIndex) +void Smoother::AllocateNodeOperators(UInt topologyIndex) { - const auto numSharedFaces = m_topologySharedFaces[topologyIndex].size(); - const auto numConnectedNodes = m_topologyConnectedNodes[topologyIndex].size(); + const auto numSharedFaces = static_cast(m_topologySharedFaces[topologyIndex].size()); + const auto numConnectedNodes = static_cast(m_topologyConnectedNodes[topologyIndex].size()); // will reallocate only if necessary m_Az[topologyIndex].resize(numSharedFaces); @@ -1028,10 +1028,10 @@ void Smoother::AllocateNodeOperators(size_t topologyIndex) std::fill(m_ww2[topologyIndex].begin(), m_ww2[topologyIndex].end(), 0.0); } -void Smoother::SaveNodeTopologyIfNeeded(size_t currentNode) +void Smoother::SaveNodeTopologyIfNeeded(UInt currentNode) { bool isNewTopology = true; - for (size_t topo = 0; topo < m_topologyConnectedNodes.size(); topo++) + for (UInt topo = 0; topo < m_topologyConnectedNodes.size(); topo++) { if (m_sharedFacesCache.size() != m_topologySharedFaces[topo].size() || m_connectedNodesCache.size() != m_topologyConnectedNodes[topo].size()) { @@ -1039,7 +1039,7 @@ void Smoother::SaveNodeTopologyIfNeeded(size_t currentNode) } isNewTopology = false; - for (size_t n = 1; n < m_connectedNodesCache.size(); n++) + for (UInt n = 1; n < m_connectedNodesCache.size(); n++) { const double thetaLoc = std::atan2(m_etaCache[n], m_xiCache[n]); const double thetaTopology = std::atan2(m_topologyEta[topo][n], m_topologyXi[topo][n]); @@ -1052,7 +1052,7 @@ void Smoother::SaveNodeTopologyIfNeeded(size_t currentNode) if (!isNewTopology) { - m_nodeTopologyMapping[currentNode] = topo; + m_nodeTopologyMapping[currentNode] = static_cast(topo); break; } } @@ -1064,11 +1064,11 @@ void Smoother::SaveNodeTopologyIfNeeded(size_t currentNode) m_topologyXi.emplace_back(m_xiCache); m_topologyEta.emplace_back(m_etaCache); m_topologyFaceNodeMapping.emplace_back(m_faceNodeMappingCache); - m_nodeTopologyMapping[currentNode] = m_topologyConnectedNodes.size() - 1; + m_nodeTopologyMapping[currentNode] = static_cast(m_topologyConnectedNodes.size() - 1); } } -void Smoother::ComputeJacobian(size_t currentNode, std::vector& J) const +void Smoother::ComputeJacobian(UInt currentNode, std::vector& J) const { const auto currentTopology = m_nodeTopologyMapping[currentNode]; const auto numNodes = m_topologyConnectedNodes[currentTopology].size(); @@ -1078,7 +1078,7 @@ void Smoother::ComputeJacobian(size_t currentNode, std::vector& J) const J[1] = 0.0; J[2] = 0.0; J[3] = 0.0; - for (size_t i = 0; i < numNodes; i++) + for (UInt i = 0; i < numNodes; i++) { J[0] += m_Jxi[currentTopology][i] * m_mesh->m_nodes[m_topologyConnectedNodes[currentTopology][i]].x; J[1] += m_Jxi[currentTopology][i] * m_mesh->m_nodes[m_topologyConnectedNodes[currentTopology][i]].y; @@ -1093,7 +1093,7 @@ void Smoother::ComputeJacobian(size_t currentNode, std::vector& J) const J[1] = 0.0; J[2] = 0.0; J[3] = 0.0; - for (size_t i = 0; i < numNodes; i++) + for (UInt i = 0; i < numNodes; i++) { J[0] += m_Jxi[currentTopology][i] * m_mesh->m_nodes[m_topologyConnectedNodes[currentTopology][i]].x * cosFactor; J[1] += m_Jxi[currentTopology][i] * m_mesh->m_nodes[m_topologyConnectedNodes[currentTopology][i]].y; diff --git a/libs/MeshKernel/src/Splines.cpp b/libs/MeshKernel/src/Splines.cpp index 95475cce0..3dd6c531a 100644 --- a/libs/MeshKernel/src/Splines.cpp +++ b/libs/MeshKernel/src/Splines.cpp @@ -39,27 +39,27 @@ Splines::Splines(CurvilinearGrid const& grid) { // first the m_n m_m-gridlines std::vector> mGridLines(grid.m_numN, std::vector(grid.m_numM)); - for (size_t n = 0; n < grid.m_numN; ++n) + for (UInt n = 0; n < grid.m_numN; ++n) { - for (size_t m = 0; m < grid.m_numM; ++m) + for (UInt m = 0; m < grid.m_numM; ++m) { mGridLines[n][m] = grid.m_gridNodes[m][n]; } - AddSpline(mGridLines[n], 0, mGridLines[n].size()); + AddSpline(mGridLines[n], 0, static_cast(mGridLines[n].size())); } // then the m_m m_n-gridlines std::vector> nGridLines(grid.m_numM, std::vector(grid.m_numN)); - for (size_t m = 0; m < grid.m_numM; ++m) + for (UInt m = 0; m < grid.m_numM; ++m) { - AddSpline(grid.m_gridNodes[m], 0, grid.m_gridNodes[m].size()); + AddSpline(grid.m_gridNodes[m], 0, static_cast(grid.m_gridNodes[m].size())); } m_projection = grid.m_projection; } /// add a new spline, return the index -void Splines::AddSpline(const std::vector& splines, size_t start, size_t size) +void Splines::AddSpline(const std::vector& splines, UInt start, UInt size) { if (size == 0) { @@ -67,7 +67,7 @@ void Splines::AddSpline(const std::vector& splines, size_t start, size_t } // copy the spline nodes from start to start + size - size_t count = 0; + UInt count = 0; std::vector splinesNodes(size); for (auto i = start; i < start + size; ++i) { @@ -78,7 +78,7 @@ void Splines::AddSpline(const std::vector& splines, size_t start, size_t // compute second order derivatives std::vector splineDerivatives(splinesNodes.size()); - const auto indices = FindIndices(splinesNodes, 0, splinesNodes.size(), constants::missing::doubleValue); + const auto indices = FindIndices(splinesNodes, 0, static_cast(splinesNodes.size()), constants::missing::doubleValue); for (auto index : indices) { const auto& [startIndex, endIndex] = index; @@ -93,14 +93,14 @@ void Splines::AddSpline(const std::vector& splines, size_t start, size_t m_splinesLength.emplace_back(ComputeSplineLength(GetNumSplines() - 1, 0.0, static_cast(size - 1))); } -void Splines::DeleteSpline(size_t splineIndex) +void Splines::DeleteSpline(UInt splineIndex) { m_splineNodes.erase(m_splineNodes.begin() + splineIndex); m_splineDerivatives.erase(m_splineDerivatives.begin() + splineIndex); m_splinesLength.erase(m_splinesLength.begin() + splineIndex); } -void Splines::AddPointInExistingSpline(size_t splineIndex, const Point& point) +void Splines::AddPointInExistingSpline(UInt splineIndex, const Point& point) { if (splineIndex > GetNumSplines()) { @@ -109,8 +109,8 @@ void Splines::AddPointInExistingSpline(size_t splineIndex, const Point& point) m_splineNodes[splineIndex].emplace_back(point); } -bool Splines::GetSplinesIntersection(size_t first, - size_t second, +bool Splines::GetSplinesIntersection(UInt first, + UInt second, double& crossProductIntersection, Point& intersectionPoint, double& firstSplineRatio, @@ -118,19 +118,19 @@ bool Splines::GetSplinesIntersection(size_t first, { double minimumCrossingDistance = std::numeric_limits::max(); double crossingDistance; - size_t numCrossing = 0; + UInt numCrossing = 0; double firstCrossingRatio = -1.0; double secondCrossingRatio = -1.0; - size_t firstCrossingIndex = 0; - size_t secondCrossingIndex = 0; + UInt firstCrossingIndex = 0; + UInt secondCrossingIndex = 0; Point closestIntersection; - const auto numNodesFirstSpline = m_splineNodes[first].size(); - const auto numNodesSecondSpline = m_splineNodes[second].size(); + const auto numNodesFirstSpline = static_cast(m_splineNodes[first].size()); + const auto numNodesSecondSpline = static_cast(m_splineNodes[second].size()); // First find a valid crossing, the closest to spline central point - for (size_t n = 0; n < numNodesFirstSpline - 1; n++) + for (UInt n = 0; n < numNodesFirstSpline - 1; n++) { - for (size_t nn = 0; nn < numNodesSecondSpline - 1; nn++) + for (UInt nn = 0; nn < numNodesSecondSpline - 1; nn++) { Point intersection; double crossProduct; @@ -191,7 +191,7 @@ bool Splines::GetSplinesIntersection(size_t first, const double maxDistanceBetweenNodes = 0.0001; double firstRatioIterations = 1.0; double secondRatioIterations = 1.0; - size_t numIterations = 0; + UInt numIterations = 0; while (squaredDistanceBetweenCrossings > maxSquaredDistanceBetweenCrossings && numIterations < 20) { // increment counter @@ -300,10 +300,10 @@ bool Splines::GetSplinesIntersection(size_t first, return false; } -double Splines::ComputeSplineLength(size_t index, +double Splines::ComputeSplineLength(UInt index, double startAdimensionalCoordinate, double endAdimensionalCoordinate, - size_t numSamples, + UInt numSamples, bool accountForCurvature, double height, double assignedDelta) const @@ -314,12 +314,12 @@ double Splines::ComputeSplineLength(size_t index, } double delta = assignedDelta; - size_t numPoints = static_cast(endAdimensionalCoordinate / delta) + 1; + UInt numPoints = static_cast(endAdimensionalCoordinate / delta) + 1; if (delta < 0.0) { delta = 1.0 / static_cast(numSamples); // TODO: Refactor or at least document the calculation of "numPoints" - numPoints = static_cast(std::max(std::floor(0.9999 + (endAdimensionalCoordinate - startAdimensionalCoordinate) / delta), 10.0)); + numPoints = static_cast(std::max(std::floor(0.9999 + (endAdimensionalCoordinate - startAdimensionalCoordinate) / delta), 10.0)); delta = (endAdimensionalCoordinate - startAdimensionalCoordinate) / static_cast(numPoints); } @@ -328,7 +328,7 @@ double Splines::ComputeSplineLength(size_t index, double splineLength = 0.0; auto rightPointCoordinateOnSpline = startAdimensionalCoordinate; - for (size_t p = 0; p < numPoints; ++p) + for (UInt p = 0; p < numPoints; ++p) { const double leftPointCoordinateOnSpline = rightPointCoordinateOnSpline; rightPointCoordinateOnSpline += delta; @@ -357,16 +357,16 @@ double Splines::ComputeSplineLength(size_t index, } std::tuple -Splines::ComputeCurvatureOnSplinePoint(size_t splineIndex, double adimensionalPointCoordinate) const +Splines::ComputeCurvatureOnSplinePoint(UInt splineIndex, double adimensionalPointCoordinate) const { if (m_splineNodes[splineIndex].empty()) { return {}; } - const auto numNodesFirstSpline = m_splineNodes[splineIndex].size(); - auto const leftCornerPoint = std::max(std::min(static_cast(std::floor(adimensionalPointCoordinate)), numNodesFirstSpline - 1), static_cast(0)); - auto const rightCornerPoint = std::max(leftCornerPoint + 1, static_cast(0)); + const auto numNodesFirstSpline = static_cast(m_splineNodes[splineIndex].size()); + auto const leftCornerPoint = std::max(std::min(static_cast(std::floor(adimensionalPointCoordinate)), numNodesFirstSpline - 1), 0U); + auto const rightCornerPoint = std::max(leftCornerPoint + 1, 0U); const auto leftSegment = static_cast(rightCornerPoint) - adimensionalPointCoordinate; const auto rightSegment = adimensionalPointCoordinate - static_cast(leftCornerPoint); @@ -407,13 +407,13 @@ Splines::ComputeCurvatureOnSplinePoint(size_t splineIndex, double adimensionalPo return {normalVector, tangentialVector, curvatureFactor}; } -std::vector Splines::SecondOrderDerivative(const std::vector& spline, size_t startIndex, size_t endIndex) +std::vector Splines::SecondOrderDerivative(const std::vector& spline, UInt startIndex, UInt endIndex) { const auto numNodes = endIndex - startIndex + 1; std::vector u(numNodes, {0.0, 0.0}); std::vector coordinatesDerivative(numNodes, {0.0, 0.0}); - size_t index = 1; + UInt index = 1; for (auto i = startIndex + 1; i < numNodes - 1; i++) { const Point p = coordinatesDerivative[index - 1] * 0.5 + 2.0; @@ -434,13 +434,13 @@ std::vector Splines::SecondOrderDerivative(const std::vector< return coordinatesDerivative; } -std::vector Splines::SecondOrderDerivative(const std::vector& coordinates, size_t startIndex, size_t endIndex) +std::vector Splines::SecondOrderDerivative(const std::vector& coordinates, UInt startIndex, UInt endIndex) { const auto numNodes = endIndex - startIndex + 1; std::vector u(numNodes, 0.0); std::vector coordinatesDerivatives(numNodes, 0.0); - size_t index = 1; + UInt index = 1; for (auto i = startIndex + 1; i < numNodes - 1; i++) { const double p = coordinatesDerivatives[index - 1] * 0.5 + 2.0; @@ -462,7 +462,7 @@ std::vector Splines::SecondOrderDerivative(const std::vector& co } std::tuple, std::vector> -Splines::ComputePointOnSplineFromAdimensionalDistance(size_t index, +Splines::ComputePointOnSplineFromAdimensionalDistance(UInt index, double maximumGridHeight, bool isSpacingCurvatureAdapted, const std::vector& distances) @@ -472,8 +472,8 @@ Splines::ComputePointOnSplineFromAdimensionalDistance(size_t index, std::vector adimensionalDistances(distances.size()); FuncAdimensionalToDimensionalDistanceOnSpline func(this, index, isSpacingCurvatureAdapted, maximumGridHeight); - const auto numNodes = m_splineNodes[index].size(); - for (size_t i = 0, size = distances.size(); i < size; ++i) + const auto numNodes = static_cast(m_splineNodes[index].size()); + for (UInt i = 0, size = static_cast(distances.size()); i < size; ++i) { func.SetDimensionalDistance(distances[i]); adimensionalDistances[i] = FindFunctionRootWithGoldenSectionSearch(func, 0, static_cast(numNodes) - 1.0); @@ -486,7 +486,7 @@ Splines::ComputePointOnSplineFromAdimensionalDistance(size_t index, return {points, adimensionalDistances}; } -meshkernel::Point Splines::ComputeClosestPointOnSplineSegment(size_t index, double startSplineSegment, double endSplineSegment, Point point) +meshkernel::Point Splines::ComputeClosestPointOnSplineSegment(UInt index, double startSplineSegment, double endSplineSegment, Point point) { FuncDistanceFromAPoint func(this, index, point); const auto adimensionalDistance = FindFunctionRootWithGoldenSectionSearch(func, startSplineSegment, endSplineSegment); diff --git a/libs/MeshKernel/src/TriangulationInterpolation.cpp b/libs/MeshKernel/src/TriangulationInterpolation.cpp index 33f9ea27b..d43244ab1 100644 --- a/libs/MeshKernel/src/TriangulationInterpolation.cpp +++ b/libs/MeshKernel/src/TriangulationInterpolation.cpp @@ -74,7 +74,7 @@ void TriangulationInterpolation::Compute() for (auto f = 0; f < triangulationWrapper.GetNumFaces(); ++f) { // compute triangle polygons - for (size_t n = 0; n < Mesh::m_numNodesInTriangle; ++n) + for (UInt n = 0; n < Mesh::m_numNodesInTriangle; ++n) { auto const node = triangulationWrapper.GetFaceNode(f, n); triangles[f][n] = {m_samples[node].x, m_samples[node].y}; @@ -93,7 +93,7 @@ void TriangulationInterpolation::Compute() const auto [lowerLeft, upperRight] = GetBoundingBox(m_samples); // loop over locations - for (size_t n = 0; n < m_locations.size(); ++n) + for (UInt n = 0; n < m_locations.size(); ++n) { if (!IsValueInBoundingBox(m_locations[n], lowerLeft, upperRight) || !IsEqual(m_results[n], constants::missing::doubleValue)) @@ -112,7 +112,7 @@ void TriangulationInterpolation::Compute() // search for the triangle where the location is included bool isInTriangle = false; int numFacesSearched = 0; - while (!isInTriangle && numFacesSearched < 2 * triangulationWrapper.GetNumFaces() && triangle != constants::missing::sizetValue && static_cast(triangle) < triangulationWrapper.GetNumFaces()) + while (!isInTriangle && numFacesSearched < 2 * triangulationWrapper.GetNumFaces() && triangle != constants::missing::uintValue && static_cast(triangle) < triangulationWrapper.GetNumFaces()) { isInTriangle = IsPointInPolygonNodes(m_locations[n], triangles[triangle], m_projection, trianglesCircumcenters[triangle]); @@ -125,7 +125,7 @@ void TriangulationInterpolation::Compute() // proceed to next triangle, which is adjacent to the edge that is cut by the line from the current triangle to the point location numFacesSearched++; - for (size_t i = 0; i < Mesh::m_numNodesInTriangle; ++i) + for (UInt i = 0; i < Mesh::m_numNodesInTriangle; ++i) { const auto edge = triangulationWrapper.GetFaceEdge(triangle, i); if (triangulationWrapper.GetEdgeFace(edge, 1) == 0) @@ -160,7 +160,7 @@ void TriangulationInterpolation::Compute() } } - if (isInTriangle && triangle != constants::missing::sizetValue && static_cast(triangle) < triangulationWrapper.GetNumFaces()) + if (isInTriangle && triangle != constants::missing::uintValue && static_cast(triangle) < triangulationWrapper.GetNumFaces()) { // Perform linear interpolation m_results[n] = LinearInterpolationInTriangle(m_locations[n], triangles[triangle], values[triangle], m_projection); diff --git a/libs/MeshKernel/src/TriangulationWrapper.cpp b/libs/MeshKernel/src/TriangulationWrapper.cpp index c11cf15e2..98cc98900 100644 --- a/libs/MeshKernel/src/TriangulationWrapper.cpp +++ b/libs/MeshKernel/src/TriangulationWrapper.cpp @@ -47,15 +47,15 @@ void TriangulationWrapper::BuildTriangulation() } // Create m_faceNodes - ResizeAndFill2DVector(m_faceNodes, m_numFaces, 3, true, constants::missing::sizetValue); - ResizeAndFill2DVector(m_faceEdges, m_numFaces, 3, true, constants::missing::sizetValue); - size_t faceCounter = 0; + ResizeAndFill2DVector(m_faceNodes, m_numFaces, 3, true, constants::missing::uintValue); + ResizeAndFill2DVector(m_faceEdges, m_numFaces, 3, true, constants::missing::uintValue); + UInt faceCounter = 0; for (int f = 0; f < m_numFaces; ++f) { for (int e = 0; e < 3; ++e) { - m_faceNodes[f][e] = static_cast(m_faceNodesFlat[faceCounter] - 1); - m_faceEdges[f][e] = static_cast(m_faceEdgesFlat[faceCounter] - 1); + m_faceNodes[f][e] = static_cast(m_faceNodesFlat[faceCounter] - 1); + m_faceEdges[f][e] = static_cast(m_faceEdgesFlat[faceCounter] - 1); faceCounter++; } } @@ -66,28 +66,28 @@ void TriangulationWrapper::BuildTriangulation() return; } - ResizeAndFill2DVector(m_edgeNodes, m_numEdges, 2, true, constants::missing::sizetValue); - size_t edgeCounter = 0; + ResizeAndFill2DVector(m_edgeNodes, m_numEdges, 2, true, constants::missing::uintValue); + UInt edgeCounter = 0; for (int e = 0; e < m_numEdges; ++e) { for (int n = 0; n < 2; ++n) { - m_edgeNodes[e][n] = static_cast(m_edgeNodesFlat[edgeCounter] - 1); + m_edgeNodes[e][n] = static_cast(m_edgeNodesFlat[edgeCounter] - 1); edgeCounter++; } } - ResizeAndFill2DVector(m_edgesFaces, m_numEdges, 2, true, constants::missing::sizetValue); + ResizeAndFill2DVector(m_edgesFaces, m_numEdges, 2, true, constants::missing::uintValue); edgeCounter = 0; for (int f = 0; f < m_numFaces; ++f) { - for (size_t n = 0; n < Mesh::m_numNodesInTriangle; ++n) + for (UInt n = 0; n < Mesh::m_numNodesInTriangle; ++n) { - auto const edge = static_cast(m_faceEdgesFlat[edgeCounter] - 1); + auto const edge = static_cast(m_faceEdgesFlat[edgeCounter] - 1); edgeCounter++; // For each edge, the shared face index - if (m_edgesFaces[edge][0] == constants::missing::sizetValue) + if (m_edgesFaces[edge][0] == constants::missing::uintValue) { m_edgesFaces[edge][0] = f; } diff --git a/libs/MeshKernel/src/Utilities/RTree.cpp b/libs/MeshKernel/src/Utilities/RTree.cpp index 47d871f9f..e75dbea61 100644 --- a/libs/MeshKernel/src/Utilities/RTree.cpp +++ b/libs/MeshKernel/src/Utilities/RTree.cpp @@ -88,14 +88,12 @@ void RTree::SearchNearestPoint(Point const& node) } } -void RTree::DeleteNode(size_t position) +void RTree::DeleteNode(UInt position) { const auto numberRemoved = m_rtree2D.remove(m_points[position]); if (numberRemoved != 1) { throw std::invalid_argument("DeleteNode: Could not remove node at given position."); } - m_points[position] = {Point2D{constants::missing::doubleValue, - constants::missing::doubleValue}, - std::numeric_limits::max()}; + m_points[position] = {Point2D{constants::missing::doubleValue, constants::missing::doubleValue}, std::numeric_limits::max()}; } diff --git a/libs/MeshKernel/tests/src/AveragingTests.cpp b/libs/MeshKernel/tests/src/AveragingTests.cpp index 8a84c29a5..532ec0898 100644 --- a/libs/MeshKernel/tests/src/AveragingTests.cpp +++ b/libs/MeshKernel/tests/src/AveragingTests.cpp @@ -68,7 +68,7 @@ TEST(Averaging, InterpolateOnEdgesSimpleAveraging) { std::vector samples = ReadSampleFile(TEST_FOLDER + "/data/AveragingInterpolationTests/inTestAveragingInterpolation.xyz"); auto mesh = ReadLegacyMesh2DFromFile(TEST_FOLDER + "/data/AveragingInterpolationTests/simple_grid_net.nc"); - ASSERT_GT(mesh->GetNumNodes(), 0); + ASSERT_GT(mesh->GetNumNodes(), static_cast(0)); // Execute averaging meshkernel::AveragingInterpolation averaging(*mesh, @@ -109,7 +109,7 @@ TEST(Averaging, InterpolateOnNodesSimpleAveraging) { std::vector samples = ReadSampleFile(TEST_FOLDER + "/data/AveragingInterpolationTests/inTestAveragingInterpolation.xyz"); auto mesh = ReadLegacyMesh2DFromFile(TEST_FOLDER + "/data/AveragingInterpolationTests/simple_grid_net.nc"); - ASSERT_GT(mesh->GetNumNodes(), 0); + ASSERT_GT(mesh->GetNumNodes(), static_cast(0)); // Execute averaging meshkernel::AveragingInterpolation averaging(*mesh, @@ -150,7 +150,7 @@ TEST(Averaging, InterpolateOnFacesSimpleAveraging) { std::vector samples = ReadSampleFile(TEST_FOLDER + "/data/AveragingInterpolationTests/inTestAveragingInterpolation.xyz"); auto mesh = ReadLegacyMesh2DFromFile(TEST_FOLDER + "/data/AveragingInterpolationTests/simple_grid_net.nc"); - ASSERT_GT(mesh->GetNumNodes(), 0); + ASSERT_GT(mesh->GetNumNodes(), static_cast(0)); // Execute averaging meshkernel::AveragingInterpolation averaging(*mesh, @@ -192,7 +192,7 @@ TEST(Averaging, InterpolateOnEdgesClosestPoint) { std::vector samples = ReadSampleFile(TEST_FOLDER + "/data/AveragingInterpolationTests/inTestAveragingInterpolation.xyz"); auto mesh = ReadLegacyMesh2DFromFile(TEST_FOLDER + "/data/AveragingInterpolationTests/sample_grid_coarse_net.nc"); - ASSERT_GT(mesh->GetNumNodes(), 0); + ASSERT_GT(mesh->GetNumNodes(), static_cast(0)); // Execute averaging meshkernel::AveragingInterpolation averaging(*mesh, @@ -233,7 +233,7 @@ TEST(Averaging, InterpolateOnNodesClosestPoint) { std::vector samples = ReadSampleFile(TEST_FOLDER + "/data/AveragingInterpolationTests/inTestAveragingInterpolation.xyz"); auto mesh = ReadLegacyMesh2DFromFile(TEST_FOLDER + "/data/AveragingInterpolationTests/sample_grid_coarse_net.nc"); - ASSERT_GT(mesh->GetNumNodes(), 0); + ASSERT_GT(mesh->GetNumNodes(), static_cast(0)); // Execute averaging meshkernel::AveragingInterpolation averaging(*mesh, @@ -272,7 +272,7 @@ TEST(Averaging, InterpolateOnFacesClosestPoint) { std::vector samples = ReadSampleFile(TEST_FOLDER + "/data/AveragingInterpolationTests/inTestAveragingInterpolation.xyz"); auto mesh = ReadLegacyMesh2DFromFile(TEST_FOLDER + "/data/AveragingInterpolationTests/sample_grid_coarse_net.nc"); - ASSERT_GT(mesh->GetNumNodes(), 0); + ASSERT_GT(mesh->GetNumNodes(), static_cast(0)); // Execute averaging meshkernel::AveragingInterpolation averaging(*mesh, @@ -304,7 +304,7 @@ TEST(Averaging, InterpolateOnEdgesMax) { std::vector samples = ReadSampleFile(TEST_FOLDER + "/data/AveragingInterpolationTests/inTestAveragingInterpolation.xyz"); auto mesh = ReadLegacyMesh2DFromFile(TEST_FOLDER + "/data/AveragingInterpolationTests/sample_grid_coarse_net.nc"); - ASSERT_GT(mesh->GetNumNodes(), 0); + ASSERT_GT(mesh->GetNumNodes(), static_cast(0)); // Execute averaging meshkernel::AveragingInterpolation averaging(*mesh, @@ -345,7 +345,7 @@ TEST(Averaging, InterpolateOnNodesMax) { std::vector samples = ReadSampleFile(TEST_FOLDER + "/data/AveragingInterpolationTests/inTestAveragingInterpolation.xyz"); auto mesh = ReadLegacyMesh2DFromFile(TEST_FOLDER + "/data/AveragingInterpolationTests/sample_grid_coarse_net.nc"); - ASSERT_GT(mesh->GetNumNodes(), 0); + ASSERT_GT(mesh->GetNumNodes(), static_cast(0)); // Execute averaging meshkernel::AveragingInterpolation averaging(*mesh, @@ -384,7 +384,7 @@ TEST(Averaging, InterpolateOnFacesMax) { std::vector samples = ReadSampleFile(TEST_FOLDER + "/data/AveragingInterpolationTests/inTestAveragingInterpolation.xyz"); auto mesh = ReadLegacyMesh2DFromFile(TEST_FOLDER + "/data/AveragingInterpolationTests/sample_grid_coarse_net.nc"); - ASSERT_GT(mesh->GetNumNodes(), 0); + ASSERT_GT(mesh->GetNumNodes(), static_cast(0)); // Execute averaging meshkernel::AveragingInterpolation averaging(*mesh, @@ -416,7 +416,7 @@ TEST(Averaging, InterpolateOnEdgesMin) { std::vector samples = ReadSampleFile(TEST_FOLDER + "/data/AveragingInterpolationTests/inTestAveragingInterpolation.xyz"); auto mesh = ReadLegacyMesh2DFromFile(TEST_FOLDER + "/data/AveragingInterpolationTests/sample_grid_coarse_net.nc"); - ASSERT_GT(mesh->GetNumNodes(), 0); + ASSERT_GT(mesh->GetNumNodes(), static_cast(0)); // Execute averaging meshkernel::AveragingInterpolation averaging(*mesh, @@ -457,7 +457,7 @@ TEST(Averaging, InterpolateOnNodesMin) { std::vector samples = ReadSampleFile(TEST_FOLDER + "/data/AveragingInterpolationTests/inTestAveragingInterpolation.xyz"); auto mesh = ReadLegacyMesh2DFromFile(TEST_FOLDER + "/data/AveragingInterpolationTests/sample_grid_coarse_net.nc"); - ASSERT_GT(mesh->GetNumNodes(), 0); + ASSERT_GT(mesh->GetNumNodes(), static_cast(0)); // Execute averaging meshkernel::AveragingInterpolation averaging(*mesh, @@ -496,7 +496,7 @@ TEST(Averaging, InterpolateOnFacesMin) { std::vector samples = ReadSampleFile(TEST_FOLDER + "/data/AveragingInterpolationTests/inTestAveragingInterpolation.xyz"); auto mesh = ReadLegacyMesh2DFromFile(TEST_FOLDER + "/data/AveragingInterpolationTests/sample_grid_coarse_net.nc"); - ASSERT_GT(mesh->GetNumNodes(), 0); + ASSERT_GT(mesh->GetNumNodes(), static_cast(0)); // Execute averaging meshkernel::AveragingInterpolation averaging(*mesh, @@ -528,7 +528,7 @@ TEST(Averaging, InterpolateOnEdgesInverseWeightedDistance) { std::vector samples = ReadSampleFile(TEST_FOLDER + "/data/AveragingInterpolationTests/inTestAveragingInterpolation.xyz"); auto mesh = ReadLegacyMesh2DFromFile(TEST_FOLDER + "/data/AveragingInterpolationTests/sample_grid_coarse_net.nc"); - ASSERT_GT(mesh->GetNumNodes(), 0); + ASSERT_GT(mesh->GetNumNodes(), static_cast(0)); // Execute averaging meshkernel::AveragingInterpolation averaging(*mesh, @@ -569,7 +569,7 @@ TEST(Averaging, InterpolateOnNodesInverseWeightedDistance) { std::vector samples = ReadSampleFile(TEST_FOLDER + "/data/AveragingInterpolationTests/inTestAveragingInterpolation.xyz"); auto mesh = ReadLegacyMesh2DFromFile(TEST_FOLDER + "/data/AveragingInterpolationTests/sample_grid_coarse_net.nc"); - ASSERT_GT(mesh->GetNumNodes(), 0); + ASSERT_GT(mesh->GetNumNodes(), static_cast(0)); // Execute averaging meshkernel::AveragingInterpolation averaging(*mesh, @@ -608,7 +608,7 @@ TEST(Averaging, InterpolateOnFacesInverseWeightedDistance) { std::vector samples = ReadSampleFile(TEST_FOLDER + "/data/AveragingInterpolationTests/inTestAveragingInterpolation.xyz"); auto mesh = ReadLegacyMesh2DFromFile(TEST_FOLDER + "/data/AveragingInterpolationTests/sample_grid_coarse_net.nc"); - ASSERT_GT(mesh->GetNumNodes(), 0); + ASSERT_GT(mesh->GetNumNodes(), static_cast(0)); // Execute averaging meshkernel::AveragingInterpolation averaging(*mesh, @@ -640,7 +640,7 @@ TEST(Averaging, InterpolateOnEdgesMinAbsValue) { std::vector samples = ReadSampleFile(TEST_FOLDER + "/data/AveragingInterpolationTests/inTestAveragingInterpolation.xyz"); auto mesh = ReadLegacyMesh2DFromFile(TEST_FOLDER + "/data/AveragingInterpolationTests/sample_grid_coarse_net.nc"); - ASSERT_GT(mesh->GetNumNodes(), 0); + ASSERT_GT(mesh->GetNumNodes(), static_cast(0)); // Execute averaging meshkernel::AveragingInterpolation averaging(*mesh, @@ -681,7 +681,7 @@ TEST(Averaging, InterpolateOnNodesMinAbsValue) { std::vector samples = ReadSampleFile(TEST_FOLDER + "/data/AveragingInterpolationTests/inTestAveragingInterpolation.xyz"); auto mesh = ReadLegacyMesh2DFromFile(TEST_FOLDER + "/data/AveragingInterpolationTests/sample_grid_coarse_net.nc"); - ASSERT_GT(mesh->GetNumNodes(), 0); + ASSERT_GT(mesh->GetNumNodes(), static_cast(0)); // Execute averaging meshkernel::AveragingInterpolation averaging(*mesh, @@ -735,7 +735,7 @@ TEST(Averaging, Interpolate_WithSamplesOnEdges_ShouldNotExtendSampleCoverage) {4.0, 1.5, 1.0}, {4.0, 2.5, 1.0}}; - ASSERT_GT(mesh->GetNumNodes(), 0); + ASSERT_GT(mesh->GetNumNodes(), static_cast(0)); // Execute averaging meshkernel::AveragingInterpolation averaging(*mesh, @@ -783,7 +783,7 @@ TEST(Averaging, Interpolate_WithSamplesOnNodes_ShouldNotExtendSampleCoverage) {4.0, 2.0, 1.0}, {4.0, 3.0, 1.0}}; - ASSERT_GT(mesh->GetNumNodes(), 0); + ASSERT_GT(mesh->GetNumNodes(), static_cast(0)); // Execute averaging, this time the minimum number of samples should at least be 2 meshkernel::AveragingInterpolation averaging(*mesh, diff --git a/libs/MeshKernel/tests/src/ContactsTests.cpp b/libs/MeshKernel/tests/src/ContactsTests.cpp index df5c6524a..7b4563f0d 100644 --- a/libs/MeshKernel/tests/src/ContactsTests.cpp +++ b/libs/MeshKernel/tests/src/ContactsTests.cpp @@ -197,7 +197,7 @@ TEST(Contacts, ComputeContactsWithPolygons) {752.151462, 786.57487}}; std::vector edges; - for (size_t index = 0; index < nodes.size() - 1; ++index) + for (meshkernel::UInt index = 0; index < nodes.size() - 1; ++index) { edges.emplace_back(meshkernel::Edge{index, index + 1}); } diff --git a/libs/MeshKernel/tests/src/CurvilinearGridFromSplinesTests.cpp b/libs/MeshKernel/tests/src/CurvilinearGridFromSplinesTests.cpp index 2164700cf..2d7a6573d 100644 --- a/libs/MeshKernel/tests/src/CurvilinearGridFromSplinesTests.cpp +++ b/libs/MeshKernel/tests/src/CurvilinearGridFromSplinesTests.cpp @@ -16,12 +16,12 @@ TEST(CurvilinearGridFromSplines, ComputeSplinesProperties) {850.255920410156, 499.130676269531}}; auto splines = std::make_shared(Projection::cartesian); - splines->AddSpline(firstSpline, 0, firstSpline.size()); + splines->AddSpline(firstSpline, 0, static_cast(firstSpline.size())); std::vector secondSpline{{72.5010681152344, 391.129577636719}, {462.503479003906, 90.3765411376953}}; - splines->AddSpline(secondSpline, 0, secondSpline.size()); + splines->AddSpline(secondSpline, 0, static_cast(secondSpline.size())); // construct CurvilinearGridFromSplines CurvilinearParameters curvilinearParameters; @@ -80,23 +80,23 @@ TEST(CurvilinearGridFromSplines, ComputeBoundingBox) {770.755432128906, 607.881774902344}}; auto splines = std::make_shared(Projection::cartesian); - splines->AddSpline(firstSpline, 0, firstSpline.size()); + splines->AddSpline(firstSpline, 0, static_cast(firstSpline.size())); std::vector secondSpline; secondSpline.emplace_back(Point{273.502319335938, 86.6264953613281}); secondSpline.emplace_back(Point{557.004089355469, 316.128814697266}); secondSpline.emplace_back(Point{847.255920410156, 409.129730224609}); - splines->AddSpline(secondSpline, 0, secondSpline.size()); + splines->AddSpline(secondSpline, 0, static_cast(secondSpline.size())); std::vector thirdSpline; thirdSpline.emplace_back(Point{62.7510070800781, 396.379608154297}); thirdSpline.emplace_back(Point{350.752807617188, 73.8763732910156}); - splines->AddSpline(thirdSpline, 0, thirdSpline.size()); + splines->AddSpline(thirdSpline, 0, static_cast(thirdSpline.size())); std::vector fourthSpline; fourthSpline.emplace_back(Point{704.755004882812, 636.382019042969}); fourthSpline.emplace_back(Point{845.005859375000, 285.378509521484}); - splines->AddSpline(fourthSpline, 0, fourthSpline.size()); + splines->AddSpline(fourthSpline, 0, static_cast(fourthSpline.size())); // construct CurvilinearGridFromSplines CurvilinearParameters curvilinearParameters; @@ -130,12 +130,12 @@ TEST(CurvilinearGridFromSplines, OrthogonalCurvilinearMeshTwoCrossingCurvatureAd {2048.50780774173, 1644.48279915859}}; auto splines = std::make_shared(Projection::cartesian); - splines->AddSpline(firstSpline, 0, firstSpline.size()); + splines->AddSpline(firstSpline, 0, static_cast(firstSpline.size())); std::vector secondSpline; secondSpline.emplace_back(Point{-179.920786312031, 1068.50251010579}); secondSpline.emplace_back(Point{600.169022647819, 321.964950993679}); - splines->AddSpline(secondSpline, 0, secondSpline.size()); + splines->AddSpline(secondSpline, 0, static_cast(secondSpline.size())); // construct CurvilinearGridFromSplines CurvilinearParameters curvilinearParameters; @@ -196,12 +196,12 @@ TEST(CurvilinearGridFromSplines, OrthogonalCurvilinearMeshTwoCrossingCurvatureNo {2048.50780774173, 1644.48279915859}}; auto splines = std::make_shared(Projection::cartesian); - splines->AddSpline(firstSpline, 0, firstSpline.size()); + splines->AddSpline(firstSpline, 0, static_cast(firstSpline.size())); std::vector secondSpline; secondSpline.emplace_back(Point{-179.920786312031, 1068.50251010579}); secondSpline.emplace_back(Point{600.169022647819, 321.964950993679}); - splines->AddSpline(secondSpline, 0, secondSpline.size()); + splines->AddSpline(secondSpline, 0, static_cast(secondSpline.size())); CurvilinearParameters curvilinearParameters; SplinesToCurvilinearParameters splinesToCurvilinearParameters; @@ -262,12 +262,12 @@ TEST(CurvilinearGridFromSplines, OrthogonalCurvilinearMeshTwoCrossingCurvatureAd {2048.50780774173, 1644.48279915859}}; auto splines = std::make_shared(Projection::cartesian); - splines->AddSpline(firstSpline, 0, firstSpline.size()); + splines->AddSpline(firstSpline, 0, static_cast(firstSpline.size())); std::vector secondSpline; secondSpline.emplace_back(Point{-179.920786312031, 1068.50251010579}); secondSpline.emplace_back(Point{600.169022647819, 321.964950993679}); - splines->AddSpline(secondSpline, 0, secondSpline.size()); + splines->AddSpline(secondSpline, 0, static_cast(secondSpline.size())); CurvilinearParameters curvilinearParameters; SplinesToCurvilinearParameters splinesToCurvilinearParameters; @@ -363,22 +363,22 @@ TEST(CurvilinearGridFromSplines, OrthogonalCurvilinearMeshFourSplineCrossingFron {1498.58116776234, 776.950530211586}}; auto splines = std::make_shared(Projection::cartesian); - splines->AddSpline(firstSpline, 0, firstSpline.size()); + splines->AddSpline(firstSpline, 0, static_cast(firstSpline.size())); std::vector secondSpline{{-250.826438421303, 394.996536194825}, {101.970762159065, 292.947759167446}}; - splines->AddSpline(secondSpline, 0, secondSpline.size()); + splines->AddSpline(secondSpline, 0, static_cast(secondSpline.size())); std::vector thirdSpline{{647.202799419633, 482.466916504007}, {486.840435519465, 144.248112641836}}; - splines->AddSpline(thirdSpline, 0, thirdSpline.size()); + splines->AddSpline(thirdSpline, 0, static_cast(thirdSpline.size())); std::vector fourthSpline{{1224.50730946023, 747.793736775192}, {1568.55747200968, 464.97284044217}}; - splines->AddSpline(fourthSpline, 0, fourthSpline.size()); + splines->AddSpline(fourthSpline, 0, static_cast(fourthSpline.size())); CurvilinearParameters curvilinearParameters; SplinesToCurvilinearParameters splinesToCurvilinearParameters; @@ -462,39 +462,39 @@ TEST(CurvilinearGridFromSplines, OrthogonalCurvilinearGridFromSplineWithSevenSpl std::vector firstCentralSpline{{1.542516E+02, 7.687640E+01}, {3.192526E+02, 2.733784E+02}, {6.350046E+02, 5.231309E+02}}; - splines->AddSpline(firstCentralSpline, 0, firstCentralSpline.size()); + splines->AddSpline(firstCentralSpline, 0, static_cast(firstCentralSpline.size())); std::vector secondCentralSpline{{1.310014E+02, 9.637659E+01}, {2.960025E+02, 2.891285E+02}, {6.222545E+02, 5.418811E+02}}; - splines->AddSpline(secondCentralSpline, 0, secondCentralSpline.size()); + splines->AddSpline(secondCentralSpline, 0, static_cast(secondCentralSpline.size())); std::vector thirdCentralSpline{{1.782517E+02, 5.662619E+01}, {3.335027E+02, 2.448781E+02}, {6.455046E+02, 4.983806E+02}}; - splines->AddSpline(thirdCentralSpline, 0, thirdCentralSpline.size()); + splines->AddSpline(thirdCentralSpline, 0, static_cast(thirdCentralSpline.size())); std::vector fourthBankSpline{{3.500084E+01, 1.901275E+02}, {2.195020E+02, 3.813795E+02}, {5.727542E+02, 6.221319E+02}}; - splines->AddSpline(fourthBankSpline, 0, fourthBankSpline.size()); + splines->AddSpline(fourthBankSpline, 0, static_cast(fourthBankSpline.size())); std::vector fifthBankSpline{{3.177526E+02, -3.712475E+01}, {4.377534E+02, 1.218768E+02}, {7.445052E+02, 4.136298E+02}}; - splines->AddSpline(fifthBankSpline, 0, fifthBankSpline.size()); + splines->AddSpline(fifthBankSpline, 0, static_cast(fifthBankSpline.size())); std::vector sixthBankSpline{{1.250633E+00, 2.748784E+02}, {3.620029E+02, -3.337471E+01}}; - splines->AddSpline(sixthBankSpline, 0, sixthBankSpline.size()); + splines->AddSpline(sixthBankSpline, 0, static_cast(sixthBankSpline.size())); std::vector seventhBankSpline{{5.030038E+02, 6.476321E+02}, {7.542553E+02, 3.378790E+02}}; - splines->AddSpline(seventhBankSpline, 0, seventhBankSpline.size()); + splines->AddSpline(seventhBankSpline, 0, static_cast(seventhBankSpline.size())); CurvilinearParameters curvilinearParameters; SplinesToCurvilinearParameters splinesToCurvilinearParameters; @@ -620,11 +620,11 @@ TEST(CurvilinearGridFromSplines, OrthogonalCurvilinearMeshTwoCrossingCurvatureAd {4.110644E+01, 4.110904E+01}}; auto splines = std::make_shared(Projection::spherical); - splines->AddSpline(firstSpline, 0, firstSpline.size()); + splines->AddSpline(firstSpline, 0, static_cast(firstSpline.size())); std::vector secondSpline{{4.109612E+01, 4.110473E+01}, {4.109923E+01, 4.110212E+01}}; - splines->AddSpline(secondSpline, 0, secondSpline.size()); + splines->AddSpline(secondSpline, 0, static_cast(secondSpline.size())); CurvilinearParameters curvilinearParameters; SplinesToCurvilinearParameters splinesToCurvilinearParameters; @@ -704,12 +704,12 @@ TEST(CurvilinearGridFromSplines, OrthogonalCurvilinearMeshTwoCrossingHighCurvatu {1465.84415268176, 1608.50892444055}}; auto splines = std::make_shared(Projection::cartesian); - splines->AddSpline(firstSpline, 0, firstSpline.size()); + splines->AddSpline(firstSpline, 0, static_cast(firstSpline.size())); std::vector secondSpline{{-333.478887051536, 921.388799234953}, {167.303577081355, 490.482958004326}}; - splines->AddSpline(secondSpline, 0, secondSpline.size()); + splines->AddSpline(secondSpline, 0, static_cast(secondSpline.size())); CurvilinearParameters curvilinearParameters; SplinesToCurvilinearParameters splinesToCurvilinearParameters; @@ -772,12 +772,12 @@ TEST(CurvilinearGridFromSplines, OrthogonalCurvilinearMeshTwoCrossingHighCurvatu {1465.84415268176, 1608.50892444055}}; auto splines = std::make_shared(Projection::cartesian); - splines->AddSpline(firstSpline, 0, firstSpline.size()); + splines->AddSpline(firstSpline, 0, static_cast(firstSpline.size())); std::vector secondSpline{{-333.478887051536, 921.388799234953}, {167.303577081355, 490.482958004326}}; - splines->AddSpline(secondSpline, 0, secondSpline.size()); + splines->AddSpline(secondSpline, 0, static_cast(secondSpline.size())); CurvilinearParameters curvilinearParameters; SplinesToCurvilinearParameters splinesToCurvilinearParameters; @@ -860,7 +860,7 @@ TEST(CurvilinearGridFromSplines, Compute_ThreeLongitudinalSplinesTwoCrossingSpli {7.9579184E+04, 3.6419894E+05}}; auto splines = std::make_shared(Projection::cartesian); - splines->AddSpline(firstSpline, 0, firstSpline.size()); + splines->AddSpline(firstSpline, 0, static_cast(firstSpline.size())); std::vector secondSpline{{7.6618112E+04, 3.7136337E+05}, {7.6754253E+04, 3.7005301E+05}, @@ -871,7 +871,7 @@ TEST(CurvilinearGridFromSplines, Compute_ThreeLongitudinalSplinesTwoCrossingSpli {7.9477078E+04, 3.6544123E+05}, {7.8779354E+04, 3.6452228E+05}}; - splines->AddSpline(secondSpline, 0, secondSpline.size()); + splines->AddSpline(secondSpline, 0, static_cast(secondSpline.size())); std::vector thirdSpline{{7.7281800E+04, 3.7144846E+05}, {7.7366889E+04, 3.6984880E+05}, @@ -883,17 +883,17 @@ TEST(CurvilinearGridFromSplines, Compute_ThreeLongitudinalSplinesTwoCrossingSpli {7.9579184E+04, 3.6484561E+05}, {7.9170760E+04, 3.6431806E+05}}; - splines->AddSpline(thirdSpline, 0, thirdSpline.size()); + splines->AddSpline(thirdSpline, 0, static_cast(thirdSpline.size())); std::vector fourthSpline{{7.613792E+04, 3.712157E+05}, {7.831719E+04, 3.710751E+05}}; - splines->AddSpline(fourthSpline, 0, fourthSpline.size()); + splines->AddSpline(fourthSpline, 0, static_cast(fourthSpline.size())); std::vector fifthSpline{{7.857202E+04, 3.649151E+05}, {8.003072E+04, 3.641506E+05}}; - splines->AddSpline(fifthSpline, 0, fifthSpline.size()); + splines->AddSpline(fifthSpline, 0, static_cast(fifthSpline.size())); SplinesToCurvilinearParameters splinesToCurvilinearParameters; CurvilinearParameters curvilinearParameters; diff --git a/libs/MeshKernel/tests/src/CurvilinearGridFromSplinesTransfiniteTests.cpp b/libs/MeshKernel/tests/src/CurvilinearGridFromSplinesTransfiniteTests.cpp index 58949bbff..b3856b7c1 100644 --- a/libs/MeshKernel/tests/src/CurvilinearGridFromSplinesTransfiniteTests.cpp +++ b/libs/MeshKernel/tests/src/CurvilinearGridFromSplinesTransfiniteTests.cpp @@ -15,20 +15,20 @@ TEST(CurvilinearGridFromSplinesTransfinite, FourSplines) {8.064374E+02, 3.987241E+02}}; auto splines = std::make_shared(Projection::cartesian); - splines->AddSpline(firstSpline, 0, firstSpline.size()); + splines->AddSpline(firstSpline, 0, static_cast(firstSpline.size())); std::vector secondSpline{{2.894012E+01, 2.010146E+02}, {2.344944E+02, 3.720490E+02}, {6.424647E+02, 5.917262E+02}}; - splines->AddSpline(secondSpline, 0, secondSpline.size()); + splines->AddSpline(secondSpline, 0, static_cast(secondSpline.size())); std::vector thirdSpline{{2.265137E+00, 2.802553E+02}, {2.799988E+02, -2.807726E+01}}; - splines->AddSpline(thirdSpline, 0, thirdSpline.size()); + splines->AddSpline(thirdSpline, 0, static_cast(thirdSpline.size())); std::vector fourthSpline{{5.067361E+02, 6.034946E+02}, {7.475956E+02, 3.336055E+02}}; - splines->AddSpline(fourthSpline, 0, fourthSpline.size()); + splines->AddSpline(fourthSpline, 0, static_cast(fourthSpline.size())); CurvilinearParameters curvilinearParameters; curvilinearParameters.n_refinement = 40; @@ -95,20 +95,20 @@ TEST(CurvilinearGridFromSplinesTransfinite, FourSplinesOneNSwapped) {8.064374E+02, 3.987241E+02}}; auto splines = std::make_shared(Projection::cartesian); - splines->AddSpline(firstSpline, 0, firstSpline.size()); + splines->AddSpline(firstSpline, 0, static_cast(firstSpline.size())); std::vector secondSpline{{2.894012E+01, 2.010146E+02}, {2.344944E+02, 3.720490E+02}, {6.424647E+02, 5.917262E+02}}; - splines->AddSpline(secondSpline, 0, secondSpline.size()); + splines->AddSpline(secondSpline, 0, static_cast(secondSpline.size())); std::vector fourthSpline{{5.067361E+02, 6.034946E+02}, {7.475956E+02, 3.336055E+02}}; - splines->AddSpline(fourthSpline, 0, fourthSpline.size()); + splines->AddSpline(fourthSpline, 0, static_cast(fourthSpline.size())); std::vector thirdSpline{{2.265137E+00, 2.802553E+02}, {2.799988E+02, -2.807726E+01}}; - splines->AddSpline(thirdSpline, 0, thirdSpline.size()); + splines->AddSpline(thirdSpline, 0, static_cast(thirdSpline.size())); CurvilinearParameters curvilinearParameters; curvilinearParameters.n_refinement = 40; @@ -175,24 +175,24 @@ TEST(CurvilinearGridFromSplinesTransfinite, FiveSplines) {8.064374E+02, 3.987241E+02}}; auto splines = std::make_shared(Projection::cartesian); - splines->AddSpline(firstSpline, 0, firstSpline.size()); + splines->AddSpline(firstSpline, 0, static_cast(firstSpline.size())); std::vector secondSpline{{2.894012E+01, 2.010146E+02}, {2.344944E+02, 3.720490E+02}, {6.424647E+02, 5.917262E+02}}; - splines->AddSpline(secondSpline, 0, secondSpline.size()); + splines->AddSpline(secondSpline, 0, static_cast(secondSpline.size())); std::vector thirdSpline{{2.265137E+00, 2.802553E+02}, {2.799988E+02, -2.807726E+01}}; - splines->AddSpline(thirdSpline, 0, thirdSpline.size()); + splines->AddSpline(thirdSpline, 0, static_cast(thirdSpline.size())); std::vector fourthSpline{{5.067361E+02, 6.034946E+02}, {7.475956E+02, 3.336055E+02}}; - splines->AddSpline(fourthSpline, 0, fourthSpline.size()); + splines->AddSpline(fourthSpline, 0, static_cast(fourthSpline.size())); std::vector fifthSpline{{2.673223E+02, 4.706788E+02}, {5.513401E+02, 1.545069E+02}}; - splines->AddSpline(fifthSpline, 0, fifthSpline.size()); + splines->AddSpline(fifthSpline, 0, static_cast(fifthSpline.size())); CurvilinearParameters curvilinearParameters; curvilinearParameters.n_refinement = 40; diff --git a/libs/MeshKernel/tests/src/LandBoundaryTests.cpp b/libs/MeshKernel/tests/src/LandBoundaryTests.cpp index db91f6e48..00b9354fa 100644 --- a/libs/MeshKernel/tests/src/LandBoundaryTests.cpp +++ b/libs/MeshKernel/tests/src/LandBoundaryTests.cpp @@ -34,9 +34,9 @@ TEST(LandBoundaries, OneLandBoundary) EXPECT_EQ(3, landboundaries->m_meshNodesLandBoundarySegments[4]); EXPECT_EQ(1, landboundaries->m_meshNodesLandBoundarySegments[5]); EXPECT_EQ(1, landboundaries->m_meshNodesLandBoundarySegments[6]); - EXPECT_EQ(meshkernel::constants::missing::sizetValue, landboundaries->m_meshNodesLandBoundarySegments[7]); - EXPECT_EQ(meshkernel::constants::missing::sizetValue, landboundaries->m_meshNodesLandBoundarySegments[8]); - EXPECT_EQ(meshkernel::constants::missing::sizetValue, landboundaries->m_meshNodesLandBoundarySegments[9]); + EXPECT_EQ(meshkernel::constants::missing::uintValue, landboundaries->m_meshNodesLandBoundarySegments[7]); + EXPECT_EQ(meshkernel::constants::missing::uintValue, landboundaries->m_meshNodesLandBoundarySegments[8]); + EXPECT_EQ(meshkernel::constants::missing::uintValue, landboundaries->m_meshNodesLandBoundarySegments[9]); } TEST(LandBoundaries, TwoLandBoundaries) @@ -71,9 +71,9 @@ TEST(LandBoundaries, TwoLandBoundaries) EXPECT_EQ(3, landboundaries->m_meshNodesLandBoundarySegments[4]); EXPECT_EQ(2, landboundaries->m_meshNodesLandBoundarySegments[5]); EXPECT_EQ(2, landboundaries->m_meshNodesLandBoundarySegments[6]); - EXPECT_EQ(meshkernel::constants::missing::sizetValue, landboundaries->m_meshNodesLandBoundarySegments[7]); - EXPECT_EQ(meshkernel::constants::missing::sizetValue, landboundaries->m_meshNodesLandBoundarySegments[8]); - EXPECT_EQ(meshkernel::constants::missing::sizetValue, landboundaries->m_meshNodesLandBoundarySegments[9]); + EXPECT_EQ(meshkernel::constants::missing::uintValue, landboundaries->m_meshNodesLandBoundarySegments[7]); + EXPECT_EQ(meshkernel::constants::missing::uintValue, landboundaries->m_meshNodesLandBoundarySegments[8]); + EXPECT_EQ(meshkernel::constants::missing::uintValue, landboundaries->m_meshNodesLandBoundarySegments[9]); } TEST(LandBoundaries, OneCrossingLandBoundary) @@ -103,9 +103,9 @@ TEST(LandBoundaries, OneCrossingLandBoundary) EXPECT_EQ(1, landboundaries->m_meshNodesLandBoundarySegments[4]); EXPECT_EQ(1, landboundaries->m_meshNodesLandBoundarySegments[5]); EXPECT_EQ(1, landboundaries->m_meshNodesLandBoundarySegments[6]); - EXPECT_EQ(meshkernel::constants::missing::sizetValue, landboundaries->m_meshNodesLandBoundarySegments[7]); - EXPECT_EQ(meshkernel::constants::missing::sizetValue, landboundaries->m_meshNodesLandBoundarySegments[8]); - EXPECT_EQ(meshkernel::constants::missing::sizetValue, landboundaries->m_meshNodesLandBoundarySegments[9]); + EXPECT_EQ(meshkernel::constants::missing::uintValue, landboundaries->m_meshNodesLandBoundarySegments[7]); + EXPECT_EQ(meshkernel::constants::missing::uintValue, landboundaries->m_meshNodesLandBoundarySegments[8]); + EXPECT_EQ(meshkernel::constants::missing::uintValue, landboundaries->m_meshNodesLandBoundarySegments[9]); } TEST(LandBoundaries, TwoCrossingLandBoundary) @@ -139,7 +139,7 @@ TEST(LandBoundaries, TwoCrossingLandBoundary) EXPECT_EQ(3, landboundaries->m_meshNodesLandBoundarySegments[4]); EXPECT_EQ(2, landboundaries->m_meshNodesLandBoundarySegments[5]); EXPECT_EQ(2, landboundaries->m_meshNodesLandBoundarySegments[6]); - EXPECT_EQ(meshkernel::constants::missing::sizetValue, landboundaries->m_meshNodesLandBoundarySegments[7]); - EXPECT_EQ(meshkernel::constants::missing::sizetValue, landboundaries->m_meshNodesLandBoundarySegments[8]); - EXPECT_EQ(meshkernel::constants::missing::sizetValue, landboundaries->m_meshNodesLandBoundarySegments[9]); + EXPECT_EQ(meshkernel::constants::missing::uintValue, landboundaries->m_meshNodesLandBoundarySegments[7]); + EXPECT_EQ(meshkernel::constants::missing::uintValue, landboundaries->m_meshNodesLandBoundarySegments[8]); + EXPECT_EQ(meshkernel::constants::missing::uintValue, landboundaries->m_meshNodesLandBoundarySegments[9]); } diff --git a/libs/MeshKernel/tests/src/Mesh2DTest.cpp b/libs/MeshKernel/tests/src/Mesh2DTest.cpp index 4f3322ad8..0bc76cdea 100644 --- a/libs/MeshKernel/tests/src/Mesh2DTest.cpp +++ b/libs/MeshKernel/tests/src/Mesh2DTest.cpp @@ -71,10 +71,10 @@ TEST(Mesh2D, OneQuadTestConstructor) ASSERT_EQ(1, mesh.m_edgesNumFaces[3]); // each edge is a boundary edge, so the second entry of edgesFaces is an invalid index (meshkernel::constants::missing::sizetValue) - ASSERT_EQ(meshkernel::constants::missing::sizetValue, mesh.m_edgesFaces[0][1]); - ASSERT_EQ(meshkernel::constants::missing::sizetValue, mesh.m_edgesFaces[1][1]); - ASSERT_EQ(meshkernel::constants::missing::sizetValue, mesh.m_edgesFaces[2][1]); - ASSERT_EQ(meshkernel::constants::missing::sizetValue, mesh.m_edgesFaces[3][1]); + ASSERT_EQ(meshkernel::constants::missing::uintValue, mesh.m_edgesFaces[0][1]); + ASSERT_EQ(meshkernel::constants::missing::uintValue, mesh.m_edgesFaces[1][1]); + ASSERT_EQ(meshkernel::constants::missing::uintValue, mesh.m_edgesFaces[2][1]); + ASSERT_EQ(meshkernel::constants::missing::uintValue, mesh.m_edgesFaces[3][1]); } TEST(Mesh2D, TriangulateSamples) @@ -236,22 +236,22 @@ TEST(Mesh2D, NodeMerging) std::vector> indicesValues(n, std::vector(m)); std::vector nodes(n * m); - std::size_t nodeIndex = 0; + meshkernel::UInt nodeIndex = 0; for (auto j = 0; j < m; ++j) { for (auto i = 0; i < n; ++i) { indicesValues[i][j] = i + j * n; - nodes[nodeIndex] = {(double)i, (double)j}; + nodes[nodeIndex] = {static_cast(i), static_cast(j)}; nodeIndex++; } } std::vector edges((n - 1) * m + (m - 1) * n); - std::size_t edgeIndex = 0; - for (auto j = 0; j < m; ++j) + meshkernel::UInt edgeIndex = 0; + for (meshkernel::UInt j = 0; j < m; ++j) { - for (auto i = 0; i < n - 1; ++i) + for (meshkernel::UInt i = 0; i < n - 1; ++i) { edges[edgeIndex] = {indicesValues[i][j], indicesValues[i + 1][j]}; edgeIndex++; @@ -279,10 +279,10 @@ TEST(Mesh2D, NodeMerging) nodes.resize(mesh.GetNumNodes() * 2); edges.resize(mesh.GetNumEdges() + mesh.GetNumNodes() * 2); - int originalNodeIndex = 0; - for (auto j = 0; j < m; ++j) + meshkernel::UInt originalNodeIndex = 0; + for (meshkernel::UInt j = 0; j < m; ++j) { - for (auto i = 0; i < n; ++i) + for (meshkernel::UInt i = 0; i < n; ++i) { nodes[nodeIndex] = {i + x_distribution(generator), j + y_distribution(generator)}; @@ -359,8 +359,8 @@ TEST(Mesh2D, MillionQuads) auto end(std::chrono::steady_clock::now()); double elapsedTime = std::chrono::duration_cast>(end - start).count(); - // std::cout << "Elapsed time " << elapsedTime << " s " << std::endl; - // std::cout << "Number of found cells " << mesh.GetNumFaces() << std::endl; + std::cout << "Elapsed time " << elapsedTime << " s " << std::endl; + std::cout << "Number of found cells " << mesh.GetNumFaces() << std::endl; EXPECT_LE(elapsedTime, 5.0); } diff --git a/libs/MeshKernel/tests/src/MeshTests.cpp b/libs/MeshKernel/tests/src/MeshTests.cpp index 3c27c297d..26cf5cb68 100644 --- a/libs/MeshKernel/tests/src/MeshTests.cpp +++ b/libs/MeshKernel/tests/src/MeshTests.cpp @@ -69,10 +69,10 @@ TEST(Mesh, OneQuadTestConstructor) ASSERT_EQ(1, mesh.m_edgesNumFaces[3]); // each edge is a boundary edge, so the second entry of edgesFaces is an invalid index (meshkernel::constants::missing::sizetValue) - ASSERT_EQ(meshkernel::constants::missing::sizetValue, mesh.m_edgesFaces[0][1]); - ASSERT_EQ(meshkernel::constants::missing::sizetValue, mesh.m_edgesFaces[1][1]); - ASSERT_EQ(meshkernel::constants::missing::sizetValue, mesh.m_edgesFaces[2][1]); - ASSERT_EQ(meshkernel::constants::missing::sizetValue, mesh.m_edgesFaces[3][1]); + ASSERT_EQ(meshkernel::constants::missing::uintValue, mesh.m_edgesFaces[0][1]); + ASSERT_EQ(meshkernel::constants::missing::uintValue, mesh.m_edgesFaces[1][1]); + ASSERT_EQ(meshkernel::constants::missing::uintValue, mesh.m_edgesFaces[2][1]); + ASSERT_EQ(meshkernel::constants::missing::uintValue, mesh.m_edgesFaces[3][1]); } TEST(Mesh2D, TriangulateSamplesWithSkinnyTriangle) @@ -224,7 +224,7 @@ TEST(Mesh, NodeMerging) std::vector> indicesValues(n, std::vector(m)); std::vector nodes(n * m); - std::size_t nodeIndex = 0; + meshkernel::UInt nodeIndex = 0; for (auto j = 0; j < m; ++j) { for (auto i = 0; i < n; ++i) @@ -267,10 +267,10 @@ TEST(Mesh, NodeMerging) nodes.resize(mesh.GetNumNodes() * 2); edges.resize(mesh.GetNumEdges() + mesh.GetNumNodes() * 2); - int originalNodeIndex = 0; - for (auto j = 0; j < m; ++j) + meshkernel::UInt originalNodeIndex = 0; + for (meshkernel::UInt j = 0; j < m; ++j) { - for (auto i = 0; i < n; ++i) + for (meshkernel::UInt i = 0; i < n; ++i) { nodes[nodeIndex] = {i + x_distribution(generator), j + y_distribution(generator)}; @@ -308,33 +308,33 @@ TEST(Mesh, MillionQuads) const int n = 4; // x const int m = 4; // y - std::vector> indicesValues(n, std::vector(m)); + std::vector> indicesValues(n, std::vector(m)); std::vector nodes(n * m); std::size_t nodeIndex = 0; - for (auto j = 0; j < m; ++j) + for (meshkernel::UInt j = 0; j < m; ++j) { - for (auto i = 0; i < n; ++i) + for (meshkernel::UInt i = 0; i < n; ++i) { indicesValues[i][j] = i + j * n; - nodes[nodeIndex] = {(double)i, (double)j}; + nodes[nodeIndex] = {static_cast(i), static_cast(j)}; nodeIndex++; } } std::vector edges((n - 1) * m + (m - 1) * n); std::size_t edgeIndex = 0; - for (auto j = 0; j < m; ++j) + for (meshkernel::UInt j = 0; j < m; ++j) { - for (auto i = 0; i < n - 1; ++i) + for (meshkernel::UInt i = 0; i < n - 1; ++i) { edges[edgeIndex] = {indicesValues[i][j], indicesValues[i + 1][j]}; edgeIndex++; } } - for (auto j = 0; j < m - 1; ++j) + for (meshkernel::UInt j = 0; j < m - 1; ++j) { - for (auto i = 0; i < n; ++i) + for (meshkernel::UInt i = 0; i < n; ++i) { edges[edgeIndex] = {indicesValues[i][j + 1], indicesValues[i][j]}; edgeIndex++; diff --git a/libs/MeshKernel/tests/src/SplineTests.cpp b/libs/MeshKernel/tests/src/SplineTests.cpp index c996454e6..02691e49f 100644 --- a/libs/MeshKernel/tests/src/SplineTests.cpp +++ b/libs/MeshKernel/tests/src/SplineTests.cpp @@ -14,7 +14,7 @@ TEST(Splines, SetSpline) {1030.506469726562, 653.380187988281}}); meshkernel::Splines splines(meshkernel::Projection::cartesian); - splines.AddSpline(splineNodes, 0, splineNodes.size()); + splines.AddSpline(splineNodes, 0, static_cast(splineNodes.size())); ASSERT_EQ(1, splines.GetNumSplines()); ASSERT_EQ(4, splines.m_splineNodes[0].size()); @@ -29,7 +29,7 @@ TEST(Splines, CubicSplineInterpolation) splineNodes.push_back(meshkernel::Point{930.506469726562, 453.380187988281}); int pointsBetweenNodes = 20; - auto coordinatesDerivatives = meshkernel::Splines::SecondOrderDerivative(splineNodes, 0, splineNodes.size() - 1); + auto coordinatesDerivatives = meshkernel::Splines::SecondOrderDerivative(splineNodes, 0, static_cast(splineNodes.size()) - 1); std::vector splineCoordinates; for (size_t n = 0; n < splineNodes.size() - 1; n++) @@ -68,12 +68,12 @@ TEST(Splines, SplineIntersection) meshkernel::Splines splines(meshkernel::Projection::cartesian); - splines.AddSpline(firstSpline, 0, firstSpline.size()); + splines.AddSpline(firstSpline, 0, static_cast(firstSpline.size())); std::vector secondSpline; secondSpline.push_back(meshkernel::Point{72.5010681152344, 391.129577636719}); secondSpline.push_back(meshkernel::Point{462.503479003906, 90.3765411376953}); - splines.AddSpline(secondSpline, 0, secondSpline.size()); + splines.AddSpline(secondSpline, 0, static_cast(secondSpline.size())); double crossProductIntersection; meshkernel::Point dimensionalIntersection; diff --git a/libs/MeshKernel/tests/src/TriangleInterpolationTests.cpp b/libs/MeshKernel/tests/src/TriangleInterpolationTests.cpp index df4c92605..35942fcda 100644 --- a/libs/MeshKernel/tests/src/TriangleInterpolationTests.cpp +++ b/libs/MeshKernel/tests/src/TriangleInterpolationTests.cpp @@ -61,7 +61,7 @@ TEST(TriangleInterpolation, InterpolateOnNodes) // Set up std::vector samples = ReadSampleFile(TEST_FOLDER + "/data/TriangleInterpolationTests/inTestTriangleInterpolation.xyz"); auto mesh = ReadLegacyMesh2DFromFile(TEST_FOLDER + "/data/TriangleInterpolationTests/simple_grid_net.nc"); - ASSERT_GT(mesh->GetNumNodes(), 0); + ASSERT_GT(mesh->GetNumNodes(), static_cast(0)); meshkernel::TriangulationInterpolation triangulationInterpolation(mesh->m_nodes, samples, meshkernel::Projection::cartesian); triangulationInterpolation.Compute(); @@ -87,7 +87,7 @@ TEST(TriangleInterpolation, InterpolateOnEdges) // Set up std::vector samples = ReadSampleFile(TEST_FOLDER + "/data/TriangleInterpolationTests/inTestTriangleInterpolation.xyz"); auto mesh = ReadLegacyMesh2DFromFile(TEST_FOLDER + "/data/TriangleInterpolationTests/simple_grid_net.nc"); - ASSERT_GT(mesh->GetNumNodes(), 0); + ASSERT_GT(mesh->GetNumNodes(), static_cast(0)); mesh->ComputeEdgesCenters(); @@ -114,7 +114,7 @@ TEST(TriangleInterpolation, InterpolateOnFaces) // Set up std::vector samples = ReadSampleFile(TEST_FOLDER + "/data/TriangleInterpolationTests/inTestTriangleInterpolation.xyz"); auto mesh = ReadLegacyMesh2DFromFile(TEST_FOLDER + "/data/TriangleInterpolationTests/simple_grid_net.nc"); - ASSERT_GT(mesh->GetNumNodes(), 0); + ASSERT_GT(mesh->GetNumNodes(), static_cast(0)); meshkernel::TriangulationInterpolation triangulationInterpolation(mesh->m_facesMassCenters, samples, meshkernel::Projection::cartesian); triangulationInterpolation.Compute(); @@ -141,7 +141,7 @@ TEST(TriangleInterpolation, InterpolateOnFacesUsingSphericalAccurateOption) // Set up std::vector samples = ReadSampleFile(TEST_FOLDER + "/data/TriangleInterpolationTests/SphericalCutted.xyz"); auto mesh = ReadLegacyMesh2DFromFile(TEST_FOLDER + "/data/TriangleInterpolationTests/SphericalCutted.nc", meshkernel::Projection::cartesian); - ASSERT_GT(mesh->GetNumNodes(), 0); + ASSERT_GT(mesh->GetNumNodes(), static_cast(0)); ASSERT_GT(samples.size(), 0); meshkernel::TriangulationInterpolation triangulationInterpolation(mesh->m_facesMassCenters, samples, meshkernel::Projection::sphericalAccurate); diff --git a/libs/MeshKernelApi/include/MeshKernelApi/State.hpp b/libs/MeshKernelApi/include/MeshKernelApi/State.hpp index 3081ec249..d645d7b2f 100644 --- a/libs/MeshKernelApi/include/MeshKernelApi/State.hpp +++ b/libs/MeshKernelApi/include/MeshKernelApi/State.hpp @@ -69,7 +69,7 @@ namespace meshkernelapi std::shared_ptr m_curvilinearGridLineShift; ///< Shared pointer to meshkernel::CurvilinearGridLineShift instance // Exclusively owned state - meshkernel::Projection m_projection; ///< Projection used by the meshes + meshkernel::Projection m_projection{meshkernel::Projection::cartesian}; ///< Projection used by the meshes }; } // namespace meshkernelapi diff --git a/libs/MeshKernelApi/include/MeshKernelApi/Utils.hpp b/libs/MeshKernelApi/include/MeshKernelApi/Utils.hpp index 876c9c292..479e17fb7 100644 --- a/libs/MeshKernelApi/include/MeshKernelApi/Utils.hpp +++ b/libs/MeshKernelApi/include/MeshKernelApi/Utils.hpp @@ -225,7 +225,7 @@ namespace meshkernelapi const auto splineCornerPoints = ConvertGeometryListToPointVector(geometryListIn); - const auto indices = FindIndices(splineCornerPoints, 0, splineCornerPoints.size(), meshkernel::constants::missing::doubleValue); + const auto indices = FindIndices(splineCornerPoints, 0, static_cast(splineCornerPoints.size()), meshkernel::constants::missing::doubleValue); for (const auto& index : indices) { diff --git a/libs/MeshKernelApi/src/MeshKernel.cpp b/libs/MeshKernelApi/src/MeshKernel.cpp index 9b8baddcd..2df62fdc5 100644 --- a/libs/MeshKernelApi/src/MeshKernel.cpp +++ b/libs/MeshKernelApi/src/MeshKernel.cpp @@ -202,11 +202,11 @@ namespace meshkernelapi const auto face_nodes = meshkernel::ConvertToFaceNodesVector(mesh2d.num_faces, mesh2d.face_nodes, mesh2d.nodes_per_face); - std::vector num_face_nodes; + std::vector num_face_nodes; num_face_nodes.reserve(mesh2d.num_faces); for (auto n = 0; n < mesh2d.num_faces; n++) { - num_face_nodes.emplace_back(static_cast(mesh2d.nodes_per_face[n])); + num_face_nodes.emplace_back(static_cast(mesh2d.nodes_per_face[n])); } // Do not change the pointer, just the object it is pointing to @@ -837,16 +837,16 @@ namespace meshkernelapi splines[i].y = geometryListIn.coordinates_y[i]; } - const auto indices = FindIndices(splines, 0, splines.size(), meshkernel::constants::missing::doubleValue); - const auto numSplines = indices.size(); + const auto indices = FindIndices(splines, 0, static_cast(splines.size()), meshkernel::constants::missing::doubleValue); + const auto numSplines = static_cast(indices.size()); int index = 0; - for (size_t s = 0; s < numSplines; s++) + for (meshkernel::UInt s = 0; s < numSplines; s++) { const auto& [startIndex, endIndex] = indices[s]; std::vector coordinates(splines.begin() + startIndex, splines.begin() + static_cast(endIndex) + 1); const int numNodes = static_cast(endIndex) - static_cast(startIndex) + 1; - const auto coordinatesDerivatives = meshkernel::Splines::SecondOrderDerivative(coordinates, 0, coordinates.size() - 1); + const auto coordinatesDerivatives = meshkernel::Splines::SecondOrderDerivative(coordinates, 0, static_cast(coordinates.size()) - 1); for (auto n = 0; n < numNodes - 1; n++) { @@ -1476,7 +1476,7 @@ namespace meshkernelapi relativeSearchRadius, refineOutsideFace, transformSamples, - static_cast(minimumNumSamples)); + static_cast(minimumNumSamples)); meshkernel::MeshRefinement meshRefinement(meshKernelState[meshKernelId].m_mesh2d, averaging, meshRefinementParameters); meshRefinement.Compute(); @@ -2485,7 +2485,7 @@ namespace meshkernelapi // Execute meshkernel::CurvilinearGridSmoothing curvilinearGridSmoothing(meshKernelState[meshKernelId].m_curvilinearGrid, - static_cast(smoothingIterations)); + static_cast(smoothingIterations)); curvilinearGridSmoothing.SetBlock(firstPoint, secondPoint); *meshKernelState[meshKernelId].m_curvilinearGrid = meshkernel::CurvilinearGrid(curvilinearGridSmoothing.Compute()); @@ -2935,7 +2935,7 @@ namespace meshkernelapi relativeSearchSize, false, false, - minNumSamples); + static_cast(minNumSamples)); averaging.Compute(); diff --git a/libs/MeshKernelApi/tests/src/ApiTest.cpp b/libs/MeshKernelApi/tests/src/ApiTest.cpp index 1c5da4925..bde235134 100644 --- a/libs/MeshKernelApi/tests/src/ApiTest.cpp +++ b/libs/MeshKernelApi/tests/src/ApiTest.cpp @@ -41,7 +41,7 @@ class CartesianApiTests : public testing::Test /// @param[in] numRows Number of rows /// @param[in] numColumns Number of columns /// @param[in] delta Distance between neighboring nodes - void MakeMesh(size_t numRows = 2, size_t numColumns = 3, double delta = 1.0) + void MakeMesh(meshkernel::UInt numRows = 2, meshkernel::UInt numColumns = 3, double delta = 1.0) { // Set-up new mesh auto [num_nodes, num_edges, node_x, node_y, edge_nodes] = MakeRectangularMeshForApiTesting(numRows, numColumns, delta); @@ -58,18 +58,18 @@ class CartesianApiTests : public testing::Test } } - void MakeUniformCurvilinearGrid(int numberOfColumns = 4, - int numberOfRows = 4, + void MakeUniformCurvilinearGrid(meshkernel::UInt numberOfColumns = 4, + meshkernel::UInt numberOfRows = 4, double blockSizeX = 10.0, double blockSizeY = 10.0, double originX = 0.0, - double originY = 0.0) + double originY = 0.0) const { meshkernel::MakeGridParameters makeGridParameters{}; meshkernelapi::GeometryList geometryList{}; - makeGridParameters.num_columns = numberOfColumns; - makeGridParameters.num_rows = numberOfRows; + makeGridParameters.num_columns = static_cast(numberOfColumns); + makeGridParameters.num_rows = static_cast(numberOfRows); makeGridParameters.angle = 0.0; makeGridParameters.origin_x = originX; makeGridParameters.origin_y = originY; @@ -3140,8 +3140,8 @@ TEST(Mesh2D, Mesh2DRefineBasedOnGriddedSamples_WithGriddedSamples_ShouldRefineMe TEST_F(CartesianApiTests, Mesh2DRefineBasedOnGriddedSamples_WithNotUniformlySpacedSamples_ShouldRefineMesh) { // Prepare - size_t nRows{5}; - size_t nCols{4}; + meshkernel::UInt nRows{5}; + meshkernel::UInt nCols{4}; MakeMesh(nRows, nCols, 100.0); auto const meshKernelId = GetMeshKernelId(); diff --git a/tools/test_utils/include/TestUtils/MakeMeshes.hpp b/tools/test_utils/include/TestUtils/MakeMeshes.hpp index 178069935..87677487f 100644 --- a/tools/test_utils/include/TestUtils/MakeMeshes.hpp +++ b/tools/test_utils/include/TestUtils/MakeMeshes.hpp @@ -49,16 +49,16 @@ ComputeEdgesAndNodes( meshkernel::Mesh::Type meshType); std::shared_ptr MakeRectangularMeshForTesting( - size_t n, - size_t m, + meshkernel::UInt n, + meshkernel::UInt m, double dim_x, double dim_y, meshkernel::Projection projection, meshkernel::Point const& origin = {0.0, 0.0}); std::shared_ptr MakeRectangularMeshForTesting( - int n, - int m, + meshkernel::UInt n, + meshkernel::UInt m, double delta, meshkernel::Projection projection, meshkernel::Point const& origin = {0.0, 0.0}); @@ -71,14 +71,14 @@ std::shared_ptr ReadLegacyMesh1DFromFile( std::filesystem::path const& file_path, meshkernel::Projection projection = meshkernel::Projection::cartesian); -std::tuple, std::vector, std::vector> MakeRectangularMeshForApiTesting( - size_t numRows, - size_t numColumns, + meshkernel::UInt numRows, + meshkernel::UInt numColumns, double delta); std::shared_ptr MakeSmallSizeTriangularMeshForTestingAsNcFile(); diff --git a/tools/test_utils/src/MakeMeshes.cpp b/tools/test_utils/src/MakeMeshes.cpp index cd737f30a..c0992b2e1 100644 --- a/tools/test_utils/src/MakeMeshes.cpp +++ b/tools/test_utils/src/MakeMeshes.cpp @@ -113,7 +113,7 @@ ComputeEdgesAndNodes( ReadLegacyMeshFile(file_path); std::vector edges; std::vector nodes; - std::vector nodeMapping; + std::vector nodeMapping; edges.reserve(num_edges); nodes.reserve(num_nodes); nodeMapping.resize(num_nodes); @@ -128,18 +128,18 @@ ComputeEdgesAndNodes( nodeType = 2; } - for (size_t i = 0; i < num_nodes; i++) + for (meshkernel::UInt i = 0; i < num_nodes; i++) { // If the node is not part of a 2 mesh, do not add it in nodes if (node_type[i] == nodeType || node_type[i] == 0) { nodes.emplace_back(node_x[i], node_y[i]); - nodeMapping[i] = static_cast(nodes.size()) - 1; + nodeMapping[i] = static_cast(nodes.size()) - 1; } } auto index = 0; - for (size_t i = 0; i < num_edges; i++) + for (meshkernel::UInt i = 0; i < num_edges; i++) { auto const firstNode = edge_nodes[index]; @@ -172,23 +172,23 @@ std::shared_ptr ReadLegacyMesh1DFromFile( } std::shared_ptr MakeRectangularMeshForTesting( - size_t n, - size_t m, + meshkernel::UInt n, + meshkernel::UInt m, double dim_x, double dim_y, meshkernel::Projection projection, meshkernel::Point const& origin) { - std::vector> node_indices(n, std::vector(m)); + std::vector> node_indices(n, std::vector(m)); std::vector nodes(n * m); { - std::size_t index = 0; + meshkernel::UInt index = 0; double const delta_x = dim_x / static_cast(n - 1); double const delta_y = dim_y / static_cast(m - 1); - for (size_t i = 0; i < n; ++i) + for (meshkernel::UInt i = 0; i < n; ++i) { - for (size_t j = 0; j < m; ++j) + for (meshkernel::UInt j = 0; j < m; ++j) { node_indices[i][j] = i * m + j; nodes[index] = {origin.x + i * delta_x, origin.y + j * delta_y}; @@ -200,20 +200,20 @@ std::shared_ptr MakeRectangularMeshForTesting( std::vector edges((n - 1) * m + (m - 1) * n); { - std::size_t index = 0; + meshkernel::UInt index = 0; - for (size_t i = 0; i < n - 1; ++i) + for (meshkernel::UInt i = 0; i < n - 1; ++i) { - for (size_t j = 0; j < m; ++j) + for (meshkernel::UInt j = 0; j < m; ++j) { edges[index] = {node_indices[i][j], node_indices[i + 1][j]}; index++; } } - for (size_t i = 0; i < n; ++i) + for (meshkernel::UInt i = 0; i < n; ++i) { - for (size_t j = 0; j < m - 1; ++j) + for (meshkernel::UInt j = 0; j < m - 1; ++j) { edges[index] = {node_indices[i][j + 1], node_indices[i][j]}; index++; @@ -225,8 +225,8 @@ std::shared_ptr MakeRectangularMeshForTesting( } std::shared_ptr MakeRectangularMeshForTesting( - int n, - int m, + meshkernel::UInt n, + meshkernel::UInt m, double delta, meshkernel::Projection projection, meshkernel::Point const& origin) @@ -242,42 +242,43 @@ std::shared_ptr MakeRectangularMeshForTesting( origin); } -std::tuple, std::vector, std::vector> MakeRectangularMeshForApiTesting( - size_t numRows, - size_t numColumns, + meshkernel::UInt numRows, + meshkernel::UInt numColumns, double delta) { - const auto numY = numRows + static_cast(1); - const auto numX = numColumns + static_cast(1); + const auto numY = numRows + static_cast(1); + const auto numX = numColumns + static_cast(1); - std::vector> indicesValues(numX, std::vector(numY)); + std::vector> indicesValues(numX, std::vector(numY)); std::vector nodeX(numX * numY); std::vector nodeY(numX * numY); - size_t nodeIndex = 0; - for (auto i = 0u; i < numX; ++i) + meshkernel::UInt nodeIndex = 0; + for (meshkernel::UInt i = 0; i < numX; ++i) { - for (auto j = 0u; j < numY; ++j) + for (meshkernel::UInt j = 0; j < numY; ++j) { nodeX[nodeIndex] = i * delta; nodeY[nodeIndex] = j * delta; - indicesValues[i][j] = static_cast(i) * numY + j; + indicesValues[i][j] = i * numY + j; nodeIndex++; } } std::vector edgeNodes(((numX - 1) * numY + (numY - 1) * numX) * 2); - size_t edgeIndex = 0; - for (auto i = 0u; i < numX - 1; ++i) + meshkernel::UInt edgeIndex = 0; + for (meshkernel::UInt i = 0; i < numX - 1; ++i) { - for (auto j = 0u; j < numY; ++j) + for (meshkernel::UInt j = 0; j < numY; ++j) { edgeNodes[edgeIndex] = static_cast(indicesValues[i][j]); edgeIndex++; @@ -286,9 +287,9 @@ MakeRectangularMeshForApiTesting( } } - for (auto i = 0u; i < numX; ++i) + for (meshkernel::UInt i = 0; i < numX; ++i) { - for (auto j = 0u; j < numY - 1; ++j) + for (meshkernel::UInt j = 0; j < numY - 1; ++j) { edgeNodes[edgeIndex] = static_cast(indicesValues[i][j + 1]); edgeIndex++; @@ -297,8 +298,8 @@ MakeRectangularMeshForApiTesting( } } - auto const numNodes = nodeIndex; - auto const numEdges = edgeIndex / 2; + const meshkernel::UInt numNodes = nodeIndex; + const meshkernel::UInt numEdges = static_cast(edgeIndex * 0.5); return {numNodes, numEdges, nodeX, nodeY, edgeNodes}; }