OpenLB 1.7
Loading...
Searching...
No Matches
analyticalBaseF.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2012 Lukas Baron, Tim Dornieden, Mathias J. Krause, Albert Mink
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 ANALYTICAL_BASE_F_HH
25#define ANALYTICAL_BASE_F_HH
26
27#include "analyticalBaseF.h"
28
29namespace olb {
30
31// identity to "store results"
32template<unsigned D, typename T, typename S>
34 : AnalyticalF<D,T,S>(f.getTargetDim()), _f(f)
35{
36 this->getName() = _f.getName();
37 // pass through the shared_ptr from _f, e.g. an arithemticClass, to the identity
38 std::swap( _f._ptrCalcC, this->_ptrCalcC );
39}
40
41template<unsigned D, typename T, typename S>
42bool AnalyticalIdentity<D,T,S>::operator()(T output[], const S input[])
43{
44 _f(output,input);
45 return true;
46}
47
48
49template <unsigned D, typename OldT, typename NewT, typename OldS, typename NewS>
52 : AnalyticalF<D,NewT,NewS>(f.getTargetDim()), _f(f)
53{
54 this->getName() = _f.getName();
55 // pass through the shared_ptr from _f, e.g. an arithemticClass, to the identity
56 //std::swap( _f._ptrCalcC, this->_ptrCalcC );
57}
58
59template <unsigned D, typename OldT, typename NewT, typename OldS, typename NewS>
60bool AnalyticalTypecast<D,OldT,NewT,OldS,NewS>::operator()(NewT output[], const NewS input[])
61{
62 OldS inputConv[D];
63 for (unsigned i = 0; i < D; ++i) {
64 inputConv[i] = OldS {input[i]};
65 }
66 OldT outputConv[this->getTargetDim()];
67
68 _f(outputConv,inputConv);
69
70 for (int i = 0; i < this->getTargetDim(); ++i) {
71 output[i] = NewT {outputConv[i]};
72 }
73 return true;
74}
75
76
78//
79template <typename T, typename S>
81 : AnalyticalF3D<T,S>(1), _indicatorF(indicatorF)
82{
83 this->getName() = "IndicatorFfrom" + _indicatorF.getName();
84}
85
86template <typename T, typename S>
87bool AnalyticalFfromIndicatorF3D<T, S>::operator() (T output[], const S input[])
88{
89 bool tmp = false;
90 _indicatorF(&tmp, input);
91 if ( tmp ) {
92 output[0] = T(1);
93 }
94 else {
95 output[0] = T(0);
96 }
97 return tmp;
98}
99
100
101
102} // end namespace olb
103
104#endif
AnalyticalF are applications from DD to XD, where X is set by the constructor.
bool operator()(T output[], const S input[]) override
has to be implemented for 'every' derived class
AnalyticalFfromIndicatorF3D(IndicatorF3D< T > &indicatorF)
AnalyticalF< D, T, S > & _f
bool operator()(T output[], const S input[]) override
has to be implemented for 'every' derived class
AnalyticalIdentity(AnalyticalF< D, T, S > &f)
AnalyticalF< D, OldT, OldS > & _f
AnalyticalTypecast(AnalyticalF< D, OldT, OldS > &f)
bool operator()(NewT output[], const NewS input[]) override
std::string & getName()
read and write access to name
Definition genericF.hh:51
IndicatorF3D is an application from .
Top level namespace for all of OpenLB.