LBIBCell
 All Classes Functions Variables Friends Pages
FluidSolver.hpp
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 #ifndef FLUIDSOLVER_HPP
23 #define FLUIDSOLVER_HPP
24 
25 #include <LbmLib/include/Field.hpp>
26 #include <LbmLib/include/solver/AbstractSolver.hpp>
27 #include <LbmLib/include/solver/FluidSolver/BaseForceModel.hpp>
28 #include <LbmLib/include/solver/FluidSolver/GuoZhengShi2002ForceModel.hpp>
29 #include <LbmLib/include/solver/FluidSolver/Luo1993ForceModel.hpp>
30 #include <array>
31 #include <string>
32 namespace LbmLib {
33 namespace nodes {
34 class PhysicalNode;
35 }
36 
37 namespace solver {
41 class FluidSolver : public AbstractSolver, private /*GuoZhengShi2002ForceModel*/ Luo1993ForceModel {
42  public:
47  explicit FluidSolver(const nodes::PhysicalNode& physicalNode);
52 
57  virtual void loadSolver(std::stringstream* const stream);
58 
63  virtual void writeSolver(std::ostream* const stream);
64 
68  virtual void collide();
69 
73  virtual void advect();
74 
80  virtual double& accessDistribution(const Direction& dir);
81 
86  virtual void rescaleDistributions(const double factor);
87 
92  double getRho() const;
93 
98  const Field<double>& getVelocity() const;
99 
104  void setVelocity(Field<double> velocity);
105 
109  virtual void initSolver();
110 
116  void addForce(Field<double> f);
117 
122  void resetForce();
123 
128  void addMass(double mass);
129 
130  private:
134  void initWithVelocity();
135 
139  void localSwap();
140 
144  const nodes::PhysicalNode& physicalNode_;
148  std::array<double, 9> distributions_;
152  Field<double> velocity_;
156  Field<double> force_;
160  bool velocityInit_;
164  static const DirectionIterator dirIter_;
168  double rhoToAdd_;
169 };
170 
171 
172 }
173 } // end namespace
174 #endif // FLUIDSOLVER_HPP
the base class of the cde and fluid solvers
void setVelocity(Field< double > velocity)
setVelocity Sets the velocity of this fluid Algorithm. Should only be used for initialisation.
void addForce(Field< double > f)
adds f to the current force
virtual void writeSolver(std::ostream *const stream)
writes the solver to the file
FluidSolver(const nodes::PhysicalNode &physicalNode)
FluidSolver Initialises the fluid solver.
virtual double & accessDistribution(const Direction &dir)
accessDistribution Access to the distribution
void addMass(double mass)
addMass The mass which is added to this fluid solver
class representing a physical node
virtual void initSolver()
initSolver Use this to initalise the solver
Definition: FluidSolver.cpp:50
double getRho() const
getRho Calculates the Rho
the Fluid Solver which solves the D2Q9 LBGK
Definition: FluidSolver.hpp:41
The Luo1993ForceModel class implements the force model presented in Luo, Lattice-Gas Automata and Lat...
void resetForce()
resets the force on this fluid solver to 0
virtual void rescaleDistributions(const double factor)
Rescales all distributions by a factor.
const Field< double > & getVelocity() const
getVelocity Returns the current velocity of the fluid
virtual void loadSolver(std::stringstream *const stream)
loads the solver from the file
virtual void advect()
advect The advect step of the LBM
virtual void collide()
collide The collision step of the LBM
The DirectionOperations_ class Provides methods to handle the Directions. Use the Function Directions...
Definition: Direction.hpp:57
~FluidSolver()
~FluidSolver Destructor non virtual to avoid inheritance
Definition: FluidSolver.hpp:51