LBIBCell
 All Classes Functions Variables Friends Pages
MassAbstractSolver.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 MASSABSTRACTSOLVER_HPP
23 #define MASSABSTRACTSOLVER_HPP
24 #include <LbmLib/include/solver/MassSolver/MassSolverFactory.hpp>
25 #include <array>
26 #include <string>
27 #include <vector>
28 
29 namespace LbmLib {
30 namespace nodes {
31 class PhysicalNode;
32 }
33 namespace solver {
39  public:
43  virtual ~MassAbstractSolver() {}
44 
49  virtual void calculateMass(
50  const std::vector<std::vector<nodes::PhysicalNode*> >& fluidGrid) =
51  0;
52 
57  virtual std::string getName() = 0;
58 
59  protected:
64 };
65 
76 template <class T>
78  public:
83  std::string getName() {
84  return T::name;
85  }
86 
87  protected:
92  reg = reg; // force specialization
93  }
94 
98  virtual ~BaseMassSolver() {}
99 
108  return new T;
109  }
110 
114  static bool reg;
119  static bool init() {
120  return MassSolverFactory::instance().registerType(T::name,
122  }
123 };
124 
125 template <class T>
126 bool BaseMassSolver<T>::reg = BaseMassSolver<T>::init();
127 }
128 } // end namespace
129 
130 #endif // MASSABSTRACTSOLVER_HPP
static MassAbstractSolver * create()
create Static constructor. A pointer to this function along with the name of the algorithm is registe...
virtual std::string getName()=0
Get the name of the solver.
The Base class for all Mass Solvers implementations This classes uses the recursive template idiom to...
static T & instance()
Definition: Singleton.hpp:90
static bool init()
init Registers the class in the Solver Factory
static bool reg
reg True if registration was successful
virtual void calculateMass(const std::vector< std::vector< nodes::PhysicalNode * > > &fluidGrid)=0
the virtual method which calculates the masses on the Geometry Nodes
virtual ~BaseMassSolver()
~BaseMassSolver virtual Destructor
The MassAbstractSolver class The abstract base class for all Mass Solvers.
MassAbstractSolver()
protected Constructor only use create method for instantiation
BaseMassSolver()
BaseMassSolver The Constructor which enforces that the specialisation is done.
virtual ~MassAbstractSolver()
~MassAbstractSolver virtual Destructor