Jet  v1.3.3
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
jet::GridFluidSolver3 Class Reference

Abstract base class for grid-based 3-D fluid solver. More...

#include <jet/grid_fluid_solver3.h>

Inheritance diagram for jet::GridFluidSolver3:
jet::PhysicsAnimation jet::Animation jet::GridSmokeSolver3 jet::LevelSetLiquidSolver3 jet::PicSolver3 jet::ApicSolver3 jet::FlipSolver3

Classes

class  Builder
 Front-end to create GridFluidSolver3 objects step by step. More...
 

Public Member Functions

 GridFluidSolver3 ()
 Default constructor. More...
 
 GridFluidSolver3 (const Size3 &resolution, const Vector3D &gridSpacing, const Vector3D &gridOrigin)
 Constructs solver with initial grid size. More...
 
virtual ~GridFluidSolver3 ()
 Default destructor. More...
 
const Vector3Dgravity () const
 Returns the gravity vector of the system. More...
 
void setGravity (const Vector3D &newGravity)
 Sets the gravity of the system. More...
 
double viscosityCoefficient () const
 Returns the viscosity coefficient. More...
 
void setViscosityCoefficient (double newValue)
 Sets the viscosity coefficient. More...
 
double cfl (double timeIntervalInSeconds) const
 Returns the CFL number from the current velocity field for given time interval. More...
 
double maxCfl () const
 Returns the max allowed CFL number. More...
 
void setMaxCfl (double newCfl)
 Sets the max allowed CFL number. More...
 
bool useCompressedLinearSystem () const
 Returns true if the solver is using compressed linear system. More...
 
void setUseCompressedLinearSystem (bool onoff)
 Sets whether the solver should use compressed linear system. More...
 
const AdvectionSolver3PtradvectionSolver () const
 Returns the advection solver instance. More...
 
void setAdvectionSolver (const AdvectionSolver3Ptr &newSolver)
 Sets the advection solver. More...
 
const GridDiffusionSolver3PtrdiffusionSolver () const
 Returns the diffusion solver instance. More...
 
void setDiffusionSolver (const GridDiffusionSolver3Ptr &newSolver)
 Sets the diffusion solver. More...
 
const GridPressureSolver3PtrpressureSolver () const
 Returns the pressure solver instance. More...
 
void setPressureSolver (const GridPressureSolver3Ptr &newSolver)
 Sets the pressure solver. More...
 
int closedDomainBoundaryFlag () const
 Returns the closed domain boundary flag. More...
 
void setClosedDomainBoundaryFlag (int flag)
 Sets the closed domain boundary flag. More...
 
const GridSystemData3PtrgridSystemData () const
 Returns the grid system data. More...
 
void resizeGrid (const Size3 &newSize, const Vector3D &newGridSpacing, const Vector3D &newGridOrigin)
 Resizes grid system data. More...
 
Size3 resolution () const
 Returns the resolution of the grid system data. More...
 
Vector3D gridSpacing () const
 Returns the grid spacing of the grid system data. More...
 
Vector3D gridOrigin () const
 Returns the origin of the grid system data. More...
 
const FaceCenteredGrid3Ptrvelocity () const
 Returns the velocity field. More...
 
const Collider3Ptrcollider () const
 Returns the collider. More...
 
void setCollider (const Collider3Ptr &newCollider)
 Sets the collider. More...
 
const GridEmitter3Ptremitter () const
 Returns the emitter. More...
 
void setEmitter (const GridEmitter3Ptr &newEmitter)
 Sets the emitter. More...
 
- Public Member Functions inherited from jet::PhysicsAnimation
 PhysicsAnimation ()
 Default constructor. More...
 
virtual ~PhysicsAnimation ()
 Destructor. More...
 
bool isUsingFixedSubTimeSteps () const
 Returns true if fixed sub-timestepping is used. More...
 
void setIsUsingFixedSubTimeSteps (bool isUsing)
 Sets true if fixed sub-timestepping is used. More...
 
unsigned int numberOfFixedSubTimeSteps () const
 Returns the number of fixed sub-timesteps. More...
 
void setNumberOfFixedSubTimeSteps (unsigned int numberOfSteps)
 Sets the number of fixed sub-timesteps. More...
 
void advanceSingleFrame ()
 Advances a single frame. More...
 
Frame currentFrame () const
 Returns current frame. More...
 
void setCurrentFrame (const Frame &frame)
 Sets current frame cursor (but do not invoke update()). More...
 
