Lagrangian Particle Code for The Simulation of 2D/3D Fluid Dynamics
 All Classes Files Functions Variables Typedefs Friends Pages
state.h
Go to the documentation of this file.
1 
16 #ifndef __STATE_H__
17 #define __STATE_H__
18 
19 #include <unordered_map>
20 
21 
41 class State {
42 public:
50  virtual double pressure(double x, double y, double z)=0;
58  virtual double density(double x, double y, double z)=0;
69  virtual void velocity(double x, double y, double z, double& vX, double& vY, double& vZ)=0;
73  virtual ~State() {};
74 };
75 
76 
77 
78 
79 
80 
81 
82 
83 
104 public:
107 
110 
118  virtual double pressure(double x, double y, double z);
119 
127  virtual double density(double x, double y, double z);
128 
139  virtual void velocity(double x, double y, double z, double& vX, double& vY, double& vZ);
140 private:
141  double m_fDen;
142  double m_fVelX, m_fVelY, m_fVelZ;
143  double m_fPCenX, m_fPCenY, m_fPCenZ;
144  double m_fPPeak;
145  double m_fPCoeff;
146 };
147 
148 
149 
150 
151 
152 
153 
175 public:
179  virtual ~UniformVelocityState() {};
180 
188  virtual double pressure(double x, double y, double z);
189 
197  virtual double density(double x, double y, double z);
198 
209  virtual void velocity(double x, double y, double z, double& vX, double& vY, double& vZ);
210 private:
211  double m_fDen;
212  double m_fPressure;
213  double m_fVelocity;
214  double m_fCenX, m_fCenY, m_fCenZ;
215 };
216 
217 
218 
219 
220 
221 
222 
223 
241 public:
245  typedef State* (*StateCreateFunc)();
246 
263  static StateFactory& instance();
264 
285  void registerState(std::string name, StateCreateFunc func);
286 
302  State* createState(std::string name);
303 
304 private:
305  std::unordered_map<std::string, StateCreateFunc> stateTable;
306  StateFactory() {};
307  StateFactory(const StateFactory& other);
308  StateFactory& operator=(const StateFactory& other);
309 
310 };
311 
312 #endif // __STATE_H__
UniformVelocityState()
Constructor.
Definition: state.cpp:41
virtual ~GaussianPressureState()
Destructor.
Definition: state.h:109
virtual double pressure(double x, double y, double z)
Specifies constant pressure as specified in construtor implementation.
Definition: state.cpp:44
The abstract factory class for creating objects in the State family.
Definition: state.h:240
virtual double density(double x, double y, double z)
Specifies a constant value as specified in constructor implementation.
Definition: state.cpp:17
A class that implements the Gaussian pressure state.
Definition: state.h:103
virtual ~State()
Destructor.
Definition: state.h:73
virtual double density(double x, double y, double z)
Specifies a constant value as specified in constructor implementation.
Definition: state.cpp:48
State *(* StateCreateFunc)()
Defines a function pointer pointing to a function which creates objects in the State family...
Definition: state.h:245
virtual ~UniformVelocityState()
Destructor.
Definition: state.h:179
virtual void velocity(double x, double y, double z, double &vX, double &vY, double &vZ)
Specifies uniform velocity as specified in constructor implementation.
Definition: state.cpp:21
virtual double density(double x, double y, double z)=0
Calculates density based on the Cartesian coordinate (x,y,z) of a particle.
virtual void velocity(double x, double y, double z, double &vX, double &vY, double &vZ)
Specifies uniform radial inward velocity with magnitude specified in constructor implementation.
Definition: state.cpp:52
An abstract class for the initialization of the state of fluid objects.
Definition: state.h:41
GaussianPressureState()
Constructor.
Definition: state.cpp:10
static StateFactory & instance()
Returns reference to a Singleton object of class StateFactory.
Definition: state.cpp:75
virtual double pressure(double x, double y, double z)=0
Calculates pressure based on the Cartesian coordinate (x,y,z) of a particle.
A class that implements the uniform velocity state.
Definition: state.h:174
virtual double pressure(double x, double y, double z)
Calculates pressure based on the Cartesian coordinate (x,y,z) of a particle and Gaussian distribution...
Definition: state.cpp:13
virtual void velocity(double x, double y, double z, double &vX, double &vY, double &vZ)=0
Calculates velocity based on the Cartesian coordinate (x,y,z) of a particle.
void registerState(std::string name, StateCreateFunc func)
Registers (links) the state name name with the function func for creating objects in the State family...
Definition: state.cpp:89