Loading...
Searching...
No Matches
SPHSolver3.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_SOLVER3_HPP
12#define CUBBYFLOW_SPH_SOLVER3_HPP
13
16
17namespace CubbyFlow
18{
33{
34 public:
35 class Builder;
36
39
44
46 SPHSolver3(const SPHSolver3&) = 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 3-D particle system solver.
Definition ParticleSystemSolver3.hpp:37
Front-end to create SPHSolver3 objects step by step.
Definition SPHSolver3.hpp:253
SPHSolver3Ptr MakeShared() const
Builds shared pointer of SPHSolver3 instance.
SPHSolver3 Build() const
Builds SPHSolver3.
3-D SPH solver.
Definition SPHSolver3.hpp:33
double GetEosExponent() const
Returns the exponent part of the equation-of-state.
void ComputePseudoViscosity(double timeStepInSeconds)
Computes pseudo viscosity.
double GetSpeedOfSound() const
Returns the speed of sound.
SPHSolver3(double targetDensity, double targetSpacing, double relativeKernelRadius)
void ComputePressure()
Computes the pressure.
double GetViscosityCoefficient() const
Returns the viscosity coefficient.
virtual void AccumulatePressureForce(double timeStepInSeconds)
void SetNegativePressureScale(double newNegativePressureScale)
Sets the negative pressure scale.
SPHSolver3(SPHSolver3 &&) noexcept=delete
Deleted move constructor.
double GetPseudoViscosityCoefficient() const
Returns the pseudo viscosity coefficient.
void SetEosExponent(double newEosExponent)
Sets the exponent part of the equation-of-state.
double GetTimeStepLimitScale() const
Multiplier that scales the max allowed time-step.
void SetPseudoViscosityCoefficient(double newPseudoViscosityCoefficient)
Sets the pseudo viscosity coefficient.
void SetSpeedOfSound(double newSpeedOfSound)
Sets the speed of sound.
unsigned int GetNumberOfSubTimeSteps(double timeIntervalInSeconds) const override
Returns the number of sub-time-steps.
SPHSolver3(const SPHSolver3 &)=delete
Deleted copy constructor.
void OnBeginAdvanceTimeStep(double timeStepInSeconds) override
Performs pre-processing step before the simulation.
void OnEndAdvanceTimeStep(double timeStepInSeconds) override
Performs post-processing step before the simulation.
void AccumulateForces(double timeStepInSeconds) override
Accumulates the force to the forces array in the particle system.
static Builder GetBuilder()
Returns builder fox SPHSolver3.
void SetViscosityCoefficient(double newViscosityCoefficient)
Sets the viscosity coefficient.
SPHSystemData3Ptr GetSPHSystemData() const
Returns the SPH system data.
SPHSolver3()
Constructs a solver with empty particle set.
void SetTimeStepLimitScale(double newScale)
Sets the multiplier that scales the max allowed time-step.
double GetNegativePressureScale() const
Returns the negative pressure scale.
virtual void AccumulateNonPressureForces(double timeStepInSeconds)
Base class for SPH-based fluid solver builder.
Definition SPHSolver3.hpp:209
DerivedBuilder & WithTargetDensity(double targetDensity)
Returns builder with target density.
Definition SPHSolver3.hpp:228
DerivedBuilder & WithRelativeKernelRadius(double relativeKernelRadius)
Returns builder with relative kernel radius.
Definition SPHSolver3.hpp:242
DerivedBuilder & WithTargetSpacing(double targetSpacing)
Returns builder with target spacing.
Definition SPHSolver3.hpp:235
Definition pybind11Utils.hpp:21
std::shared_ptr< SPHSystemData3 > SPHSystemData3Ptr
Shared pointer for the SPHSystemData3 type.
Definition SPHSystemData.hpp:256
constexpr double WATER_DENSITY
Definition Constants.hpp:303
std::shared_ptr< SPHSolver3 > SPHSolver3Ptr
Shared pointer type for the SPHSolver3.
Definition SPHSolver3.hpp:202
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738