|
Fluid Dynamics Library
|
Public Member Functions | |
| FluidSolver (fdl::Grid *grid) | |
| FluidSolver (TiXmlElement &element) | |
| void | step (float dt=0) |
| void | project (float dt) |
| void | applyForces (float dt) |
| void | advect (float dt) |
| void | diffuse (float dt, float rate=0.25f) |
| void | diffuseHeat (float dt, float rate) |
| void | applyViscosity (float dt) |
| void | setCGTolerance (float tol) |
| void | setCGMaxIter (unsigned N) |
| virtual void | fromXML (TiXmlElement &element) |
| virtual TiXmlElement | toXML () |
| virtual void | draw () const |
| const Vector & | getCurlMagnitude () const |
| const Vector & | getDivergence () const |
| const Vector & | getPressure () const |
| fdl::Grid * | getGrid () const |
Protected Member Functions | |
| float | computeMaxTimeStep () const |
| void | axpy_prod (const Vector &x, Vector &y) const |
| void | solvePreconditioner (const Vector &b, Vector &x) |
| void | constructMatrix (float dx, float dt, float rho=0.25f) |
| void | constructPreconditioner (float rho=0.25f, float tau=0.97f) |
| float | cgSolve (const Vector &b, Vector &x) |
| float | pcgSolve (const Vector &b, Vector &x) |
Static Private Member Functions | |
| template<class T > | |
| static void | convolve (const std::vector< double > &kernel, const std::vector< T > &signal, std::vector< T > &output) |
| static std::vector< double > * | gaussianHeatKernel (const int size, double diffusion, float dt) |
Private Attributes | |
| std::vector< fdl::Vector3 > | curl_ |
| std::vector< fdl::Vector3 > | vorticityConfinementForce_ |
| Vector | curlMagnitude_ |
| fdl::Grid * | grid_ |
| Vector | divergence_ |
| Vector | pressure_ |
| Vector | tempP_ |
| Vector | tempW_ |
| Vector | tempZ_ |
| Vector | tempR_ |
| Vector | tempQ_ |
| Vector | ADiag_ |
| Vector | APlusX_ |
| Vector | APlusY_ |
| Vector | APlusZ_ |
| Vector | precond_ |
| float | tol_cg |
| unsigned | maxiter_cg |
| Vector3 | gravity_ |
| int | gridX_ |
| int | gridY_ |
| int | gridZ_ |
| int | numPoints_ |
| int | slice_ |
| int | velSlice_ |
| float | time_ |
| float | dx_ |
Definition at line 39 of file fluidsolver.h.
| fdl::FluidSolver::FluidSolver | ( | fdl::Grid * | grid | ) |
FluidSolver constructor collect information about the grid in order to allocate all the data for the linear solve(s) and forces.
| grid | domain to be solved |
Definition at line 25 of file fluidsolver.cpp.
| void fdl::FluidSolver::advect | ( | float | dt | ) |
Performs a semi-lagrangian particle back-trace from each cell center.
See: Jos Stam. Stable Fluids. SIGGRAPH, pages 121–128, 1999.
| dt | delta time value to step forward |
Definition at line 676 of file fluidsolver.cpp.
| void fdl::FluidSolver::applyForces | ( | float | dt | ) |
Computes and applies all body forces to the system. Currently this includes vorticity confinement and bouyancy. More to come...
| dt | delta time value to step forward |
Definition at line 296 of file fluidsolver.cpp.
| void fdl::FluidSolver::applyViscosity | ( | float | dt | ) |
NOT IMPLEMENTED YET
| dt | delta time value to step forward |
Definition at line 630 of file fluidsolver.cpp.
| void fdl::FluidSolver::axpy_prod | ( | const Vector & | x, |
| Vector & | y | ||
| ) | const [protected] |
axpy_prod computes y = Ax. This function provides an alternative to the BLAS function axpy_prod which uses the sparse matrix A represented by vectors only.
See the uBlas axpy_prod method for more info.
| x | vector to be multiplied by A |
| y | result of Ax |
Definition at line 1046 of file fluidsolver.cpp.
| float fdl::FluidSolver::cgSolve | ( | const Vector & | b, |
| Vector & | x | ||
| ) | [protected] |
cgSolve performs a conjugate gradient solve for the pressure matrix given two vectors x and b.
| b | the vector representing the negative divergence |
| x | the resulting pressure gradient after the linear solve |
Definition at line 946 of file fluidsolver.cpp.
| float fdl::FluidSolver::computeMaxTimeStep | ( | ) | const [protected] |
Uses the formulation of the maximum timestep from Foster and Fedkiw '01.
See: Nick Foster Ronald Fedkiw. Practical Animation of Liquids. SIGGRAPH, pages 23-30, 2001.
Definition at line 206 of file fluidsolver.cpp.
| void fdl::FluidSolver::constructMatrix | ( | float | dx, |
| float | dt, | ||
| float | rho = 0.25f |
||
| ) | [protected] |
Populates vectors that contain the coefficients of the sparse linear system that we intend to solve. The approach is described in Bridson Chapter 4.
| dx | cell width of the grid |
| dt | delta time value to step forward |
| rho | the global scaling factor accounting for density |
Definition at line 748 of file fluidsolver.cpp.
| void fdl::FluidSolver::constructPreconditioner | ( | float | rho = 0.25f, |
| float | tau = 0.97f |
||
| ) | [protected] |
constructPreconditioner currently makes the modified incomplete cholesky preconditioner for a preconditioned conjugate gradient solve of the positive semi-definite pressure matrix.
| rho | the global scaling factor accounting for density |
| tau | precondiitoner "tuning parameter" |
Definition at line 887 of file fluidsolver.cpp.
| void fdl::FluidSolver::diffuse | ( | float | dt, |
| float | rate = 0.25f |
||
| ) |
Appy diffusion by scaling the density values by an arbitrary constant rate. The calculation used here is d = e^(-dt*rate).
| dt | delta time value to step forward |
| rate | the rate by which we will scale down the density |
Definition at line 543 of file fluidsolver.cpp.
| void fdl::FluidSolver::fromXML | ( | TiXmlElement & | element | ) | [virtual] |
Initializes the object purely from XML inputs.
Structure should resemble:
<FluidSolver> <Grid x="50" y="50" z="50" dx="0.1"> <maxiter_cg>100</maxiter_cg> <tol_cg>0.0001</tol_cg> </FluidSolver>
Implements fdl::XmlInterface.
Definition at line 139 of file fluidsolver.cpp.
| float fdl::FluidSolver::pcgSolve | ( | const Vector & | b, |
| Vector & | x | ||
| ) | [protected] |
pcgSolve performs a preconditioned conjugate gradient solve for the pressure matrix given two vectors x and b.
| b | the vector representing the negative divergence |
| x | the resulting pressure gradient after the linear solve |
Definition at line 988 of file fluidsolver.cpp.
| void fdl::FluidSolver::project | ( | float | dt | ) |
Takes the fluid field update and projects it down to a divergence-free field using a linear solve on the new pressure values. Afterwards, the solved pressures will be applied to the grid_->
| dt | delta time value to step forward |
Definition at line 386 of file fluidsolver.cpp.
| void fdl::FluidSolver::setCGMaxIter | ( | unsigned | N | ) |
Sets the maximum number of iterations for the conjugate gradients solver(s).
Definition at line 198 of file fluidsolver.cpp.
| void fdl::FluidSolver::setCGTolerance | ( | float | tol | ) |
Sets the tolerance for the residual at step n,
, in the Euclidean 2-norm.
Definition at line 193 of file fluidsolver.cpp.
| void fdl::FluidSolver::solvePreconditioner | ( | const Vector & | b, |
| Vector & | x | ||
| ) | [protected] |
| void fdl::FluidSolver::step | ( | float | dt = 0 | ) |
This is the main function for updating the fluid system. Input of zero or less (which is the default) will trigger a call to compute the maximum time step using computeMaxTimeStep.
| dt | delta time value to step forward |
Definition at line 230 of file fluidsolver.cpp.
| TiXmlElement fdl::FluidSolver::toXML | ( | ) | [virtual] |
Structures all member data in an XML formatted node.
Implements fdl::XmlInterface.
Definition at line 164 of file fluidsolver.cpp.
1.7.4