22 #include <LbmLib/include/nodes/BoundaryNode.hpp>
23 #include <LbmLib/include/nodes/PhysicalNode.hpp>
24 #include <LbmLib/include/solver/BoundaryAbstractSolver.hpp>
25 #include <LbmLib/include/solver/CDESolver/CDESolverD2Q4.hpp>
27 #include <UtilLib/include/Exception.hpp>
28 #include <UtilLib/include/Log.hpp>
44 for (
auto d : distributions_) {
45 (*stream) <<
'\t' << d;
55 for (
auto d : cdeDirIter_) {
56 (*stream) >> distributions_[d];
61 assert(dir > T && dir < NE);
62 return distributions_[dir];
66 for (
auto &it: this->distributions_) {
72 return std::accumulate(distributions_.begin(), distributions_.end(), 0.0);
77 assert(distributions_[0] == 0.0);
79 const double C =
getC();
85 const double w = C / 4.0;
86 const double tauI = 1.0/
getTau();
89 temp[E] = w * (1.0 + 2.0 * u);
90 temp[N] = w * (1.0 + 2.0 * v);
91 temp[W] = w * (1.0 + 2.0 * (-u));
92 temp[S] = w * (1.0 + 2.0 * (-v));
94 for (
auto d : cdeDirIter_) {
95 double tempD = distributions_[d];
98 distributions_[d] = tempD - tempD * tauI + temp[d] * tauI;
107 const double C =
getC();
112 const double w = C / 4.0;
116 return w * (1.0 + 2.0 * u);
119 return w * (1.0 + 2.0 * v);
122 return w * (1.0 + 2.0 * (-u));
125 return w * (1.0 + 2.0 * (-v));
130 "you want to get a inverse direction of Direction that does not exist");
137 std::swap(distributions_[getInverseDirection(W)],
140 std::swap(distributions_[getInverseDirection(S)],
145 void CDESolverD2Q4::localSwap() {
146 std::swap(distributions_[E], distributions_[W]);
147 std::swap(distributions_[N], distributions_[S]);
153 for (
auto d : cdeDirIter_) {
158 getDomainIdentifier()) ) {
165 std::array<Direction, 4> dir {{NE, NW, SW, SE}
171 getDomainIdentifier()) {
178 LOG(UtilLib::logINFO) <<
179 "the default initialisation failed. Therefore the node was reinitialised from the diagonal directions";
183 "The cde solver failed to reinitialise the node, this might be due to a stange geometry");
185 sumC /=
static_cast<double>(counter);
186 for (
auto d : cdeDirIter_) {
187 distributions_[d] = sumC / 4.0;
192 const std::string CDESolverD2Q4::name =
"CDESolverD2Q4";
199 distributions_(std::array<double,
200 5> {{0.0, 0.0, 0.0, 0.0, 0.0}
virtual double calculateEquilibrium(const Direction &dir)
calculateEquilibrium calculates the equilibirum for direction dir
virtual void rescaleDistributions(const double factor)
Rescales all distributions by a factor.
The Base class for all CDESolver implementations This classes uses the recursive template idiom to au...
virtual void reinitialise()
reinitialise this solver as the corresponding physical node has switched domain
size_t solverID_
solverID_ The ID of the solver instance. Coincides with the index in the vector PhysicalNode::cdeSolv...
PhysicalNode * getPhysicalNeighbour(const Direction &d) const
getPhysicalNeighbour Getter method to access the Physical Neighbour
const nodes::PhysicalNode * physicalNode_
physicalNode_ The physical Node which owns this solver
virtual double & accessDistribution(const Direction &dir)
accessDistribution Access to the distribution
T x
x the value in x direction
virtual double & accessDistribution(const Direction &dir)=0
accessDistribution Access to the distribution
unsigned int getDomainIdentifier() const
getter for the Domain Identifier of this node
virtual void advect()
advect The advect step of the LBM
virtual double getC() const =0
getC Calculates the concentration on this node
const Field< double > & getVelocity() const
getVelocity Returns the current velocity of the fluid
double getTau() const
getTau Getter method for the tau parameter
const solver::FluidSolver & getFluidSolver() const
getFluidSolver Const getter method for the fluid Solver
int getXPos() const
getXPos Getter for the X position
virtual double getC() const
getC Calculates the concentration on this node
BoundaryNode * getBoundaryNeighbour(const Direction &d) const
getBoundaryNeighbour Getter method to access the Boundary Neighbour
virtual void initSolver()
initSolver Use this to initalise the solver
int getYPos() const
getYPos Getter for the Y position
virtual void collide()
collide The collision step of the LBM
solver::CDEAbstractSolver & getCDESolver(size_t id) const
getCDESolver Getter method for the cde Solver
virtual void loadSolver(std::stringstream *const stream)
loads the solver from the stream
virtual void writeSolver(std::ostream *const stream)
writes the solver to the stream
T y
y the value in y direction
The CDEDirectionsIteratorD2Q4 class Provides methods to handle the Directions. Use the Function Direc...