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/DiracD2Q4.hpp>
27 #include <LbmLib/include/Constants.hpp>
29 #include <UtilLib/include/Exception.hpp>
30 #include <UtilLib/include/Log.hpp>
39 const double pos = 32;
40 constexpr
double D = 0.04;
46 double deltaDiracStart(
double deltaX) {
47 constexpr
double t = 50;
48 return std::exp(-deltaX * deltaX / (4.0 * D * t)) / (4.0 * PI * D * t);
60 for (
auto d : cdeDirIter_) {
61 distributions_[d] = deltaDiracStart(dist) * 0.25;
69 for (
auto d : distributions_) {
70 (*stream) <<
'\t' << d;
80 for (
auto d : cdeDirIter_) {
81 (*stream) >> distributions_[d];
86 assert(dir > T && dir < NE);
87 return distributions_[dir];
91 for (
auto &it: this->distributions_) {
97 return std::accumulate(distributions_.begin(), distributions_.end(), 0.0);
102 assert(distributions_[0] == 0.0);
104 const double C =
getC();
110 const double w = C * 0.25;
113 temp[E] = w * (1.0 + 2.0 * u);
114 temp[N] = w * (1.0 + 2.0 * v);
115 temp[W] = w * (1.0 + 2.0 * (-u));
116 temp[S] = w * (1.0 + 2.0 * (-v));
118 const double tauI = 1.0 /
getTau();
120 for (
auto d : cdeDirIter_) {
121 double tempD = distributions_[d];
124 distributions_[d] = tempD - tempD * tauI + temp[d] * tauI;
133 const double C =
getC();
138 const double w = C / 4.0;
142 return w * (1.0 + 2.0 * u);
145 return w * (1.0 + 2.0 * v);
148 return w * (1.0 + 2.0 * (-u));
151 return w * (1.0 + 2.0 * (-v));
156 "you want to get a inverse direction of Direction that does not exist");
164 std::swap(distributions_[getInverseDirection(
170 std::swap(distributions_[getInverseDirection(
177 void DiracD2Q4::localSwap() {
178 std::swap(distributions_[E], distributions_[W]);
179 std::swap(distributions_[N], distributions_[S]);
185 for (
auto d : cdeDirIter_) {
190 getDomainIdentifier()) ) {
197 std::array<Direction, 4> dir {{NE, NW, SW, SE}
203 getDomainIdentifier()) {
210 LOG(UtilLib::logINFO) <<
211 "the default initialisation failed. Therefore the node was reinitialised from the diagonal directions";
215 "The cde solver failed to reinitialise the node, this might be due to a stange geometry");
217 sumC /=
static_cast<double>(counter);
218 for (
auto d : cdeDirIter_) {
219 distributions_[d] = sumC / 4.0;
224 const std::string DiracD2Q4::name =
"DiracD2Q4";
231 distributions_(std::array<double,
virtual double & accessDistribution(const Direction &dir)
accessDistribution Access to the distribution
The Base class for all CDESolver implementations This classes uses the recursive template idiom to au...
virtual void loadSolver(std::stringstream *const stream)
loads the solver from the stream
virtual void rescaleDistributions(const double factor)
Rescales all distributions by a factor.
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
T x
x the value in x direction
virtual double & accessDistribution(const Direction &dir)=0
accessDistribution Access to the distribution
virtual void collide()
collide The collision step of the LBM
unsigned int getDomainIdentifier() const
getter for the Domain Identifier of this node
virtual void initSolver()
initSolver Use this to initalise the solver
virtual double getC() const =0
getC Calculates the concentration on this node
virtual double getC() const
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 calculateEquilibrium(const Direction &dir)
calculateEquilibrium calculates the equilibirum for direction dir
BoundaryNode * getBoundaryNeighbour(const Direction &d) const
getBoundaryNeighbour Getter method to access the Boundary Neighbour
virtual void advect()
advect The advect step of the LBM
int getYPos() const
getYPos Getter for the Y position
virtual void writeSolver(std::ostream *const stream)
writes the solver to the stream
solver::CDEAbstractSolver & getCDESolver(size_t id) const
getCDESolver Getter method for the cde Solver
T y
y the value in y direction
The CDEDirectionsIteratorD2Q4 class Provides methods to handle the Directions. Use the Function Direc...