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

File which defines the FunctionView class, which describes a function whose values are stored in an external memory region, the Function class, which owns the values of a function, and the helper functions used to query them and to create views. More...

#include <span>
#include <limits>
#include <vector>
#include "MGIS/Config.hxx"
#include "MGIS/Contract.hxx"
#include "MGIS/Function/SpaceConcept.hxx"
#include "MGIS/Function/FunctionConcept.hxx"
#include "MGIS/Function/Evaluator.hxx"
#include "MGIS/Function/Function.ixx"

Classes

struct  mgis::function::FunctionDataSize< data_size >
 class describing the size (number of components) of the data manipulated by a function, when this size is known at compile time More...
struct  mgis::function::FunctionDataSize< dynamic_extent >
 specialisation of FunctionDataSize used when the number of components of the function is only known at run time More...
struct  mgis::function::FunctionDataStride< data_stride >
 class describing the stride of the data manipulated by a function, i.e. the distance between the values associated with two successive integration points, when this stride is known at compile time More...
struct  mgis::function::FunctionDataStride< dynamic_extent >
 specialisation of FunctionDataStride used when the stride is only known at run time More...
struct  mgis::function::FunctionDataLayoutDescription
 a simple data structure describing how the data of a function is mapped in memory, which is used as a non-type template argument More...
struct  mgis::function::FunctionDataLayout< layout >
 a simple data structure describing how the data of a function is mapped in memory More...
struct  mgis::function::FunctionView< Space, layout, is_mutable >
 function defined on a space, whose values are stored in an external memory region. More...
struct  mgis::function::LightweightViewTraits< FunctionView< Space, layout, is_mutable > >
 specialisation stating that a FunctionView is a lightweight view, i.e. a function which is its own view: it can be copied at a negligible cost More...
struct  mgis::function::FunctionStorage< Space, N >
 an helper class storing the values of a function in a std::vector More...
struct  mgis::function::Function< Space, N >
 default implementation of a function, which owns its values More...

Namespaces

namespace  mgis
 the namespace mgis encloses all the MGIS project.

Typedefs

template<LinearFunctionalSpaceConcept Space, FunctionDataLayoutDescription layout = FunctionDataLayoutDescription{}>
using mgis::function::FunctionEvaluator = FunctionView<Space, layout, false>
 an immutable FunctionView, i.e. a view which cannot modify the values stored in the external memory region and which matches the EvaluatorConcept concept
template<LinearFunctionalSpaceConcept Space, size_type N>
using mgis::function::FunctionViewAlias
 a mutable FunctionView whose stride is equal to the number of components, used to simplify the implementation of the Function class

Functions

constexpr bool mgis::function::has_dynamic_properties (const FunctionDataLayoutDescription &)
 checks if the given data layout description has properties which are only known at run time
template<LinearFunctionalSpaceConcept Space, FunctionDataLayoutDescription layout, bool is_mutable>
constexpr bool mgis::function::check (AbstractErrorHandler &, const FunctionView< Space, layout, is_mutable > &) MGIS_NOEXCEPT
 a noop function allowing FunctionView to match the EvaluatorConcept concept
template<LinearFunctionalSpaceConcept Space, FunctionDataLayoutDescription layout, bool is_mutable>
constexpr mgis::size_type mgis::function::getNumberOfComponents (const FunctionView< Space, layout, is_mutable > &) MGIS_NOEXCEPT
 return the number of components of the given view
template<LinearFunctionalSpaceConcept SpaceType>
 mgis::function::Function (const SpaceType &, const size_type) -> Function< SpaceType, dynamic_extent >
 class template deduction guide: a Function constructed from a space and a run-time number of components has a number of components which is only known at run time
template<LinearFunctionalSpaceConcept Space, size_type N>
constexpr auto mgis::function::view (Function< Space, N > &)
 convert a function to a mutable view
template<size_type N, LinearFunctionalSpaceConcept Space, size_type N2>
requires ((N > 0) && (N != dynamic_extent) && (N == N2))
constexpr auto mgis::function::view (Function< Space, N2 > &)
 convert a function to a mutable view
template<LinearFunctionalSpaceConcept Space, size_type N>
constexpr auto mgis::function::view (const Function< Space, N > &)
 convert a function to an immutable view
