GridSmokeSolver2.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: GridSmokeSolver2.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 2-D grid-based smoke solver.
6 > Created Time: 2017/08/17
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_GRID_SMOKE_SOLVER2_H
10 #define CUBBYFLOW_GRID_SMOKE_SOLVER2_H
11 
13 
14 namespace CubbyFlow
15 {
28  {
29  public:
30  class Builder;
31 
34 
37  const Size2& resolution,
38  const Vector2D& gridSpacing,
39  const Vector2D& gridOrigin);
40 
42  virtual ~GridSmokeSolver2();
43 
45  double GetSmokeDiffusionCoefficient() const;
46 
48  void SetSmokeDiffusionCoefficient(double newValue);
49 
52 
54  void SetTemperatureDiffusionCoefficient(double newValue);
55 
69  double GetBuoyancySmokeDensityFactor() const;
70 
84  void SetBuoyancySmokeDensityFactor(double newValue);
85 
99  double GetBuoyancyTemperatureFactor() const;
100 
114  void SetBuoyancyTemperatureFactor(double newValue);
115 
124  double GetSmokeDecayFactor() const;
125 
134  void SetSmokeDecayFactor(double newValue);
135 
144  double GetTemperatureDecayFactor() const;
145 
154  void SetTemperatureDecayFactor(double newValue);
155 
158 
161 
163  static Builder GetBuilder();
164 
165  protected:
166  void OnEndAdvanceTimeStep(double timeIntervalInSeconds) override;
167 
168  void ComputeExternalForces(double timeIntervalInSeconds) override;
169 
170  private:
171  size_t m_smokeDensityDataID = 0;
172  size_t m_temperatureDataID = 0;
173  double m_smokeDiffusionCoefficient = 0.0;
174  double m_temperatureDiffusionCoefficient = 0.0;
175  double m_buoyancySmokeDensityFactor = -0.000625;
176  double m_buoyancyTemperatureFactor = 5.0;
177  double m_smokeDecayFactor = 0.001;
178  double m_temperatureDecayFactor = 0.001;
179 
180  void ComputeDiffusion(double timeIntervalInSeconds);
181 
182  void ComputeBuoyancyForce(double timeIntervalInSeconds);
183  };
184 
186  using GridSmokeSolver2Ptr = std::shared_ptr<GridSmokeSolver2>;
187 
191  class GridSmokeSolver2::Builder final : public GridFluidSolverBuilderBase2<GridSmokeSolver2::Builder>
192  {
193  public:
195  GridSmokeSolver2 Build() const;
196 
199  };
200 }
201 
202 #endif
void ComputeExternalForces(double timeIntervalInSeconds) override
Computes the external force terms.
void SetBuoyancySmokeDensityFactor(double newValue)
Sets the buoyancy factor which will be multiplied to the smoke density.
GridSmokeSolver2Ptr MakeShared() const
Builds shared pointer of GridSmokeSolver2 instance.
2-D grid-based smoke solver.
Definition: GridSmokeSolver2.h:27
double GetTemperatureDiffusionCoefficient() const
Returns temperature diffusion coefficient.
double GetBuoyancyTemperatureFactor() const
Returns the buoyancy factor which will be multiplied to the temperature.
Base class for grid-based fluid solver builder.
Definition: GridFluidSolver2.h:303
void SetSmokeDiffusionCoefficient(double newValue)
Sets smoke diffusion coefficient.
GridSmokeSolver2()
Default constructor.
double GetSmokeDecayFactor() const
Returns smoke decay factor.
2-D point class.
Definition: Point2.h:25
void SetBuoyancyTemperatureFactor(double newValue)
Sets the buoyancy factor which will be multiplied to the temperature.
void SetSmokeDecayFactor(double newValue)
Sets the smoke decay factor.
virtual ~GridSmokeSolver2()
Destructor.
void SetTemperatureDecayFactor(double newValue)
Sets the temperature decay factor.
Definition: pybind11Utils.h:24
std::shared_ptr< ScalarGrid2 > ScalarGrid2Ptr
Shared pointer for the ScalarGrid2 type.
Definition: ScalarGrid2.h:179
ScalarGrid2Ptr GetSmokeDensity() const
Returns smoke density field.
ScalarGrid2Ptr GetTemperature() const
Returns temperature field.
Front-end to create GridSmokeSolver2 objects step by step.
Definition: GridSmokeSolver2.h:191
GridSmokeSolver2 Build() const
Builds GridSmokeSolver2.
static Builder GetBuilder()
Returns builder fox GridSmokeSolver2.
Abstract base class for grid-based 2-D fluid solver.
Definition: GridFluidSolver2.h:33
2-D vector class.
Definition: Vector2.h:26
std::shared_ptr< GridSmokeSolver2 > GridSmokeSolver2Ptr
Shared pointer type for the GridSmokeSolver2.
Definition: GridSmokeSolver2.h:186
void OnEndAdvanceTimeStep(double timeIntervalInSeconds) override
Called at the end of a time-step.
void SetTemperatureDiffusionCoefficient(double newValue)
Sets temperature diffusion coefficient.
double GetTemperatureDecayFactor() const
Returns temperature decay factor.
double GetBuoyancySmokeDensityFactor() const
Returns the buoyancy factor which will be multiplied to the smoke density.
double GetSmokeDiffusionCoefficient() const
Returns smoke diffusion coefficient.