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/SchnakenbergD2Q4u.hpp>
28 #include <UtilLib/include/Exception.hpp>
29 #include <UtilLib/include/Log.hpp>
38 const double gamma = 300.0;
45 static std::random_device rd;
46 static std::mt19937 gen(rd());
47 static std::uniform_real_distribution<> dis(-0.01, 0.01);
48 double temp = 0.25 * (1.0 + dis(gen));
49 for (
auto d : cdeDirIter_) {
50 distributions_[d] = temp;
52 deltaT = 20.0 / Parameters.getIterations();
57 for (
auto d : distributions_) {
58 (*stream) <<
'\t' << d;
68 for (
auto d : cdeDirIter_) {
69 (*stream) >> distributions_[d];
74 assert(dir > T && dir < NE);
75 return distributions_[dir];
79 for (
auto &it: this->distributions_) {
85 return std::accumulate(distributions_.begin(), distributions_.end(), 0.0);
90 assert(distributions_[0] == 0.0);
92 const double C =
getC();
98 const double w = C * 0.25;
101 temp[E] = w * (1.0 + 2.0 * u);
102 temp[N] = w * (1.0 + 2.0 * v);
103 temp[W] = w * (1.0 + 2.0 * (-u));
104 temp[S] = w * (1.0 + 2.0 * (-v));
106 const double tauI = 1.0 /
getTau();
107 const std::string schnakenbergD2Q4v =
"SchnakenbergD2Q4v";
109 const double reaktionTerm = 0.25 * deltaT * gamma * (a - C + C * C * Cv);
111 for (
auto d : cdeDirIter_) {
112 double tempD = distributions_[d];
115 distributions_[d] = tempD - tempD * tauI + temp[d] * tauI +
125 const double C =
getC();
130 const double w = C / 4.0;
134 return w * (1.0 + 2.0 * u);
137 return w * (1.0 + 2.0 * v);
140 return w * (1.0 + 2.0 * (-u));
143 return w * (1.0 + 2.0 * (-v));
148 "you want to get a inverse direction of Direction that does not exist");
155 std::swap(distributions_[getInverseDirection(W)],
158 std::swap(distributions_[getInverseDirection(S)],
163 void SchnakenbergD2Q4u::localSwap() {
164 std::swap(distributions_[E], distributions_[W]);
165 std::swap(distributions_[N], distributions_[S]);
171 for (
auto d : cdeDirIter_) {
176 getDomainIdentifier()) ) {
183 std::array<Direction, 4> dir {{NE, NW, SW, SE}
189 getDomainIdentifier()) {
196 LOG(UtilLib::logINFO) <<
197 "the default initialisation failed. Therefore the node was reinitialised from the diagonal directions";
201 "The cde solver failed to reinitialise the node, this might be due to a stange geometry");
203 sumC /=
static_cast<double>(counter);
204 for (
auto d : cdeDirIter_) {
205 distributions_[d] = sumC / 4.0;
210 const std::string SchnakenbergD2Q4u::name =
"SchnakenbergD2Q4u";
217 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
The Base class for all CDESolver implementations This classes uses the recursive template idiom to au...
virtual void collide()
collide The collision step of the LBM
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 initSolver()
initSolver Use this to initalise the solver
unsigned int getDomainIdentifier() const
getter for the Domain Identifier of this node
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
virtual double getC() const =0
getC Calculates the concentration on this node
virtual double calculateEquilibrium(const Direction &dir)
calculateEquilibrium calculates the equilibirum for direction dir
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 advect()
advect The advect step of the LBM
virtual void rescaleDistributions(const double factor)
Rescales all distributions by a factor.
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
virtual double & accessDistribution(const Direction &dir)
accessDistribution Access to the distribution
int getYPos() const
getYPos Getter for the Y position
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...