template<LinearFunctionalSpaceConcept Space, size_type N>
auto mgis::function::view (Function< Space, N > &&)=delete
 deletion of the view of a rvalue function to prevent creating a view pointing to values which are about to be destroyed
template<size_type N, LinearFunctionalSpaceConcept Space, size_type N2>
requires ((N > 0) && (N != dynamic_extent) && (N == N2))
constexpr auto mgis::function::view (const Function< Space, N2 > &)
 convert a function to an immutable view
template<size_type N, LinearFunctionalSpaceConcept Space, size_type N2>
auto mgis::function::view (Function< Space, N2 > &&)=delete
 deletion of the view of a rvalue function to prevent creating a view pointing to values which are about to be destroyed
template<LinearFunctionalSpaceConcept Space, FunctionDataLayoutDescription layout, bool is_mutable>
constexpr const auto & mgis::function::getSpace (const FunctionView< Space, layout, is_mutable > &)
 return the space on which the given view is defined
template<LinearFunctionalSpaceConcept Space, size_type N>
bool mgis::function::check (AbstractErrorHandler &, const Function< Space, N > &)=delete
 deleted function so that Function does not match the EvaluatorConcept concept: the values of a function must be evaluated through a view

Variables

template<size_type N>
constexpr auto mgis::function::simple_data_layout_description
 data layout description whose number of components and stride are both equal to N

Detailed Description

File which defines the FunctionView class, which describes a function whose values are stored in an external memory region, the Function class, which owns the values of a function, and the helper functions used to query them and to create views.

Author
Thomas Helfer
Date
11/06/2020

Typedef Documentation

◆ FunctionEvaluator

template<LinearFunctionalSpaceConcept Space, FunctionDataLayoutDescription layout = FunctionDataLayoutDescription{}>
using mgis::function::FunctionEvaluator = FunctionView<Space, layout, false>

an immutable FunctionView, i.e. a view which cannot modify the values stored in the external memory region and which matches the EvaluatorConcept concept

Template Parameters
Spacetype of the discretization space
layoutdata layout description

◆ FunctionViewAlias

template<LinearFunctionalSpaceConcept Space, size_type N>
using mgis::function::FunctionViewAlias
Initial value:
function defined on a space, whose values are stored in an external memory region.
Definition Function.hxx:224

a mutable FunctionView whose stride is equal to the number of components, used to simplify the implementation of the Function class

Template Parameters
Spacetype of the discretization space
Nnumber of components, which may be dynamic_extent

Function Documentation

◆ check() [1/2]

template<LinearFunctionalSpaceConcept Space, size_type N>
bool mgis::function::check ( AbstractErrorHandler & ,
const Function< Space, N > &  )
delete

deleted function so that Function does not match the EvaluatorConcept concept: the values of a function must be evaluated through a view

Template Parameters
Spacetype of the functional space
Nnumber of components of the function
Parameters
[in]eherror handler
[in]ffunction to check

◆ check() [2/2]

template<LinearFunctionalSpaceConcept Space, FunctionDataLayoutDescription layout, bool is_mutable>
bool mgis::function::check ( AbstractErrorHandler & ,
const FunctionView< Space, layout, is_mutable > &  )
nodiscardconstexpr

a noop function allowing FunctionView to match the EvaluatorConcept concept

Template Parameters
Spacetype of the discretization space
layoutdata layout description
is_mutablemutability flag of the view
Parameters
[in]ehunused error handler
[in]eview to be checked
Returns
always true: the values held by a view are always valid

◆ Function()

template<LinearFunctionalSpaceConcept SpaceType>
mgis::function::Function ( const SpaceType & ,
const size_type  )->Function< SpaceType, dynamic_extent >

class template deduction guide: a Function constructed from a space and a run-time number of components has a number of components which is only known at run time

Template Parameters
SpaceTypetype of the discretization space

◆ getNumberOfComponents()

template<LinearFunctionalSpaceConcept Space, FunctionDataLayoutDescription layout, bool is_mutable>
mgis::size_type mgis::function::getNumberOfComponents ( const FunctionView< Space, layout, is_mutable > & e)
nodiscardconstexpr

return the number of components of the given view

