22 #include <LbmLib/include/GlobalSimulationParameters.hpp>
23 #include <LbmLib/include/nodes/BoundaryNode.hpp>
24 #include <LbmLib/include/nodes/PhysicalNode.hpp>
25 #include <LbmLib/include/solver/BoundaryAbstractSolver.hpp>
26 #include <LbmLib/include/solver/CDESolver/CDESolverD2Q5.hpp>
27 #include <UtilLib/include/Exception.hpp>
28 #include <UtilLib/include/Log.hpp>
38 distributions_[T] = 1.0;
47 for (
auto d : cdeDirIter_) {
48 (*stream) >> distributions_[d];
54 for (
auto d : distributions_) {
55 (*stream) <<
'\t' << 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);
78 const double C =
getC();
84 const double w0 = C / 3.0;
85 const double w1 = C / 6.0;
86 const double tauI = 1.0 /
getTau();
91 temp[E] = w1 * (1.0 + ux * 3.0);
92 temp[N] = w1 * (1.0 + uy * 3.0);
93 temp[W] = w1 * (1.0 + (-ux) * 3.0);
94 temp[S] = w1 * (1.0 + (-uy) * 3.0);
97 for (
auto d : cdeDirIter_) {
98 double tempD = distributions_[d];
101 distributions_[d] = tempD - tempD * tauI + temp[d] * tauI;
110 const double C =
getC();
115 const double w1 = C / 6.0;
122 return w1 * (1.0 + u * 3.0);
125 return w1 * (1.0 + v * 3.0);
128 return w1 * (1.0 + (-u) * 3.0);
131 return w1 * (1.0 + (-v) * 3.0);
136 "you want to get a inverse direction of a Direction that does not exist");
143 std::swap(distributions_[getInverseDirection(W)],
146 std::swap(distributions_[getInverseDirection(S)],
151 void CDESolverD2Q5::localSwap() {
152 std::swap(distributions_[E], distributions_[W]);
153 std::swap(distributions_[N], distributions_[S]);
163 std::array<Direction, 4> dir1 {{E, N, W, S}};
164 for (
auto d : dir1) {
176 std::array<Direction, 4> dir2 {{NE, NW, SW, SE}};
177 for (
auto d : dir2) {
188 std::stringstream message;
189 message << std::setprecision(12);
190 message <<
"Default initialisation on PhysicalNode ";
192 message <<
" failed. Therefore the node was reinitialised from the diagonal directions";
193 LOG(UtilLib::logINFO) << message.str().c_str();
198 std::stringstream message;
199 message << std::setprecision(12);
200 message <<
"Initialization on PhysicalNode ";
202 message <<
" failed at time ";
203 message << Parameters.getCurrentIteration();
204 message <<
". Therefore the node was NOT INITIALIZED.";
206 message <<
". DirectNeighbor(domainID): {";
208 std::array<Direction, 8> dir3 {{E, N, W, S, NE, NW, SW, SE}};
209 for (
auto d : dir3) {
220 LOG(UtilLib::logINFO) << message.str().c_str();
223 sumC /=
static_cast<double>(counter);
224 for (
auto d : cdeDirIter_) {
225 this->distributions_[d] = sumC / 5.0;
231 distributions_(std::array<double,
232 5> {{0.0, 0.0, 0.0, 0.0, 0.0}
238 const std::string CDESolverD2Q5::name =
"CDESolverD2Q5";
240 CDEDirectionsIteratorD2Q5
const CDESolverD2Q5::cdeDirIter_ =
241 CDEDirectionsIteratorD2Q5();
virtual void loadSolver(std::stringstream *const stream)
loads the solver from the file
The Base class for all CDESolver implementations This classes uses the recursive template idiom to au...
virtual double getC() const
getC Calculates the concentration on this node
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
T x
x the value in x direction
virtual void initSolver()
initSolver Use this to initalise the solver
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 collide()
collide The collision 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
BoundaryNode * getBoundaryNeighbour(const Direction &d) const
getBoundaryNeighbour Getter method to access the Boundary Neighbour
int getYPos() const
getYPos Getter for the Y position
virtual void reinitialise()
reinitialise this solver iff the corresponding physical node has switched domain
virtual void writeSolver(std::ostream *const stream)
writes the solver to the file
virtual double calculateEquilibrium(const Direction &dir)
calculateEquilibrium calculates the equilibirum for direction dir
solver::CDEAbstractSolver & getCDESolver(size_t id) const
getCDESolver Getter method for the cde Solver
virtual void rescaleDistributions(const double factor)
Rescales all distributions by a factor.
virtual void advect()
advect The advect step of the LBM
virtual double & accessDistribution(const Direction &dir)
accessDistribution Access to the distribution
T y
y the value in y direction