Skip to content

Commit

Permalink
Merge branch 'master' into feature/GRIDEDIT-768_generate_global_grid
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacarniato authored Dec 21, 2023
2 parents 5b7e3f5 + 8b9af4c commit 7e1fcfe
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 141 deletions.
26 changes: 12 additions & 14 deletions libs/MeshKernel/benchmark/src/perf_curvilinear_rectangular.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,11 @@ static void BM_CurvilinearRectangular(benchmark::State& state)
state.ResumeTiming();

CurvilinearGridRectangular const curvilinearGridRecatngular(Projection::cartesian);
const auto curvilinearGrid = std::make_shared<CurvilinearGrid>(
curvilinearGridRecatngular.Compute(makeGridParameters.angle,
makeGridParameters.block_size_x,
makeGridParameters.block_size_y,
polygons,
0));
const auto curvilinearGrid = curvilinearGridRecatngular.Compute(makeGridParameters.angle,
makeGridParameters.block_size_x,
makeGridParameters.block_size_y,
polygons,
0);
}
}
BENCHMARK(BM_CurvilinearRectangular)
Expand Down Expand Up @@ -86,14 +85,13 @@ static void BM_CurvilinearRectangular_add_faces_to_left_boundary(benchmark::Stat
const double blockSizeY = block_size;

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

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

Expand Down
34 changes: 17 additions & 17 deletions libs/MeshKernel/benchmark/src/perf_mesh_refinement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ static void BM_MeshRefinementBasedOnSamples(benchmark::State& state)
// that are irrelevant to the benchmark and should not be measured)
state.PauseTiming();

std::shared_ptr<meshkernel::Mesh2D> mesh =
MakeRectangularMeshForTesting(static_cast<UInt>(state.range(0)),
static_cast<UInt>(state.range(1)),
10.0,
15.0,
Projection::cartesian);
auto mesh = MakeRectangularMeshForTesting(static_cast<UInt>(state.range(0)),
static_cast<UInt>(state.range(1)),
10.0,
15.0,
Projection::cartesian);

// sample points
std::vector<Sample> samples;
Expand All @@ -34,15 +33,14 @@ static void BM_MeshRefinementBasedOnSamples(benchmark::State& state)
}
}

auto const interpolator = std::make_shared<AveragingInterpolation>(
*mesh,
samples,
AveragingInterpolation::Method::MinAbsValue,
Location::Faces,
1.0,
false,
false,
1);
auto interpolator = std::make_unique<AveragingInterpolation>(*mesh,
samples,
AveragingInterpolation::Method::MinAbsValue,
Location::Faces,
1.0,
false,
false,
1);

MeshRefinementParameters mesh_refinement_parameters;
mesh_refinement_parameters.max_num_refinement_iterations = 1;
Expand All @@ -56,7 +54,9 @@ static void BM_MeshRefinementBasedOnSamples(benchmark::State& state)
// resume the timers to begin benchmarking
state.ResumeTiming();

MeshRefinement meshRefinement(mesh, interpolator, mesh_refinement_parameters);
MeshRefinement meshRefinement(*mesh,
std::move(interpolator),
mesh_refinement_parameters);

meshRefinement.Compute();
}
Expand Down Expand Up @@ -110,7 +110,7 @@ static void BM_MeshRefinementBasedOnPolygons(benchmark::State& state)
// resume the timers to begin benchmarking
state.ResumeTiming();

MeshRefinement meshRefinement(mesh, polygon, mesh_refinement_parameters);
MeshRefinement meshRefinement(*mesh, polygon, mesh_refinement_parameters);

meshRefinement.Compute();
}
Expand Down
18 changes: 9 additions & 9 deletions libs/MeshKernel/benchmark/src/perf_orthogonalization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,21 @@ static void BM_Orthogonalization(benchmark::State& state)
orthogonalization_parameters.orthogonalization_to_smoothing_factor_at_boundary = 0.975;
orthogonalization_parameters.areal_to_angle_smoothing_factor = 1.0;

