OpenLB 1.7
Loading...
Searching...
No Matches
Functions
olb::functor_dsl Namespace Reference

Helper functions for building functors via composition. More...

Functions

template<typename T , typename W >
std::shared_ptr< SuperF2D< T, W > > lift (SuperF2D< T, W > &f)
 Lifts functor reference to std::shared_ptr functor arithmetic.
 
template<typename T , typename W >
std::shared_ptr< SuperF2D< T, W > > lift (SuperF2D< T, W > *f)
 Lifts functor pointer to std::shared_ptr functor arithmetic.
 
template<typename T , typename W >
std::shared_ptr< AnalyticalF2D< T, W > > lift (AnalyticalF2D< T, W > &f)
 Lifts functor reference to std::shared_ptr functor arithmetic.
 
template<typename T , typename W >
std::shared_ptr< AnalyticalF2D< T, W > > lift (AnalyticalF2D< T, W > *f)
 Lifts functor pointer to std::shared_ptr functor arithmetic.
 
template<typename T , typename W >
std::shared_ptr< SuperF2D< T, W > > pow (std::shared_ptr< SuperF2D< T, W > > baseF, std::shared_ptr< SuperF2D< T, W > > exponentF)
 Returns baseF raised to the power of exponentF.
 
template<typename T , typename W , typename E >
std::shared_ptr< SuperF2D< T, W > > pow (std::shared_ptr< SuperF2D< T, W > > baseF, E exponent)
 Returns baseF raised to the power of exponent.
 
template<typename T , typename W , typename B >
std::shared_ptr< SuperF2D< T, W > > pow (B base, std::shared_ptr< SuperF2D< T, W > > exponentF)
 Returns base raised to the power of exponentF.
 
template<int P, typename T , typename W >
std::shared_ptr< SuperF2D< T, W > > norm (std::shared_ptr< SuperF2D< T, W > > f, std::shared_ptr< SuperIndicatorF2D< T > > indicatorF)
 Returns Lp norm for a functor f on the subset described by indicatorF.
 
template<typename T , typename W , typename DESCRIPTOR >
std::shared_ptr< SuperF2D< T, W > > restrictF (std::shared_ptr< AnalyticalF2D< T, W > > f, SuperLattice< T, DESCRIPTOR > &sLattice)
 Returns restriction of a analytical functor f to the lattice sLattice.
 
template<typename T , typename DESCRIPTOR , typename FIELD >
std::enable_if_t< DESCRIPTOR::d==2, std::shared_ptr< SuperF2D< T > > > field (SuperLattice< T, DESCRIPTOR > &sLattice)
 Returns external field functor.
 
template<typename T , typename W >
std::shared_ptr< SuperF3D< T, W > > lift (SuperF3D< T, W > &f)
 Lifts functor reference to std::shared_ptr functor arithmetic.
 
template<typename T , typename W >
std::shared_ptr< SuperF3D< T, W > > lift (SuperF3D< T, W > *f)
 Lifts functor pointer to std::shared_ptr functor arithmetic.
 
template<typename T , typename W >
std::shared_ptr< AnalyticalF3D< T, W > > lift (AnalyticalF3D< T, W > &f)
 Lifts functor reference to std::shared_ptr functor arithmetic.
 
template<typename T , typename W >
std::shared_ptr< AnalyticalF3D< T, W > > lift (AnalyticalF3D< T, W > *f)
 Lifts functor pointer to std::shared_ptr functor arithmetic.
 
template<typename T , typename W >
std::shared_ptr< SuperF3D< T, W > > pow (std::shared_ptr< SuperF3D< T, W > > baseF, std::shared_ptr< SuperF3D< T, W > > exponentF)
 Returns baseF raised to the power of exponentF.
 
template<typename T , typename W , typename E >
std::shared_ptr< SuperF3D< T, W > > pow (std::shared_ptr< SuperF3D< T, W > > baseF, E exponent)
 Returns baseF raised to the power of exponent.
 
template<typename T , typename W , typename B >
std::shared_ptr< SuperF3D< T, W > > pow (B base, std::shared_ptr< SuperF3D< T, W > > exponentF)
 Returns base raised to the power of exponentF.
 
template<int P, typename T , typename W >
std::shared_ptr< SuperF3D< T, W > > norm (std::shared_ptr< SuperF3D< T, W > > f, std::shared_ptr< SuperIndicatorF3D< T > > indicatorF)
 Returns Lp norm for a functor f on the subset described by indicatorF.
 
