diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 053a1db99..6a25f79fc 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -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) @@ -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) diff --git a/include/MGIS/Function/DataViewConcept.hxx b/include/MGIS/Function/DataViewConcept.hxx new file mode 100644 index 000000000..cf534bd95 --- /dev/null +++ b/include/MGIS/Function/DataViewConcept.hxx @@ -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 +#include + +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 + struct IsDataView : std::false_type {}; + + //! \brief partial specialisation for std::span + template + struct IsDataView<::std::span> : std::true_type{}; + +} // end of namespace mgis::function::internals + +namespace mgis::function { + + //! \brief a concept used to distinguish views from data + template + concept DataViewConcept = ::mgis::function::internals::IsDataView::value; + +} // end of namespace mgis::function + +#endif /* LIB_MGIS_FUNCTION_DATAVIEWCONCEPT_HXX */ diff --git a/include/MGIS/Function/TFEL/CoalescedMemoryAccessCompositeTensorsView.hxx b/include/MGIS/Function/TFEL/CoalescedMemoryAccessCompositeTensorsView.hxx index 09ebb7223..c40c2bfb3 100644 --- a/include/MGIS/Function/TFEL/CoalescedMemoryAccessCompositeTensorsView.hxx +++ b/include/MGIS/Function/TFEL/CoalescedMemoryAccessCompositeTensorsView.hxx @@ -24,6 +24,7 @@ #include #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 { diff --git a/include/MGIS/Function/TFEL/CoalescedMemoryAccessTensorView.hxx b/include/MGIS/Function/TFEL/CoalescedMemoryAccessTensorView.hxx index 9e25ddb2b..8b433ef59 100644 --- a/include/MGIS/Function/TFEL/CoalescedMemoryAccessTensorView.hxx +++ b/include/MGIS/Function/TFEL/CoalescedMemoryAccessTensorView.hxx @@ -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" diff --git a/include/MGIS/Function/TFEL/DataView.hxx b/include/MGIS/Function/TFEL/DataView.hxx new file mode 100644 index 000000000..8e12af0b9 --- /dev/null +++ b/include/MGIS/Function/TFEL/DataView.hxx @@ -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 + struct IsDataView<::tfel::math::View> + : std::true_type{}; + + //! \brief partial specialisation for tfel::math::CoalescedView + template < + ::tfel::math::MappableMathObjectUsingCoalescedViewConcept MappedType, + typename IndexingPolicyType> + struct IsDataView<::tfel::math::CoalescedView> + : std::true_type{}; + +} // end of namespace mgis::function::internals + +#endif /* LIB_MGIS_FUNCTION_TFEL_DATAVIEW_HXX */ diff --git a/include/MGIS/Function/TFEL/General.hxx b/include/MGIS/Function/TFEL/General.hxx new file mode 100644 index 000000000..48a43ec66 --- /dev/null +++ b/include/MGIS/Function/TFEL/General.hxx @@ -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 */ diff --git a/include/MGIS/Function/TFEL/Mechanics.hxx b/include/MGIS/Function/TFEL/Mechanics.hxx index 004747789..a3cc89291 100644 --- a/include/MGIS/Function/TFEL/Mechanics.hxx +++ b/include/MGIS/Function/TFEL/Mechanics.hxx @@ -22,6 +22,7 @@ #include #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 { diff --git a/include/MGIS/Function/TFEL/Quantity.hxx b/include/MGIS/Function/TFEL/Quantity.hxx index 422d991a4..b947d2d89 100644 --- a/include/MGIS/Function/TFEL/Quantity.hxx +++ b/include/MGIS/Function/TFEL/Quantity.hxx @@ -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" diff --git a/include/MGIS/Function/TFEL/QuantityModifier.hxx b/include/MGIS/Function/TFEL/QuantityModifier.hxx index cd2249b79..21666ccef 100644 --- a/include/MGIS/Function/TFEL/QuantityModifier.hxx +++ b/include/MGIS/Function/TFEL/QuantityModifier.hxx @@ -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 { diff --git a/include/MGIS/Function/TFEL/QuantityView.hxx b/include/MGIS/Function/TFEL/QuantityView.hxx index 4d4f6c23d..94b45e5e4 100644 --- a/include/MGIS/Function/TFEL/QuantityView.hxx +++ b/include/MGIS/Function/TFEL/QuantityView.hxx @@ -21,6 +21,7 @@ #include "TFEL/Math/qt.hxx" #include "MGIS/Function/FunctionConcept.hxx" +#include "MGIS/Function/TFEL/General.hxx" namespace mgis::function { diff --git a/include/MGIS/Function/TFEL/StridedCoalescedMemoryAccessCompositeTensorsView.hxx b/include/MGIS/Function/TFEL/StridedCoalescedMemoryAccessCompositeTensorsView.hxx index 7b4243572..ae9a88601 100644 --- a/include/MGIS/Function/TFEL/StridedCoalescedMemoryAccessCompositeTensorsView.hxx +++ b/include/MGIS/Function/TFEL/StridedCoalescedMemoryAccessCompositeTensorsView.hxx @@ -25,6 +25,7 @@ #include #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 { diff --git a/include/MGIS/Function/TFEL/StridedCoalescedMemoryAccessTensorView.hxx b/include/MGIS/Function/TFEL/StridedCoalescedMemoryAccessTensorView.hxx index 0ce5849b1..04b535b76 100644 --- a/include/MGIS/Function/TFEL/StridedCoalescedMemoryAccessTensorView.hxx +++ b/include/MGIS/Function/TFEL/StridedCoalescedMemoryAccessTensorView.hxx @@ -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 { diff --git a/include/MGIS/Function/TFEL/TensorConcept.hxx b/include/MGIS/Function/TFEL/TensorConcept.hxx index a2ad5c297..27542d3c6 100644 --- a/include/MGIS/Function/TFEL/TensorConcept.hxx +++ b/include/MGIS/Function/TFEL/TensorConcept.hxx @@ -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 { diff --git a/include/MGIS/Function/TFEL/TensorModifier.hxx b/include/MGIS/Function/TFEL/TensorModifier.hxx index 8355a6112..c514455ce 100644 --- a/include/MGIS/Function/TFEL/TensorModifier.hxx +++ b/include/MGIS/Function/TFEL/TensorModifier.hxx @@ -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 { diff --git a/include/MGIS/Function/TFEL/TensorModifier.ixx b/include/MGIS/Function/TFEL/TensorModifier.ixx index 1a5d376ab..8a1a1938d 100644 --- a/include/MGIS/Function/TFEL/TensorModifier.ixx +++ b/include/MGIS/Function/TFEL/TensorModifier.ixx @@ -31,7 +31,11 @@ namespace mgis::function { EvaluatorType>) // constexpr auto TensorModifier::apply( const evaluator_result& values) const { - return tfel::math::map(values.data()); + if constexpr (DataViewConcept>) { + return tfel::math::map(values.data()); + } else { + return TensorType(tfel::math::map(values.data())); + } } // end of apply template diff --git a/include/MGIS/Function/TFEL/TensorOperations.hxx b/include/MGIS/Function/TFEL/TensorOperations.hxx index e33b64a4e..f6560b468 100644 --- a/include/MGIS/Function/TFEL/TensorOperations.hxx +++ b/include/MGIS/Function/TFEL/TensorOperations.hxx @@ -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 { diff --git a/include/MGIS/Function/TFEL/TensorView.hxx b/include/MGIS/Function/TFEL/TensorView.hxx index 710ed0b4f..e0a6a84c2 100644 --- a/include/MGIS/Function/TFEL/TensorView.hxx +++ b/include/MGIS/Function/TFEL/TensorView.hxx @@ -24,6 +24,7 @@ #include #include "MGIS/Contract.hxx" #include "MGIS/Function/Function.hxx" +#include "MGIS/Function/TFEL/General.hxx" #include "MGIS/Function/TFEL/TensorConcept.hxx" namespace mgis::function { diff --git a/include/MGIS/Function/TFEL/TensorialFunction.hxx b/include/MGIS/Function/TFEL/TensorialFunction.hxx index 1b6fccb95..f667edae8 100644 --- a/include/MGIS/Function/TFEL/TensorialFunction.hxx +++ b/include/MGIS/Function/TFEL/TensorialFunction.hxx @@ -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 { diff --git a/include/MGIS/Function/TFEL/Tensors.hxx b/include/MGIS/Function/TFEL/Tensors.hxx index 3a2368c83..49c9670ec 100644 --- a/include/MGIS/Function/TFEL/Tensors.hxx +++ b/include/MGIS/Function/TFEL/Tensors.hxx @@ -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"