Loading...
Searching...
No Matches
SPHSolver2.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_SPH_SOLVER2_HPP
12#define CUBBYFLOW_SPH_SOLVER2_HPP
13
16
17namespace CubbyFlow
18{
33{
34 public:
35 class Builder;
36
39
44
46 SPHSolver2(const SPHSolver2&) = delete;
47
50
53
56
59
62
71
74
84
87
90
93
101
104
113
122
131
134
137
138 protected:
141 double timeIntervalInSeconds) const override;
142
145
148
151
155
159
162
168
172
175
176 private:
178 double m_eosExponent = 7.0;
179
182 double m_negativePressureScale = 0.0;
183
185 double m_viscosityCoefficient = 0.01;
186
190 double m_pseudoViscosityCoefficient = 10.0;
191
195 double m_speedOfSound = 100.0;
196
198 double m_timeStepLimitScale = 1.0;
199};
200
203
209{
210 public:
213
216
219 double relativeKernelRadius);
220
221 protected:
222 double m_targetDensity = WATER_DENSITY;
223 double m_targetSpacing = 0.1;
224 double m_relativeKernelRadius = 1.8;
225};
226
227template <typename T>
229{
230 m_targetDensity = targetDensity;
231 return static_cast<T&>(*this);
232}
233
234template <typename T>
236{
237 m_targetSpacing = targetSpacing;
238 return static_cast<T&>(*this);
239}
240
241template <typename T>
244{
245 m_relativeKernelRadius = relativeKernelRadius;
246 return static_cast<T&>(*this);
247}
248
253{
254 public:
257
260};
261} // namespace CubbyFlow
262
263#endif
Generic N-dimensional array class interface.
Definition ArrayView.hpp:26
Definition Matrix.hpp:30
Basic 2-D particle system solver.
Definition ParticleSystemSolver2.hpp:37
Front-end to create SPHSolver2 objects step by step.
Definition SPHSolver2.hpp:253
SPHSolver2Ptr MakeShared() const
Builds shared pointer of SPHSolver2 instance.
SPHSolver2 Build() const
Builds SPHSolver2.
2-D SPH solver.
Definition SPHSolver2.hpp:33
void SetViscosityCoefficient(double newViscosityCoefficient)
Sets the viscosity coefficient.
unsigned int GetNumberOfSubTimeSteps(double timeIntervalInSeconds) const override
Returns the number of sub-time-steps.
double GetViscosityCoefficient() const
Returns the viscosity coefficient.
void OnEndAdvanceTimeStep(double timeStepInSeconds) override
Performs post-processing step before the simulation.
void ComputePseudoViscosity(double timeStepInSeconds)
Computes pseudo viscosity.
void SetSpeedOfSound(double newSpeedOfSound)
Sets the speed of sound.
SPHSolver2(SPHSolver2 &&) noexcept=delete
Deleted move constructor.
double GetEosExponent() const
Returns the exponent part of the equation-of-state.
void ComputePressure()
Computes the pressure.
double GetPseudoViscosityCoefficient() const
Returns the pseudo viscosity coefficient.
SPHSolver2(double targetDensity, double targetSpacing, double relativeKernelRadius)
void SetPseudoViscosityCoefficient(double newPseudoViscosityCoefficient)
Sets the pseudo viscosity coefficient.
void SetNegativePressureScale(double newNegativePressureScale)
Sets the negative pressure scale.
void AccumulateForces(double timeStepInSeconds) override
Accumulates the force to the forces array in the particle system.
void SetEosExponent(double newEosExponent)
Sets the exponent part of the equation-of-state.
double GetTimeStepLimitScale() const
Multiplier that scales the max allowed time-step.
SPHSolver2()
Constructs a solver with empty particle set.
static Builder GetBuilder()
Returns builder fox SPHSolver2.
void OnBeginAdvanceTimeStep(double timeStepInSeconds) override
Performs pre-processing step before the simulation.
SPHSystemData2Ptr GetSPHSystemData() const
Returns the SPH system data.
virtual void AccumulatePressureForce(double timeStepInSeconds)
SPHSolver2(const SPHSolver2 &)=delete
Deleted copy constructor.
void SetTimeStepLimitScale(double newScale)
Sets the multiplier that scales the max allowed time-step.
virtual void AccumulateNonPressureForces(double timeStepInSeconds)
double GetNegativePressureScale() const
Returns the negative pressure scale.
double GetSpeedOfSound() const
Returns the speed of sound.
Base class for SPH-based fluid solver builder.
Definition SPHSolver2.hpp:209
DerivedBuilder & WithTargetDensity(double targetDensity)
Returns builder with target density.
Definition SPHSolver2.hpp:228
DerivedBuilder & WithTargetSpacing(double targetSpacing)
Returns builder with target spacing.
Definition SPHSolver2.hpp:235
DerivedBuilder & WithRelativeKernelRadius(double relativeKernelRadius)
Returns builder with relative kernel radius.
Definition SPHSolver2.hpp:242
Definition pybind11Utils.hpp:21
constexpr double WATER_DENSITY
Definition Constants.hpp:303
std::shared_ptr< SPHSolver2 > SPHSolver2Ptr
Shared pointer type for the SPHSolver2.
Definition SPHSolver2.hpp:202
std::shared_ptr< SPHSystemData2 > SPHSystemData2Ptr
Shared pointer for the SPHSystemData2 type.
Definition SPHSystemData.hpp:253
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738