template<typename T , typename W , typename DESCRIPTOR >
std::shared_ptr< SuperF3D< T, W > > restrictF (std::shared_ptr< AnalyticalF3D< T, W > > f, SuperLattice< T, DESCRIPTOR > &sLattice)
 Returns restriction of a analytical functor f to the lattice sLattice.
 
template<typename T , typename DESCRIPTOR , typename FIELD >
std::enable_if_t< DESCRIPTOR::d==3, std::shared_ptr< SuperF3D< T > > > field (SuperLattice< T, DESCRIPTOR > &sLattice)
 Returns external field functor.
 

Detailed Description

Helper functions for building functors via composition.

Certain types of functors such as error norms (see e.g. SuperRelativeErrorLpNorm3D) lend themselves to being expressed as a composition of existing functors.

std::shared_ptr based functor arithmetic offers a memory-safe way to perform functor composition. However common operations such as lifting stack-allocated functors into the std::shared_ptr context, constructing Lp norms or restricting analytical functors on a lattice can become quite verbose.

This is why the functor_dsl namespace contains a set of conveniently named helper functions that aim to ease writing composed functors.

e.g. a slightly modified version of SuperRelativeErrorLpNorm3D's constructor:

using namespace functor_dsl;
// decltype(wantedF) == std::shared_ptr<AnalyticalF3D<T,W>>
// decltype(f) == std::shared_ptr<SuperF3D<T,W>>
// decltype(indicatorF) == std::shared_ptr<SuperIndicatorF3D<T>>
auto wantedLatticeF = restrictF(wantedF, sLattice);
auto relaticeErrorF = norm<P>(wantedLatticeF - f, indicatorF)
/ norm<P>(wantedLatticeF, indicatorF);
std::shared_ptr< SuperF2D< T, W > > restrictF(std::shared_ptr< AnalyticalF2D< T, W > > f, SuperLattice< T, DESCRIPTOR > &sLattice)
Returns restriction of a analytical functor f to the lattice sLattice.

Note that any of the functors managed by std::shared_ptr may be returned and reused independently.

i.e. it is not necessary to manually assure the lifetime of any functor used by the composition.

Function Documentation

◆ field() [1/2]

template<typename T , typename DESCRIPTOR , typename FIELD >
std::enable_if_t< DESCRIPTOR::d==2, std::shared_ptr< SuperF2D< T > > > olb::functor_dsl::field ( SuperLattice< T, DESCRIPTOR > & sLattice)

Returns external field functor.

Definition at line 110 of file functorDsl2D.hh.

111{
112 return std::make_shared<SuperLatticeField2D<T,DESCRIPTOR,FIELD>>(sLattice);
113}

◆ field() [2/2]

template<typename T , typename DESCRIPTOR , typename FIELD >
std::enable_if_t< DESCRIPTOR::d==3, std::shared_ptr< SuperF3D< T > > > olb::functor_dsl::field ( SuperLattice< T, DESCRIPTOR > & sLattice)

Returns external field functor.

Definition at line 111 of file functorDsl3D.hh.

112{
113 return std::make_shared<SuperLatticeField3D<T,DESCRIPTOR,FIELD>>(sLattice);
114}

◆ lift() [1/8]

template<typename T , typename W >
std::shared_ptr< AnalyticalF2D< T, W > > olb::functor_dsl::lift ( AnalyticalF2D< T, W > & f)

Lifts functor reference to std::shared_ptr functor arithmetic.

Definition at line 49 of file functorDsl2D.hh.

50{
51 return FunctorPtr<AnalyticalF2D<T,W>>(f).toShared();
52}
Smart pointer for managing the various ways of passing functors around.
Definition functorPtr.h:60

◆ lift() [2/8]

template<typename T , typename W >
std::shared_ptr< AnalyticalF2D< T, W > > olb::functor_dsl::lift ( AnalyticalF2D< T, W > * f)

Lifts functor pointer to std::shared_ptr functor arithmetic.

Definition at line 55 of file functorDsl2D.hh.

56{
57 return FunctorPtr<AnalyticalF2D<T,W>>(f).toShared();
58}

◆ lift() [3/8]

template<typename T , typename W >
std::shared_ptr< AnalyticalF3D< T, W > > olb::functor_dsl::lift ( AnalyticalF3D< T, W > & f)

Lifts functor reference to std::shared_ptr functor arithmetic.

Definition at line 50 of file functorDsl3D.hh.

51{
52 return FunctorPtr<AnalyticalF3D<T,W>>(f).toShared();
53}

◆ lift() [4/8]

template<typename T , typename W >
std::shared_ptr< AnalyticalF3D< T, W > > olb::functor_dsl::lift ( AnalyticalF3D< T, W > * f)

Lifts functor pointer to std::shared_ptr functor arithmetic.

Definition at line 56 of file functorDsl3D.hh.

57{
58 return FunctorPtr<AnalyticalF3D<T,W>>(f).toShared();
59}

◆ lift() [5/8]

template<typename T , typename W >
std::shared_ptr< SuperF2D< T, W > > olb::functor_dsl::lift ( SuperF2D< T, W > & f)

Lifts functor reference to std::shared_ptr functor arithmetic.

Definition at line 37 of file functorDsl2D.hh.

38{
39 return FunctorPtr<SuperF2D<T,W>>(f).toShared();
40}

◆ lift() [6/8]

template<typename T , typename W >
std::shared_ptr< SuperF2D< T, W > > olb::functor_dsl::lift ( SuperF2D< T, W > * f)

Lifts functor pointer to std::shared_ptr functor arithmetic.

Definition at line 43 of file functorDsl2D.hh.

44{
45 return FunctorPtr<SuperF2D<T,W>>(f).toShared();
46}

◆ lift() [7/8]

template<typename T , typename W >
std::shared_ptr< SuperF3D< T, W > > olb::functor_dsl::lift ( SuperF3D< T, W > & f)

Lifts functor reference to std::shared_ptr functor arithmetic.

Definition at line 38 of file functorDsl3D.hh.

39{
40 return FunctorPtr<SuperF3D<T,W>>(f).toShared();
41}

◆ lift() [8/8]

template<typename T , typename W >
std::shared_ptr< SuperF3D< T, W > > olb::functor_dsl::lift ( SuperF3D< T, W > * f)

Lifts functor pointer to std::shared_ptr functor arithmetic.

Definition at line 44 of file functorDsl3D.hh.

45{
46 return FunctorPtr<SuperF3D<T,W>>(f).toShared();
47}

◆ norm() [1/2]

template<int P, typename T , typename W >
std::shared_ptr< SuperF2D< T, W > > olb::functor_dsl::norm ( std::shared_ptr< SuperF2D< T, W > > f,
std::shared_ptr< SuperIndicatorF2D< T > > indicatorF )

Returns Lp norm for a functor f on the subset described by indicatorF.

Definition at line 91 of file functorDsl2D.hh.

93{
94 return std::shared_ptr<SuperF2D<T,W>>(
95 new SuperLpNorm2D<T,W,P>(std::move(f),
96 std::move(indicatorF))
97 );
98}
Functor that returns the Lp norm over omega of the the euklid norm of the input functor.

◆ norm() [2/2]

template<int P, typename T , typename W >
std::shared_ptr< SuperF3D< T, W > > olb::functor_dsl::norm ( std::shared_ptr< SuperF3D< T, W > > f,
std::shared_ptr< SuperIndicatorF3D< T > > indicatorF )

Returns Lp norm for a functor f on the subset described by indicatorF.

Definition at line 92 of file functorDsl3D.hh.

94{
95 return std::shared_ptr<SuperF3D<T,W>>(
96 new SuperLpNorm3D<T,W,P>(std::move(f),
97 std::move(indicatorF))
98 );
99}
Functor that returns the Lp norm over omega of the the euklid norm of the input functor.

◆ pow() [1/6]

template<typename T , typename W , typename B >
std::shared_ptr< SuperF2D< T, W > > olb::functor_dsl::pow ( B base,
std::shared_ptr< SuperF2D< T, W > > exponentF )

Returns base raised to the power of exponentF.

Definition at line 81 of file functorDsl2D.hh.

83{
84 static_assert(std::is_arithmetic<B>::value,
85 "Base must be an arithmetic value");
86 return std::shared_ptr<SuperF2D<T,W>>(
87 new SuperCalcPower2D<T,W>(base, std::move(exponentF)));
88}
Arithmetic operations for SuperF2D functors.

◆ pow() [2/6]

template<typename T , typename W , typename B >
std::shared_ptr< SuperF3D< T, W > > olb::functor_dsl::pow ( B base,
std::shared_ptr< SuperF3D< T, W > > exponentF )

Returns base raised to the power of exponentF.

Definition at line 82 of file functorDsl3D.hh.

84{
85 static_assert(std::is_arithmetic<B>::value,
86 "Base must be an arithmetic value");
87 return std::shared_ptr<SuperF3D<T,W>>(
88 new SuperCalcPower3D<T,W>(base, std::move(exponentF)));
89}
Arithmetic operations for SuperF3D functors.

◆ pow() [3/6]

template<typename T , typename W , typename E >
std::shared_ptr< SuperF2D< T, W > > olb::functor_dsl::pow ( std::shared_ptr< SuperF2D< T, W > > baseF,
E exponent )

Returns baseF raised to the power of exponent.

Definition at line 71 of file functorDsl2D.hh.

73{
74 static_assert(std::is_arithmetic<E>::value,
75 "Exponent must be an arithmetic value");
76 return std::shared_ptr<SuperF2D<T,W>>(
77 new SuperCalcPower2D<T,W>(std::move(baseF), exponent));
78}

◆ pow() [4/6]

template<typename T , typename W >
std::shared_ptr< SuperF2D< T, W > > olb::functor_dsl::pow ( std::shared_ptr< SuperF2D< T, W > > baseF,
std::shared_ptr< SuperF2D< T, W > > exponentF )

Returns baseF raised to the power of exponentF.

Definition at line 61 of file functorDsl2D.hh.

63{
64 return std::shared_ptr<SuperF2D<T,W>>(
65 new SuperCalcPower2D<T,W>(std::move(baseF),
66 std::move(exponentF))
67 );
68}

◆ pow() [5/6]

template<typename T , typename W , typename E >
std::shared_ptr< SuperF3D< T, W > > olb::functor_dsl::pow ( std::shared_ptr< SuperF3D< T, W > > baseF,
E exponent )

Returns baseF raised to the power of exponent.

Definition at line 72 of file functorDsl3D.hh.

74{
75 static_assert(std::is_arithmetic<E>::value,
76 "Exponent must be an arithmetic value");
77 return std::shared_ptr<SuperF3D<T,W>>(
78 new SuperCalcPower3D<T,W>(std::move(baseF), exponent));
79}

◆ pow() [6/6]

template<typename T , typename W >
std::shared_ptr< SuperF3D< T, W > > olb::functor_dsl::pow ( std::shared_ptr< SuperF3D< T, W > > baseF,
std::shared_ptr< SuperF3D< T, W > > exponentF )

Returns baseF raised to the power of exponentF.

Definition at line 62 of file functorDsl3D.hh.

64{
65 return std::shared_ptr<SuperF3D<T,W>>(
66 new SuperCalcPower3D<T,W>(std::move(baseF),
67 std::move(exponentF))
68 );
69}

◆ restrictF() [1/2]

template<typename T , typename W , typename DESCRIPTOR >
std::shared_ptr< SuperF2D< T, W > > olb::functor_dsl::restrictF ( std::shared_ptr< AnalyticalF2D< T, W > > f,
SuperLattice< T, DESCRIPTOR > & sLattice )

Returns restriction of a analytical functor f to the lattice sLattice.

Definition at line 101 of file functorDsl2D.hh.

103{
104 return std::shared_ptr<SuperF2D<T,W>>(
105 new SuperLatticeFfromAnalyticalF2D<T,DESCRIPTOR>(std::move(f), sLattice));
106}
Functor used to convert analytical functions to lattice functions.

◆ restrictF() [2/2]

template<typename T , typename W , typename DESCRIPTOR >
std::shared_ptr< SuperF3D< T, W > > olb::functor_dsl::restrictF ( std::shared_ptr< AnalyticalF3D< T, W > > f,
SuperLattice< T, DESCRIPTOR > & sLattice )

Returns restriction of a analytical functor f to the lattice sLattice.

Definition at line 102 of file functorDsl3D.hh.

104{
105 return std::shared_ptr<SuperF3D<T,W>>(
106 new SuperLatticeFfromAnalyticalF3D<T,DESCRIPTOR>(std::move(f), sLattice));
107}
Functor used to convert analytical functions to lattice functions.