Template Parameters
Spacetype of the discretization space
layoutdata layout description
is_mutablemutability flag of the view
Parameters
[in]eview whose number of components is queried
Returns
the number of components of the values of the view

◆ getSpace()

template<LinearFunctionalSpaceConcept Space, FunctionDataLayoutDescription layout, bool is_mutable>
const auto & mgis::function::getSpace ( const FunctionView< Space, layout, is_mutable > & f)
nodiscardconstexpr

return the space on which the given view is defined

Template Parameters
Spacetype of the discretization space
layoutdata layout description
is_mutablemutability flag of the view
Parameters
[in]fview whose space is queried
Returns
the space on which the view is defined

◆ has_dynamic_properties()

bool mgis::function::has_dynamic_properties ( const FunctionDataLayoutDescription & layout)
nodiscardconstexpr

checks if the given data layout description has properties which are only known at run time

Parameters
[in]layoutdata layout description
Returns
true if the data size or the data stride is dynamic_extent

◆ view() [1/6]

template<LinearFunctionalSpaceConcept Space, size_type N>
auto mgis::function::view ( const Function< Space, N > & f)
nodiscardconstexpr

convert a function to an immutable view

Template Parameters
Spacetype of the functional space
Nnumber of components of the function
Parameters
[in]ffunction to convert
Returns
an immutable view of the function values

◆ view() [2/6]

template<size_type N, LinearFunctionalSpaceConcept Space, size_type N2>
requires ((N > 0) && (N != dynamic_extent) && (N == N2))
auto mgis::function::view ( const Function< Space, N2 > & f)
nodiscardconstexpr

convert a function to an immutable view

Template Parameters
Nnumber of components of the view, which must be greater than zero and known at compile time
Spacetype of the functional space
N2number of components of the function
Parameters
[in]ffunction to convert
Returns
an immutable view of the function values
Note
the requires clause makes this overload viable only when the number of components of the function is known at compile time and equal to N

◆ view() [3/6]

template<LinearFunctionalSpaceConcept Space, size_type N>
auto mgis::function::view ( Function< Space, N > && )
delete

deletion of the view of a rvalue function to prevent creating a view pointing to values which are about to be destroyed

Template Parameters
Spacetype of the functional space
Nnumber of components of the function
Parameters
[in]frvalue function

◆ view() [4/6]

template<LinearFunctionalSpaceConcept Space, size_type N>
auto mgis::function::view ( Function< Space, N > & f)
nodiscardconstexpr

convert a function to a mutable view

Template Parameters
Spacetype of the functional space
Nnumber of components of the function
Parameters
[in]ffunction to convert
Returns
a mutable view of the function, which shares its values

◆ view() [5/6]

template<size_type N, LinearFunctionalSpaceConcept Space, size_type N2>
auto mgis::function::view ( Function< Space, N2 > && )
delete

deletion of the view of a rvalue function to prevent creating a view pointing to values which are about to be destroyed

Template Parameters
Nnumber of components of the view
Spacetype of the functional space
N2number of components of the function
Parameters
[in]frvalue function

◆ view() [6/6]

template<size_type N, LinearFunctionalSpaceConcept Space, size_type N2>
requires ((N > 0) && (N != dynamic_extent) && (N == N2))
auto mgis::function::view ( Function< Space, N2 > & f)
nodiscardconstexpr

convert a function to a mutable view

Template Parameters
Nnumber of components of the view, which must be greater than zero and known at compile time
Spacetype of the functional space
N2number of components of the function
Parameters
[in]ffunction to convert
Returns
a mutable view of the function, which shares its values
Note
the requires clause makes this overload viable only when the number of components of the function is known at compile time and equal to N

Variable Documentation

◆ simple_data_layout_description

template<size_type N>
auto mgis::function::simple_data_layout_description
inlineconstexpr
Initial value:
=
FunctionDataLayoutDescription{.data_size = N, .data_stride = N}
a simple data structure describing how the data of a function is mapped in memory,...
Definition Function.hxx:113

data layout description whose number of components and stride are both equal to N

This variable is a workaround for a limitation of Visual Studio 2022 on defining default values for non-type template arguments.

Template Parameters
Nnumber of components, which may be dynamic_extent