Skip to content

Commit 984f73e

Browse files
committed
add the LigthweightViewConcept concept. Enforce that Functions shall be either lightweight or that there exist a free function view returning a lightweigth object
1 parent e5f586d commit 984f73e

23 files changed

Lines changed: 264 additions & 294 deletions

include/MGIS/Function/Algorithms.hxx

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,11 @@ namespace mgis::function {
5757
FunctionType&,
5858
const ExecutionPolicy,
5959
const EvaluatorType) //
60-
requires(((LinearElementSpaceConcept<std::decay_t<
61-
decltype(getSpace(std::declval<EvaluatorType>()))>>) ||
62-
(LinearQuadratureSpaceConcept<std::decay_t<
63-
decltype(getSpace(std::declval<EvaluatorType>()))>>)) &&
64-
internals::same_decay_type<
65-
decltype(getSpace(std::declval<FunctionType>())),
66-
decltype(getSpace(std::declval<EvaluatorType>()))>);
60+
requires(
61+
((LinearElementSpaceConcept<evaluator_space<EvaluatorType>>) ||
62+
(LinearQuadratureSpaceConcept<evaluator_space<EvaluatorType>>)) &&
63+
std::same_as<function_space<FunctionType>,
64+
evaluator_space<EvaluatorType>>);
6765
/*!
6866
* \brief assign the evaluator to a function
6967
* \param[in] ctx: execution context
@@ -80,10 +78,7 @@ namespace mgis::function {
8078
const ExecutionPolicy,
8179
const EvaluatorType,
8280
const OperatorType,
83-
const real) requires(LinearElementSpaceConcept<std::
84-
decay_t<decltype(getSpace(
85-
std::declval<
86-
EvaluatorType>()))>>);
81+
const real) requires(LinearElementSpaceConcept<evaluator_space<EvaluatorType>>);
8782
#endif /* MGIS_HAS_STL_PARALLEL_ALGORITHMS */
8883

8984
/*!
@@ -96,13 +91,11 @@ namespace mgis::function {
9691
[[nodiscard]] constexpr bool assign(AbstractErrorHandler&,
9792
FunctionType&,
9893
const EvaluatorType) //
99-
requires(((LinearElementSpaceConcept<std::decay_t<
100-
decltype(getSpace(std::declval<EvaluatorType>()))>>) ||
101-
(LinearQuadratureSpaceConcept<std::decay_t<
102-
decltype(getSpace(std::declval<EvaluatorType>()))>>)) &&
103-
internals::same_decay_type<
104-
decltype(getSpace(std::declval<FunctionType>())),
105-
decltype(getSpace(std::declval<EvaluatorType>()))>);
94+
requires(
95+
((LinearElementSpaceConcept<evaluator_space<EvaluatorType>>) ||
96+
(LinearQuadratureSpaceConcept<evaluator_space<EvaluatorType>>)) &&
97+
std::same_as<function_space<FunctionType>,
98+
evaluator_space<EvaluatorType>>);
10699
/*!
107100
* \brief assign the evaluator to a function
108101
* \param[in] ctx: execution context
@@ -115,10 +108,7 @@ namespace mgis::function {
115108
AbstractErrorHandler&,
116109
const EvaluatorType,
117110
const OperatorType,
118-
const real) requires(LinearElementSpaceConcept<std::
119-
decay_t<decltype(getSpace(
120-
std::declval<
121-
EvaluatorType>()))>>);
111+
const real) requires(LinearElementSpaceConcept<evaluator_space<EvaluatorType>>);
122112

123113
#endif /* MSC_VER */
124114

include/MGIS/Function/Algorithms.ixx

Lines changed: 119 additions & 108 deletions
Large diffs are not rendered by default.

