diff --git a/CMakeLists.txt b/CMakeLists.txt index 48e17e288..723fb1ebe 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} ) @@ -106,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) @@ -119,32 +120,27 @@ 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() + +# 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 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() 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/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()) 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..9220cf450 100644 --- a/demos/multigrid/main.cpp +++ b/demos/multigrid/main.cpp @@ -14,57 +14,57 @@ #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" - "\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"; +[[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"; template auto create_uniform_mesh(std::size_t level) 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/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/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/field/scalar_field.hpp b/include/samurai/field/scalar_field.hpp index 6ba8cc335..61e70aae8 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); } 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) { 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) { } 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/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); 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/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/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; 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 }