22 #include <LbmLib/include/nodes/BoundaryNode.hpp>
23 #include <LbmLib/include/nodes/PhysicalNode.hpp>
24 #include <LbmLib/include/GlobalSimulationParameters.hpp>
25 #include <LbmLib/include/solver/BoundaryAbstractSolver.hpp>
26 #include <LbmLib/include/solver/CDESolver/DiracD2Q5.hpp>
27 #include <LbmLib/include/Constants.hpp>
29 #include <UtilLib/include/Exception.hpp>
30 #include <UtilLib/include/Log.hpp>
40 const double pos = 32;
41 constexpr
double D = 0.04;
47 double deltaDiracStart(
double deltaX) {
48 constexpr
double t = 50;
49 return std::exp(-deltaX * deltaX / (4.0 * D * t)) / (4.0 * PI * D * t);
61 for (
auto d : cdeDirIter_) {
62 distributions_[d] = deltaDiracStart(dist) * 0.2;
70 for (
auto d : distributions_) {
71 (*stream) <<
'\t' << d;
81 for (
auto d : cdeDirIter_) {
82 (*stream) >> distributions_[d];
87 assert(dir > T && dir < NE);
88 return distributions_[dir];
92 for (
auto &it: this->distributions_) {
98 return std::accumulate(distributions_.begin(), distributions_.end(), 0.0);
103 assert(distributions_[0] == 0.0);
105 const double C =
getC();
111 const double w0 = C / 3.0;
112 const double w1 = C / 6.0;
113 const double tauI = 1.0 /
getTau();
118 temp[E] = w1 * (1.0 + ux * 3.0);
119 temp[N] = w1 * (1.0 + uy * 3.0);
120 temp[W] = w1 * (1.0 + (-ux) * 3.0);
121 temp[S] = w1 * (1.0 + (-uy) * 3.0);
123 for (
auto d : cdeDirIter_) {
124 double tempD = distributions_[d];
127 distributions_[d] = tempD - tempD * tauI + temp[d] * tauI;
136 const double C =
getC();
141 const double w1 = C / 6.0;
148 return w1 * (1.0 + u * 3.0);
151 return w1 * (1.0 + v * 3.0);
154 return w1 * (1.0 + (-u) * 3.0);
157 return w1 * (1.0 + (-v) * 3.0);
162 "you want to get a inverse direction of a Direction that does not exist");
170 std::swap(distributions_[getInverseDirection(
176 std::swap(distributions_[getInverseDirection(
183 void DiracD2Q5::localSwap() {
184 std::swap(distributions_[E], distributions_[W]);
185 std::swap(distributions_[N], distributions_[S]);
191 for (
auto d : cdeDirIter_) {
196 getDomainIdentifier()) ) {
203 std::array<Direction, 4> dir {{NE, NW, SW, SE}
209 getDomainIdentifier()) {
216 LOG(UtilLib::logINFO) <<
217 "the default initialisation failed. Therefore the node was reinitialised from the diagonal directions";
221 "The cde solver failed to reinitialise the node, this might be due to a stange geometry");
223 sumC /=
static_cast<double>(counter);
224 for (
auto d : cdeDirIter_) {
225 distributions_[d] = sumC / 4.0;
230 const std::string DiracD2Q5::name =
"DiracD2Q5";
237 distributions_(std::array<double,
virtual void advect()
advect The advect step of the LBM
virtual double calculateEquilibrium(const Direction &dir)
calculateEquilibrium calculates the equilibirum for direction dir
virtual void reinitialise()
reinitialise this solver as the corresponding physical node has switched domain
virtual void initSolver()
initSolver Use this to initalise the solver
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 writeSolver(std::ostream *const stream)
writes the solver to the stream
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
The CDEDirectionsIteratorD2Q5 class Provides methods to handle the Directions. Use the Function Direc...
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 double & accessDistribution(const Direction &dir)
accessDistribution Access to the distribution
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 void collide()
collide The collision step of the LBM
BoundaryNode * getBoundaryNeighbour(const Direction &d) const
getBoundaryNeighbour Getter method to access the Boundary Neighbour
virtual double getC() const
getC Calculates the concentration on this node
int getYPos() const
getYPos Getter for the Y position
virtual void loadSolver(std::stringstream *const stream)
loads the solver from the stream
solver::CDEAbstractSolver & getCDESolver(size_t id) const
getCDESolver Getter method for the cde Solver
T y
y the value in y direction