LBIBCell
 All Classes Functions Variables Friends Pages
BoundarySolverNoFlux.cpp
1 /* Copyright (c) 2013 David Sichau <mail"at"sichau"dot"eu>
2  * 2013-2015 Simon Tanaka <tanakas"at"gmx"dot"ch>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 #include <LbmLib/include/solver/BoundarySolverNoFlux.hpp>
23 #include <LbmLib/include/solver/CDESolver/CDEAbstractSolver.hpp>
24 
25 #include <LbmLib/include/nodes/BoundaryNode.hpp>
26 #include <LbmLib/include/nodes/PhysicalNode.hpp>
27 #include <utility>
28 #include <algorithm>
29 #include <string>
30 
31 namespace LbmLib {
32 namespace solver {
33 BoundarySolverNoFlux::BoundarySolverNoFlux() : BaseBoundarySolver(),
34  distribution_(0.0)
35 {}
36 
38  for (const auto& s : cdeSolvers_) {
39  const Direction dir = boundaryNode_->getDirectionToNeighbour();
40  if ((dir > T) && (dir < NE)) {
41  std::swap(distribution_,
44  getDirectionToNeighbour()));
45  }
46  }
47 }
48 
50 
52  for (const auto& s : cdeSolvers_) {
53  const double Cf =
55  4.0;
56  const double ux = boundaryNode_->getXVelocity();
57  const double uy = boundaryNode_->getYVelocity();
58  const Direction dir = boundaryNode_->getDirectionToNeighbour();
59 
60  double feq = 0.0;
61  double fneq = 0.0;
62  switch (dir) {
63  case E:
64  feq = Cf * (1 + 2 * ux);
65  fneq =
68  getInverseDirection(dir)) -
70  calculateEquilibrium(dir);
71  distribution_ = feq + fneq;
72  return;
73  break;
74  case N:
75  feq = Cf * (1 + 2 * uy);
76  fneq =
79  getInverseDirection(dir)) -
81  calculateEquilibrium(dir);
82  distribution_ = feq + fneq;
83  return;
84  break;
85  case W:
86  feq = Cf * (1 - 2 * ux);
87  fneq =
90  getInverseDirection(dir)) -
92  calculateEquilibrium(dir);
93  distribution_ = feq + fneq;
94  return;
95  break;
96  case S:
97  feq = Cf * (1 - 2 * uy);
98  fneq =
101  getInverseDirection(dir)) -
103  calculateEquilibrium(dir);
104  distribution_ = feq + fneq;
105  return;
106  break;
107  default:
109  "for the boundary condition only e,n,w and s direction exists there must somewhere be an error");
110  break;
111  }
112  }
113 }
114 
116 
117 double& BoundarySolverNoFlux::accessDistribution(const Direction& dir) {
118  return distribution_;
119 }
120 
121 const std::string BoundarySolverNoFlux::name = "BoundarySolverNoFlux";
122 }
123 } // end namespace
solver::CDEAbstractSolver & getCDESolverSlow(const std::string &name) const
getCDESolverSlow Getter method for the cde Solver
virtual void preAdvect()
preAdvect Executed before the advection step
std::vector< std::string > cdeSolvers_
cdeSolvers_ The cde solver this boundary solver is responsible for.
virtual double & accessDistribution(const Direction &dir)=0
accessDistribution Access to the distribution
PhysicalNode * getPhysicalNeighbour() const
getFluidNeighbour Getter for the Physical neighbour
virtual double & accessDistribution(const Direction &dir)
accessDistribution Access to the distribution
virtual double getC() const =0
getC Calculates the concentration on this node
virtual void advect()
advect The advect step of the LBM
Direction getDirectionToNeighbour() const
getDirectionToNeighbour returns the direction to the next neighbour
virtual void postAdvect()
postAdvect Executed after the advection step
double getXVelocity() const
getXVelocity Getter for x-velocity component
virtual void initSolver()
initSolver Use this to initalise the solver
const nodes::BoundaryNode * boundaryNode_
physicalNode_ The physical Node which owns this solver
double getYVelocity() const
getYVelocity Getter for the y-velocity component