double currentTimeInSeconds () const
 Returns current time in seconds. More...
 
- Public Member Functions inherited from jet::Animation
 Animation ()
 
virtual ~Animation ()
 
void update (const Frame &frame)
 Updates animation state for given frame. More...
 

Static Public Member Functions

static Builder builder ()
 Returns builder fox GridFluidSolver3. More...
 

Protected Member Functions

void onInitialize () override
 Called when it needs to setup initial condition. More...
 
void onAdvanceTimeStep (double timeIntervalInSeconds) override
 Called when advancing a single time-step. More...
 
unsigned int numberOfSubTimeSteps (double timeIntervalInSeconds) const override
 Returns the required sub-time-steps for given time interval. More...
 
virtual void onBeginAdvanceTimeStep (double timeIntervalInSeconds)
 Called at the beginning of a time-step. More...
 
virtual void onEndAdvanceTimeStep (double timeIntervalInSeconds)
 Called at the end of a time-step. More...
 
virtual void computeExternalForces (double timeIntervalInSeconds)
 Computes the external force terms. More...
 
virtual void computeViscosity (double timeIntervalInSeconds)
 Computes the viscosity term using the diffusion solver. More...
 
virtual void computePressure (double timeIntervalInSeconds)
 Computes the pressure term using the pressure solver. More...
 
virtual void computeAdvection (double timeIntervalInSeconds)
 Computes the advection term using the advection solver. More...
 
virtual ScalarField3Ptr fluidSdf () const
 
void computeGravity (double timeIntervalInSeconds)
 Computes the gravity term. More...
 
void applyBoundaryCondition ()
 Applies the boundary condition to the velocity field. More...
 
void extrapolateIntoCollider (ScalarGrid3 *grid)
 Extrapolates given field into the collider-occupied region. More...
 
void extrapolateIntoCollider (CollocatedVectorGrid3 *grid)
 Extrapolates given field into the collider-occupied region. More...
 
void extrapolateIntoCollider (FaceCenteredGrid3 *grid)
 Extrapolates given field into the collider-occupied region. More...
 
ScalarField3Ptr colliderSdf () const
 Returns the signed-distance field representation of the collider. More...
 
VectorField3Ptr colliderVelocityField () const
 Returns the velocity field of the collider. More...
 

Detailed Description

Abstract base class for grid-based 3-D fluid solver.

This is an abstract base class for grid-based 3-D fluid solver based on Jos Stam's famous 1999 paper - "Stable Fluids". This solver takes fractional step method as its foundation which is consisted of independent advection, diffusion, external forces, and pressure projection steps. Each step is configurable so that a custom step can be implemented. For example, if a user wants to change the advection solver to her/his own implementation, simply call GridFluidSolver3::setAdvectionSolver(newSolver).

Constructor & Destructor Documentation

◆ GridFluidSolver3() [1/2]

jet::GridFluidSolver3::GridFluidSolver3 ( )

Default constructor.

◆ GridFluidSolver3() [2/2]

jet::GridFluidSolver3::GridFluidSolver3 ( const Size3 resolution,
const Vector3D gridSpacing,
const Vector3D gridOrigin 
)

Constructs solver with initial grid size.

◆ ~GridFluidSolver3()

virtual jet::GridFluidSolver3::~GridFluidSolver3 ( )
virtual

Default destructor.

Member Function Documentation

◆ advectionSolver()

const AdvectionSolver3Ptr& jet::GridFluidSolver3::advectionSolver ( ) const

Returns the advection solver instance.

◆ applyBoundaryCondition()

void jet::GridFluidSolver3::applyBoundaryCondition ( )
protected

Applies the boundary condition to the velocity field.

This function applies the boundary condition to the velocity field by constraining the flow based on the boundary condition solver.

◆ builder()

static Builder jet::GridFluidSolver3::builder ( )
static

Returns builder fox GridFluidSolver3.

◆ cfl()

double jet::GridFluidSolver3::cfl ( double  timeIntervalInSeconds) const

Returns the CFL number from the current velocity field for given time interval.

Parameters
[in]timeIntervalInSecondsThe time interval in seconds.

◆ closedDomainBoundaryFlag()

int jet::GridFluidSolver3::closedDomainBoundaryFlag ( ) const

Returns the closed domain boundary flag.

◆ collider()

const Collider3Ptr& jet::GridFluidSolver3::collider ( ) const

Returns the collider.

◆ colliderSdf()

