OpenLB 1.7
Loading...
Searching...
No Matches
fringe3D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2015 Mathias J. Krause
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 FRINGE_3D_HH
25#define FRINGE_3D_HH
26
27#include<vector>
28#include<cmath>
29
30#include "fringe3D.h"
31
32namespace olb {
33
34template <typename T, typename S>
35Fringe3D<T,S>::Fringe3D(AnalyticalF3D<T,S>& wantedVelocity, T start, T end, int direction, T lambdaMax, T rise, T fall)
36 : AnalyticalF3D<T,S>(12), _wantedVelocity(wantedVelocity), _start(start),
37 _end(end), _direction(direction), _lambdaMax(lambdaMax), _rise(rise),
38 _fall(fall)
39{
40 this->getName() = "fringe";
41}
42
43template <typename T, typename S>
44bool Fringe3D<T,S>::operator()(T output[12], const S input[3])
45{
46
47 output[4] = T();
48 output[5] = T();
49 output[6] = T();
50 output[8] = T();
51 output[9] = T();
52 output[10] = T();
53 if ( _wantedVelocity(output, input) ) {
54 T scaleLambda = lambda(input[_direction]);
55 output[0] = -scaleLambda*output[0];
56 output[1] = -scaleLambda*output[1];
57 output[2] = -scaleLambda*output[2];
58 output[3] = scaleLambda;
59 output[7] = scaleLambda;
60 output[11] = scaleLambda;
61 return true;
62 }
63 else {
64 output[0] = T();
65 output[1] = T();
66 output[2] = T();
67 output[3] = T();
68 output[7] = T();
69 output[11] = T();
70 return false;
71 }
72}
73
74template <typename T, typename S>
75T Fringe3D<T,S>::s(const T& x) const
76{
77 if ( x < std::numeric_limits<T>::epsilon() ) {
78 return 0.;
79 }
80 else if (x > T(1)-std::numeric_limits<T>::epsilon() ) {
81 return T(1);
82 }
83 else {
84 return T(1)/(T(1) + util::exp( T(1)/(x - T(1) ) + T(1)/x ) );
85 }
86}
87
88template <typename T, typename S>
89T Fringe3D<T,S>::lambda(const T& x) const
90{
91 return _lambdaMax*(s((x - _start)/_rise*(_end - _start) ) - s((x - _end)/_fall*(_end - _start) + T(1.)) );
92}
93
94} // end namespace olb
95
96#endif
97
AnalyticalF are applications from DD to XD, where X is set by the constructor.
bool operator()(T output[12], const S input[3])
Returns coefficients (a1, a2, a2, B11, B12, B13, B21, B22, B23, B31, B32, B33) for a linear velocity ...
Definition fringe3D.hh:44
Fringe3D(AnalyticalF3D< T, S > &wantedVelocity, T start, T end, int direction, T lambdaMax=.005, T rise=.4, T fall=.2)
Definition fringe3D.hh:35
std::string & getName()
read and write access to name
Definition genericF.hh:51
platform_constant Fraction s[Q]
ADf< T, DIM > exp(const ADf< T, DIM > &a)
Definition aDiff.h:455
Top level namespace for all of OpenLB.