Skip to content
30 changes: 13 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ message(STATUS "Available FEATURES: ${FEATURES}")
project_options(
${FEATURES}
ENABLE_VS_ANALYSIS
# WARNINGS_AS_ERRORS
${ENABLE_CONAN}
)

Expand All @@ -106,7 +107,7 @@ target_include_directories(samurai INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")

# 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)
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion demos/FiniteVolume/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
4 changes: 2 additions & 2 deletions demos/FiniteVolume/nagumo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion demos/highorder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion demos/multigrid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
102 changes: 51 additions & 51 deletions demos/multigrid/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <int> Level used to set the problem size\n"
"--tc <enum> 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 <string> Output path\n"
"--filename <string> Solution file name\n"
"\n"
"-------- Samurai Multigrid ('-pc_type mg' to activate)\n"
"\n"
"--samg_smooth <enum> 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 <double> Sets the solver tolerance\n"
"-ksp_max_it <int> Sets the maximum number of iterations\n"
"-pc_mg_levels <int> Sets the number of multigrid levels\n"
"-mg_levels_up_pc_sor_its <int> 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 <int> Level used to set the problem size\n"
"--tc <enum> 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 <string> Output path\n"
"--filename <string> Solution file name\n"
"\n"
"-------- Samurai Multigrid ('-pc_type mg' to activate)\n"
"\n"
"--samg_smooth <enum> 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 <double> Sets the solver tolerance\n"
"-ksp_max_it <int> Sets the maximum number of iterations\n"
"-pc_mg_levels <int> Sets the number of multigrid levels\n"
"-mg_levels_up_pc_sor_its <int> Sets the number of post-smoothing "
"iterations\n"
"-log_view -pc_mg_log Monitors the multigrid performance\n"
"\n";

template <std::size_t dim>
auto create_uniform_mesh(std::size_t level)
Expand Down
8 changes: 8 additions & 0 deletions include/samurai/algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,16 @@ namespace samurai
template <class MeshIntervalType, class SetType, class Func>
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;
Expand Down Expand Up @@ -235,12 +239,16 @@ namespace samurai
using cell_t = Cell<dim, TInterval>;
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;
Expand Down
40 changes: 9 additions & 31 deletions include/samurai/amr/mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,6 @@ namespace samurai::amr
// reference = cells_and_ghosts
};

template <std::size_t dim_,
std::size_t max_stencil_width_ = default_config::ghost_width,
std::size_t graduation_width_ = default_config::graduation_width,
std::size_t max_refinement_level_ = default_config::max_level,
std::size_t prediction_order_ = default_config::prediction_stencil_radius,
class TInterval = default_config::interval_t>
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<int>(max_stencil_width),
static_cast<int>(prediction_order));

using interval_t = TInterval;
using mesh_id_t = AMR_Id;
};

/////////////////////////
// AMR mesh definition //
/////////////////////////
Expand All @@ -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::dim>& config);
Mesh(const ca_type& ca, const mesh_config<Config::dim>& config);
Mesh(const Box<double, dim>& b, const mesh_config<Config::dim>& config);
Mesh(const cl_type& cl, const mesh_config<Config::dim>& mesh_cfg);
Mesh(const ca_type& ca, const mesh_config<Config::dim>& mesh_cfg);
Mesh(const Box<double, dim>& b, const mesh_config<Config::dim>& 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);
Expand Down Expand Up @@ -102,20 +80,20 @@ namespace samurai::amr
}

template <class Config>
SAMURAI_INLINE Mesh<Config>::Mesh(const cl_type& cl, const mesh_config<Config::dim>& config)
: base_type(cl, config)
SAMURAI_INLINE Mesh<Config>::Mesh(const cl_type& cl, const mesh_config<Config::dim>& mesh_cfg)
: base_type(cl, mesh_cfg)
{
}

template <class Config>
SAMURAI_INLINE Mesh<Config>::Mesh(const ca_type& ca, const mesh_config<Config::dim>& config)
: base_type(ca, config)
SAMURAI_INLINE Mesh<Config>::Mesh(const ca_type& ca, const mesh_config<Config::dim>& mesh_cfg)
: base_type(ca, mesh_cfg)
{
}

template <class Config>
SAMURAI_INLINE Mesh<Config>::Mesh(const Box<double, dim>& b, const mesh_config<Config::dim>& config)
: base_type(b, config)
SAMURAI_INLINE Mesh<Config>::Mesh(const Box<double, dim>& b, const mesh_config<Config::dim>& mesh_cfg)
: base_type(b, mesh_cfg)
{
}

Expand Down
8 changes: 3 additions & 5 deletions include/samurai/bc/apply_field_bc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(stencil_size_());
// static constexpr int stencil_size = static_cast<int>(stencil_size_());

if constexpr (stencil_size % 2 == 0) // (because PolynomialExtrapolation is only implemented for even stencil_size)
{
Expand All @@ -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<int>(stencil_size_());

if constexpr (stencil_size % 2 == 0) // (because PolynomialExtrapolation is only implemented for even stencil_size)
{
if (stencil_s == stencil_size)
Expand Down
1 change: 1 addition & 0 deletions include/samurai/field/scalar_field.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ namespace samurai

template <class mesh_t, class value_t>
SAMURAI_INLINE ScalarField<mesh_t, value_t>::ScalarField(const ScalarField& field)
: inner_mesh_t(field.mesh())
{
this->assign_from(field);
}
Expand Down
8 changes: 4 additions & 4 deletions include/samurai/level_cell_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand Down
Loading
Loading