ScalarField3Ptr jet::GridFluidSolver3::colliderSdf ( ) const
protected

Returns the signed-distance field representation of the collider.

◆ colliderVelocityField()

VectorField3Ptr jet::GridFluidSolver3::colliderVelocityField ( ) const
protected

Returns the velocity field of the collider.

◆ computeAdvection()

virtual void jet::GridFluidSolver3::computeAdvection ( double  timeIntervalInSeconds)
protectedvirtual

Computes the advection term using the advection solver.

Reimplemented in jet::LevelSetLiquidSolver3, and jet::PicSolver3.

◆ computeExternalForces()

virtual void jet::GridFluidSolver3::computeExternalForces ( double  timeIntervalInSeconds)
protectedvirtual

Computes the external force terms.

This function computes the external force applied for given time interval. By default, it only computes the gravity.

See also
GridFluidSolver3::computeGravity

Reimplemented in jet::GridSmokeSolver3.

◆ computeGravity()

void jet::GridFluidSolver3::computeGravity ( double  timeIntervalInSeconds)
protected

Computes the gravity term.

◆ computePressure()

virtual void jet::GridFluidSolver3::computePressure ( double  timeIntervalInSeconds)
protectedvirtual

Computes the pressure term using the pressure solver.

◆ computeViscosity()

virtual void jet::GridFluidSolver3::computeViscosity ( double  timeIntervalInSeconds)
protectedvirtual

Computes the viscosity term using the diffusion solver.

◆ diffusionSolver()

const GridDiffusionSolver3Ptr& jet::GridFluidSolver3::diffusionSolver ( ) const

Returns the diffusion solver instance.

◆ emitter()

const GridEmitter3Ptr& jet::GridFluidSolver3::emitter ( ) const

Returns the emitter.

◆ extrapolateIntoCollider() [1/3]

void jet::GridFluidSolver3::extrapolateIntoCollider ( CollocatedVectorGrid3 grid)
protected

Extrapolates given field into the collider-occupied region.

◆ extrapolateIntoCollider() [2/3]

void jet::GridFluidSolver3::extrapolateIntoCollider ( FaceCenteredGrid3 grid)
protected

Extrapolates given field into the collider-occupied region.

◆ extrapolateIntoCollider() [3/3]

void jet::GridFluidSolver3::extrapolateIntoCollider ( ScalarGrid3 grid)
protected

Extrapolates given field into the collider-occupied region.

◆ fluidSdf()

virtual ScalarField3Ptr jet::GridFluidSolver3::fluidSdf ( ) const
protectedvirtual

\breif Returns the signed-distance representation of the fluid.

This function returns the signed-distance representation of the fluid. Positive sign area is considered to be atmosphere and won't be included for computing the dynamics. By default, this will return constant scalar field of -kMaxD, meaning that the entire volume is occupied with fluid.

Reimplemented in jet::LevelSetLiquidSolver3, and jet::PicSolver3.

◆ gravity()

const Vector3D& jet::GridFluidSolver3::gravity ( ) const

Returns the gravity vector of the system.

◆ gridOrigin()

Vector3D jet::GridFluidSolver3::gridOrigin ( ) const

Returns the origin of the grid system data.

This function returns the resolution of the grid system data. This is equivalent to calling gridSystemData()->origin(), but provides a shortcut.

◆ gridSpacing()

Vector3D jet::GridFluidSolver3::gridSpacing ( ) const

Returns the grid spacing of the grid system data.

This function returns the resolution of the grid system data. This is equivalent to calling gridSystemData()->gridSpacing(), but provides a shortcut.

◆ gridSystemData()

const GridSystemData3Ptr& jet::GridFluidSolver3::gridSystemData ( ) const

Returns the grid system data.

This function returns the grid system data. The grid system data stores the core fluid flow fields such as velocity. By default, the data instance has velocity field only.

See also
GridSystemData3

◆ maxCfl()

double jet::GridFluidSolver3::maxCfl ( ) const

Returns the max allowed CFL number.

◆ numberOfSubTimeSteps()

unsigned int jet::GridFluidSolver3::numberOfSubTimeSteps ( double  timeIntervalInSeconds) const
overrideprotectedvirtual

Returns the required sub-time-steps for given time interval.

This function returns the required sub-time-steps for given time interval based on the max allowed CFL number. If the time interval is too large so that it makes the CFL number greater than the max value, This function will return a numebr that is greater than 1.

See also
GridFluidSolver3::maxCfl

