Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GRIDEDIT-576 Split mkernel_curvilinear_make_uniform API function #234

Merged
2 changes: 1 addition & 1 deletion cmake/fetch_content.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ if(ENABLE_BENCHMARKING)
set(ENABLE_BENCHMARKING_MEM_REPORT OFF)
message(
WARNING
"The benchmarks and their depenedencies can be built only if the build is configured "
"The benchmarks and their dependencies can be built only if the build is configured "
"with CMAKE_BUILD_TYPE set to Release or RelWithDebInfo. "
"The current build is configured with CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}."
"All benchmarking configuration options are ignored."
Expand Down
4 changes: 2 additions & 2 deletions libs/MeshKernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ set(
CURVILINEAR_GRID_SRC_LIST
${CURVILINEAR_GRID_SRC_DIR}/CurvilinearGrid.cpp
${CURVILINEAR_GRID_SRC_DIR}/CurvilinearGridAlgorithm.cpp
${CURVILINEAR_GRID_SRC_DIR}/CurvilinearGridCreateUniform.cpp
${CURVILINEAR_GRID_SRC_DIR}/CurvilinearGridDeRefinement.cpp
${CURVILINEAR_GRID_SRC_DIR}/CurvilinearGridFromPolygon.cpp
${CURVILINEAR_GRID_SRC_DIR}/CurvilinearGridFromSplines.cpp
Expand All @@ -81,6 +80,7 @@ set(
${CURVILINEAR_GRID_SRC_DIR}/CurvilinearGridLineMirror.cpp
${CURVILINEAR_GRID_SRC_DIR}/CurvilinearGridLineShift.cpp
${CURVILINEAR_GRID_SRC_DIR}/CurvilinearGridOrthogonalization.cpp
${CURVILINEAR_GRID_SRC_DIR}/CurvilinearGridRectangular.cpp
${CURVILINEAR_GRID_SRC_DIR}/CurvilinearGridRefinement.cpp
${CURVILINEAR_GRID_SRC_DIR}/CurvilinearGridSmoothing.cpp
${CURVILINEAR_GRID_SRC_DIR}/CurvilinearGridSnapping.cpp
Expand Down Expand Up @@ -147,7 +147,6 @@ set(
CURVILINEAR_GRID_INC_LIST
${CURVILINEAR_GRID_INC_DIR}/CurvilinearGrid.hpp
${CURVILINEAR_GRID_INC_DIR}/CurvilinearGridAlgorithm.hpp
${CURVILINEAR_GRID_INC_DIR}/CurvilinearGridCreateUniform.hpp
${CURVILINEAR_GRID_INC_DIR}/CurvilinearGridDeRefinement.hpp
${CURVILINEAR_GRID_INC_DIR}/CurvilinearGridFromPolygon.hpp
${CURVILINEAR_GRID_INC_DIR}/CurvilinearGridFromSplines.hpp
Expand All @@ -158,6 +157,7 @@ set(
${CURVILINEAR_GRID_INC_DIR}/CurvilinearGridLineShift.hpp
${CURVILINEAR_GRID_INC_DIR}/CurvilinearGridNodeIndices.hpp
${CURVILINEAR_GRID_INC_DIR}/CurvilinearGridOrthogonalization.hpp
${CURVILINEAR_GRID_INC_DIR}/CurvilinearGridRectangular.hpp
${CURVILINEAR_GRID_INC_DIR}/CurvilinearGridRefinement.hpp
${CURVILINEAR_GRID_INC_DIR}/CurvilinearGridSmoothing.hpp
${CURVILINEAR_GRID_INC_DIR}/CurvilinearGridSnapping.hpp
Expand Down
4 changes: 2 additions & 2 deletions libs/MeshKernel/benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(
SRC_LIST
${SRC_DIR}/main.cpp
${SRC_DIR}/perf_rtree.cpp
${SRC_DIR}/perf_curvilinear_rectangular.cpp
${SRC_DIR}/perf_mesh_refinement.cpp
${SRC_DIR}/perf_orthogonalization.cpp
${SRC_DIR}/perf_curvilinear_uniform.cpp
${SRC_DIR}/perf_rtree.cpp
)

# add sources to target
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "MeshKernel/CurvilinearGrid/CurvilinearGridFromSplinesTransfinite.hpp"

#include <MeshKernel/CurvilinearGrid/CurvilinearGrid.hpp>
#include <MeshKernel/CurvilinearGrid/CurvilinearGridCreateUniform.hpp>
#include <MeshKernel/CurvilinearGrid/CurvilinearGridFromSplines.hpp>
#include <MeshKernel/CurvilinearGrid/CurvilinearGridRectangular.hpp>
#include <MeshKernel/Entities.hpp>
#include <MeshKernel/Mesh2D.hpp>
#include <MeshKernel/Parameters.hpp>
Expand All @@ -13,7 +13,7 @@

using namespace meshkernel;

static void BM_CurvilinearUniform(benchmark::State& state)
static void BM_CurvilinearRectangular(benchmark::State& state)
{
for (auto _ : state)
{
Expand All @@ -38,36 +38,36 @@ static void BM_CurvilinearUniform(benchmark::State& state)
double const delta_x = dim_x / static_cast<double>(state.range(0) - 1);
double const delta_y = dim_y / static_cast<double>(state.range(1) - 1);

MakeGridParameters make_grid_parameters;
make_grid_parameters.angle = 0.0;
make_grid_parameters.origin_x = 0.0;
make_grid_parameters.origin_y = 0.0;
make_grid_parameters.num_columns = 3;
make_grid_parameters.num_rows = 3;
make_grid_parameters.block_size_x = delta_x;
make_grid_parameters.block_size_y = delta_y;
MakeGridParameters makeGridParameters;
makeGridParameters.angle = 0.0;
makeGridParameters.origin_x = 0.0;
makeGridParameters.origin_y = 0.0;
makeGridParameters.num_columns = 3;
makeGridParameters.num_rows = 3;
makeGridParameters.block_size_x = delta_x;
makeGridParameters.block_size_y = delta_y;

// resume the timers to begin benchmarking
state.ResumeTiming();

CurvilinearGridCreateUniform const curvilinear_grid_create_uniform(Projection::cartesian);
CurvilinearGridRectangular const curvilinearGridRecatngular(Projection::cartesian);
const auto curvilinearGrid = std::make_shared<CurvilinearGrid>(
curvilinear_grid_create_uniform.Compute(make_grid_parameters.angle,
make_grid_parameters.block_size_x,
make_grid_parameters.block_size_y,
polygons,
0));
curvilinearGridRecatngular.Compute(makeGridParameters.angle,
makeGridParameters.block_size_x,
makeGridParameters.block_size_y,
polygons,
0));
}
}
BENCHMARK(BM_CurvilinearUniform)
BENCHMARK(BM_CurvilinearRectangular)
->ArgNames({"x-nodes", "y-nodes"})
->Args({500, 500})
->Args({1000, 1000})
->Args({2000, 2000})
->Args({4000, 4000})
->Args({5000, 5000});

static void BM_CurvilinearUniform_add_faces_to_left_boundary(benchmark::State& state)
static void BM_CurvilinearRectangular_add_faces_to_left_boundary(benchmark::State& state)
{
for (auto _ : state)
{
Expand All @@ -85,15 +85,15 @@ static void BM_CurvilinearUniform_add_faces_to_left_boundary(benchmark::State& s
const double blockSizeX = block_size;
const double blockSizeY = block_size;

CurvilinearGridCreateUniform const curvilinear_grid_create_uniform(Projection::cartesian);
CurvilinearGridRectangular const curvilinearGridRecatngular(Projection::cartesian);
const auto curvilinearGrid = std::make_shared<CurvilinearGrid>(
curvilinear_grid_create_uniform.Compute(numColumns,
numRows,
origin_x,
origin_y,
angle,
blockSizeX,
blockSizeY));
curvilinearGridRecatngular.Compute(numColumns,
numRows,
origin_x,
origin_y,
angle,
blockSizeX,
blockSizeY));

int const faces_to_add = static_cast<int>(state.range(2));

Expand All @@ -108,7 +108,7 @@ static void BM_CurvilinearUniform_add_faces_to_left_boundary(benchmark::State& s
}
}
}
BENCHMARK(BM_CurvilinearUniform_add_faces_to_left_boundary)
BENCHMARK(BM_CurvilinearRectangular_add_faces_to_left_boundary)
->ArgNames({"x-nodes", "y-nodes", "faces_to_add"})
->Args({500, 500, 10})
->Args({1000, 1000, 100});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ namespace meshkernel
class Polygons;
class CurvilinearGrid;

/// @brief A class implementing the generation of a uniform curvilinear grid
class CurvilinearGridCreateUniform
/// @brief A class implementing the generation of a rectangular curvilinear grid
class CurvilinearGridRectangular
{
public:
/// @brief Class constructor
///
/// @param[in] projection The projection to use
CurvilinearGridCreateUniform(Projection projection);
CurvilinearGridRectangular(Projection projection);

/// @brief Compute an uniform curvilinear grid, given the origin and the number of rows, columns and block size
/// @brief Compute a rectangular curvilinear grid, given the origin and the number of rows, columns and block size
/// @param[in] numColumns The number of columns in x direction
/// @param[in] numRows The number of columns in y direction
/// @param[in] originX The x coordinate of the origin, located at the bottom left corner
Expand All @@ -64,7 +64,7 @@ namespace meshkernel
const double blockSizeX,
const double blockSizeY) const;

/// @brief Compute an uniform curvilinear grid in one polygon, given an angle and the block sizes
/// @brief Compute a rectangular curvilinear grid in one polygon, given an angle and the block sizes
/// @param[in] angle The grid angle
/// @param[in] blockSizeX The grid block size in x dimension
/// @param[in] blockSizeY The grid block size in y dimension
Expand All @@ -75,7 +75,7 @@ namespace meshkernel
std::shared_ptr<Polygons> polygons,
UInt polygonIndex) const;

/// @brief Compute an uniform curvilinear grid in one polygon, given the block size and the extension. The grid angle is 0
/// @brief Compute a rectangular 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
/// @param[in] originY The y coordinate of the origin, located at the bottom left corner
/// @param[in] blockSizeX The grid block size in x dimension
Expand All @@ -91,7 +91,7 @@ namespace meshkernel
const double upperRightY) const;

private:
/// @brief Compute an uniform curvilinear grid on cartesian coordinates.
/// @brief Compute a rectangular curvilinear grid on cartesian coordinates.
/// @param[in] numColumns The number of columns in x direction
/// @param[in] numRows The number of columns in y direction
/// @param[in] originX The x coordinate of the origin, located at the bottom left corner
Expand All @@ -108,7 +108,7 @@ namespace meshkernel
const double blockSizeX,
const double blockSizeY);

/// @brief Compute an uniform curvilinear grid on spherical coordinates.
/// @brief Compute a rectangular curvilinear grid on spherical coordinates.
/// A correction to the longitudinal discretization is applied to preserve an aspect ratio ds/dy = 1 on real distances.
/// For preventing the creation of small edges, the correction stops when the distance is less than 2000 meters and the grid is generated around the poles.
/// This is a customized fix for GTSM models.
Expand Down
Loading