diff --git a/ci_tools/gyselalib_static_analysis.py b/ci_tools/gyselalib_static_analysis.py index 6fcd314f3..3b8e9faf6 100644 --- a/ci_tools/gyselalib_static_analysis.py +++ b/ci_tools/gyselalib_static_analysis.py @@ -48,7 +48,7 @@ HOME_DIR = Path(__file__).parent.parent.absolute() global_folders = [HOME_DIR / f for f in ('src', 'simulations', 'tests')] -auto_functions = set() +auto_functions = set(['build_kokkos_layout']) field_mem_functions = set() def report_error(level, file, linenr, message): diff --git a/src/data_types/derivative_field.hpp b/src/data_types/derivative_field.hpp index 6b0e0aa02..0c1b056ef 100644 --- a/src/data_types/derivative_field.hpp +++ b/src/data_types/derivative_field.hpp @@ -27,6 +27,10 @@ template > = true; +template +inline constexpr bool enable_data_access_methods< + DerivField> = true; + namespace ddcHelper { /** @@ -170,7 +174,7 @@ class DerivField, LayoutStridedPolicy, MemorySpa using reference = typename chunk_type::reference; /// @brief The number of chunks which must be created to describe this object. - static constexpr int n_fields = base_type::n_fields; + using base_type::n_fields; private: /** @brief Get the subindex range to be extracted from a DerivFieldMem to build the internal_chunk at position ArrayIndex @@ -251,7 +255,8 @@ class DerivField, LayoutStridedPolicy, MemorySpa int NDerivs, class Allocator, class = std::enable_if_t>> - constexpr DerivField(DerivFieldMem& field) + explicit constexpr DerivField( + DerivFieldMem& field) : base_type( field.m_physical_idx_range, field.m_deriv_idx_range, @@ -273,7 +278,7 @@ class DerivField, LayoutStridedPolicy, MemorySpa int NDerivs, class Allocator, class = std::enable_if_t>> - constexpr DerivField( + explicit constexpr DerivField( DerivFieldMem const& field) : base_type( field.m_physical_idx_range, diff --git a/src/data_types/derivative_field_mem.hpp b/src/data_types/derivative_field_mem.hpp index afc30dada..4a97f1bcf 100644 --- a/src/data_types/derivative_field_mem.hpp +++ b/src/data_types/derivative_field_mem.hpp @@ -3,6 +3,7 @@ #pragma once #include +#include "ddc_alias_inline_functions.hpp" #include "ddc_aliases.hpp" #include "derivative_field.hpp" #include "derivative_field_common.hpp" @@ -17,6 +18,14 @@ template inline constexpr bool enable_deriv_field> = true; +template +inline constexpr bool enable_data_access_methods< + DerivFieldMem> = true; + +template +inline constexpr bool + enable_mem_type> = true; + /** * @brief A class which holds a chunk of memory describing a field and its derivatives. @@ -132,7 +141,7 @@ class DerivFieldMem, NDerivs, MemSpace> using internal_mdspan_type = typename base_type::internal_mdspan_type; /// @brief The number of chunks which must be created to describe this object. - static constexpr int n_fields = base_type::n_fields; + using base_type::n_fields; private: /// @brief A function to get the index range along direction Tag for the ArrayIndex-th element of internal_fields. @@ -354,7 +363,7 @@ class DerivFieldMem, NDerivs, MemSpace> */ span_type span_view() { - return *this; + return span_type(*this); } }; diff --git a/src/data_types/vector_field.hpp b/src/data_types/vector_field.hpp index e938bdfe3..21812a26c 100644 --- a/src/data_types/vector_field.hpp +++ b/src/data_types/vector_field.hpp @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT #pragma once +#include "ddc_alias_inline_functions.hpp" #include "ddc_aliases.hpp" #include "vector_field_mem.hpp" @@ -22,6 +23,15 @@ template < inline constexpr bool enable_field< VectorField> = true; +template < + class ElementType, + class IdxRangeType, + class NDTag, + class LayoutStridedPolicy, + class MemorySpace> +inline constexpr bool enable_data_access_methods< + VectorField> = true; + template < class ElementType, class IdxRangeType, diff --git a/src/data_types/vector_field_mem.hpp b/src/data_types/vector_field_mem.hpp index 734b2aeab..1ea90a5de 100644 --- a/src/data_types/vector_field_mem.hpp +++ b/src/data_types/vector_field_mem.hpp @@ -3,6 +3,7 @@ #pragma once #include +#include "ddc_alias_inline_functions.hpp" #include "ddc_aliases.hpp" #include "vector_field_common.hpp" @@ -21,6 +22,14 @@ template inline constexpr bool enable_field> = true; +template +inline constexpr bool enable_data_access_methods< + VectorFieldMem> = true; + +template +inline constexpr bool + enable_mem_type> = true; + /** * @brief Pre-declaration of VectorField. */ diff --git a/src/multipatch/data_types/multipatch_field.hpp b/src/multipatch/data_types/multipatch_field.hpp new file mode 100644 index 000000000..abf19f697 --- /dev/null +++ b/src/multipatch/data_types/multipatch_field.hpp @@ -0,0 +1,189 @@ +// SPDX-License-Identifier: MIT + +#pragma once +#include "multipatch_type.hpp" + + +/** + * @brief A class to store field objects on patches. + * + * On a multipatch domain when we have objects and types defined on different patches, e.g. fields. + * They can be stored in this class and then be accessed by the patch they are defined + * on. + * + * @tparam T The type of the fields/derivative fields/vector fields that are stored on the given patches. + * @tparam Patches The patches of the objects in the same order of the patches + * that the given objects are defined on. + * + * @warning The objects have to be defined on different patches. Otherwise retrieving + * them by their patch is ill-defined. + */ +template