Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 41 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,32 @@ project_options(
${ENABLE_CONAN}
)

add_library(samurai INTERFACE)
target_compile_features(samurai INTERFACE cxx_std_20)
target_link_libraries(samurai INTERFACE project_options project_warnings)
set(SAMURAI_SOURCES
src/samurai/mesh_interval.cpp
src/samurai/level_cell_list.cpp
src/samurai/box.cpp
src/samurai/reconstruction.cpp
src/samurai/interval.cpp
src/samurai/cell.cpp
src/samurai/cell_list.cpp
src/samurai/stencil_field.cpp
src/samurai/cell_array.cpp
src/samurai/level_cell_array.cpp
src/samurai/list_of_intervals.cpp
src/samurai/domain_builder.cpp
src/samurai/mr/mesh.cpp
src/samurai/mr/adapt.cpp
src/samurai/array_of_interval_and_point.cpp
src/samurai/field/scalar_field.cpp
src/samurai/field/vector_field.cpp)

add_library(samurai ${SAMURAI_SOURCES})
target_compile_features(samurai PUBLIC cxx_std_20)
target_link_libraries(samurai PUBLIC project_options project_warnings)

# Includes
set(INCLUDE_DIR "include") # must be relative paths
target_include_directories(samurai INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${INCLUDE_DIR}>"
target_include_directories(samurai PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${INCLUDE_DIR}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")

# Find dependencies:
Expand All @@ -122,7 +141,7 @@ endforeach()
# Link dependencies:
target_link_system_libraries(
samurai
INTERFACE
PUBLIC
HighFive
pugixml::pugixml
fmt::fmt
Expand All @@ -140,7 +159,7 @@ if(SAMURAI_FIELD_CONTAINER MATCHES xtensor)

target_link_system_libraries(
samurai
INTERFACE
PUBLIC
xtensor
)

Expand All @@ -155,17 +174,17 @@ if(SAMURAI_FIELD_CONTAINER MATCHES eigen3 OR SAMURAI_FLUX_CONTAINER MATCHES eige
find_package(Eigen3 CONFIG REQUIRED)
target_link_system_libraries(
samurai
INTERFACE
PUBLIC
Eigen3::Eigen
)
target_compile_definitions(samurai INTERFACE EIGEN_ARRAYBASE_PLUGIN="${CMAKE_CURRENT_SOURCE_DIR}/include/samurai/storage/eigen/array_eigen_addons.hpp")
target_compile_definitions(samurai PUBLIC EIGEN_ARRAYBASE_PLUGIN="${CMAKE_CURRENT_SOURCE_DIR}/include/samurai/storage/eigen/array_eigen_addons.hpp")
endif()

if(${WITH_OPENMP})
find_package(OpenMP)
if(OpenMP_CXX_FOUND)
target_link_libraries(samurai INTERFACE OpenMP::OpenMP_CXX)
target_compile_definitions(samurai INTERFACE SAMURAI_WITH_OPENMP)
target_link_libraries(samurai PUBLIC OpenMP::OpenMP_CXX)
target_compile_definitions(samurai PUBLIC SAMURAI_WITH_OPENMP)
else()
message(FATAL_ERROR "OpenMP not found")
endif()
Expand All @@ -178,15 +197,14 @@ if(${WITH_MPI})
find_package(Boost REQUIRED COMPONENTS serialization mpi)
target_link_system_libraries(
samurai
INTERFACE
PUBLIC
Boost::serialization
Boost::mpi
)
target_compile_definitions(samurai INTERFACE SAMURAI_WITH_MPI)
target_compile_definitions(samurai PUBLIC SAMURAI_WITH_MPI)
endif()


target_compile_features(samurai INTERFACE cxx_std_20)
target_compile_features(samurai PUBLIC cxx_std_20)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})

OPTION(BUILD_BENCHMARKS "samurai benchmark suite" OFF)
Expand All @@ -199,20 +217,20 @@ option(SAMURAI_CHECK_NAN "Check NaN in computations" OFF)

if(WITH_STATS)
find_package(nlohmann_json REQUIRED)
target_link_libraries(samurai INTERFACE nlohmann_json::nlohmann_json)
target_compile_definitions(samurai INTERFACE WITH_STATS)
target_link_libraries(samurai PUBLIC nlohmann_json::nlohmann_json)
target_compile_definitions(samurai PUBLIC WITH_STATS)
endif()

if(SAMURAI_CHECK_NAN)
target_compile_definitions(samurai INTERFACE SAMURAI_CHECK_NAN)
target_compile_definitions(samurai PUBLIC SAMURAI_CHECK_NAN)
endif()

if(SAMURAI_ENABLE_INLINE)
target_compile_definitions(samurai INTERFACE SAMURAI_ENABLE_INLINE)
target_compile_definitions(samurai PUBLIC SAMURAI_ENABLE_INLINE)
endif()

if(SAMURAI_FORCE_INLINE)
target_compile_definitions(samurai INTERFACE SAMURAI_FORCE_INLINE)
target_compile_definitions(samurai PUBLIC SAMURAI_FORCE_INLINE)
endif()

if(BUILD_BENCHMARKS)
Expand All @@ -234,28 +252,28 @@ else()
endif()

if(SAMURAI_CONTAINER_LAYOUT_COL_MAJOR)
target_compile_definitions(samurai INTERFACE SAMURAI_CONTAINER_LAYOUT_COL_MAJOR)
target_compile_definitions(samurai PUBLIC SAMURAI_CONTAINER_LAYOUT_COL_MAJOR)
endif()

if(NOT SAMURAI_FIELD_CONTAINER IN_LIST FIELD_CONTAINER_LIST)
message(FATAL_ERROR "SAMURAI_FIELD_CONTAINER must be one of: ${FIELD_CONTAINER_LIST}")
else()
string(TOUPPER ${SAMURAI_FIELD_CONTAINER} SAMURAI_FIELD_CONTAINER)
target_compile_definitions(samurai INTERFACE SAMURAI_FIELD_CONTAINER_${SAMURAI_FIELD_CONTAINER})
target_compile_definitions(samurai PUBLIC SAMURAI_FIELD_CONTAINER_${SAMURAI_FIELD_CONTAINER})
endif()

if(NOT SAMURAI_FLUX_CONTAINER IN_LIST FLUX_CONTAINER_LIST)
message(FATAL_ERROR "SAMURAI_FLUX_CONTAINER must be one of: ${FLUX_CONTAINER_LIST}")
else()
string(TOUPPER ${SAMURAI_FLUX_CONTAINER} SAMURAI_FLUX_CONTAINER)
target_compile_definitions(samurai INTERFACE SAMURAI_FLUX_CONTAINER_${SAMURAI_FLUX_CONTAINER})
target_compile_definitions(samurai PUBLIC SAMURAI_FLUX_CONTAINER_${SAMURAI_FLUX_CONTAINER})
endif()

if(NOT SAMURAI_STATIC_MAT_CONTAINER IN_LIST STATIC_MATRIX_CONTAINER_LIST)
message(FATAL_ERROR "SAMURAI_STATIC_MAT_CONTAINER must be one of: ${STATIC_MATRIX_CONTAINER_LIST}")
else()
string(TOUPPER ${SAMURAI_STATIC_MAT_CONTAINER} SAMURAI_STATIC_MAT_CONTAINER)
target_compile_definitions(samurai INTERFACE SAMURAI_STATIC_MAT_CONTAINER_${SAMURAI_STATIC_MAT_CONTAINER})
target_compile_definitions(samurai PUBLIC SAMURAI_STATIC_MAT_CONTAINER_${SAMURAI_STATIC_MAT_CONTAINER})
endif()

# Package the project
Expand Down
4 changes: 2 additions & 2 deletions demos/FiniteVolume/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ if(${WITH_PETSC})

add_executable(${executable_name} ${source_file})
target_compile_definitions(${executable_name} PUBLIC SAMURAI_WITH_PETSC)
target_link_libraries(${executable_name} samurai ${PETSC_LINK_LIBRARIES})
target_link_libraries(${executable_name} PUBLIC samurai ${PETSC_LINK_LIBRARIES})
endforeach()
endif()

Expand All @@ -62,7 +62,7 @@ foreach(demo_entry ${STANDARD_DEMOS})
list(GET demo_parts 1 executable_name)

add_executable(${executable_name} ${source_file})
target_link_libraries(${executable_name} samurai)
target_link_libraries(${executable_name} PUBLIC samurai)
endforeach()

# Specific options for MSVC
Expand Down
18 changes: 16 additions & 2 deletions include/samurai/array_of_interval_and_point.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#pragma once

#include "samurai_config.hpp"

namespace samurai
{

template <typename TInterval, typename TCoord>
class ArrayOfIntervalAndPoint
{
Expand Down Expand Up @@ -83,6 +84,18 @@ namespace samurai
std::vector<size_t> m_idx;
};

////////////////////////////////////////////////////////////////////
//// explicit instanciation
////////////////////////////////////////////////////////////////////

extern template class ArrayOfIntervalAndPoint<default_config::interval_t, xt::xtensor_fixed<default_config::value_t, xt::xshape<1 - 1>>>;
extern template class ArrayOfIntervalAndPoint<default_config::interval_t, xt::xtensor_fixed<default_config::value_t, xt::xshape<2 - 1>>>;
extern template class ArrayOfIntervalAndPoint<default_config::interval_t, xt::xtensor_fixed<default_config::value_t, xt::xshape<3 - 1>>>;

////////////////////////////////////////////////////////////////////
//// method implementation
////////////////////////////////////////////////////////////////////

template <typename TInterval, typename TCoord>
void ArrayOfIntervalAndPoint<TInterval, TCoord>::sort_intervals()
{
Expand Down Expand Up @@ -136,4 +149,5 @@ namespace samurai
});
m_idx.erase(it, m_idx.end());
}
}

} // namespace samurai
9 changes: 9 additions & 0 deletions include/samurai/box.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ namespace samurai
point_t m_max_corner{0};
};

