LBIBCell
 All Classes Functions Variables Friends Pages
FluidSolver.hpp
1 /* Copyright (c) 2012 David Sichau <mail"at"sichau"dot"eu>
2 
3  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the
4  "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish,
5  distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to
6  the following conditions:
7 
8  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9 
10  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
11  LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
12  NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
13  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
14  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15  */
16 #ifndef FLUIDSOLVER_HPP
17 #define FLUIDSOLVER_HPP
18 
19 #include <LbmLib/include/Field.hpp>
20 #include <LbmLib/include/solver/AbstractSolver.hpp>
21 #include <array>
22 #include <string>
23 namespace LbmLib {
24 namespace nodes {
25 class PhysicalNode;
26 }
27 
28 namespace solver {
32 class FluidSolver : public AbstractSolver {
33  public:
38  explicit FluidSolver(const nodes::PhysicalNode& physicalNode);
43 
48  virtual void loadSolver(std::stringstream* const stream);
49 
54  virtual void writeSolver(std::ostream* const stream);
55 
59  virtual void collide();
60 
64  virtual void advect();
65 
71  virtual double& accessDistribution(const Direction& dir);
72 
77  virtual void rescaleDistributions(const double factor);
78 
83  double getRho() const;
84 
89  const Field<double>& getVelocity() const;
90 
95  void setVelocity(Field<double> velocity);
96 
100  virtual void initSolver();
101 
107  void addForce(Field<double> f);
108 
113  void resetForce();
114 
119  void addMass(double mass);
120 
121  private:
125  void initWithVelocity();
126 
130  void localSwap();
131 
135  const nodes::PhysicalNode& physicalNode_;
139  std::array<double, 9> distributions_;
143  Field<double> velocity_;
147  Field<double> force_;
151  bool velocityInit_;
155  static const DirectionIterator dirIter_;
159  double rhoToAdd_;
160 };
161 }
162 } // end namespace
163 #endif // FLUIDSOLVER_HPP
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
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:42