auto polygon = std::make_shared<Polygons>();
auto polygon = std::make_unique<Polygons>();
std::vector<Point> land_boundary{};
auto landboundaries = std::make_shared<LandBoundaries>(land_boundary, mesh, polygon);
auto landboundaries = std::make_unique<LandBoundaries>(land_boundary, *mesh, *polygon);

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

auto orthogonalizer = std::make_shared<Orthogonalizer>(mesh);
auto smoother = std::make_shared<Smoother>(mesh);
auto orthogonalizer = std::make_unique<Orthogonalizer>(*mesh);
auto smoother = std::make_unique<Smoother>(*mesh);
OrthogonalizationAndSmoothing orthogonalization(
mesh,
smoother,
orthogonalizer,
polygon,
landboundaries,
*mesh,
std::move(smoother),
std::move(orthogonalizer),
std::move(polygon),
std::move(landboundaries),
project_to_land_Boundary,
orthogonalization_parameters);

Expand Down
6 changes: 3 additions & 3 deletions libs/MeshKernel/include/MeshKernel/MeshRefinement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ namespace meshkernel
/// @param[in] interpolant The averaging interpolation to use
/// @param[in] meshRefinementParameters The mesh refinement parameters
MeshRefinement(Mesh2D& mesh,
std::shared_ptr<MeshInterpolation> interpolant,
std::unique_ptr<MeshInterpolation> interpolant,
const MeshRefinementParameters& meshRefinementParameters);

/// @brief The constructor for refining based on samples
Expand All @@ -104,7 +104,7 @@ namespace meshkernel
/// @param[in] meshRefinementParameters The mesh refinement parameters
/// @param[in] useNodalRefinement Use nodal refinement
MeshRefinement(Mesh2D& mesh,
std::shared_ptr<MeshInterpolation> interpolant,
std::unique_ptr<MeshInterpolation> interpolant,
const MeshRefinementParameters& meshRefinementParameters,
bool useNodalRefinement);

Expand Down Expand Up @@ -240,7 +240,7 @@ namespace meshkernel
bool m_directionalRefinement = false; ///< Whether there is directional refinement

Mesh2D& m_mesh; ///< A reference to the mesh
std::shared_ptr<MeshInterpolation> m_interpolant; ///< Pointer to the AveragingInterpolation instance
std::unique_ptr<MeshInterpolation> m_interpolant; ///< Pointer to the AveragingInterpolation instance
Polygons m_polygons; ///< Polygons
MeshRefinementParameters m_meshRefinementParameters; ///< The mesh refinement parameters
bool m_useNodalRefinement = false; ///< Use refinement based on interpolated values at nodes
Expand Down
8 changes: 4 additions & 4 deletions libs/MeshKernel/src/MeshRefinement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ using meshkernel::Mesh2D;
using meshkernel::MeshRefinement;

MeshRefinement::MeshRefinement(Mesh2D& mesh,
std::shared_ptr<MeshInterpolation> interpolant,
std::unique_ptr<MeshInterpolation> interpolant,
const MeshRefinementParameters& meshRefinementParameters) : m_samplesRTree(RTreeFactory::Create(mesh.m_projection)),
m_mesh(mesh),
m_interpolant(interpolant)
m_interpolant(std::move(interpolant))
{
CheckMeshRefinementParameters(meshRefinementParameters);
m_isRefinementBasedOnSamples = true;
Expand All @@ -50,11 +50,11 @@ MeshRefinement::MeshRefinement(Mesh2D& mesh,
}

MeshRefinement::MeshRefinement(Mesh2D& mesh,
std::shared_ptr<MeshInterpolation> interpolant,
std::unique_ptr<MeshInterpolation> interpolant,
const MeshRefinementParameters& meshRefinementParameters,
bool useNodalRefinement) : m_samplesRTree(RTreeFactory::Create(mesh.m_projection)),
m_mesh(mesh),
m_interpolant(interpolant),
m_interpolant(std::move(interpolant)),
m_useNodalRefinement(useNodalRefinement)
{
CheckMeshRefinementParameters(meshRefinementParameters);
Expand Down
Loading

0 comments on commit 7e1fcfe

Please sign in to comment.