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/SchnakenbergD2Q4v.hpp>
28 #include <UtilLib/include/Exception.hpp>
29 #include <UtilLib/include/Log.hpp>
38 const double gamma = 300.0;
46 static std::random_device rd;
47 static std::mt19937 gen(rd());
48 static std::uniform_real_distribution<> dis(-0.01, 0.01);
49 double temp = 0.25 * (1.0 + dis(gen));
50 for (
auto d : cdeDirIter_) {
51 distributions_[d] = temp;
53 deltaT = 20.0 / Parameters.getIterations();
58 for (
auto d : distributions_) {
59 (*stream) <<
'\t' << d;
69 for (
auto d : cdeDirIter_) {
70 (*stream) >> distributions_[d];
75 assert(dir > T && dir < NE);
76 return distributions_[dir];
80 for (
auto &it: this->distributions_) {
86 return std::accumulate(distributions_.begin(), distributions_.end(), 0.0);
91 assert(distributions_[0] == 0.0);
93 const double C =
getC();
99 const double w = C * 0.25;
102 temp[E] = w * (1.0 + 2.0 * u);
103 temp[N] = w * (1.0 + 2.0 * v);
104 temp[W] = w * (1.0 + 2.0 * (-u));
105 temp[S] = w * (1.0 + 2.0 * (-v));
107 const double tauI = 1.0 /
getTau();
109 const double reaktionTerm = 0.25 * deltaT * gamma * (b - Cu * Cu * C);
110 for (
auto d : cdeDirIter_) {
111 double tempD = distributions_[d];
114 distributions_[d] = tempD - tempD * tauI + temp[d] * tauI +
124 const double C =
getC();
129 const double w = C * 0.25;
133 return w * (1.0 + 2.0 * u);
136 return w * (1.0 + 2.0 * v);
139 return w * (1.0 + 2.0 * (-u));
142 return w * (1.0 + 2.0 * (-v));
147 "you want to get a inverse direction of Direction that does not exist");
154 std::swap(distributions_[getInverseDirection(W)],
157 std::swap(distributions_[getInverseDirection(S)],
162 void SchnakenbergD2Q4v::localSwap() {
163 std::swap(distributions_[E], distributions_[W]);
164 std::swap(distributions_[N], distributions_[S]);
170 for (
auto d : cdeDirIter_) {
175 getDomainIdentifier()) ) {
182 std::array<Direction, 4> dir {{NE, NW, SW, SE}
188 getDomainIdentifier()) {
195 LOG(UtilLib::logINFO) <<
196 "the default initialisation failed. Therefore the node was reinitialised from the diagonal directions";
200 "The cde solver failed to reinitialise the node, this might be due to a stange geometry");
202 sumC /=
static_cast<double>(counter);
203 for (
auto d : cdeDirIter_) {
204 distributions_[d] = sumC * 0.25;
209 const std::string SchnakenbergD2Q4v::name =
"SchnakenbergD2Q4v";
216 distributions_(std::array<double,
solver::CDEAbstractSolver & getCDESolverSlow(const std::string &name) const
getCDESolverSlow Getter method for the cde Solver
virtual void reinitialise()
reinitialise this solver as the corresponding physical node has switched domain
virtual void collide()
collide The collision step of the LBM
virtual void loadSolver(std::stringstream *const stream)
loads the solver from the stream
The Base class for all CDESolver implementations This classes uses the recursive template idiom to au...
size_t solverID_
solverID_ The ID of the solver instance. Coincides with the index in the vector PhysicalNode::cdeSolv...
virtual void initSolver()
initSolver Use this to initalise the solver
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 advect()
advect The advect step of the LBM
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
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 rescaleDistributions(const double factor)
Rescales all distributions by a factor.
solver::CDEAbstractSolver & getCDESolver(size_t id) const
getCDESolver Getter method for the cde Solver
virtual double calculateEquilibrium(const Direction &dir)
calculateEquilibrium calculates the equilibirum for direction dir
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...