GridSmokeSolver2.hpp
Go to the documentation of this file.
1 // This code is based on Jet framework.
2 // Copyright (c) 2018 Doyub Kim
3 // CubbyFlow is voxel-based fluid simulation engine for computer games.
4 // Copyright (c) 2020 CubbyFlow Team
5 // Core Part: Chris Ohk, Junwoo Hwang, Jihong Sin, Seungwoo Yoo
6 // AI Part: Dongheon Cho, Minseo Kim
7 // We are making my contributions/submissions to this project solely in our
8 // personal capacity and are not conveying any rights to any intellectual
9 // property of any third parties.
10 
11 #ifndef CUBBYFLOW_GRID_SMOKE_SOLVER2_HPP
12 #define CUBBYFLOW_GRID_SMOKE_SOLVER2_HPP
13 
15 
16 namespace CubbyFlow
17 {
30 {
31  public:
32  class Builder;
33 
36 
38  GridSmokeSolver2(const Vector2UZ& resolution, const Vector2D& gridSpacing,
39  const Vector2D& gridOrigin);
40 
42  GridSmokeSolver2(const GridSmokeSolver2&) = delete;
43 
45  GridSmokeSolver2(GridSmokeSolver2&&) noexcept = delete;
46 
48  ~GridSmokeSolver2() override = default;
49 
52 
54  GridSmokeSolver2& operator=(GridSmokeSolver2&&) noexcept = delete;
55 
57  [[nodiscard]] double GetSmokeDiffusionCoefficient() const;
58 
60  void SetSmokeDiffusionCoefficient(double newValue);
61 
63  [[nodiscard]] double GetTemperatureDiffusionCoefficient() const;
64 
66  void SetTemperatureDiffusionCoefficient(double newValue);
67 
81  [[nodiscard]] double GetBuoyancySmokeDensityFactor() const;
82 
96  void SetBuoyancySmokeDensityFactor(double newValue);
97 
111  [[nodiscard]] double GetBuoyancyTemperatureFactor() const;
112 
126  void SetBuoyancyTemperatureFactor(double newValue);
127 
136  [[nodiscard]] double GetSmokeDecayFactor() const;
137 
146  void SetSmokeDecayFactor(double newValue);
147 
156  [[nodiscard]] double GetTemperatureDecayFactor() const;
157 
166  void SetTemperatureDecayFactor(double newValue);
167 
169  [[nodiscard]] ScalarGrid2Ptr GetSmokeDensity() const;
170 
172  [[nodiscard]] ScalarGrid2Ptr GetTemperature() const;
173 
175  [[nodiscard]] static Builder GetBuilder();
176 
177  protected:
178  void OnEndAdvanceTimeStep(double timeIntervalInSeconds) override;
179 
180  void ComputeExternalForces(double timeIntervalInSeconds) override;
181 
182  private:
183  void ComputeDiffusion(double timeIntervalInSeconds);
184 
185  void ComputeBuoyancyForce(double timeIntervalInSeconds);
186 
187  size_t m_smokeDensityDataID = 0;
188  size_t m_temperatureDataID = 0;
189  double m_smokeDiffusionCoefficient = 0.0;
190  double m_temperatureDiffusionCoefficient = 0.0;
191  double m_buoyancySmokeDensityFactor = -0.000625;
192  double m_buoyancyTemperatureFactor = 5.0;
193  double m_smokeDecayFactor = 0.001;
194  double m_temperatureDecayFactor = 0.001;
195 };
196 
198 using GridSmokeSolver2Ptr = std::shared_ptr<GridSmokeSolver2>;
199 
204  : public GridFluidSolverBuilderBase2<Builder>
205 {
206  public:
208  [[nodiscard]] GridSmokeSolver2 Build() const;
209 
211  [[nodiscard]] GridSmokeSolver2Ptr MakeShared() const;
212 };
213 } // namespace CubbyFlow
214 
215 #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.
2-D grid-based smoke solver.
Definition: GridSmokeSolver2.hpp:29
double GetTemperatureDiffusionCoefficient() const
Returns temperature diffusion coefficient.
double GetBuoyancyTemperatureFactor() const
Returns the buoyancy factor which will be multiplied to the temperature.
~GridSmokeSolver2() override=default
Default virtual destructor.
Base class for grid-based fluid solver builder.
Definition: GridFluidSolver2.hpp:315
void SetSmokeDiffusionCoefficient(double newValue)
Sets smoke diffusion coefficient.
GridSmokeSolver2 & operator=(const GridSmokeSolver2 &)=delete
Deleted copy assignment operator.
GridSmokeSolver2()
Default constructor.
double GetSmokeDecayFactor() const
Returns smoke decay factor.
void SetBuoyancyTemperatureFactor(double newValue)
Sets the buoyancy factor which will be multiplied to the temperature.
void SetSmokeDecayFactor(double newValue)
Sets the smoke decay factor.
Definition: Matrix.hpp:27
void SetTemperatureDecayFactor(double newValue)
Sets the temperature decay factor.
Definition: pybind11Utils.hpp:20
std::shared_ptr< ScalarGrid2 > ScalarGrid2Ptr
Shared pointer for the ScalarGrid2 type.
Definition: ScalarGrid.hpp:266
ScalarGrid2Ptr GetSmokeDensity() const
Returns smoke density field.
ScalarGrid2Ptr GetTemperature() const
Returns temperature field.
Front-end to create GridSmokeSolver2 objects step by step.
Definition: GridSmokeSolver2.hpp:203
static Builder GetBuilder()
Returns builder fox GridSmokeSolver2.
Abstract base class for grid-based 2-D fluid solver.
Definition: GridFluidSolver2.hpp:35
std::shared_ptr< GridSmokeSolver2 > GridSmokeSolver2Ptr
Shared pointer type for the GridSmokeSolver2.
Definition: GridSmokeSolver2.hpp:198
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.