Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion libs/MeshKernel/include/MeshKernel/Definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ namespace meshkernel
EdgeLength = 1,
FaceCircumcenter = 2,
NetlinkContourPolygon = 3,
FaceBounds = 4
FaceBounds = 4,
Smoothness = 5,
LastValue
};

/// \brief Describe how the circumcentre should be computed.
Expand Down
3 changes: 3 additions & 0 deletions libs/MeshKernelApi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ set(SRC_LIST
${SRC_DIR}/Mesh2DFaceBoundsPropertyCalculator.cpp
${SRC_DIR}/NetlinkContourPolygonPropertyCalculator.cpp
${SRC_DIR}/OrthogonalityPropertyCalculator.cpp
${SRC_DIR}/MeshSmoothnessPropertyCalculator.cpp
${SRC_DIR}/InterpolatedSamplePropertyCalculator.cpp
)

Expand Down Expand Up @@ -64,11 +65,13 @@ set(
${DOMAIN_INC_DIR}/Mesh2D.hpp
${DOMAIN_INC_DIR}/MeshKernel.hpp
${DOMAIN_INC_DIR}/PropertyCalculator.hpp
${DOMAIN_INC_DIR}/PredefinedPropertyCalculator.hpp
${DOMAIN_INC_DIR}/EdgeLengthPropertyCalculator.hpp
${DOMAIN_INC_DIR}/FaceCircumcenterPropertyCalculator.hpp
${DOMAIN_INC_DIR}/Mesh2DFaceBoundsPropertyCalculator.hpp
${DOMAIN_INC_DIR}/NetlinkContourPolygonPropertyCalculator.hpp
${DOMAIN_INC_DIR}/OrthogonalityPropertyCalculator.hpp
${DOMAIN_INC_DIR}/MeshSmoothnessPropertyCalculator.hpp
${DOMAIN_INC_DIR}/InterpolatedSamplePropertyCalculator.hpp
${DOMAIN_INC_DIR}/State.hpp
${DOMAIN_INC_DIR}/Utils.hpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,32 @@
#include "MeshKernel/SampleInterpolator.hpp"

#include "MeshKernelApi/GeometryList.hpp"
#include "MeshKernelApi/PropertyCalculator.hpp"
#include "MeshKernelApi/PredefinedPropertyCalculator.hpp"

namespace meshkernelapi
{

/// @brief Calculator for the edge lengths for a mesh
class EdgeLengthPropertyCalculator : public PropertyCalculator
class EdgeLengthPropertyCalculator : public PredefinedPropertyCalculator
{
public:
/// @brief Determine is the calculator can compute the desired results correctly.
///
/// This has a default of checking that the mesh2d is valid and the location is at edges
bool IsValid(const MeshKernelState& state, const meshkernel::Location location) const override;
/// This has a default of checking that the mesh2d is valid
bool IsValid(const MeshKernelState& state) const override;

/// @brief Calculate the edge-length for a mesh
///
/// \note This calculator is for mesh edges only
void Calculate(const MeshKernelState& state, const meshkernel::Location location, const GeometryList& geometryList) const override;
void Calculate(const MeshKernelState& state, const GeometryList& geometryList) const override;

/// @brief Get the location at which the property can be evaluated
///
/// Can be evaluated only at Location::Edges
meshkernel::Location EvaluationLocation() const override;

/// @brief Determine the size of the edge-length vector required
int Size(const MeshKernelState& state, const meshkernel::Location location) const override;
int Size(const MeshKernelState& state) const override;
};

} // namespace meshkernelapi
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,32 @@
#include "MeshKernel/SampleInterpolator.hpp"

#include "MeshKernelApi/GeometryList.hpp"
#include "MeshKernelApi/PropertyCalculator.hpp"
#include "MeshKernelApi/PredefinedPropertyCalculator.hpp"

namespace meshkernelapi
{

/// @brief Calculator for the face circumcenter for a mesh
class FaceCircumcenterPropertyCalculator : public PropertyCalculator
class FaceCircumcenterPropertyCalculator : public PredefinedPropertyCalculator
{
public:
/// @brief Determine is the calculator can compute the desired results correctly.
///
/// This has a default of checking that the mesh2d is valid and the location is at faces
bool IsValid(const MeshKernelState& state, const meshkernel::Location location) const override;
/// This has a default of checking that the mesh2d is valid
bool IsValid(const MeshKernelState& state) const override;

/// @brief Calculate the face circumcentres for a mesh
///
/// \note This calculator is for mesh faces only
void Calculate(const MeshKernelState& state, const meshkernel::Location location, const GeometryList& geometryList) const override;
void Calculate(const MeshKernelState& state, const GeometryList& geometryList) const override;

/// @brief Get the location at which the property can be evaluated
///
/// Can be evaluated only at Location::Faces
meshkernel::Location EvaluationLocation() const override;

/// @brief Determine the size of the face circumcentre vector required
int Size(const MeshKernelState& state, const meshkernel::Location location) const override;
int Size(const MeshKernelState& state) const override;
};

} // namespace meshkernelapi
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,30 @@
#include "MeshKernel/SampleInterpolator.hpp"

#include "MeshKernelApi/GeometryList.hpp"
#include "MeshKernelApi/PropertyCalculator.hpp"
#include "MeshKernelApi/PredefinedPropertyCalculator.hpp"

namespace meshkernelapi
{

/// @brief Calculator for the face bounds values for a mesh
class Mesh2DFaceBoundsPropertyCalculator : public PropertyCalculator
class Mesh2DFaceBoundsPropertyCalculator : public PredefinedPropertyCalculator
{
public:
/// @brief Determine is the calculator can compute the desired results correctly.
///
/// This has a default of checking that the mesh2d is valid and the location is at faces
bool IsValid(const MeshKernelState& state, const meshkernel::Location location) const override;
/// This has a default of checking that the mesh2d is valid
bool IsValid(const MeshKernelState& state) const override;

/// @brief Calculate the face bounds values for a mesh
void Calculate(const MeshKernelState& state, const meshkernel::Location location, const GeometryList& geometryList) const override;
void Calculate(const MeshKernelState& state, const GeometryList& geometryList) const override;

/// @brief Get the location at which the property can be evaluated
///
/// Can be evaluated only at Location::Faces
meshkernel::Location EvaluationLocation() const override;

/// @brief Determine the size of the face bounds array (for all faces) required
int Size(const MeshKernelState& state, const meshkernel::Location location) const override;
int Size(const MeshKernelState& state) const override;
};

} // namespace meshkernelapi
21 changes: 21 additions & 0 deletions libs/MeshKernelApi/include/MeshKernelApi/MeshKernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,11 @@ namespace meshkernelapi
/// @returns Error code
MKERNEL_API int mkernel_mesh2d_get_face_bounds_property_type(int& type);

/// @brief Gets an int indicating the mesh smoothness property type for mesh2d
/// @param[out] type The int indicating the mesh smoothness property type
/// @returns Error code
MKERNEL_API int mkernel_mesh2d_get_mesh_smoothness_property_type(int& type);

/// @brief Gets the Mesh2D inner boundary polygons data
///
/// @param[in] meshKernelId The id of the mesh state
Expand Down Expand Up @@ -1451,6 +1456,22 @@ namespace meshkernelapi
/// @returns Error code
MKERNEL_API int mkernel_mesh2d_get_property_dimension(int meshKernelId, int propertyValue, int locationId, int& dimension);

/// @brief Retrieves a specified predefined property of a 2D mesh.
///
/// @param[in] meshKernelId The id of the mesh state
/// @param[in] propertyId The identifier representing the specific property
/// @param[in,out] geometrylist A reference to a GeometryList object that will be populated with the values of the requested property
/// @returns Error code
MKERNEL_API int mkernel_mesh2d_get_predefined_property(int meshKernelId, int propertyId, const GeometryList& geometrylist);

/// @brief The dimension of a specified property of a 2D mesh.
///
/// @param[in] meshKernelId The id of the mesh state
/// @param[in] propertyId The identifier representing the specific property
/// @param[out] dimension The dimension of the specified property
/// @returns Error code
MKERNEL_API int mkernel_mesh2d_get_predefined_property_dimension(int meshKernelId, int propertyId, int& dimension);

/// @brief Gets the small mesh2d flow edges. The flow edges are the edges connecting faces circumcenters.
/// @param[in] meshKernelId The id of the mesh state
/// @param[in] smallFlowEdgesThreshold The configurable threshold for detecting a small flow edge
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//---- GPL ---------------------------------------------------------------------
//
// Copyright (C) Stichting Deltares, 2011-2025.
//
// 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 <http://www.gnu.org/licenses/>.
//
// 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 "MeshKernel/Definitions.hpp"

#include "MeshKernelApi/GeometryList.hpp"
#include "MeshKernelApi/PredefinedPropertyCalculator.hpp"

namespace meshkernelapi
{

/// @brief Calculator for the mesh smoothness (edge size ratio) for a mesh
class MeshSmoothnessPropertyCalculator : public PredefinedPropertyCalculator
{
public:
/// @brief Determine if the calculator can compute the desired results correctly.
///
/// This has a default of checking that the mesh2d is valid
bool IsValid(const MeshKernelState& state) const override;

/// @brief Calculate the mesh smoothness for a mesh
///
/// \note This calculator is for mesh edges only
void Calculate(const MeshKernelState& state, const GeometryList& geometryList) const override;

/// @brief Get the location at which the property can be evaluated
///
/// Can be evaluated only at Location::Edges
meshkernel::Location EvaluationLocation() const override;

/// @brief Determine the size of the smoothness vector required
int Size(const MeshKernelState& state) const override;
};

} // namespace meshkernelapi
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,30 @@
#include "MeshKernel/SampleInterpolator.hpp"

#include "MeshKernelApi/GeometryList.hpp"
#include "MeshKernelApi/PropertyCalculator.hpp"
#include "MeshKernelApi/PredefinedPropertyCalculator.hpp"

namespace meshkernelapi
{

/// @brief Calculator for the netlink contour polygons for a mesh
class NetlinkContourPolygonPropertyCalculator : public PropertyCalculator
class NetlinkContourPolygonPropertyCalculator : public PredefinedPropertyCalculator
{
public:
/// @brief Determine is the calculator can compute the desired results correctly.
///
/// This has a default of checking that the mesh2d is valid and the location is at edges
bool IsValid(const MeshKernelState& state, const meshkernel::Location location) const override;
/// This has a default of checking that the mesh2d is valid
bool IsValid(const MeshKernelState& state) const override;

/// @brief Calculate the netlink contour polygons for a mesh
void Calculate(const MeshKernelState& state, const meshkernel::Location location, const GeometryList& geometryList) const override;
void Calculate(const MeshKernelState& state, const GeometryList& geometryList) const override;

/// @brief Get the location at which the property can be evaluated
///
/// Can be evaluated only at Location::Edges
meshkernel::Location EvaluationLocation() const override;

/// @brief Determine the size of the netlink contour polygon array (for all edges) required
int Size(const MeshKernelState& state, const meshkernel::Location location) const override;
int Size(const MeshKernelState& state) const override;
};

} // namespace meshkernelapi
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,30 @@
#include "MeshKernel/SampleInterpolator.hpp"

#include "MeshKernelApi/GeometryList.hpp"
#include "MeshKernelApi/PropertyCalculator.hpp"
#include "MeshKernelApi/PredefinedPropertyCalculator.hpp"

namespace meshkernelapi
{

/// @brief Calculator for orthogonality of a mesh.
class OrthogonalityPropertyCalculator : public PropertyCalculator
class OrthogonalityPropertyCalculator : public PredefinedPropertyCalculator
{
public:
/// @brief Determine is the calculator can compute the desired results correctly.
///
/// This has a default of checking that the mesh2d is valid and the location is at edges
bool IsValid(const MeshKernelState& state, const meshkernel::Location location) const override;
/// This has a default of checking that the mesh2d is valid
bool IsValid(const MeshKernelState& state) const override;

/// @brief Calculate the orthogonality for a mesh
void Calculate(const MeshKernelState& state, const meshkernel::Location location, const GeometryList& geometryList) const override;
void Calculate(const MeshKernelState& state, const GeometryList& geometryList) const override;

/// @brief Get the location at which the property can be evaluated
///
/// Can be evaluated only at Location::Edges
meshkernel::Location EvaluationLocation() const override;

/// @brief Determine the size of the orthogonality vector required
int Size(const MeshKernelState& state, const meshkernel::Location location) const override;
int Size(const MeshKernelState& state) const override;
};

} // namespace meshkernelapi
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//---- GPL ---------------------------------------------------------------------
//
// Copyright (C) Stichting Deltares, 2011-2024.
//
// 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 <http://www.gnu.org/licenses/>.
//
// 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 "MeshKernel/Definitions.hpp"

#include "MeshKernelApi/GeometryList.hpp"

namespace meshkernelapi
{

/// @brief Forward declaration of MeshKernelState
struct MeshKernelState;

/// @brief Base class for property calculators with a predefined (fixed) evaluation location
///
/// PredefinedPropertyCalculator has a fixed location determined by EvaluationLocation().
class PredefinedPropertyCalculator
{
public:
/// @brief Destructor
virtual ~PredefinedPropertyCalculator() = default;

/// @brief Get the location at which the property can be evaluated
///
/// Must return a specific location (Nodes, Edges, or Faces), not Unknown
virtual meshkernel::Location EvaluationLocation() const = 0;

/// @brief Determine if the calculator can compute the desired results correctly
virtual bool IsValid(const MeshKernelState& state) const = 0;

/// @brief Calculate the property
virtual void Calculate(const MeshKernelState& state, const GeometryList& geometryList) const = 0;

/// @brief Determine the size of the vector required to store the calculated properties
virtual int Size(const MeshKernelState& state) const = 0;
};

} // namespace meshkernelapi
2 changes: 2 additions & 0 deletions libs/MeshKernelApi/include/MeshKernelApi/State.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "MeshKernelApi/ApiCache/PolygonRefinementCache.hpp"
#include "MeshKernelApi/ApiCache/SmallFlowEdgeCentreCache.hpp"
#include "MeshKernelApi/ApiCache/SplineIntersectionCache.hpp"
#include "MeshKernelApi/PredefinedPropertyCalculator.hpp"
#include "MeshKernelApi/PropertyCalculator.hpp"

#include "ApiCache/MeshBoundariesAsPolygonCache.hpp"
Expand Down Expand Up @@ -87,6 +88,7 @@ namespace meshkernelapi
std::shared_ptr<meshkernel::CurvilinearGridLineShift> m_curvilinearGridLineShift; ///< Shared pointer to meshkernel::CurvilinearGridLineShift instance
std::shared_ptr<meshkernel::CurvilinearGridOrthogonalization> m_curvilinearGridOrthogonalization; ///< Shared pointer to meshkernel::CurvilinearGridOrthogonalization instance
std::map<int, std::shared_ptr<PropertyCalculator>> m_propertyCalculators; ///< Property calculators for the mesh2d
std::map<int, std::shared_ptr<PredefinedPropertyCalculator>> m_predefinedPropertyCalculators; ///< Predefined property calculators for the mesh2d
std::unordered_map<meshkernel::UInt, std::pair<meshkernel::Point, meshkernel::Point>> m_frozenLines; ///< Map for string the frozen lines
meshkernel::UInt m_frozenLinesCounter = 0; ///< An increasing counter for returning the id of frozen lines to the client

Expand Down
Loading
Loading