OpenLB 1.7
Loading...
Searching...
No Matches
functorDsl3D.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_3D_HH
25#define FUNCTOR_DSL_3D_HH
26
27#include "functorPtr.h"
32
33namespace olb {
34
35namespace functor_dsl {
36
37template<typename T, typename W>
38std::shared_ptr<SuperF3D<T,W>> lift(SuperF3D<T,W>& f)
39{
40 return FunctorPtr<SuperF3D<T,W>>(f).toShared();
41}
42
43template<typename T, typename W>
44std::shared_ptr<SuperF3D<T,W>> lift(SuperF3D<T,W>* f)
45{
46 return FunctorPtr<SuperF3D<T,W>>(f).toShared();
47}
48
49template<typename T, typename W>
50std::shared_ptr<AnalyticalF3D<T,W>> lift(AnalyticalF3D<T,W>& f)
51{
52 return FunctorPtr<AnalyticalF3D<T,W>>(f).toShared();
53}
54
55template<typename T, typename W>
56std::shared_ptr<AnalyticalF3D<T,W>> lift(AnalyticalF3D<T,W>* f)
57{
58 return FunctorPtr<AnalyticalF3D<T,W>>(f).toShared();
59}
60
61template<typename T, typename W>
62std::shared_ptr<SuperF3D<T,W>> pow(std::shared_ptr<SuperF3D<T,W>> baseF,
63 std::shared_ptr<SuperF3D<T,W>> exponentF)
64{
65 return std::shared_ptr<SuperF3D<T,W>>(
66 new SuperCalcPower3D<T,W>(std::move(baseF),
67 std::move(exponentF))
68 );
69}
70
71template<typename T, typename W, typename E>
72std::shared_ptr<SuperF3D<T,W>> pow(std::shared_ptr<SuperF3D<T,W>> baseF,
73 E exponent)
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}
80
81template<typename T, typename W, typename B>
82std::shared_ptr<SuperF3D<T,W>> pow(B base,
83 std::shared_ptr<SuperF3D<T,W>> exponentF)
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}
90
91template<int P, typename T, typename W>
92std::shared_ptr<SuperF3D<T,W>> norm(std::shared_ptr<SuperF3D<T,W>> f,
93 std::shared_ptr<SuperIndicatorF3D<T>> indicatorF)
94{
95 return std::shared_ptr<SuperF3D<T,W>>(
96 new SuperLpNorm3D<T,W,P>(std::move(f),
97 std::move(indicatorF))
98 );
99}
100
101template<typename T, typename W, typename DESCRIPTOR>
102std::shared_ptr<SuperF3D<T,W>> restrictF(std::shared_ptr<AnalyticalF3D<T,W>> f,
104{
105 return std::shared_ptr<SuperF3D<T,W>>(
106 new SuperLatticeFfromAnalyticalF3D<T,DESCRIPTOR>(std::move(f), sLattice));
107}
108
109template<typename T,typename DESCRIPTOR, typename FIELD>
110std::enable_if_t<DESCRIPTOR::d == 3, std::shared_ptr<SuperF3D<T>>>
112{
113 return std::make_shared<SuperLatticeField3D<T,DESCRIPTOR,FIELD>>(sLattice);
114}
115
116}
117
118}
119
120#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 SuperF3D functors.
represents all functors that operate on a SuperStructure<T,3> in general
Base indicator functor (discrete)
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.