Skip to content

Commit

Permalink
GRIDEDIT-1552 Changes made after review
Browse files Browse the repository at this point in the history
  • Loading branch information
BillSenior authored and lucacarniato committed Jan 28, 2025
1 parent c4962a9 commit bb10a0a
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 20 deletions.
6 changes: 3 additions & 3 deletions libs/MeshKernel/include/MeshKernel/MeshOrthogonality.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ namespace meshkernel
{
public:
/// @brief Compute the orthogonality values returning values in a vector
std::vector<double> Compute(const Mesh2D& mesh) const;
static std::vector<double> Compute(const Mesh2D& mesh);

/// @brief Compute the orthogonality values overwriting the values in an array
void Compute(const Mesh2D& mesh, std::span<double> orthogonality) const;
static void Compute(const Mesh2D& mesh, std::span<double> orthogonality);

private:
/// @brief Compute the orthogonality value for the edge
double ComputeValue(const Mesh2D& mesh, const UInt edgeId) const;
static double ComputeValue(const Mesh2D& mesh, const UInt edgeId);
};

} // namespace meshkernel
4 changes: 2 additions & 2 deletions libs/MeshKernel/include/MeshKernel/MeshSmoothness.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ namespace meshkernel
{
public:
/// @brief Compute the smoothness values returning values in a vector
std::vector<double> Compute(const Mesh2D& mesh) const;
static std::vector<double> Compute(const Mesh2D& mesh);

/// @brief Compute the smoothness values overwriting the values in an array
void Compute(const Mesh2D& mesh, std::span<double> smoothness) const;
static void Compute(const Mesh2D& mesh, std::span<double> smoothness);

private:
static constexpr double m_minimumCellArea = 1e-12; ///< Minimum cell area
Expand Down
6 changes: 3 additions & 3 deletions libs/MeshKernel/src/MeshOrthogonality.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
#include "MeshKernel/Exceptions.hpp"
#include "MeshKernel/Operations.hpp"

std::vector<double> meshkernel::MeshOrthogonality::Compute(const Mesh2D& mesh) const
std::vector<double> meshkernel::MeshOrthogonality::Compute(const Mesh2D& mesh)
{
std::vector<double> orthogonality(mesh.GetNumEdges(), constants::missing::doubleValue);
Compute(mesh, orthogonality);

return orthogonality;
}

double meshkernel::MeshOrthogonality::ComputeValue(const Mesh2D& mesh, const UInt edgeId) const
double meshkernel::MeshOrthogonality::ComputeValue(const Mesh2D& mesh, const UInt edgeId)
{
const auto [firstNode, secondNode] = mesh.GetEdge(edgeId);

Expand Down Expand Up @@ -76,7 +76,7 @@ double meshkernel::MeshOrthogonality::ComputeValue(const Mesh2D& mesh, const UIn
return val;
}

void meshkernel::MeshOrthogonality::Compute(const Mesh2D& mesh, std::span<double> orthogonality) const
void meshkernel::MeshOrthogonality::Compute(const Mesh2D& mesh, std::span<double> orthogonality)
{
if (orthogonality.size() != mesh.GetNumEdges())
{
Expand Down
4 changes: 2 additions & 2 deletions libs/MeshKernel/src/MeshSmoothness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "MeshKernel/Constants.hpp"
#include "MeshKernel/Exceptions.hpp"

std::vector<double> meshkernel::MeshSmoothness::Compute(const Mesh2D& mesh) const
std::vector<double> meshkernel::MeshSmoothness::Compute(const Mesh2D& mesh)
{

std::vector<double> smoothness(mesh.GetNumEdges(), constants::missing::doubleValue);
Expand All @@ -38,7 +38,7 @@ std::vector<double> meshkernel::MeshSmoothness::Compute(const Mesh2D& mesh) cons
return smoothness;
}

void meshkernel::MeshSmoothness::Compute(const Mesh2D& mesh, std::span<double> smoothness) const
void meshkernel::MeshSmoothness::Compute(const Mesh2D& mesh, std::span<double> smoothness)
{

if (smoothness.size() != mesh.GetNumEdges())
Expand Down
6 changes: 2 additions & 4 deletions libs/MeshKernel/tests/src/Mesh2DTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1446,8 +1446,7 @@ TEST(Mesh2D, GetSmoothness_OnTriangularMesh_ShouldgetSmoothnessValues)
const auto mesh = ReadLegacyMesh2DFromFile(TEST_FOLDER + "/data/TestOrthogonalizationMediumTriangularGrid_net.nc");

// Execute
meshkernel::MeshSmoothness meshSmoothness;
const auto smoothness = meshSmoothness.Compute(*mesh); //->GetSmoothness();
const auto smoothness = meshkernel::MeshSmoothness::Compute(*mesh);

// Assert
const double tolerance = 1e-6;
Expand All @@ -1463,8 +1462,7 @@ TEST(Mesh2D, GetOrthogonality_OnTriangularMesh_ShouldGetOrthogonalityValues)
const auto mesh = ReadLegacyMesh2DFromFile(TEST_FOLDER + "/data/TestOrthogonalizationMediumTriangularGrid_net.nc");

// Execute
meshkernel::MeshOrthogonality meshOrthogonality;
const auto orthogonality = meshOrthogonality.Compute(*mesh);
const auto orthogonality = meshkernel::MeshOrthogonality::Compute(*mesh);

// Assert
const double tolerance = 1e-6;
Expand Down
6 changes: 2 additions & 4 deletions libs/MeshKernelApi/src/MeshKernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1581,8 +1581,7 @@ namespace meshkernelapi
}

std::span<double> orthogonality(geometryList.values, geometryList.num_coordinates);
meshkernel::MeshOrthogonality meshOrthogonality;
meshOrthogonality.Compute(*meshKernelState[meshKernelId].m_mesh2d, orthogonality);
meshkernel::MeshOrthogonality::Compute(*meshKernelState[meshKernelId].m_mesh2d, orthogonality);
}
catch (...)
{
Expand Down Expand Up @@ -1697,8 +1696,7 @@ namespace meshkernelapi
}

std::span<double> smoothness(geometryList.values, geometryList.num_coordinates);
meshkernel::MeshSmoothness meshSmoothness;
meshSmoothness.Compute(*meshKernelState[meshKernelId].m_mesh2d, smoothness);
meshkernel::MeshSmoothness::Compute(*meshKernelState[meshKernelId].m_mesh2d, smoothness);
}
catch (...)
{
Expand Down
3 changes: 1 addition & 2 deletions libs/MeshKernelApi/src/PropertyCalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ void meshkernelapi::OrthogonalityPropertyCalculator::Calculate(const MeshKernelS
}

std::span<double> orthogonality(geometryList.values, geometryList.num_coordinates);
meshkernel::MeshOrthogonality meshOrthogonality;
meshOrthogonality.Compute(*state.m_mesh2d, orthogonality);
meshkernel::MeshOrthogonality::Compute(*state.m_mesh2d, orthogonality);
}

int meshkernelapi::OrthogonalityPropertyCalculator::Size(const MeshKernelState& state, const meshkernel::Location location [[maybe_unused]]) const
Expand Down

0 comments on commit bb10a0a

Please sign in to comment.