LBIBCell
 All Classes Functions Variables Friends Pages
GuoZhengShi2002ForceModel.cpp
1 /* Copyright (c) 2013 David Sichau <mail"at"sichau"dot"eu>
2  * 2013-2015 Simon Tanaka <tanakas"at"gmx"dot"ch>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 #include <LbmLib/include/solver/FluidSolver/GuoZhengShi2002ForceModel.hpp>
23 #include <LbmLib/include/Direction.hpp>
24 #include <iostream>
25 
26 namespace LbmLib {
27 namespace solver {
28 
30  const double rho,
31  const Field<double> u,
32  const Field<double> f,
33  std::vector<double>& forcecontribution)
34 {
35  /*
36  * f_i = (1-1/(2*tau)) * w_i * [1/cs^2*(e_i-u)+1/cs^4*(e_i*u)e_i] * f
37  * where e_i is the unit vector in direction i,
38  */
39  forcecontribution.clear();
40  forcecontribution.resize(9);
41 
42  const double W0 = (1.0-0.5/tau) * 4.0/9.0;
43  const double W1 = (1.0-0.5/tau) / 9.0;
44  const double W2 = (1.0-0.5/tau) / 36.0;
45 
46  forcecontribution[T] = W0 * (- 3.0*u.x*f.x - 3.0*u.y*f.y);
47  forcecontribution[E] = W1 * ((6.0*u.x + 3.0)*f.x - 3.0*u.y*f.y);
48  forcecontribution[N] = W1 * (- 3.0*u.x*f.x + (6.0*u.y + 3.0)*f.y);
49  forcecontribution[W] = W1 * ((6.0*u.x - 3.0)*f.x - 3.0*u.y*f.y);
50  forcecontribution[S] = W1 * (- 3.0*u.x*f.x + (6.0*u.y - 3.0)*f.y);
51  forcecontribution[NE] = W2 * ((6.0*u.x + 9.0*u.y + 3.0)*f.x + (9.0*u.x - 3.0*u.y + 3.0)*f.y);
52  forcecontribution[NW] = W2 * ((6.0*u.x - 9.0*u.y - 3.0)*f.x + (-9.0*u.x + 6.0*u.y + 3.0)*f.y);
53  forcecontribution[SW] = W2 * ((6.0*u.x + 9.0*u.y - 3.0)*f.x + (9.0*u.x + 6.0*u.y - 3.0)*f.y);
54  forcecontribution[SE] = W2 * ((6.0*u.x - 9.0*u.y + 3.0)*f.x + (-9.0*u.x + 6.0*u.y - 3.0)*f.y);
55 }
56 
58  const std::array<double, 9> &fi,
59  const Field<double> f,
60  Field<double>& u)
61 {
62  const double rhoI = 1.0/rho;
63  u.x = (fi[E]
64  + fi[NE]
65  + fi[SE]
66  - (fi[NW]
67  + fi[W]
68  + fi[SW])
69  + 0.5*f.x) * rhoI;
70 
71  u.y = (fi[NE]
72  + fi[N]
73  + fi[NW]
74  - (fi[SW]
75  + fi[S]
76  + fi[SE])
77  + 0.5*f.y) * rhoI;
78 }
79 
80 }
81 }
82 
83 
T x
x the value in x direction
Definition: Field.hpp:50
virtual void computeVelocity(const double rho, const std::array< double, 9 > &fi, const Field< double > f, Field< double > &u)
computeVelocity since this operation depends on the force model.
virtual void computeForce(const double tau, const double rho, const Field< double > u, const Field< double > f, std::vector< double > &forcecontribution)
computeForce
T y
y the value in y direction
Definition: Field.hpp:54