LBIBCell
 All Classes Functions Variables Friends Pages
CDEAbstractSolver.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 CDEABSTRACTSOLVER_HPP
23 #define CDEABSTRACTSOLVER_HPP
24 #include <LbmLib/include/solver/AbstractSolver.hpp>
25 #include <LbmLib/include/solver/CDESolver/CDESolverFactory.hpp>
26 #include <array>
27 #include <string>
28 #include <iostream>
29 
30 namespace LbmLib {
31 namespace nodes {
32 class PhysicalNode;
33 }
34 namespace solver {
40  public:
44  virtual ~CDEAbstractSolver() {}
45 
52  void initCDESolver(
53  const nodes::PhysicalNode* physicalNode,
54  size_t id);
55 
61  virtual double calculateEquilibrium(const Direction& dir) = 0;
62 
67  virtual double getC() const = 0;
68 
72  virtual void reinitialise() = 0;
73 
78  virtual std::string getName() = 0;
79 
84  size_t getId();
85 
86  protected:
95 
99  size_t solverID_;
100 
101  private:
102 };
103 
126 template <class T>
128  public:
133  std::string getName() {
134  return T::name;
135  }
136 
137  protected:
142  reg = reg; // force specialization
143  }
144 
148  virtual ~BaseCDESolver() {}
149 
158  return new T;
159  }
160 
164  static bool reg;
169  static bool init() {
170  return CDESolverFactory::instance().registerType(T::name,
172  }
173 };
174 
175 template <class T>
176 bool BaseCDESolver<T>::reg = BaseCDESolver<T>::init();
177 }
178 } // end namespace
179 
180 #endif // CDEABSTRACTSOLVER_HPP
the base class of the cde and fluid solvers
The abstract base class for all CDESolvers.
static bool reg
reg True if registration was successful
static bool init()
init Registers the class in the Solver Factory
The Base class for all CDESolver implementations This classes uses the recursive template idiom to au...
virtual ~CDEAbstractSolver()
~CDEAbstractSolver virtual Destructor
size_t solverID_
solverID_ The ID of the solver instance. Coincides with the index in the vector PhysicalNode::cdeSolv...
virtual std::string getName()=0
Get the name of the solver.
BaseCDESolver()
BaseCDESolver The Constructor which enforces that the specialisation is done.
const nodes::PhysicalNode * physicalNode_
physicalNode_ The physical Node which owns this solver
static T & instance()
Definition: Singleton.hpp:90
virtual ~BaseCDESolver()
~BaseCDESolver virtual Destructor
class representing a physical node
virtual void reinitialise()=0
reinitialise this solver iff the corresponding physical node has changed domain identifier ...
virtual double getC() const =0
getC Calculates the concentration on this node
static CDEAbstractSolver * create()
Create static constructor. A pointer to this function along with the name of the algorithm is registe...
void initCDESolver(const nodes::PhysicalNode *physicalNode, size_t id)
initCDESolver This connects the Solver with an physical node this should be executed before using thi...
CDEAbstractSolver()
CDEAbstractSolver protected Constructor only use create method for instantiation. ...
virtual double calculateEquilibrium(const Direction &dir)=0
calculateEquilibrium calculates the equilibirum for direction dir
size_t getId()
return the id of this solver