LBIBCell
 All Classes Functions Variables Friends Pages
BoundaryAbstractSolver.hpp
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 #ifndef BOUNDARYABSTRACTSOLVER_HPP
23 #define BOUNDARYABSTRACTSOLVER_HPP
24 #include <LbmLib/include/Direction.hpp>
25 #include <LbmLib/include/solver/BoundarySolverFactory.hpp>
26 #include <array>
27 #include <vector>
28 #include <string>
29 #include <iostream>
30 
31 namespace LbmLib {
32 namespace nodes {
33 class BoundaryNode;
34 }
35 namespace solver {
41  public:
46 
52  void connectBoundaryNode(const nodes::BoundaryNode* boundaryNode);
53 
57  virtual void advect() = 0;
58 
62  virtual void postAdvect() = 0;
63 
67  virtual void preAdvect() = 0;
68 
72  virtual void initSolver() = 0;
73 
78  void connectToCDESolvers(const std::vector<std::string>& cdeSolvers);
79 
85  virtual double& accessDistribution(const Direction& dir) = 0;
86 
87  protected:
99  std::vector<std::string> cdeSolvers_;
100 };
101 
112 template <class T>
114  protected:
119  reg = reg; // force specialization
120  }
121 
125  virtual ~BaseBoundarySolver() {}
126 
135  return new T;
136  }
137 
141  static bool reg;
146  static bool init() {
147  return BoundarySolverFactory::instance().registerType(T::name,
149  }
150 };
151 
152 template <class T>
153 bool BaseBoundarySolver<T>::reg = BaseBoundarySolver<T>::init();
154 }
155 } // end namespace
156 
157 #endif // BOUNDARYABSTRACTSOLVER_HPP
virtual ~BaseBoundarySolver()
~BaseBoundarySolver virtual Destructor
virtual ~BoundaryAbstractSolver()
~BoundaryAbstractSolver virtual Destructor
static bool init()
init Registers the class in the Solver Factory
static bool reg
reg True if registration was successful
std::vector< std::string > cdeSolvers_
cdeSolvers_ The cde solver this boundary solver is responsible for.
The BoundaryAbstractSolver class The abstract base class for all Boundary Solvers.
virtual void advect()=0
advect The advect step of the LBM
void connectBoundaryNode(const nodes::BoundaryNode *boundaryNode)
connectPhysicalNode This connects the Solver with an physical node this should be executed before usi...
static T & instance()
Definition: Singleton.hpp:90
virtual void preAdvect()=0
preAdvect Executed before the advection step
void connectToCDESolvers(const std::vector< std::string > &cdeSolvers)
connectToCDESolvers makes sure that this boundary Solver is executed on all connected CDE Solvers ...
virtual double & accessDistribution(const Direction &dir)=0
accessDistribution Access to the distribution
BaseBoundarySolver()
BaseBoundarySolver The Constructor which enforces that the specialisation is done.
virtual void postAdvect()=0
postAdvect Executed after the advection step
BoundaryAbstractSolver()
CDESolver protected Constructor only use create method for instantiation.
class representing a boundary node
The Base class for all BoundarySolvers implementations This classes uses the recursive template idiom...
virtual void initSolver()=0
initSolver Use this to initalise the solver
const nodes::BoundaryNode * boundaryNode_
physicalNode_ The physical Node which owns this solver
static BoundaryAbstractSolver * create()
create Static constructor. A pointer to this function along with the name of the algorithm is registe...