////////////////////////////////
// Box explicit instanciation //
////////////////////////////////

extern template class Box<default_config::value_t, 1>;
extern template class Box<default_config::value_t, 2>;
extern template class Box<default_config::value_t, 3>;

////////////////////////
// Box implementation //
////////////////////////
Expand Down Expand Up @@ -361,4 +369,5 @@ namespace samurai
approx_box.max_corner() = box.min_corner() + approx_length;
return approx_box;
}

} // namespace samurai
14 changes: 14 additions & 0 deletions include/samurai/cell.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <xtensor/io/xio.hpp>
#include <xtensor/views/xview.hpp>

#include "interval.hpp"
#include "samurai_config.hpp"

namespace samurai
Expand Down Expand Up @@ -76,6 +77,18 @@ namespace samurai
double length = 0;
};

////////////////////////////////////////////////////////////////////
//// explicit instanciation
////////////////////////////////////////////////////////////////////

extern template struct Cell<1, default_config::interval_t>;
extern template struct Cell<2, default_config::interval_t>;
extern template struct Cell<3, default_config::interval_t>;

////////////////////////////////////////////////////////////////////
//// method implementation
////////////////////////////////////////////////////////////////////

template <std::size_t dim_, class TInterval>
SAMURAI_INLINE Cell<dim_, TInterval>::Cell(const coords_t& origin_point_,
double scaling_factor,
Expand Down Expand Up @@ -170,4 +183,5 @@ namespace samurai
{
return !(c1 == c2);
}

} // namespace samurai
8 changes: 8 additions & 0 deletions include/samurai/cell_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ namespace samurai
#endif
};

