MGIS 3.1.0
Loading...
Searching...
No Matches
FunctionConcept.hxx File Reference

File which defines the concept a function must satisfy and the helpers used to query the space, the type of the values and the view of a function. More...

#include <span>
#include <array>
#include <utility>
#include <concepts>
#include <type_traits>
#include "MGIS/Config.hxx"
#include "MGIS/Function/CompileTimeSize.hxx"
#include "MGIS/Function/SpaceConcept.hxx"
#include "MGIS/Function/EvaluatorConcept.hxx"
#include "MGIS/Function/FunctionConcept.ixx"
#include "MGIS/Function/FixedSizeView.hxx"
#include "MGIS/Function/FixedSizeModifier.hxx"

Classes

struct  mgis::function::internals::FunctionResultTypeTraits< T >
 traits that must be specialized to allow functions to return this type. More...
struct  mgis::function::internals::FunctionResultTypeTraits< real & >
 partial specialization for reference to a scalar value More...
struct  mgis::function::internals::FunctionResultTypeTraits< std::span< real, N > >
 partial specialization for a mutable span More...
struct  mgis::function::internals::FunctionResultTypeTraits< std::array< real, N > & >
 partial specialization for a reference to a mutable array More...
struct  mgis::function::internals::FunctionResultQueryImplementation1< bool, FunctionType >
 helper class used to determine the type returned by a function called with an element index, which is an invalid type if the function cannot be called this way More...
struct  mgis::function::internals::FunctionResultQueryImplementation1< true, FunctionType >
 specialization used when the function can be called this way More...
struct  mgis::function::internals::FunctionResultQueryImplementation2< bool, FunctionType >
 helper class used to determine the type returned by a function called with an element workspace and an element index, which is an invalid type if the function cannot be called this way More...
struct  mgis::function::internals::FunctionResultQueryImplementation2< true, FunctionType >
 specialization used when the function can be called this way More...
struct  mgis::function::internals::FunctionResultQueryImplementation3< bool, FunctionType >
 helper class used to determine the type returned by a function called with a cell index and a quadrature point index, which is an invalid type if the function cannot be called this way More...
struct  mgis::function::internals::FunctionResultQueryImplementation3< true, FunctionType >
 specialization used when the function can be called this way More...
struct  mgis::function::internals::FunctionResultQueryImplementation4< bool, FunctionType >
 helper class used to determine the type returned by a function called with a cell workspace, a cell index and a quadrature point index, which is an invalid type if the function cannot be called this way More...
struct  mgis::function::internals::FunctionResultQueryImplementation4< true, FunctionType >
 specialization used when the function can be called this way More...
struct  mgis::function::internals::FunctionResultQueryImplementation< bool, FunctionType >
 helper class used to determine how a function can be called and the type of the values it returns More...
struct  mgis::function::internals::FunctionResultQueryImplementation< true, FunctionType >
 specialization used when the function provides a getSpace function More...
struct  mgis::function::internals::FunctionResultQuery< FunctionType >
 alias used to determine how a function can be called and the type of the values it returns More...
struct  mgis::function::LightweightViewTraits< FunctionType >
 traits defining the functions which are their own view More...
struct  mgis::function::internals::ViewResultType< bool, FunctionType >
 helper structure used to determine the type of the view of a function which is not its own view More...
struct  mgis::function::internals::ViewResultType< false, FunctionType >
 specialization used when a view is required More...
struct  mgis::function::internals::NumberOfComponents< FunctionType >
 number of components of a function when known at compile-time, dynamic_extent otherwise More...
struct  mgis::function::internals::fixed_size_modifier< N >
 structure used to modify a function or an evaluator so that it returns a fixed number of components More...

Namespaces

namespace  mgis
 the namespace mgis encloses all the MGIS project.

Concepts

concept  mgis::function::internals::mutable_return_value
 concept defining the types a function may return
concept  mgis::function::LightweightViewConcept
 concept defining the functions which are their own view
concept  mgis::function::FunctionConcept
 a concept that must satisfy a function
concept  mgis::function::LightweightFunctionConcept
 concept defining the functions which are their own view
concept  mgis::function::NonLightweightFunctionConcept
 concept defining the functions which are not their own view
concept  mgis::function::ViewableFunctionArgumentConcept
 concept defining the arguments of the algorithms which can be viewed as a mutable function
concept  mgis::function::ElementFunctionConcept
 concept defining functions which can be called on an element space, i.e. with an element index or with an element workspace and an element index
concept  mgis::function::QuadratureFunctionConcept
 concept defining functions which can be called on a quadrature space, i.e. with a cell index and a quadrature point index or with a cell workspace, a cell index and a quadrature point index

Typedefs

