OpenLB 1.7
Loading...
Searching...
No Matches
fringe2D.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_2D_HH
25#define FRINGE_2D_HH
26
27#include<vector>
28#include<cmath>
29
30#include "fringe2D.h"
31
32namespace olb {
33
34template <typename T, typename S>
35Fringe2D<T,S>::Fringe2D(AnalyticalF2D<T,S>& wantedVelocity, T start, T end, int direction, T lambdaMax, T rise, T fall)
36 : AnalyticalF2D<T,S>(6), _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 Fringe2D<T,S>::operator()(T output[6], const S input[2])
45{
46 output[3] = T();
47 output[4] = T();
48 if ( _wantedVelocity(output, input) ) {
49 T scaleLambda = lambda(input[_direction]);
50 output[0] = -scaleLambda*output[0];
51 output[1] = -scaleLambda*output[1];
52 output[2] = scaleLambda;
53 output[5] = scaleLambda;
54 return true;
55 }
56 else {
57 output[0] = T();
58 output[1] = T();
59 output[2] = T();
60 output[5] = T();
61 return false;
62 }
63}
64
65template <typename T, typename S>
66T Fringe2D<T,S>::s(const T& x) const
67{
68 if ( x < std::numeric_limits<T>::epsilon() ) {
69 return 0.;
70 }
71 else if (x > T(1)-std::numeric_limits<T>::epsilon() ) {
72 return T(1);
73 }
74 else {
75 return T(1)/(T(1) + util::exp( T(1)/(x - T(1) ) + T(1)/x ) );
76 }
77}
78
79template <typename T, typename S>
80T Fringe2D<T,S>::lambda(const T& x) const
81{
82 return _lambdaMax*(s((x - _start)/_rise*(_end - _start) ) - s((x - _end)/_fall*(_end - _start) + T(1.)) );
83}
84
85} // end namespace olb
86
87#endif
88
AnalyticalF are applications from DD to XD, where X is set by the constructor.
Fringe2D(AnalyticalF2D< T, S > &wantedVelocity, T start, T end, int direction, T lambdaMax=.005, T rise=.4, T fall=.2)
Definition fringe2D.hh:35
bool operator()(T output[6], const S input[2])
Returns coefficients (a1, a2, B11, B12, B21, B22) for a linear velocity force modell where F = a + B*...
Definition fringe2D.hh:44
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.