////////////////////////////////////////////////////////////////////
//// explicit instanciation
////////////////////////////////////////////////////////////////////

extern template class CellArray<1>;
extern template class CellArray<2>;
extern template class CellArray<3>;

////////////////////////////////////
// CellArray_iterator definition //
///////////////////////////////////
Expand Down
9 changes: 9 additions & 0 deletions include/samurai/cell_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ namespace samurai
std::array<lcl_type, max_size + 1> m_cells;
};

////////////////////////////////////////////////////////////////////
//// explicit instanciation
////////////////////////////////////////////////////////////////////

extern template class CellList<1>;
extern template class CellList<2>;
extern template class CellList<3>;

/////////////////////////////
// CellList implementation //
/////////////////////////////
Expand Down Expand Up @@ -121,4 +129,5 @@ namespace samurai
cell_list.to_stream(out);
return out;
}

} // namespace samurai
8 changes: 8 additions & 0 deletions include/samurai/domain_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,12 @@ namespace samurai
return largest_subdivision;
}
};

////////////////////////////////////////////////////////////////////
//// explicit instanciation
////////////////////////////////////////////////////////////////////

extern template class DomainBuilder<1>;
extern template class DomainBuilder<2>;
extern template class DomainBuilder<3>;
}
21 changes: 21 additions & 0 deletions include/samurai/field/scalar_field.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "../concepts.hpp"
#include "../field_expression.hpp"
#include "../mesh_holder.hpp"
#include "../mr/mesh.hpp"
#include "../numeric/gauss_legendre.hpp"
#include "access_base.hpp"
#include "field_base.hpp"
Expand Down Expand Up @@ -109,6 +110,26 @@ namespace samurai
~ScalarField() = default;
};