Reimplemented from jet::PhysicsAnimation.

◆ onAdvanceTimeStep()

void jet::GridFluidSolver3::onAdvanceTimeStep ( double  timeIntervalInSeconds)
overrideprotectedvirtual

Called when advancing a single time-step.

Implements jet::PhysicsAnimation.

◆ onBeginAdvanceTimeStep()

virtual void jet::GridFluidSolver3::onBeginAdvanceTimeStep ( double  timeIntervalInSeconds)
protectedvirtual

Called at the beginning of a time-step.

Reimplemented in jet::LevelSetLiquidSolver3, and jet::PicSolver3.

◆ onEndAdvanceTimeStep()

virtual void jet::GridFluidSolver3::onEndAdvanceTimeStep ( double  timeIntervalInSeconds)
protectedvirtual

Called at the end of a time-step.

Reimplemented in jet::GridSmokeSolver3, and jet::LevelSetLiquidSolver3.

◆ onInitialize()

void jet::GridFluidSolver3::onInitialize ( )
overrideprotectedvirtual

Called when it needs to setup initial condition.

Reimplemented from jet::PhysicsAnimation.

Reimplemented in jet::PicSolver3.

◆ pressureSolver()

const GridPressureSolver3Ptr& jet::GridFluidSolver3::pressureSolver ( ) const

Returns the pressure solver instance.

◆ resizeGrid()

void jet::GridFluidSolver3::resizeGrid ( const Size3 newSize,
const Vector3D newGridSpacing,
const Vector3D newGridOrigin 
)

Resizes grid system data.

This function resizes grid system data. You can also resize the grid by calling resize function directly from GridFluidSolver3::gridSystemData(), but this function provides a shortcut for the same operation.

Parameters
[in]newSizeThe new size.
[in]newGridSpacingThe new grid spacing.
[in]newGridOriginThe new grid origin.

◆ resolution()

Size3 jet::GridFluidSolver3::resolution ( ) const

Returns the resolution of the grid system data.

This function returns the resolution of the grid system data. This is equivalent to calling gridSystemData()->resolution(), but provides a shortcut.

◆ setAdvectionSolver()

void jet::GridFluidSolver3::setAdvectionSolver ( const AdvectionSolver3Ptr newSolver)

Sets the advection solver.

◆ setClosedDomainBoundaryFlag()

void jet::GridFluidSolver3::setClosedDomainBoundaryFlag ( int  flag)

Sets the closed domain boundary flag.

◆ setCollider()

void jet::GridFluidSolver3::setCollider ( const Collider3Ptr newCollider)

Sets the collider.

◆ setDiffusionSolver()

void jet::GridFluidSolver3::setDiffusionSolver ( const GridDiffusionSolver3Ptr newSolver)

Sets the diffusion solver.

◆ setEmitter()

void jet::GridFluidSolver3::setEmitter ( const GridEmitter3Ptr newEmitter)

Sets the emitter.

◆ setGravity()

void jet::GridFluidSolver3::setGravity ( const Vector3D newGravity)

Sets the gravity of the system.

◆ setMaxCfl()

void jet::GridFluidSolver3::setMaxCfl ( double  newCfl)

Sets the max allowed CFL number.

◆ setPressureSolver()

void jet::GridFluidSolver3::setPressureSolver ( const GridPressureSolver3Ptr newSolver)

Sets the pressure solver.

◆ setUseCompressedLinearSystem()

void jet::GridFluidSolver3::setUseCompressedLinearSystem ( bool  onoff)

Sets whether the solver should use compressed linear system.

◆ setViscosityCoefficient()

void jet::GridFluidSolver3::setViscosityCoefficient ( double  newValue)

Sets the viscosity coefficient.

This function sets the viscosity coefficient. Non-positive input will be clamped to zero.

Parameters
[in]newValueThe new viscosity coefficient value.

◆ useCompressedLinearSystem()

bool jet::GridFluidSolver3::useCompressedLinearSystem ( ) const

Returns true if the solver is using compressed linear system.

◆ velocity()

const FaceCenteredGrid3Ptr& jet::GridFluidSolver3::velocity ( ) const

Returns the velocity field.

This function returns the velocity field from the grid system data. It is just a shortcut to the most commonly accessed data chunk.

◆ viscosityCoefficient()

double jet::GridFluidSolver3::viscosityCoefficient ( ) const

Returns the viscosity coefficient.


The documentation for this class was generated from the following file: