OpenLB 1.7
Loading...
Searching...
No Matches
functorDsl2D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2018 Adrian Kummerlaender
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#ifndef FUNCTOR_DSL_2D_HH
25#define FUNCTOR_DSL_2D_HH
26
27#include "functorPtr.h"
31
32namespace olb {
33
34namespace functor_dsl {
35
36template<typename T, typename W>
37std::shared_ptr<SuperF2D<T,W>> lift(SuperF2D<T,W>& f)
38{
39 return FunctorPtr<SuperF2D<T,W>>(f).toShared();
40}
41
42template<typename T, typename W>
43std::shared_ptr<SuperF2D<T,W>> lift(SuperF2D<T,W>* f)
44{
45 return FunctorPtr<SuperF2D<T,W>>(f).toShared();
46}
47
48template<typename T, typename W>
49std::shared_ptr<AnalyticalF2D<T,W>> lift(AnalyticalF2D<T,W>& f)
50{
51 return FunctorPtr<AnalyticalF2D<T,W>>(f).toShared();
52}
53
54template<typename T, typename W>
55std::shared_ptr<AnalyticalF2D<T,W>> lift(AnalyticalF2D<T,W>* f)
56{
57 return FunctorPtr<AnalyticalF2D<T,W>>(f).toShared();
58}
59
60template<typename T, typename W>
61std::shared_ptr<SuperF2D<T,W>> pow(std::shared_ptr<SuperF2D<T,W>> baseF,
62 std::shared_ptr<SuperF2D<T,W>> exponentF)
63{
64 return std::shared_ptr<SuperF2D<T,W>>(
65 new SuperCalcPower2D<T,W>(std::move(baseF),
66 std::move(exponentF))
67 );
68}
69
70template<typename T, typename W, typename E>
71std::shared_ptr<SuperF2D<T,W>> pow(std::shared_ptr<SuperF2D<T,W>> baseF,
72 E exponent)
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}
79
80template<typename T, typename W, typename B>
81std::shared_ptr<SuperF2D<T,W>> pow(B base,
82 std::shared_ptr<SuperF2D<T,W>> exponentF)
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}
89
90template<int P, typename T, typename W>
91std::shared_ptr<SuperF2D<T,W>> norm(std::shared_ptr<SuperF2D<T,W>> f,
92 std::shared_ptr<SuperIndicatorF2D<T>> indicatorF)
93{
94 return std::shared_ptr<SuperF2D<T,W>>(
95 new SuperLpNorm2D<T,W,P>(std::move(f),
96 std::move(indicatorF))
97 );
98}
99
100template<typename T, typename W, typename DESCRIPTOR>
101std::shared_ptr<SuperF2D<T,W>> restrictF(std::shared_ptr<AnalyticalF2D<T,W>> f,
103{
104 return std::shared_ptr<SuperF2D<T,W>>(
105 new SuperLatticeFfromAnalyticalF2D<T,DESCRIPTOR>(std::move(f), sLattice));
106}
107
108template<typename T,typename DESCRIPTOR, typename FIELD>
109std::enable_if_t<DESCRIPTOR::d == 2, std::shared_ptr<SuperF2D<T>>>
111{
112 return std::make_shared<SuperLatticeField2D<T,DESCRIPTOR,FIELD>>(sLattice);
113}
114
115}
116
117}
118
119#endif
AnalyticalF are applications from DD to XD, where X is set by the constructor.
Smart pointer for managing the various ways of passing functors around.
Definition functorPtr.h:60
Arithmetic operations for SuperF2D functors.
represents all functors that operate on a SuperStructure<T,2> in general
Functor used to convert analytical functions to lattice functions.
Super class maintaining block lattices for a cuboid decomposition.
Functor that returns the Lp norm over omega of the the euklid norm of the input functor.
std::enable_if_t< DESCRIPTOR::d==2, std::shared_ptr< SuperF2D< T > > > field(SuperLattice< T, DESCRIPTOR > &sLattice)
Returns external field functor.
std::shared_ptr< SuperF2D< T, W > > lift(SuperF2D< T, W > &f)
Lifts functor reference to std::shared_ptr functor arithmetic.
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.
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.
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.
Top level namespace for all of OpenLB.