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/tutorial_01_CDESolverD2Q5_SIGNAL.hpp>
27 #include <UtilLib/include/Exception.hpp>
28 #include <UtilLib/include/Log.hpp>
39 const double deltaT = 1.0;
40 const unsigned int SWITCHOFF_TIME = 5000;
41 const double SIGNAL_decay = 0.00001;
42 const double SIGNAL_production = 0.0001;
43 const double SIGNAL_initalcondition = 1.0;
48 for (
auto d : cdeDirIter_) {
49 distributions_[d] = 0.0;
53 for (
auto d : cdeDirIter_) {
54 distributions_[d] = SIGNAL_initalcondition/5.0;
61 for (
auto d : distributions_) {
62 (*stream) <<
'\t' << d;
72 for (
auto d : cdeDirIter_) {
73 (*stream) >> distributions_[d];
78 assert(dir > T && dir < NE);
79 return distributions_[dir];
83 for (
auto &it: this->distributions_) {
89 return std::accumulate(distributions_.begin(), distributions_.end(), 0.0);
95 return SIGNAL_production;
98 return -SIGNAL_decay*this->
getC();
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 const double reactionTerm = this->
reaction();
124 const double reactionTerm_ZERO = deltaT*reactionTerm / 3.0;
125 const double reactionTerm_OTHERS = deltaT*reactionTerm / 6.0;
127 distributions_[T] = distributions_[T] - distributions_[T] * tauI + temp[T] * tauI + reactionTerm_ZERO;
128 distributions_[E] = distributions_[E] - distributions_[E] * tauI + temp[E] * tauI + reactionTerm_OTHERS;
129 distributions_[N] = distributions_[N] - distributions_[N] * tauI + temp[N] * tauI + reactionTerm_OTHERS;
130 distributions_[W] = distributions_[W] - distributions_[W] * tauI + temp[W] * tauI + reactionTerm_OTHERS;
131 distributions_[S] = distributions_[S] - distributions_[S] * tauI + temp[S] * tauI + reactionTerm_OTHERS;
138 const double C =
getC();
143 const double w1 = C / 6.0;
150 return w1 * (1.0 + u * 3.0);
153 return w1 * (1.0 + v * 3.0);
156 return w1 * (1.0 + (-u) * 3.0);
159 return w1 * (1.0 + (-v) * 3.0);
164 "you want to get a inverse direction of a Direction that does not exist");
171 std::swap(distributions_[getInverseDirection(W)],
174 std::swap(distributions_[getInverseDirection(S)],
179 void tutorial_01_CDESolverD2Q5_SIGNAL::localSwap() {
180 std::swap(distributions_[E], distributions_[W]);
181 std::swap(distributions_[N], distributions_[S]);
191 std::array<Direction, 4> dir1 {{E, N, W, S}};
192 for (
auto d : dir1) {
204 std::array<Direction, 4> dir2 {{NE, NW, SW, SE}};
205 for (
auto d : dir2) {
216 std::stringstream message;
217 message << std::setprecision(12);
218 message <<
"Default initialisation on PhysicalNode ";
220 message <<
" failed. Therefore the node was reinitialised from the diagonal directions";
221 LOG(UtilLib::logINFO) << message.str().c_str();
228 std::stringstream message;
229 message << std::setprecision(12)
230 <<
"Initialization on PhysicalNode "
232 <<
" failed at time "
233 << Parameters.getCurrentIteration()
234 <<
". Therefore the node was initialized with all neighbors {E,N,W,S}, ignoring their domainID."
236 for (
auto d : dir1) {
242 LOG(UtilLib::logINFO) << message.str().c_str();
245 sumC /=
static_cast<double>(counter);
246 for (
auto d : cdeDirIter_) {
247 this->distributions_[d] = sumC / 5.0;
252 const std::string tutorial_01_CDESolverD2Q5_SIGNAL::name =
"tutorial_01_CDESolverD2Q5_SIGNAL";
258 tutorial_01_CDESolverD2Q5_SIGNAL::tutorial_01_CDESolverD2Q5_SIGNAL() :
BaseCDESolver(),
259 distributions_(std::array<double,
virtual void loadSolver(std::stringstream *const stream)
loads the solver from the stream
virtual void initSolver()
initSolver Use this to initalise the solver
The Base class for all CDESolver implementations This classes uses the recursive template idiom to au...
virtual void advect()
advect The advect step of the LBM
virtual double & accessDistribution(const Direction &dir)
accessDistribution Access to the distribution
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...
virtual void rescaleDistributions(const double factor)
Rescales all distributions by a factor.
T x
x the value in x direction
const double reaction(void) const
reaction The reaction term of the tutorial_01_CDESolverD2Q5_SIGNAL solver is implemented here...
virtual void collide()
collide The collision step of the LBM
virtual double & accessDistribution(const Direction &dir)=0
accessDistribution Access to the distribution
virtual void reinitialise()
reinitialise this solver as the corresponding physical node has switched domain
unsigned int getDomainIdentifier() const
getter for the Domain Identifier of this node
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 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
solver::CDEAbstractSolver & getCDESolver(size_t id) const
getCDESolver Getter method for the cde Solver
T y
y the value in y direction