////////////////////////////////////////////////////////////////////
//// explicit instanciation
////////////////////////////////////////////////////////////////////

extern template class ScalarField<MRMesh<mesh_config<1>>, float>;
extern template class ScalarField<MRMesh<mesh_config<2>>, float>;
extern template class ScalarField<MRMesh<mesh_config<3>>, float>;

extern template class ScalarField<MRMesh<mesh_config<1>>, double>;
extern template class ScalarField<MRMesh<mesh_config<2>>, double>;
extern template class ScalarField<MRMesh<mesh_config<3>>, double>;

extern template class ScalarField<MRMesh<mesh_config<1>>, long double>;
extern template class ScalarField<MRMesh<mesh_config<2>>, long double>;
extern template class ScalarField<MRMesh<mesh_config<3>>, long double>;

////////////////////////////////////////////////////////////////////
//// methods implementations
////////////////////////////////////////////////////////////////////

// ScalarField constructors -----------------------------------------------

template <class mesh_t, class value_t>
Expand Down
27 changes: 27 additions & 0 deletions include/samurai/field/vector_field.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
#include <fmt/format.h>

#include "../algorithm.hpp"
#include "../concepts.hpp"
#include "../field_expression.hpp"
#include "../mesh_holder.hpp"
#include "../mr/mesh.hpp"
#include "../numeric/gauss_legendre.hpp"
#include "access_base.hpp"
#include "concepts.hpp"
Expand Down Expand Up @@ -172,6 +174,31 @@ namespace samurai
~VectorField() = default;
};

////////////////////////////////////////////////////////////////////
//// explicit instanciation
////////////////////////////////////////////////////////////////////

extern template class VectorField<MRMesh<mesh_config<1>>, float, 1, false>;
extern template class VectorField<MRMesh<mesh_config<2>>, float, 1, true>;
extern template class VectorField<MRMesh<mesh_config<3>>, float, 2, false>;
extern template class VectorField<MRMesh<mesh_config<1>>, float, 2, true>;
extern template class VectorField<MRMesh<mesh_config<2>>, float, 3, false>;
extern template class VectorField<MRMesh<mesh_config<3>>, float, 3, true>;

extern template class VectorField<MRMesh<mesh_config<1>>, double, 1, false>;
extern template class VectorField<MRMesh<mesh_config<2>>, double, 1, true>;
extern template class VectorField<MRMesh<mesh_config<3>>, double, 2, false>;
extern template class VectorField<MRMesh<mesh_config<1>>, double, 2, true>;
extern template class VectorField<MRMesh<mesh_config<2>>, double, 3, false>;
extern template class VectorField<MRMesh<mesh_config<3>>, double, 3, true>;

extern template class VectorField<MRMesh<mesh_config<1>>, long double, 1, false>;
extern template class VectorField<MRMesh<mesh_config<2>>, long double, 1, true>;
extern template class VectorField<MRMesh<mesh_config<3>>, long double, 2, false>;
extern template class VectorField<MRMesh<mesh_config<1>>, long double, 2, true>;
extern template class VectorField<MRMesh<mesh_config<2>>, long double, 3, false>;
extern template class VectorField<MRMesh<mesh_config<3>>, long double, 3, true>;

// VectorField constructors -----------------------------------------------

template <class mesh_t, class value_t, std::size_t n_comp_, bool SOA>
Expand Down
Loading
Loading