include/MGIS/Function/BinaryOperationEvaluatorBase.hxx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ namespace mgis::function {
2121
template <EvaluatorConcept FirstEvaluatorType,
2222
EvaluatorConcept SecondEvaluatorType>
2323
inline constexpr auto BinaryOperationEvaluatorBaseRequirement =
24-
(internals::same_decay_type<
25-
decltype(getSpace(std::declval<FirstEvaluatorType>())),
26-
decltype(getSpace(std::declval<FirstEvaluatorType>()))>)&& //
24+
(std::same_as<evaluator_space<FirstEvaluatorType>,
25+
evaluator_space<SecondEvaluatorType>>)&& //
2726
(((ElementEvaluatorConcept<FirstEvaluatorType>)&&(
2827
ElementEvaluatorConcept<SecondEvaluatorType>)) ||
2928
((QuadratureEvaluatorConcept<FirstEvaluatorType>)&&(
@@ -69,8 +68,6 @@ namespace mgis::function {
6968
[[nodiscard]] constexpr decltype(auto) getSpace() const;
7069
//! \brief perform consistency checks
7170
[[nodiscard]] constexpr bool check(AbstractErrorHandler&) const;
72-
//! \brief allocate internal workspace
73-
constexpr void allocateWorkspace();
7471
/*!
7572
* \brief call operator
7673
* \param[in] i: integration point index
@@ -130,14 +127,6 @@ namespace mgis::function {
130127
const BinaryOperationEvaluatorBase<Child,
131128
FirstEvaluatorType,
132129
SecondEvaluatorType>&);
133-
//! \brief allocate internal workspace
134-
template <typename Child,
135-
EvaluatorConcept FirstEvaluatorType,
136-
EvaluatorConcept SecondEvaluatorType>
137-
constexpr void allocateWorkspace(
138-
BinaryOperationEvaluatorBase<Child,
139-
FirstEvaluatorType,
140-
SecondEvaluatorType>&);
141130

142131
} // end of namespace mgis::function
143132

include/MGIS/Function/BinaryOperationEvaluatorBase.ixx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,6 @@ namespace mgis::function {
6767
return true;
6868
} // end of check
6969

70-
template <typename Child,
71-
EvaluatorConcept FirstEvaluatorType,
72-
EvaluatorConcept SecondEvaluatorType>
73-
requires(BinaryOperationEvaluatorBaseRequirement<FirstEvaluatorType,
74-
SecondEvaluatorType>) //
75-
constexpr void BinaryOperationEvaluatorBase<
76-
Child,
77-
FirstEvaluatorType,
78-
SecondEvaluatorType>::allocateWorkspace() {
79-
internals::disambiguateAllocateWorkspace(this->first_evaluator);
80-
internals::disambiguateAllocateWorkspace(this->second_evaluator);
81-
} // end of allocatWorkspace
82-
8370
template <typename Child,
8471
EvaluatorConcept FirstEvaluatorType,
8572
EvaluatorConcept SecondEvaluatorType>

include/MGIS/Function/EvaluatorConcept.hxx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,7 @@ namespace mgis::function {
156156
concept EvaluatorConcept = std::is_move_constructible_v<EvaluatorType> &&
157157
std::is_copy_constructible_v<EvaluatorType> && SpaceConcept<
158158
std::decay_t<decltype(getSpace(std::declval<EvaluatorType>()))>> &&
159-
requires(EvaluatorType& e) {
160-
allocateWorkspace(e);
161-
} && requires(const EvaluatorType& e) {
159+
requires(const EvaluatorType& e) {
162160
{ getNumberOfComponents(e) } -> std::same_as<mgis::size_type>;
163161
} && requires(const EvaluatorType& e, AbstractErrorHandler& eh) {
164162
{ check(eh, e) } -> std::same_as<bool>;
@@ -239,17 +237,11 @@ namespace mgis::function {
239237
constexpr decltype(auto) disambiguateGetSpace(const EvaluatorType&);
240238
/*!
241239
* This helper function allows to disambiguate the call to
242-
* the allocateWorkspace function
240+
* the check function
243241
*/
244242
template <EvaluatorConcept EvaluatorType>
245243
[[nodiscard]] constexpr bool disambiguateCheck(AbstractErrorHandler&,
246244
const EvaluatorType&);
247-
/*!
248-
* This helper function allows to disambiguate the call to
249-
* the allocateWorkspace function
250-
*/
251-
template <EvaluatorConcept EvaluatorType>
252-
constexpr void disambiguateAllocateWorkspace(const EvaluatorType&);
253245
/*!
254246
* This helper function allows to disambiguate the call to
255247
* the getNumberOfComponents function

include/MGIS/Function/EvaluatorConcept.ixx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ namespace mgis::function::internals {
2121
return check(ctx, e);
2222
}
2323

24-
template <EvaluatorConcept EvaluatorType>
25-
constexpr void disambiguateAllocateWorkspace(EvaluatorType& e) {
26-
allocateWorkspace(e);
27-
} // end of disambiguateAllocateWorkspace
28-
2924
template <EvaluatorConcept EvaluatorType>
3025
constexpr mgis::size_type disambiguateGetNumberOfComponents(
3126
const EvaluatorType& e) {

include/MGIS/Function/EvaluatorModifierBase.hxx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ namespace mgis::function {
3636
[[nodiscard]] constexpr decltype(auto) getSpace() const;
3737
//! \brief perform consistency checks
3838
[[nodiscard]] constexpr bool check(AbstractErrorHandler&) const;
39-
//! \brief allocate internal workspace
40-
constexpr void allocateWorkspace();
4139
/*!
4240
* \brief call operator
4341
* \param[in] i: integration point index
@@ -83,10 +81,6 @@ namespace mgis::function {
8381
[[nodiscard]] constexpr bool check(
8482
AbstractErrorHandler&,
8583
const EvaluatorModifierBase<Child, EvaluatorType>&);
86-
//! \brief allocate internal workspace
87-
template <typename Child, EvaluatorConcept EvaluatorType>
88-
constexpr void allocateWorkspace(
89-
EvaluatorModifierBase<Child, EvaluatorType>&);
9084

9185
} // namespace mgis::function
9286

include/MGIS/Function/EvaluatorModifierBase.ixx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ namespace mgis::function {
2929
return internals::disambiguateCheck(ctx, this->evaluator);
3030
} // end of check
3131

32-
template <typename Child, EvaluatorConcept EvaluatorType>
33-
constexpr void
34-
EvaluatorModifierBase<Child, EvaluatorType>::allocateWorkspace() {
35-
internals::disambiguateAllocateWorkspace(this->evaluator);
36-
} // end of allocatWorkspace
37-
3832
template <typename Child, EvaluatorConcept EvaluatorType>
3933
constexpr decltype(auto)
4034
EvaluatorModifierBase<Child, EvaluatorType>::getSpace() const {
@@ -87,12 +81,6 @@ namespace mgis::function {
8781
return e.check(eh);
8882
} // end of check
8983

90-
template <typename Child, EvaluatorConcept EvaluatorType>
91-
constexpr void allocateWorkspace(
92-
EvaluatorModifierBase<Child, EvaluatorType>& e) {
93-
return e.allocateWorkspace();
94-
} // end of allocateWorkspace
95-
9684
} // end of namespace mgis::function
9785

9886
#endif /* LIB_MGIS_FUNCTION_EVALUATORMODIFIERBASE_IXX */

include/MGIS/Function/FixedSizeModifier.hxx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ namespace mgis::function {
4949
const EvaluatorType&);
5050
//! \brief perform consistency checks
5151
[[nodiscard]] constexpr bool check(AbstractErrorHandler&) const;
52-
//! \brief allocate internal workspace
53-
constexpr void allocateWorkspace();
5452
//! \brief return the underlying space
5553
[[nodiscard]] decltype(auto) getSpace() const;
5654
//! \return the number of components
@@ -112,9 +110,6 @@ namespace mgis::function {
112110
template <EvaluatorConcept EvaluatorType, size_type N>
113111
[[nodiscard]] constexpr bool check(
114112
AbstractErrorHandler&, const FixedSizeModifier<EvaluatorType, N>&);
115-
//! \brief allocate internal workspace
116-
template <EvaluatorConcept EvaluatorType, size_type N>
117-
constexpr void allocateWorkspace(FixedSizeModifier<EvaluatorType, N>&);
118113
//! \return the number of components
119114
template <EvaluatorConcept EvaluatorType, size_type N>
120115
[[nodiscard]] constexpr size_type getNumberOfComponents(

include/MGIS/Function/FixedSizeModifier.ixx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ namespace mgis::function {
4545
return checkPreconditions(ctx, this->evaluator);
4646
}
4747

48-
template <EvaluatorConcept EvaluatorType, size_type N>
49-
requires(N > 0) //
50-
constexpr void FixedSizeModifier<EvaluatorType, N>::allocateWorkspace() {
51-
return internals::disambiguateAllocateWorkspace(this->evaluator);
52-
}
53-
5448
template <EvaluatorConcept EvaluatorType, size_type N>
5549
requires(N > 0) //
5650
decltype(auto) FixedSizeModifier<EvaluatorType, N>::getSpace() const {
@@ -190,11 +184,6 @@ namespace mgis::function {
190184
return e.check(eh);
191185
} // end of check
192186

193-
template <EvaluatorConcept EvaluatorType, size_type N>
194-
constexpr void allocateWorkspace(FixedSizeModifier<EvaluatorType, N>& e) {
195-
return e.allocateWorkspace();
196-
} // end of allocateWorkspace
197-
198187
template <EvaluatorConcept EvaluatorType, size_type N>
199188
constexpr size_type getNumberOfComponents(
200189
const FixedSizeModifier<EvaluatorType, N>& e) {

0 commit comments

Comments
 (0)