|
| 1 | +/*! |
| 2 | + * \file MGIS/Function/StridedCoalescedMemoryAccessFunctionViewBase.hxx |
| 3 | + * \brief |
| 4 | + * \author Thomas Helfer |
| 5 | + * \date 17/01/2026 |
| 6 | + * \copyright (C) Copyright Thomas Helfer 2018. |
| 7 | + * Use, modification and distribution are subject |
| 8 | + * to one of the following licences: |
| 9 | + * - GNU Lesser General Public License (LGPL), Version 3.0. (See accompanying |
| 10 | + * file LGPL-3.0.txt) |
| 11 | + * - CECILL-C, Version 1.0 (See accompanying files |
| 12 | + * CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt). |
| 13 | + */ |
| 14 | + |
| 15 | +#ifndef LIB_MGIS_FUNCTION_STRIDEDCOALESCEDMEMORYACCESSFUNCTIONVIEWBASE_HXX |
| 16 | +#define LIB_MGIS_FUNCTION_STRIDEDCOALESCEDMEMORYACCESSFUNCTIONVIEWBASE_HXX |
| 17 | + |
| 18 | +#include <span> |
| 19 | +#include <array> |
| 20 | +#include "MGIS/Config.hxx" |
| 21 | +#include "MGIS/Contract.hxx" |
| 22 | +#include "MGIS/Function/SpaceConcept.hxx" |
| 23 | +#include "MGIS/Function/FunctionConcept.hxx" |
| 24 | +#include "MGIS/Function/Function.hxx" |
| 25 | +#include "MGIS/Function/Evaluator.hxx" |
| 26 | + |
| 27 | +namespace mgis::function { |
| 28 | + |
| 29 | + /*! |
| 30 | + * \brief a class meant to describe a function, each component of which is |
| 31 | + * stored contiguously in non interleaved manner using the following scheme: |
| 32 | + * |
| 33 | + * ~~~~ |
| 34 | + * | <------- Component 1 ---------> |....| <----- Component Nc ---------> | |
| 35 | + * +-------++-------++------++-------+----+-------++------++------++-------+ |
| 36 | + * | Elt 1 || Elt 2 || .... || Elt N |....| Elt 1 ||Elt 2 || .... || Elt N | |
| 37 | + * +-------++-------++------++-------+----+-------++------++------++-------+ |
| 38 | + * ~~~~ |
| 39 | + */ |
| 40 | + template <FunctionalSpaceConcept Space, size_type N, bool is_mutable = true> |
| 41 | + requires(N > 0) struct StridedCoalescedMemoryAccessFunctionViewBase |
| 42 | + : private PreconditionsChecker< |
| 43 | + StridedCoalescedMemoryAccessFunctionViewBase<Space, |
| 44 | + N, |
| 45 | + is_mutable>> { |
| 46 | + /*! |
| 47 | + * \brief check that the preconditions to build the view are met |
| 48 | + * \param[in] eh: error handler. |
| 49 | + * \param[in] space: space |
| 50 | + * \param[in] values: values |
| 51 | + */ |
| 52 | + [[nodiscard]] static constexpr bool checkPreconditions( |
| 53 | + AbstractErrorHandler&, |
| 54 | + const Space& space, |
| 55 | + std::span<const real>) requires(!is_mutable); |
| 56 | + /*! |
| 57 | + * \param[in] space: space |
| 58 | + * \param[in] values: values |
| 59 | + */ |
| 60 | + constexpr StridedCoalescedMemoryAccessFunctionViewBase( |
| 61 | + const Space&, std::span<const real>) requires(!is_mutable); |
| 62 | + /*! |
| 63 | + * \brief check that the preconditions to build the view are met |
| 64 | + * \param[in] eh: error handler. |
| 65 | + * \param[in] space: space |
| 66 | + * \param[in] values: values |
| 67 | + */ |
| 68 | + [[nodiscard]] static constexpr bool checkPreconditions( |
| 69 | + AbstractErrorHandler&, const Space&, std::span<real>); |
| 70 | + /*! |
| 71 | + * \param[in] space: space |
| 72 | + * \param[in] values: values |
| 73 | + */ |
| 74 | + constexpr StridedCoalescedMemoryAccessFunctionViewBase(const Space&, |
| 75 | + std::span<real>); |
| 76 | + /*! |
| 77 | + * \return the data associated with an integration point |
| 78 | + * \param[in] o: offset associated with the integration point |
| 79 | + */ |
| 80 | + [[nodiscard]] constexpr std::array<real, N> getValues(const size_type) const |
| 81 | + requires(LinearElementSpaceConcept<Space>); |
| 82 | + /*! |
| 83 | + * \return the data associated with an integration point |
| 84 | + * \param[in] e: element index |
| 85 | + * \param[in] i: quadrature point index |
| 86 | + */ |
| 87 | + [[nodiscard]] constexpr std::array<real, N> getValues(const size_type, |
| 88 | + const size_type) const |
| 89 | + requires(LinearQuadratureSpaceConcept<Space>); |
| 90 | + //! \return the underlying quadrature space |
| 91 | + [[nodiscard]] constexpr const Space& getSpace() const noexcept; |
| 92 | + |
| 93 | + protected: |
| 94 | + /*! |
| 95 | + * \param[in] space: space |
| 96 | + * \param[in] values: values |
| 97 | + */ |
| 98 | + template <bool doPreconditionsCheck> |
| 99 | + constexpr StridedCoalescedMemoryAccessFunctionViewBase( |
| 100 | + const PreconditionsCheck<doPreconditionsCheck>&, |
| 101 | + const Space&, |
| 102 | + std::span<const real>) requires(!is_mutable); |
| 103 | + /*! |
| 104 | + * \param[in] space: space |
| 105 | + * \param[in] values: values |
| 106 | + */ |
| 107 | + template <bool doPreconditionsCheck> |
| 108 | + constexpr StridedCoalescedMemoryAccessFunctionViewBase( |
| 109 | + const PreconditionsCheck<doPreconditionsCheck>&, |
| 110 | + const Space&, |
| 111 | + std::span<real>); |
| 112 | + //! \brief underlying discretization space |
| 113 | + const Space space; |
| 114 | + //! \brief pointer to the first component |
| 115 | + const std::conditional_t<is_mutable, real*, const real*> data_pointer; |
| 116 | + }; |
| 117 | + |
| 118 | +} // namespace mgis::function |
| 119 | + |
| 120 | +#include "MGIS/Function/StridedCoalescedMemoryAccessFunctionViewBase.ixx" |
| 121 | + |
| 122 | +#endif /* LIB_MGIS_FUNCTION_STRIDEDCOALESCEDMEMORYACCESSFUNCTIONVIEWBASE_HXX \ |
| 123 | + */ |
0 commit comments