Skip to content
Merged
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
3 changes: 3 additions & 0 deletions include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ if(enable-mgis-function)
mgis_header(MGIS/Function Algorithms.hxx)
mgis_header(MGIS/Function Algorithms.ixx)
mgis_header(MGIS/Function Buffer.hxx)
mgis_header(MGIS/Function DataViewConcept.hxx)
mgis_header(MGIS/Function CoalescedMemoryAccessFunctionViewBase.hxx)
mgis_header(MGIS/Function CoalescedMemoryAccessFunctionViewBase.ixx)
mgis_header(MGIS/Function StridedCoalescedMemoryAccessFunctionViewBase.hxx)
Expand All @@ -108,6 +109,8 @@ if(enable-mgis-function)
mgis_header(MGIS/Function/CUDA Algorithms.ixx)
endif(enable-cuda-algorithms)
if(MGIS_HAVE_TFEL)
mgis_header(MGIS/Function/TFEL General.hxx)
mgis_header(MGIS/Function/TFEL DataView.hxx)
mgis_header(MGIS/Function/TFEL Quantity.hxx)
mgis_header(MGIS/Function/TFEL QuantityView.hxx)
mgis_header(MGIS/Function/TFEL QuantityView.ixx)
Expand Down
38 changes: 38 additions & 0 deletions include/MGIS/Function/DataViewConcept.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*!
* \file MGIS/Function/DataViewConcept.hxx
* \brief This file declares `DataViewConcept`
* \author Thomas Helfer
* \date 02/10/2026
*/

#ifndef LIB_MGIS_FUNCTION_DATAVIEWCONCEPT_HXX
#define LIB_MGIS_FUNCTION_DATAVIEWCONCEPT_HXX

#include <span>
#include <type_traits>

namespace mgis::function::internals {

/*!
* \brief this class must be specialised
* for class holding views to data, such as
* std::span or tfel::math::View
*/
template <typename T>
struct IsDataView : std::false_type {};

//! \brief partial specialisation for std::span
template <class T, std::size_t Extent>
struct IsDataView<::std::span<T, Extent>> : std::true_type{};

} // end of namespace mgis::function::internals

namespace mgis::function {

//! \brief a concept used to distinguish views from data
template <typename T>
concept DataViewConcept = ::mgis::function::internals::IsDataView<T>::value;

} // end of namespace mgis::function

#endif /* LIB_MGIS_FUNCTION_DATAVIEWCONCEPT_HXX */
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <type_traits>
#include "TFEL/Math/Array/CoalescedView.hxx"
#include "MGIS/Function/CoalescedMemoryAccessFunctionViewBase.hxx"
#include "MGIS/Function/TFEL/General.hxx"
#include "MGIS/Function/TFEL/TensorConcept.hxx"