template<FunctionConcept FunctionType>
using mgis::function::function_view
 an alias which returns a view corresponding to the given function type
template<FunctionConcept FunctionType>
using mgis::function::function_space
 alias giving the type of the space on which a function is defined
template<FunctionConcept FunctionType>
using mgis::function::function_result
 type of the result of a function, i.e. the type of the values returned by the function, which can be a scalar value, a std::span or a std::array
template<FunctionConcept FunctionType>
using mgis::function::function_const_result
 type of the result of a constant function, i.e. the type of the values returned by a constant function, which can be a scalar value, a constant std::span or a constant std::array

Functions

template<ViewableFunctionArgumentConcept FunctionType>
constexpr function_view< std::decay_t< FunctionType > > mgis::function::make_view (FunctionType &&f)
 an helper function to create a view when required
template<FunctionConcept FunctionType>
requires (!EvaluatorConcept<FunctionType>)
constexpr decltype(auto) mgis::function::internals::disambiguateGetSpace (const FunctionType &f)
 This helper function allows to disambiguate the call to the getSpace function.
template<FunctionConcept FunctionType>
requires (!EvaluatorConcept<FunctionType>)
constexpr mgis::size_type mgis::function::internals::disambiguateGetNumberOfComponents (const FunctionType &f)
 This helper function allows to disambiguate the call to the getNumberOfComponents function.
template<ViewableFunctionArgumentConcept QualifiedFunctionArgumentType, size_type N>
constexpr bool mgis::function::internals::checkNumberOfComponentsCompatibility () MGIS_NOEXCEPT
 checks if the number of components of a function is compatible with the number of components expected by a modifier
template<EvaluatorConcept EvaluatorType, ViewableFunctionArgumentConcept FunctionType>
requires ( std::same_as<evaluator_space<EvaluatorType>, function_space<std::decay_t<FunctionType>>>)
bool mgis::function::operator| (EvaluatorType e, FunctionType &&f)
 assign an evaluator to a mutable function
template<ViewableFunctionArgumentConcept QualifiedFunctionArgumentType, size_type N>
requires (internals::checkNumberOfComponentsCompatibility< QualifiedFunctionArgumentType, N>())
constexpr auto mgis::function::operator| (QualifiedFunctionArgumentType &&f, const internals::fixed_size_modifier< N > &m)
 create a view returning a fixed number of components

Variables

template<FunctionConcept FunctionType>
constexpr auto mgis::function::isFunctionResultTypeMappable
 true if the result of a function is a mappable type, i.e. a type for which the getDataPointer function returns a mutable pointer
template<FunctionConcept FunctionType>
constexpr auto mgis::function::isFunctionConstResultTypeMappable
 true if the result of a constant function is a mappable type, i.e. a type for which the getDataPointer function returns a constant pointer
template<size_type N>
constexpr auto mgis::function::as_array = internals::fixed_size_modifier<N>{}
 modifier used to return a fixed number of components of a function or an evaluator
constexpr auto mgis::function::as_scalar = internals::fixed_size_modifier<1>{}
 modifier used to return the first component of a function or an evaluator

Detailed Description

File which defines the concept a function must satisfy and the helpers used to query the space, the type of the values and the view of a function.

Author
Thomas Helfer
Date
14/05/2025

Typedef Documentation

◆ function_const_result

template<FunctionConcept FunctionType>
using mgis::function::function_const_result
Initial value:

type of the result of a constant function, i.e. the type of the values returned by a constant function, which can be a scalar value, a constant std::span or a constant std::array

Template Parameters
FunctionTypefunction type

◆ function_result

template<FunctionConcept FunctionType>
using mgis::function::function_result
Initial value:

type of the result of a function, i.e. the type of the values returned by the function, which can be a scalar value, a std::span or a std::array

Template Parameters
FunctionTypefunction type

◆ function_space

template<FunctionConcept FunctionType>
using mgis::function::function_space
Initial value:
std::decay_t<decltype(getSpace(std::declval<FunctionType>()))>

alias giving the type of the space on which a function is defined

Template Parameters
FunctionTypefunction type

◆ function_view

template<FunctionConcept FunctionType>
using mgis::function::function_view
Initial value:
std::conditional_t<
FunctionType,
FunctionType>::type>
concept defining the functions which are their own view
Definition FunctionConcept.hxx:433
helper structure used to determine the type of the view of a function which is not its own view
Definition FunctionConcept.hxx:570

an alias which returns a view corresponding to the given function type

Template Parameters
FunctionTypefunction type

Function Documentation

◆ checkNumberOfComponentsCompatibility()

template<ViewableFunctionArgumentConcept QualifiedFunctionArgumentType, size_type N>
bool mgis::function::internals::checkNumberOfComponentsCompatibility ( )
nodiscardconstexpr

checks if the number of components of a function is compatible with the number of components expected by a modifier

The check is always satisfied if the number of components of the function is only known at run time.

Template Parameters
QualifiedFunctionArgumentTypetype of the function argument, which may be a qualified type (reference, const, etc...)
Nnumber of components expected by the modifier
Returns
true if the number of components is compatible

◆ disambiguateGetNumberOfComponents()

template<FunctionConcept FunctionType>
requires (!EvaluatorConcept<FunctionType>)
mgis::size_type mgis::function::internals::disambiguateGetNumberOfComponents ( const FunctionType & f)
constexpr

This helper function allows to disambiguate the call to the getNumberOfComponents function.

forwards the call to the getNumberOfComponents function

Template Parameters
FunctionTypefunction type
Parameters
[in]ffunction
Returns
the number of components of the values returned by the function

◆ disambiguateGetSpace()

template<FunctionConcept FunctionType>
requires (!EvaluatorConcept<FunctionType>)
decltype(auto) mgis::function::internals::disambiguateGetSpace ( const FunctionType & f)
constexpr

This helper function allows to disambiguate the call to the getSpace function.

forwards the call to the getSpace function of the function

Template Parameters
FunctionTypefunction type
Parameters
[in]ffunction
Returns
the space on which the function is defined

◆ make_view()

template<ViewableFunctionArgumentConcept FunctionType>
function_view< std::decay_t< FunctionType > > mgis::function::make_view ( FunctionType && f)
constexpr

an helper function to create a view when required

Template Parameters
FunctionTypetype of the function, which may be a qualified type (reference, const, etc...)
Parameters
[in]ffunction
Returns
a view of the function, which is the function itself if the function is a lightweight view

◆ operator|() [1/2]

template<EvaluatorConcept EvaluatorType, ViewableFunctionArgumentConcept FunctionType>
requires ( std::same_as<evaluator_space<EvaluatorType>, function_space<std::decay_t<FunctionType>>>)
bool mgis::function::operator| ( EvaluatorType e,
FunctionType && f )
nodiscard

assign an evaluator to a mutable function

implementation of the operator| which assigns the values computed by an evaluator to the values of a function

Template Parameters
EvaluatorTypeevaluator type
FunctionTypetype of the function, which may be a qualified type (reference, const, etc...)
Parameters
[in]eevaluator
[in,out]ffunction
Returns
true if the assignment succeeded
Note
the errors detected during the assignment are reported by a default constructed Context object, which is not returned to the caller.

◆ operator|() [2/2]

template<ViewableFunctionArgumentConcept QualifiedFunctionArgumentType, size_type N>
requires (internals::checkNumberOfComponentsCompatibility< QualifiedFunctionArgumentType, N>())
auto mgis::function::operator| ( QualifiedFunctionArgumentType && f,
const internals::fixed_size_modifier< N > & m )
constexpr

create a view returning a fixed number of components

Template Parameters
QualifiedFunctionArgumentTypetype of the function, which may be a qualified type (reference, const, etc...)
Nnumber of components
Parameters
[in]ffunction
[in]mmodifier
Returns
a view of the function returning the first N components of the values of the function

Variable Documentation

◆ as_array

template<size_type N>
auto mgis::function::as_array = internals::fixed_size_modifier<N>{}
inlineconstexpr

modifier used to return a fixed number of components of a function or an evaluator

Template Parameters
Nnumber of components

◆ isFunctionConstResultTypeMappable

template<FunctionConcept FunctionType>
auto mgis::function::isFunctionConstResultTypeMappable
inlineconstexpr
Initial value:
=
{ getDataPointer(rf) } -> std::same_as<const real*>;
}
constexpr auto getDataPointer(ResultType &&r)
returns a pointer to the values held by an object with a data method, such as std::span,...
Definition EvaluatorConcept.hxx:421
typename internals::FunctionResultQuery< FunctionType >::const_result_type function_const_result
type of the result of a constant function, i.e. the type of the values returned by a constant functio...
Definition FunctionConcept.hxx:668

true if the result of a constant function is a mappable type, i.e. a type for which the getDataPointer function returns a constant pointer

Template Parameters
FunctionTypefunction type

◆ isFunctionResultTypeMappable

template<FunctionConcept FunctionType>
auto mgis::function::isFunctionResultTypeMappable
inlineconstexpr
Initial value:
=
{ getDataPointer(rf) } -> std::same_as<real*>;
}
typename internals::FunctionResultQuery< FunctionType >::result_type function_result
type of the result of a function, i.e. the type of the values returned by the function,...
Definition FunctionConcept.hxx:659

true if the result of a function is a mappable type, i.e. a type for which the getDataPointer function returns a mutable pointer

Template Parameters
FunctionTypefunction type