From b6fce28bd677a3e9b36c3b28173189353222b19b Mon Sep 17 00:00:00 2001 From: Loic Gouarin Date: Sun, 1 Feb 2026 14:51:54 +0100 Subject: [PATCH 01/16] fix warning From 7187db2dab8c2dbc815ee4672c847c5454819429 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 11 Sep 2025 14:22:41 +0000 Subject: [PATCH 02/16] fix: remove warnings at compile time --- include/samurai/algorithm.hpp | 8 +++++ include/samurai/level_cell_array.hpp | 11 ++++++- include/samurai/mr/rel_detail.hpp | 6 ++-- .../samurai/petsc/nonlinear_local_solvers.hpp | 4 +++ include/samurai/reconstruction.hpp | 20 ++++++------- .../explicit_flux_based_scheme__lin_hom.hpp | 30 +++++++++++++++++++ .../explicit_flux_based_scheme__nonlin.hpp | 2 ++ 7 files changed, 67 insertions(+), 14 deletions(-) diff --git a/include/samurai/algorithm.hpp b/include/samurai/algorithm.hpp index 9711bc5dc..9e97fce74 100644 --- a/include/samurai/algorithm.hpp +++ b/include/samurai/algorithm.hpp @@ -174,12 +174,16 @@ namespace samurai template SAMURAI_INLINE void parallel_for_each_meshinterval(SetType& set, Func&& f) { +#if defined(SAMURAI_WITH_OPENMP) #pragma omp parallel #pragma omp single nowait +#endif set( [&](const auto& i, const auto& index) { +#if defined(SAMURAI_WITH_OPENMP) #pragma omp task +#endif { MeshIntervalType mesh_interval(set.level()); mesh_interval.i = i; @@ -235,12 +239,16 @@ namespace samurai using cell_t = Cell; using index_value_t = typename cell_t::value_t; +#if defined(SAMURAI_WITH_OPENMP) #pragma omp parallel #pragma omp single nowait +#endif { for (auto it = lca.cbegin(); it != lca.cend(); ++it) { +#if defined(SAMURAI_WITH_OPENMP) #pragma omp task +#endif for (index_value_t i = it->start; i < it->end; ++i) { typename cell_t::indices_t index; diff --git a/include/samurai/level_cell_array.hpp b/include/samurai/level_cell_array.hpp index 5df8f2a78..c2d93271a 100644 --- a/include/samurai/level_cell_array.hpp +++ b/include/samurai/level_cell_array.hpp @@ -9,6 +9,7 @@ #include #include + #ifdef SAMURAI_WITH_MPI #include #include @@ -45,7 +46,11 @@ namespace samurai explicit LevelCellArray_reverse_iterator(iterator&& it) : base_type(std::move(it)) { - } +} + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif const coord_type index() const { @@ -497,6 +502,7 @@ namespace samurai typename iterator::offset_type_iterator offset_index; typename iterator::iterator_container current_index; typename iterator::coord_type index; + index.fill(0); for (std::size_t d = 0; d < dim; ++d) { @@ -517,6 +523,7 @@ namespace samurai typename iterator::offset_type_iterator offset_index; typename iterator::iterator_container current_index; typename iterator::coord_type index; + index.fill(0); for (std::size_t d = 0; d < dim; ++d) { @@ -539,6 +546,7 @@ namespace samurai typename const_iterator::offset_type_iterator offset_index; typename const_iterator::iterator_container current_index; typename const_iterator::coord_type index; + index.fill(0); for (std::size_t d = 0; d < dim; ++d) { @@ -561,6 +569,7 @@ namespace samurai typename const_iterator::offset_type_iterator offset_index; typename const_iterator::iterator_container current_index; typename const_iterator::coord_type index; + index.fill(0); for (std::size_t d = 0; d < dim; ++d) { diff --git a/include/samurai/mr/rel_detail.hpp b/include/samurai/mr/rel_detail.hpp index 0c8959696..aa1f1e9e9 100644 --- a/include/samurai/mr/rel_detail.hpp +++ b/include/samurai/mr/rel_detail.hpp @@ -40,10 +40,10 @@ namespace samurai template void set_inv_max_field(auto& inv_max_fields, const Field_tuple& field) { - auto f = [](auto& inv_max_fields, const auto& field, auto& dec) + auto f = [](auto& inv_max_fields_var, const auto& fld, auto& offset) { - set_inv_max_field(inv_max_fields, field, dec); - dec += field.n_comp; + set_inv_max_field(inv_max_fields_var, fld, offset); + offset += fld.n_comp; }; std::size_t dec = 0; diff --git a/include/samurai/petsc/nonlinear_local_solvers.hpp b/include/samurai/petsc/nonlinear_local_solvers.hpp index 6bd6201ff..b57452c24 100644 --- a/include/samurai/petsc/nonlinear_local_solvers.hpp +++ b/include/samurai/petsc/nonlinear_local_solvers.hpp @@ -134,7 +134,9 @@ namespace samurai std::vector J_list(n_threads); std::vector r_list(n_threads); +#if defined(SAMURAI_WITH_OPENMP) #pragma omp parallel for +#endif for (std::size_t thread_num = 0; thread_num < n_threads; ++thread_num) { SNESCreate(PETSC_COMM_SELF, &snes_list[thread_num]); @@ -186,7 +188,9 @@ namespace samurai VecDestroy(&b); }); +#if defined(SAMURAI_WITH_OPENMP) #pragma omp parallel for +#endif for (std::size_t thread_num = 0; thread_num < n_threads; ++thread_num) { MatDestroy(&J_list[thread_num]); diff --git a/include/samurai/reconstruction.hpp b/include/samurai/reconstruction.hpp index 785bc3a52..1349c235c 100644 --- a/include/samurai/reconstruction.hpp +++ b/include/samurai/reconstruction.hpp @@ -280,9 +280,9 @@ namespace samurai }(std::make_index_sequence>>{}); auto end = std::apply( - [](auto&... coeff_arrays) + [](auto&... arrays) { - return std::make_tuple(coeff_arrays.size()...); + return std::make_tuple(arrays.size()...); }, coeff_arrays); @@ -666,9 +666,9 @@ namespace samurai const std::tuple& i, const std::tuple& ii) { - auto get_f = [&](std::size_t level, const auto&... indices) + auto get_f = [&](std::size_t lvl, const auto&... indices) { - return f(element, level, indices...); + return f(element, lvl, indices...); }; detail::portion_impl(result, f, get_f, level, delta_l, i, ii); } @@ -699,9 +699,9 @@ namespace samurai const std::tuple& i, const std::tuple& ii) { - auto get_f = [&](std::size_t level, const auto&... indices) + auto get_f = [&](std::size_t lvl, const auto&... indices) { - return f(level, indices...); + return f(lvl, indices...); }; detail::portion_impl(result, get_f, level, delta_l, i, ii); @@ -781,21 +781,21 @@ namespace samurai using interval_t = typename Field::interval_t; static_assert(dim <= 3, "Not implemented for dim > 3"); - auto get_f = [&](std::size_t level, const auto&... indices) + auto get_f = [&](std::size_t lvl, const auto&... indices) { if constexpr (Field::is_scalar) { - return f(level, indices...); + return f(lvl, indices...); } else { if constexpr (Field::is_soa) { - return xt::view(f(level, indices...), xt::all(), 0); + return xt::view(f(lvl, indices...), xt::all(), 0); } else { - return xt::view(f(level, indices...), 0); + return xt::view(f(lvl, indices...), 0); } } }; diff --git a/include/samurai/schemes/fv/flux_based/explicit_flux_based_scheme__lin_hom.hpp b/include/samurai/schemes/fv/flux_based/explicit_flux_based_scheme__lin_hom.hpp index ecc2cdddc..0baaf6fe5 100644 --- a/include/samurai/schemes/fv/flux_based/explicit_flux_based_scheme__lin_hom.hpp +++ b/include/samurai/schemes/fv/flux_based/explicit_flux_based_scheme__lin_hom.hpp @@ -67,12 +67,16 @@ namespace samurai // clang-format off if (left_cell.level == right_cell.level || i.size() == 1) // if same level, or a jump in the x-direction (<=> i.size()=1) { + #if defined(SAMURAI_WITH_OPENMP) #pragma omp simd + #endif for (index_t ii = 0; ii < static_cast(i.size()); ++ii) { field_value(output_field, left_cell_index_init + ii, field_i) += left_cell_coeff * field_value(input_field, comput_index_init + ii, field_j); } + #if defined(SAMURAI_WITH_OPENMP) #pragma omp simd + #endif for (index_t ii = 0; ii < static_cast(i.size()); ++ii) { field_value(output_field, right_cell_index_init + ii, field_i) += right_cell_coeff * field_value(input_field, comput_index_init + ii, field_j); @@ -84,13 +88,17 @@ namespace samurai // The fine interval is even (exept in the x-direction, handled by the preceding if). // We always have i.size() fine cells for i.size()/2 coarse cells. assert(i.size() % 2 == 0); + #if defined(SAMURAI_WITH_OPENMP) #pragma omp simd + #endif for (index_t ii = 0; ii < static_cast(i.size() / 2); ++ii) // iteration on the coarse cells { field_value(output_field, left_cell_index_init + ii, field_i) += left_cell_coeff * field_value(input_field, comput_index_init + 2*ii , field_j) + left_cell_coeff * field_value(input_field, comput_index_init + 2*ii+1, field_j); } + #if defined(SAMURAI_WITH_OPENMP) #pragma omp simd + #endif for (index_t ii = 0; ii < static_cast(i.size()); ++ii) // iteration on the fine cells { field_value(output_field, right_cell_index_init + ii, field_i) += right_cell_coeff * field_value(input_field, comput_index_init + ii, field_j); @@ -100,12 +108,16 @@ namespace samurai { // Same as above, the other way around. assert(i.size() % 2 == 0); + #if defined(SAMURAI_WITH_OPENMP) #pragma omp simd + #endif for (index_t ii = 0; ii < static_cast(i.size()); ++ii) { field_value(output_field, left_cell_index_init + ii, field_i) += left_cell_coeff * field_value(input_field, comput_index_init + ii, field_j); } + #if defined(SAMURAI_WITH_OPENMP) #pragma omp simd + #endif for (index_t ii = 0; ii < static_cast(i.size() / 2); ++ii) { field_value(output_field, right_cell_index_init + ii, field_i) += right_cell_coeff * field_value(input_field, comput_index_init + 2*ii , field_j) @@ -161,12 +173,16 @@ namespace samurai // clang-format off if (left_cell.level == right_cell.level || i.size() == 1) // if same level, or a jump in the x-direction (<=> i.size()=1) { + #if defined(SAMURAI_WITH_OPENMP) #pragma omp simd + #endif for (index_t ii = 0; ii < static_cast(i.size()); ++ii) { left_contributions[static_cast(ii)] += left_cell_coeff * field_value(input_field, comput_index_init + ii, field_j); } + #if defined(SAMURAI_WITH_OPENMP) #pragma omp simd + #endif for (index_t ii = 0; ii < static_cast(i.size()); ++ii) { right_contributions[static_cast(ii)] += right_cell_coeff * field_value(input_field, comput_index_init + ii, field_j); @@ -178,13 +194,17 @@ namespace samurai // The fine interval is even (exept in the x-direction, handled by the preceding if). // We always have i.size() fine cells for i.size()/2 coarse cells. assert(i.size() % 2 == 0); + #if defined(SAMURAI_WITH_OPENMP) #pragma omp simd + #endif for (index_t ii = 0; ii < static_cast(i.size() / 2); ++ii) // iteration on the coarse cells { left_contributions[static_cast(ii)] += left_cell_coeff * field_value(input_field, comput_index_init + 2*ii , field_j) + left_cell_coeff * field_value(input_field, comput_index_init + 2*ii+1, field_j); } + #if defined(SAMURAI_WITH_OPENMP) #pragma omp simd + #endif for (index_t ii = 0; ii < static_cast(i.size()); ++ii) // iteration on the fine cells { right_contributions[static_cast(ii)] += right_cell_coeff * field_value(input_field, comput_index_init + ii, field_j); @@ -194,12 +214,16 @@ namespace samurai { // Same as above, the other way around. assert(i.size() % 2 == 0); + #if defined(SAMURAI_WITH_OPENMP) #pragma omp simd + #endif for (index_t ii = 0; ii < static_cast(i.size()); ++ii) { left_contributions[static_cast(ii)] += left_cell_coeff * field_value(input_field, comput_index_init + ii, field_j); } + #if defined(SAMURAI_WITH_OPENMP) #pragma omp simd + #endif for (index_t ii = 0; ii < static_cast(i.size() / 2); ++ii) { right_contributions[static_cast(ii)] += right_cell_coeff * field_value(input_field, comput_index_init + 2*ii , field_j) @@ -216,12 +240,16 @@ namespace samurai // clang-format off for (index_t ii = 0; ii < static_cast(left_contributions.size()); ++ii) { + #if defined(SAMURAI_WITH_OPENMP) #pragma omp atomic update + #endif field_value(output_field, left_cell_index_init + ii, field_i) += left_contributions[static_cast(ii)]; } for (index_t ii = 0; ii < static_cast(right_contributions.size()); ++ii) { + #if defined(SAMURAI_WITH_OPENMP) #pragma omp atomic update + #endif field_value(output_field, right_cell_index_init + ii, field_i) += right_contributions[static_cast(ii)]; } // clang-format on @@ -303,7 +331,9 @@ namespace samurai // clang-format off + #if defined(SAMURAI_WITH_OPENMP) #pragma omp simd + #endif for (index_t ii = 0; ii < static_cast(stencil.interval().size()); ++ii) { field_value(output_field, cell_index_init + ii, field_i) += coeff * field_value(input_field, comput_index_init + ii, field_j); diff --git a/include/samurai/schemes/fv/flux_based/explicit_flux_based_scheme__nonlin.hpp b/include/samurai/schemes/fv/flux_based/explicit_flux_based_scheme__nonlin.hpp index 0eb713c79..e74763242 100644 --- a/include/samurai/schemes/fv/flux_based/explicit_flux_based_scheme__nonlin.hpp +++ b/include/samurai/schemes/fv/flux_based/explicit_flux_based_scheme__nonlin.hpp @@ -44,7 +44,9 @@ namespace samurai for (size_type field_i = 0; field_i < output_n_comp; ++field_i) { // clang-format off + #if defined(SAMURAI_WITH_OPENMP) #pragma omp atomic update + #endif field_value(output_field, cell, field_i) += this->scheme().flux_value_cmpnent(contrib, field_i); // clang-format on } From a1700e37bc26504a247e512ca4d5b080f00ae31b Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 11 Sep 2025 14:38:52 +0000 Subject: [PATCH 03/16] ci: pre-commit --- include/samurai/level_cell_array.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/samurai/level_cell_array.hpp b/include/samurai/level_cell_array.hpp index c2d93271a..7e4ae42ed 100644 --- a/include/samurai/level_cell_array.hpp +++ b/include/samurai/level_cell_array.hpp @@ -9,7 +9,6 @@ #include #include - #ifdef SAMURAI_WITH_MPI #include #include @@ -46,7 +45,7 @@ namespace samurai explicit LevelCellArray_reverse_iterator(iterator&& it) : base_type(std::move(it)) { -} + } #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic pop From c7ebeae7474c3bbe2161ba2bd93da3f55aca8ac0 Mon Sep 17 00:00:00 2001 From: sbstndb/sbstndbs Date: Mon, 6 Oct 2025 13:03:40 +0200 Subject: [PATCH 04/16] chore: remove usuned GNU bloc --- include/samurai/level_cell_array.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/samurai/level_cell_array.hpp b/include/samurai/level_cell_array.hpp index 7e4ae42ed..d58754594 100644 --- a/include/samurai/level_cell_array.hpp +++ b/include/samurai/level_cell_array.hpp @@ -47,10 +47,6 @@ namespace samurai { } -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC diagnostic pop -#endif - const coord_type index() const { iterator it = this->base(); From 1b396a6de9211b8833a281dcdf7296e0a14b9f58 Mon Sep 17 00:00:00 2001 From: sbstndb/sbstndbs Date: Mon, 6 Oct 2025 13:06:23 +0200 Subject: [PATCH 05/16] chore: remove fill --- include/samurai/level_cell_array.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/samurai/level_cell_array.hpp b/include/samurai/level_cell_array.hpp index d58754594..5df8f2a78 100644 --- a/include/samurai/level_cell_array.hpp +++ b/include/samurai/level_cell_array.hpp @@ -497,7 +497,6 @@ namespace samurai typename iterator::offset_type_iterator offset_index; typename iterator::iterator_container current_index; typename iterator::coord_type index; - index.fill(0); for (std::size_t d = 0; d < dim; ++d) { @@ -518,7 +517,6 @@ namespace samurai typename iterator::offset_type_iterator offset_index; typename iterator::iterator_container current_index; typename iterator::coord_type index; - index.fill(0); for (std::size_t d = 0; d < dim; ++d) { @@ -541,7 +539,6 @@ namespace samurai typename const_iterator::offset_type_iterator offset_index; typename const_iterator::iterator_container current_index; typename const_iterator::coord_type index; - index.fill(0); for (std::size_t d = 0; d < dim; ++d) { @@ -564,7 +561,6 @@ namespace samurai typename const_iterator::offset_type_iterator offset_index; typename const_iterator::iterator_container current_index; typename const_iterator::coord_type index; - index.fill(0); for (std::size_t d = 0; d < dim; ++d) { From 07dbe10a7107e57d16fe931fbd2be3a0815dc5b7 Mon Sep 17 00:00:00 2001 From: sbstndb/sbstndbs Date: Mon, 6 Oct 2025 13:26:50 +0200 Subject: [PATCH 06/16] level_cell_array: value-initialize iterator coord index Initialize coord_type index{} in begin/end/cbegin/cend to avoid GCC -Wmaybe-uninitialized with xt::xtensor_fixed (xtensor 0.24). Fixes warnings like: xfixed.hpp:334:9: warning: may be used uninitialized [-Wmaybe-uninitialized] triggered via LevelCellArray::cbegin() constructing const_iterator. --- include/samurai/level_cell_array.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/samurai/level_cell_array.hpp b/include/samurai/level_cell_array.hpp index 5df8f2a78..0458d42c0 100644 --- a/include/samurai/level_cell_array.hpp +++ b/include/samurai/level_cell_array.hpp @@ -496,7 +496,7 @@ namespace samurai { typename iterator::offset_type_iterator offset_index; typename iterator::iterator_container current_index; - typename iterator::coord_type index; + typename iterator::coord_type index{}; for (std::size_t d = 0; d < dim; ++d) { @@ -516,7 +516,7 @@ namespace samurai { typename iterator::offset_type_iterator offset_index; typename iterator::iterator_container current_index; - typename iterator::coord_type index; + typename iterator::coord_type index{}; for (std::size_t d = 0; d < dim; ++d) { @@ -538,7 +538,7 @@ namespace samurai { typename const_iterator::offset_type_iterator offset_index; typename const_iterator::iterator_container current_index; - typename const_iterator::coord_type index; + typename const_iterator::coord_type index{}; for (std::size_t d = 0; d < dim; ++d) { @@ -560,7 +560,7 @@ namespace samurai { typename const_iterator::offset_type_iterator offset_index; typename const_iterator::iterator_container current_index; - typename const_iterator::coord_type index; + typename const_iterator::coord_type index{}; for (std::size_t d = 0; d < dim; ++d) { From df7c9ec7d98dbf550318cba832e941eda3560ad1 Mon Sep 17 00:00:00 2001 From: Loic Gouarin Date: Sun, 1 Feb 2026 14:31:51 +0100 Subject: [PATCH 07/16] fix gcc warnings --- include/samurai/bc/apply_field_bc.hpp | 8 ++--- include/samurai/mesh.hpp | 22 ++++++------- include/samurai/mr/mesh.hpp | 45 +++++---------------------- 3 files changed, 22 insertions(+), 53 deletions(-) diff --git a/include/samurai/bc/apply_field_bc.hpp b/include/samurai/bc/apply_field_bc.hpp index 9b28137c6..76e36a5c3 100644 --- a/include/samurai/bc/apply_field_bc.hpp +++ b/include/samurai/bc/apply_field_bc.hpp @@ -382,9 +382,9 @@ namespace samurai { int stencil_s = 2 * ghost_layer; static_for<2, max_stencil_size_implemented_PE + 1>::apply( - [&](auto stencil_size_) + [&](auto stencil_size) { - static constexpr int stencil_size = static_cast(stencil_size_()); + // static constexpr int stencil_size = static_cast(stencil_size_()); if constexpr (stencil_size % 2 == 0) // (because PolynomialExtrapolation is only implemented for even stencil_size) { @@ -409,10 +409,8 @@ namespace samurai { int stencil_s = 2 * ghost_layer; static_for<2, max_stencil_size_implemented_PE + 1>::apply( - [&](auto stencil_size_) + [&](auto stencil_size) { - static constexpr int stencil_size = static_cast(stencil_size_()); - if constexpr (stencil_size % 2 == 0) // (because PolynomialExtrapolation is only implemented for even stencil_size) { if (stencil_s == stencil_size) diff --git a/include/samurai/mesh.hpp b/include/samurai/mesh.hpp index cf2defbb8..874367137 100644 --- a/include/samurai/mesh.hpp +++ b/include/samurai/mesh.hpp @@ -273,9 +273,9 @@ namespace samurai } template - SAMURAI_INLINE Mesh_base::Mesh_base(const samurai::Box& b, const mesh_config& config) - : m_domain{config.start_level(), b, config.approx_box_tol(), config.scaling_factor()} - , m_config(config) + SAMURAI_INLINE Mesh_base::Mesh_base(const samurai::Box& b, const mesh_config& mesh_cfg) + : m_domain{mesh_cfg.start_level(), b, mesh_cfg.approx_box_tol(), mesh_cfg.scaling_factor()} + , m_config(mesh_cfg) { #ifdef SAMURAI_WITH_MPI partition_mesh(m_config.start_level(), b); @@ -301,11 +301,11 @@ namespace samurai } template - Mesh_base::Mesh_base(const samurai::DomainBuilder& domain_builder, const mesh_config& config) - : m_config(config) + Mesh_base::Mesh_base(const samurai::DomainBuilder& domain_builder, const mesh_config& mesh_cfg) + : m_config(mesh_cfg) { - if (std::any_of(config.periodic().begin(), - config.periodic().end(), + if (std::any_of(mesh_cfg.periodic().begin(), + mesh_cfg.periodic().end(), [](bool b) { return b; @@ -350,8 +350,8 @@ namespace samurai } template - SAMURAI_INLINE Mesh_base::Mesh_base(const cl_type& cl, const mesh_config& config) - : m_config(config) + SAMURAI_INLINE Mesh_base::Mesh_base(const cl_type& cl, const mesh_config& mesh_cfg) + : m_config(mesh_cfg) { this->m_cells[mesh_id_t::cells] = {cl}; @@ -371,8 +371,8 @@ namespace samurai } template - SAMURAI_INLINE Mesh_base::Mesh_base(const ca_type& ca, const mesh_config& config) - : m_config(config) + SAMURAI_INLINE Mesh_base::Mesh_base(const ca_type& ca, const mesh_config& mesh_cfg) + : m_config(mesh_cfg) { this->m_cells[mesh_id_t::cells] = ca; diff --git a/include/samurai/mr/mesh.hpp b/include/samurai/mr/mesh.hpp index 958a8823d..c248a6312 100644 --- a/include/samurai/mr/mesh.hpp +++ b/include/samurai/mr/mesh.hpp @@ -30,35 +30,6 @@ namespace samurai reference = all_cells }; - template - struct [[deprecated("Use samurai::mesh_config instead")]] MRConfig - { - // cppcheck-suppress-begin unusedStructMember - - static constexpr std::size_t dim = dim_; - static constexpr std::size_t max_refinement_level = max_refinement_level_; - - // deprecated interface - [[deprecated("Use max_stencil_radius() method instead")]] static constexpr int max_stencil_width = max_stencil_width_; - [[deprecated("Use prediction_stencil_radius instead")]] static constexpr int prediction_order = prediction_order_; - [[deprecated("Use graduation_width() method instead")]] static constexpr std::size_t graduation_width = graduation_width_; - [[deprecated("Use ghost_width() method instead")]] static constexpr int ghost_width = std::max(static_cast(max_stencil_width), - static_cast(prediction_order)); - - // new interface - static constexpr int prediction_stencil_radius = prediction_order_; - - // cppcheck-suppress-end unusedStructMember - - using interval_t = TInterval; - using mesh_id_t = MRMeshId; - }; - template class MRMesh : public samurai::Mesh_base, Config> { @@ -126,26 +97,26 @@ namespace samurai } template - SAMURAI_INLINE MRMesh::MRMesh(const cl_type& cl, const mesh_config& config) - : base_type(cl, config) + SAMURAI_INLINE MRMesh::MRMesh(const cl_type& cl, const mesh_config& mesh_cfg) + : base_type(cl, mesh_cfg) { } template - SAMURAI_INLINE MRMesh::MRMesh(const ca_type& ca, const mesh_config& config) - : base_type(ca, config) + SAMURAI_INLINE MRMesh::MRMesh(const ca_type& ca, const mesh_config& mesh_cfg) + : base_type(ca, mesh_cfg) { } template - SAMURAI_INLINE MRMesh::MRMesh(const samurai::Box& b, const mesh_config& config) - : base_type(b, config) + SAMURAI_INLINE MRMesh::MRMesh(const samurai::Box& b, const mesh_config& mesh_cfg) + : base_type(b, mesh_cfg) { } template - SAMURAI_INLINE MRMesh::MRMesh(const samurai::DomainBuilder& domain_builder, const mesh_config& config) - : base_type(domain_builder, config) + SAMURAI_INLINE MRMesh::MRMesh(const samurai::DomainBuilder& domain_builder, const mesh_config& mesh_cfg) + : base_type(domain_builder, mesh_cfg) { } From 8d4ee244cbc6df41209a04a1639f385b870b8c79 Mon Sep 17 00:00:00 2001 From: Loic Gouarin Date: Sun, 1 Feb 2026 14:50:51 +0100 Subject: [PATCH 08/16] fix warnings --- include/samurai/amr/mesh.hpp | 40 ++++++-------------------- include/samurai/field/scalar_field.hpp | 1 + 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/include/samurai/amr/mesh.hpp b/include/samurai/amr/mesh.hpp index e65576753..989ac26a9 100644 --- a/include/samurai/amr/mesh.hpp +++ b/include/samurai/amr/mesh.hpp @@ -25,28 +25,6 @@ namespace samurai::amr // reference = cells_and_ghosts }; - template - struct [[deprecated("Use samurai::mesh_config instead")]] Config - { - static constexpr std::size_t dim = dim_; - static constexpr std::size_t max_refinement_level = max_refinement_level_; - - // deprecated interface - [[deprecated("Use max_stencil_radius() method instead")]] static constexpr int max_stencil_width = max_stencil_width_; - [[deprecated("Use prediction_stencil_radius instead")]] static constexpr int prediction_order = prediction_order_; - [[deprecated("Use graduation_width() method instead")]] static constexpr int graduation_width = graduation_width_; - [[deprecated("Use ghost_width() method instead")]] static constexpr int ghost_width = std::max(static_cast(max_stencil_width), - static_cast(prediction_order)); - - using interval_t = TInterval; - using mesh_id_t = AMR_Id; - }; - ///////////////////////// // AMR mesh definition // ///////////////////////// @@ -72,9 +50,9 @@ namespace samurai::amr Mesh() = default; Mesh(const ca_type& ca, const self_type& ref_mesh); Mesh(const cl_type& cl, const self_type& ref_mesh); - Mesh(const cl_type& cl, const mesh_config& config); - Mesh(const ca_type& ca, const mesh_config& config); - Mesh(const Box& b, const mesh_config& config); + Mesh(const cl_type& cl, const mesh_config& mesh_cfg); + Mesh(const ca_type& ca, const mesh_config& mesh_cfg); + Mesh(const Box& b, const mesh_config& mesh_cfg); Mesh(const cl_type& cl, std::size_t min_level, std::size_t max_level); Mesh(const ca_type& ca, std::size_t min_level, std::size_t max_level); @@ -102,20 +80,20 @@ namespace samurai::amr } template - SAMURAI_INLINE Mesh::Mesh(const cl_type& cl, const mesh_config& config) - : base_type(cl, config) + SAMURAI_INLINE Mesh::Mesh(const cl_type& cl, const mesh_config& mesh_cfg) + : base_type(cl, mesh_cfg) { } template - SAMURAI_INLINE Mesh::Mesh(const ca_type& ca, const mesh_config& config) - : base_type(ca, config) + SAMURAI_INLINE Mesh::Mesh(const ca_type& ca, const mesh_config& mesh_cfg) + : base_type(ca, mesh_cfg) { } template - SAMURAI_INLINE Mesh::Mesh(const Box& b, const mesh_config& config) - : base_type(b, config) + SAMURAI_INLINE Mesh::Mesh(const Box& b, const mesh_config& mesh_cfg) + : base_type(b, mesh_cfg) { } diff --git a/include/samurai/field/scalar_field.hpp b/include/samurai/field/scalar_field.hpp index 6ba8cc335..fd77983f0 100644 --- a/include/samurai/field/scalar_field.hpp +++ b/include/samurai/field/scalar_field.hpp @@ -130,6 +130,7 @@ namespace samurai template SAMURAI_INLINE ScalarField::ScalarField(const ScalarField& field) + : inner_mesh_t(field.mesh()) { this->assign_from(field); } From be0c7801bd9b23f4c703cdb87635464ab5734e8a Mon Sep 17 00:00:00 2001 From: Loic Gouarin Date: Sun, 1 Feb 2026 15:30:25 +0100 Subject: [PATCH 09/16] fix pre-commit --- include/samurai/field/scalar_field.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/samurai/field/scalar_field.hpp b/include/samurai/field/scalar_field.hpp index fd77983f0..61e70aae8 100644 --- a/include/samurai/field/scalar_field.hpp +++ b/include/samurai/field/scalar_field.hpp @@ -130,7 +130,7 @@ namespace samurai template SAMURAI_INLINE ScalarField::ScalarField(const ScalarField& field) - : inner_mesh_t(field.mesh()) + : inner_mesh_t(field.mesh()) { this->assign_from(field); } From 71a7e578788841381f695f406e0d668374f408c2 Mon Sep 17 00:00:00 2001 From: Loic Gouarin Date: Sun, 1 Feb 2026 16:30:56 +0100 Subject: [PATCH 10/16] fix --- include/samurai/petsc/compute_cell_ownership.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/samurai/petsc/compute_cell_ownership.hpp b/include/samurai/petsc/compute_cell_ownership.hpp index d4a3385d9..7692ab952 100644 --- a/include/samurai/petsc/compute_cell_ownership.hpp +++ b/include/samurai/petsc/compute_cell_ownership.hpp @@ -43,7 +43,7 @@ namespace samurai auto samurai_cell_indices_field = make_scalar_field("samurai_cell_index", mesh); for (std::size_t cell_index = 0; cell_index < mesh.nb_cells(); ++cell_index) { - samurai_cell_indices_field[cell_index] = static_cast(cell_index); + samurai_cell_indices_field[cell_index] = cell_index; } auto petsc_cell_indices_field = make_scalar_field("petsc_cell_index", mesh); From 365b2b2984421e58ffc503b2e6dc0e77132ddf9f Mon Sep 17 00:00:00 2001 From: Loic Gouarin Date: Sun, 1 Feb 2026 17:04:16 +0100 Subject: [PATCH 11/16] fix shadow --- demos/FiniteVolume/nagumo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/FiniteVolume/nagumo.cpp b/demos/FiniteVolume/nagumo.cpp index ceacdfea6..922229b20 100644 --- a/demos/FiniteVolume/nagumo.cpp +++ b/demos/FiniteVolume/nagumo.cpp @@ -111,9 +111,9 @@ int main(int argc, char* argv[]) return e / (1 + e); }; - auto exact_solution = [&](double x, double t) + auto exact_solution = [&](double x, double time) { - return beta(x - c * t); + return beta(x - c * time); }; if (restart_file.empty()) From 184a3783632d567615577be7e9fb877bb5e2c79f Mon Sep 17 00:00:00 2001 From: Loic Gouarin Date: Sun, 1 Feb 2026 18:40:03 +0100 Subject: [PATCH 12/16] fix --- include/samurai/petsc/manual_assembly.hpp | 2 ++ include/samurai/petsc/zero_block_assembly.hpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/samurai/petsc/manual_assembly.hpp b/include/samurai/petsc/manual_assembly.hpp index e7f171fd6..94c2e4f35 100644 --- a/include/samurai/petsc/manual_assembly.hpp +++ b/include/samurai/petsc/manual_assembly.hpp @@ -18,6 +18,8 @@ namespace samurai using scheme_t = ManualAssembly; using input_field_t = UnknownField; + using MatrixAssembly::setup; + private: UnknownField* m_unknown = nullptr; diff --git a/include/samurai/petsc/zero_block_assembly.hpp b/include/samurai/petsc/zero_block_assembly.hpp index c888ebb46..6cbefe39d 100644 --- a/include/samurai/petsc/zero_block_assembly.hpp +++ b/include/samurai/petsc/zero_block_assembly.hpp @@ -16,6 +16,8 @@ namespace samurai using scheme_t = int; // deactivate compatibility test in block_operator.tie_unknowns() using input_field_t = void; // deactivate compatibility test during assembly + using MatrixAssembly::setup; + private: PetscInt m_owned_rows = 0; From 15c136d48d3a8dd388d21ee2d640d48acffb94b3 Mon Sep 17 00:00:00 2001 From: Loic Gouarin Date: Mon, 2 Feb 2026 04:49:56 +0100 Subject: [PATCH 13/16] remove PETSc warnings and add `-Werror` --- CMakeLists.txt | 1 + demos/FiniteVolume/CMakeLists.txt | 2 +- demos/highorder/CMakeLists.txt | 2 +- demos/multigrid/CMakeLists.txt | 2 +- demos/multigrid/main.cpp | 4 ++-- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 48e17e288..87eafa12d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,6 +93,7 @@ message(STATUS "Available FEATURES: ${FEATURES}") project_options( ${FEATURES} ENABLE_VS_ANALYSIS + WARNINGS_AS_ERRORS ${ENABLE_CONAN} ) diff --git a/demos/FiniteVolume/CMakeLists.txt b/demos/FiniteVolume/CMakeLists.txt index e55a22913..c91b41269 100644 --- a/demos/FiniteVolume/CMakeLists.txt +++ b/demos/FiniteVolume/CMakeLists.txt @@ -33,7 +33,7 @@ if(${WITH_PETSC}) find_dependency(PkgConfig) pkg_check_modules(PETSC REQUIRED PETSc) - include_directories(${PETSC_INCLUDE_DIRS}) + include_directories(SYSTEM ${PETSC_INCLUDE_DIRS}) foreach(demo_entry ${PETSC_DEMOS}) string(REPLACE ":" ";" demo_parts ${demo_entry}) diff --git a/demos/highorder/CMakeLists.txt b/demos/highorder/CMakeLists.txt index 4f2e97728..75abd6652 100644 --- a/demos/highorder/CMakeLists.txt +++ b/demos/highorder/CMakeLists.txt @@ -3,7 +3,7 @@ if(${WITH_PETSC}) find_dependency(PkgConfig) pkg_check_modules(PETSC REQUIRED PETSc) - include_directories(${PETSC_INCLUDE_DIRS}) + include_directories(SYSTEM ${PETSC_INCLUDE_DIRS}) add_executable(highorder main.cpp) target_compile_definitions(highorder PUBLIC SAMURAI_WITH_PETSC) diff --git a/demos/multigrid/CMakeLists.txt b/demos/multigrid/CMakeLists.txt index 538301069..9f7c5429f 100644 --- a/demos/multigrid/CMakeLists.txt +++ b/demos/multigrid/CMakeLists.txt @@ -3,7 +3,7 @@ if(${WITH_PETSC}) find_dependency(PkgConfig) pkg_check_modules(PETSC REQUIRED PETSc) - include_directories(${PETSC_INCLUDE_DIRS}) + include_directories(SYSTEM ${PETSC_INCLUDE_DIRS}) add_executable(multigrid main.cpp) target_compile_definitions(multigrid PUBLIC SAMURAI_WITH_PETSC) diff --git a/demos/multigrid/main.cpp b/demos/multigrid/main.cpp index 7fb393732..6f2ad3052 100644 --- a/demos/multigrid/main.cpp +++ b/demos/multigrid/main.cpp @@ -14,8 +14,8 @@ #include "samurai_new/utils.cpp" #include "test_cases.hpp" -static char help[] = "Solution of the Poisson problem in the domain [0,1]^d.\n" - "Geometric multigrid using the samurai meshes.\n" +[[maybe_unused]] static char help[] = "Solution of the Poisson problem in the domain [0,1]^d.\n" + "Geometric multigrid using the samurai meshes.\n" "\n" "-------- General\n" "\n" From 540c9074c35a67380fee33103225d27e1138947b Mon Sep 17 00:00:00 2001 From: Loic Gouarin Date: Mon, 2 Feb 2026 04:51:06 +0100 Subject: [PATCH 14/16] fix pre-commit --- demos/multigrid/main.cpp | 100 +++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/demos/multigrid/main.cpp b/demos/multigrid/main.cpp index 6f2ad3052..9220cf450 100644 --- a/demos/multigrid/main.cpp +++ b/demos/multigrid/main.cpp @@ -15,56 +15,56 @@ #include "test_cases.hpp" [[maybe_unused]] static char help[] = "Solution of the Poisson problem in the domain [0,1]^d.\n" - "Geometric multigrid using the samurai meshes.\n" - "\n" - "-------- General\n" - "\n" - "--level Level used to set the problem size\n" - "--tc Test case:\n" - " poly - The solution is a polynomial " - "function.\n" - " Homogeneous Dirichlet b.c.\n" - " exp - The solution is an exponential " - "function.\n" - " Non-homogeneous Dirichlet " - "b.c.\n" - "--save_sol [0|1] Save solution (default 0)\n" - "--save_mesh [0|1] Save mesh (default 0)\n" - "--path Output path\n" - "--filename Solution file name\n" - "\n" - "-------- Samurai Multigrid ('-pc_type mg' to activate)\n" - "\n" - "--samg_smooth Smoother used in the samurai multigrid:\n" - " sgs - symmetric Gauss-Seidel\n" - " gs - Gauss-Seidel (pre: lexico., " - "post: antilexico.)\n" - " petsc - defined by Petsc options " - "(default: Chebytchev polynomials)\n" - "--samg_transfer_ops [1:4] Samurai multigrid transfer operators " - "(default: 1):\n" - " 1 - P assembled, R assembled\n" - " 2 - P assembled, R = P^T\n" - " 3 - P mat-free, R mat-free (via " - "double*)\n" - " 4 - P mat-free, R mat-free (via " - "Fields)\n" - "--samg_pred_order [0|1] Prediction order used in the prolongation " - "operator\n" - "\n" - "-------- Useful Petsc options\n" - "\n" - "-pc_type [mg|gamg|hypre...] Sets the preconditioner ('mg' for the " - "samurai multigrid)\n" - "-ksp_monitor ascii Prints the residual at each iteration\n" - "-ksp_view ascii View the solver's parametrization\n" - "-ksp_rtol Sets the solver tolerance\n" - "-ksp_max_it Sets the maximum number of iterations\n" - "-pc_mg_levels Sets the number of multigrid levels\n" - "-mg_levels_up_pc_sor_its Sets the number of post-smoothing " - "iterations\n" - "-log_view -pc_mg_log Monitors the multigrid performance\n" - "\n"; + "Geometric multigrid using the samurai meshes.\n" + "\n" + "-------- General\n" + "\n" + "--level Level used to set the problem size\n" + "--tc Test case:\n" + " poly - The solution is a polynomial " + "function.\n" + " Homogeneous Dirichlet b.c.\n" + " exp - The solution is an exponential " + "function.\n" + " Non-homogeneous Dirichlet " + "b.c.\n" + "--save_sol [0|1] Save solution (default 0)\n" + "--save_mesh [0|1] Save mesh (default 0)\n" + "--path Output path\n" + "--filename Solution file name\n" + "\n" + "-------- Samurai Multigrid ('-pc_type mg' to activate)\n" + "\n" + "--samg_smooth Smoother used in the samurai multigrid:\n" + " sgs - symmetric Gauss-Seidel\n" + " gs - Gauss-Seidel (pre: lexico., " + "post: antilexico.)\n" + " petsc - defined by Petsc options " + "(default: Chebytchev polynomials)\n" + "--samg_transfer_ops [1:4] Samurai multigrid transfer operators " + "(default: 1):\n" + " 1 - P assembled, R assembled\n" + " 2 - P assembled, R = P^T\n" + " 3 - P mat-free, R mat-free (via " + "double*)\n" + " 4 - P mat-free, R mat-free (via " + "Fields)\n" + "--samg_pred_order [0|1] Prediction order used in the prolongation " + "operator\n" + "\n" + "-------- Useful Petsc options\n" + "\n" + "-pc_type [mg|gamg|hypre...] Sets the preconditioner ('mg' for the " + "samurai multigrid)\n" + "-ksp_monitor ascii Prints the residual at each iteration\n" + "-ksp_view ascii View the solver's parametrization\n" + "-ksp_rtol Sets the solver tolerance\n" + "-ksp_max_it Sets the maximum number of iterations\n" + "-pc_mg_levels Sets the number of multigrid levels\n" + "-mg_levels_up_pc_sor_its Sets the number of post-smoothing " + "iterations\n" + "-log_view -pc_mg_log Monitors the multigrid performance\n" + "\n"; template auto create_uniform_mesh(std::size_t level) From 801c5d51b287e56c667fb1cc0956fec60c8477dc Mon Sep 17 00:00:00 2001 From: Loic Gouarin Date: Mon, 2 Feb 2026 05:10:57 +0100 Subject: [PATCH 15/16] try to fix xtensor warnings --- CMakeLists.txt | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 87eafa12d..818a2c49a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,7 +107,7 @@ target_include_directories(samurai INTERFACE "$") # Find dependencies: -set(DEPENDENCIES_CONFIGURED HighFive pugixml fmt CLI11) +set(DEPENDENCIES_CONFIGURED xtensor HighFive pugixml fmt CLI11) if(${ENABLE_VCPKG}) list(APPEND DEPENDENCIES_CONFIGURED hdf5) @@ -120,32 +120,21 @@ foreach(DEPENDENCY ${DEPENDENCIES_CONFIGURED}) find_package(${DEPENDENCY} CONFIG REQUIRED) endforeach() +if (xtensor_VERSION VERSION_LESS_EQUAL "0.25.0") + message(FATAL_ERROR "xtensor version ${xtensor_VERSION} is too old. Minimum allowed version is 0.26.") +endif() + # Link dependencies: target_link_system_libraries( samurai INTERFACE + xtensor HighFive pugixml::pugixml fmt::fmt CLI11::CLI11 ) -if(SAMURAI_FIELD_CONTAINER MATCHES xtensor) - message(STATUS "Using xtensor as field container") - list(APPEND DEPENDENCIES_CONFIGURED xtensor) - find_package(xtensor CONFIG REQUIRED) - - if (xtensor_VERSION VERSION_LESS_EQUAL "0.25.0") - message(FATAL_ERROR "xtensor version ${xtensor_VERSION} is too old. Minimum allowed version is 0.26.") - endif() - - target_link_system_libraries( - samurai - INTERFACE - xtensor - ) - -endif() if(SAMURAI_FIELD_CONTAINER MATCHES eigen3) message(STATUS "Using Eigen3 as field container") endif() From bdc21e4fa6aeee297e47e283cfee3ba69a4393cc Mon Sep 17 00:00:00 2001 From: Loic Gouarin Date: Tue, 3 Feb 2026 10:49:23 +0100 Subject: [PATCH 16/16] remove Werror --- CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 818a2c49a..723fb1ebe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,7 +93,7 @@ message(STATUS "Available FEATURES: ${FEATURES}") project_options( ${FEATURES} ENABLE_VS_ANALYSIS - WARNINGS_AS_ERRORS + # WARNINGS_AS_ERRORS ${ENABLE_CONAN} ) @@ -124,6 +124,12 @@ if (xtensor_VERSION VERSION_LESS_EQUAL "0.25.0") message(FATAL_ERROR "xtensor version ${xtensor_VERSION} is too old. Minimum allowed version is 0.26.") endif() +# Get include directories from targets and mark as SYSTEM +get_target_property(HIGHFIVE_INCLUDE_DIRS HighFive INTERFACE_INCLUDE_DIRECTORIES) +if(HIGHFIVE_INCLUDE_DIRS) + target_include_directories(samurai SYSTEM INTERFACE ${HIGHFIVE_INCLUDE_DIRS}) +endif() + # Link dependencies: target_link_system_libraries( samurai