namespace mgis::function {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define LIB_MGIS_FUNCTION_TFEL_COALESCEDMEMORYACCESSTENSORVIEW_HXX

#include "TFEL/Math/Array/CoalescedView.hxx"
#include "MGIS/Function/TFEL/General.hxx"
#include "MGIS/Function/CoalescedMemoryAccessFunctionViewBase.hxx"
#include "MGIS/Function/TFEL/TensorConcept.hxx"

Expand Down
31 changes: 31 additions & 0 deletions include/MGIS/Function/TFEL/DataView.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*!
* \file MGIS/Function/TFEL/DataView.hxx
* \brief This file specializes the `IsDataView` class for TFEL' types
* \author Thomas Helfer
* \date 02/10/2026
*/

#ifndef LIB_MGIS_FUNCTION_TFEL_DATAVIEW_HXX
#define LIB_MGIS_FUNCTION_TFEL_DATAVIEW_HXX

#include "TFEL/Math/Array/View.hxx"
#include "TFEL/Math/Array/CoalescedView.hxx"
#include "MGIS/Function/DataViewConcept.hxx"

namespace mgis::function::internals {

//! \brief partial specialisation for tfel::math::View
template <typename MappedType, typename IndexingPolicyType>
struct IsDataView<::tfel::math::View<MappedType, IndexingPolicyType>>
: std::true_type{};

//! \brief partial specialisation for tfel::math::CoalescedView
template <
::tfel::math::MappableMathObjectUsingCoalescedViewConcept MappedType,
typename IndexingPolicyType>
struct IsDataView<::tfel::math::CoalescedView<MappedType, IndexingPolicyType>>
: std::true_type{};

} // end of namespace mgis::function::internals

#endif /* LIB_MGIS_FUNCTION_TFEL_DATAVIEW_HXX */
13 changes: 13 additions & 0 deletions include/MGIS/Function/TFEL/General.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*!
* \file MGIS/Function/TFEL/General.hxx
* \brief This file contains common defintions to integrate TFEL's types properly
* \author Thomas Helfer
* \date 02/10/2026
*/

#ifndef LIB_MGIS_FUNCTION_TFEL_GENERAL_HXX
#define LIB_MGIS_FUNCTION_TFEL_GENERAL_HXX

#include "MGIS/Function/TFEL/DataView.hxx"

#endif /* LIB_MGIS_FUNCTION_TFEL_GENERAL_HXX */
1 change: 1 addition & 0 deletions include/MGIS/Function/TFEL/Mechanics.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <type_traits>
#include "TFEL/Material/FiniteStrainBehaviourTangentOperator.hxx"
#include "MGIS/Function/Evaluator.hxx"
#include "MGIS/Function/TFEL/General.hxx"
#include "MGIS/Function/TFEL/Tensors.hxx"

namespace mgis::function::internals {
Expand Down
1 change: 1 addition & 0 deletions include/MGIS/Function/TFEL/Quantity.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "TFEL/Math/qt.hxx"
#include "MGIS/Function/CompileTimeSize.hxx"
#include "MGIS/Function/TFEL/General.hxx"
#include "MGIS/Function/TFEL/QuantityView.hxx"
#include "MGIS/Function/TFEL/QuantityModifier.hxx"

Expand Down
1 change: 1 addition & 0 deletions include/MGIS/Function/TFEL/QuantityModifier.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "MGIS/Contract.hxx"
#include "MGIS/Function/SpaceConcept.hxx"
#include "MGIS/Function/EvaluatorConcept.hxx"
#include "MGIS/Function/TFEL/General.hxx"

namespace mgis::function {

Expand Down
1 change: 1 addition & 0 deletions include/MGIS/Function/TFEL/QuantityView.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "TFEL/Math/qt.hxx"
#include "MGIS/Function/FunctionConcept.hxx"
#include "MGIS/Function/TFEL/General.hxx"

namespace mgis::function {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <type_traits>
#include "TFEL/Math/Array/StridedCoalescedView.hxx"
#include "MGIS/Function/StridedCoalescedMemoryAccessFunctionViewBase.hxx"
#include "MGIS/Function/TFEL/General.hxx"
#include "MGIS/Function/TFEL/TensorConcept.hxx"

namespace mgis::function {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "TFEL/Math/Array/StridedCoalescedView.hxx"
#include "MGIS/Function/StridedCoalescedMemoryAccessFunctionViewBase.hxx"
#include "MGIS/Function/TFEL/General.hxx"
#include "MGIS/Function/TFEL/TensorConcept.hxx"

namespace mgis::function {
Expand Down
1 change: 1 addition & 0 deletions include/MGIS/Function/TFEL/TensorConcept.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "TFEL/Math/st2tost2.hxx"
#include "TFEL/Math/Array/View.hxx"
#include "MGIS/Function/CompileTimeSize.hxx"
#include "MGIS/Function/TFEL/General.hxx"

namespace mgis::function {

Expand Down
1 change: 1 addition & 0 deletions include/MGIS/Function/TFEL/TensorModifier.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "MGIS/Function/Evaluator.hxx"
#include "MGIS/Function/EvaluatorModifierBase.hxx"
#include "MGIS/Function/TFEL/General.hxx"
#include "MGIS/Function/TFEL/TensorConcept.hxx"

namespace mgis::function {
Expand Down
6 changes: 5 additions & 1 deletion include/MGIS/Function/TFEL/TensorModifier.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ namespace mgis::function {
EvaluatorType>) //
constexpr auto TensorModifier<TensorType, EvaluatorType>::apply(
const evaluator_result<EvaluatorType>& values) const {
return tfel::math::map<const TensorType>(values.data());
if constexpr (DataViewConcept<evaluator_result<EvaluatorType>>) {
return tfel::math::map<const TensorType>(values.data());
} else {
return TensorType(tfel::math::map<const TensorType>(values.data()));
}
} // end of apply

template <TensorConcept TensorType, EvaluatorConcept EvaluatorType>
Expand Down
1 change: 1 addition & 0 deletions include/MGIS/Function/TFEL/TensorOperations.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "MGIS/Config.hxx"
#include "MGIS/Function/BasicLinearSpace.hxx"
#include "MGIS/Function/Function.hxx"
#include "MGIS/Function/TFEL/General.hxx"

namespace mgis::function {

Expand Down
1 change: 1 addition & 0 deletions include/MGIS/Function/TFEL/TensorView.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <span>
#include "MGIS/Contract.hxx"
#include "MGIS/Function/Function.hxx"
#include "MGIS/Function/TFEL/General.hxx"
#include "MGIS/Function/TFEL/TensorConcept.hxx"

namespace mgis::function {
Expand Down
1 change: 1 addition & 0 deletions include/MGIS/Function/TFEL/TensorialFunction.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define LIB_MGIS_FUNCTION_TFEL_TENSORIALFUNCTION_HXX

#include "MGIS/Function/Function.hxx"
#include "MGIS/Function/TFEL/General.hxx"
#include "MGIS/Function/TFEL/Tensors.hxx"

namespace mgis::function {
Expand Down
1 change: 1 addition & 0 deletions include/MGIS/Function/TFEL/Tensors.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "TFEL/Math/Forward/General.hxx"
#include "MGIS/Function/FunctionConcept.hxx"
#include "MGIS/Function/EvaluatorConcept.hxx"
#include "MGIS/Function/TFEL/General.hxx"
#include "MGIS/Function/TFEL/TensorConcept.hxx"
#include "MGIS/Function/TFEL/TensorView.hxx"
#include "MGIS/Function/TFEL/TensorModifier.hxx"
Expand Down
Loading