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

#include <Core/Solver/Grid/GridFluidSolver2.hpp>

Inheritance diagram for CubbyFlow::GridFluidSolver2:
CubbyFlow::PhysicsAnimation CubbyFlow::Animation CubbyFlow::GridSmokeSolver2 CubbyFlow::LevelSetLiquidSolver2 CubbyFlow::PICSolver2 CubbyFlow::APICSolver2 CubbyFlow::FLIPSolver2

Classes

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

Public Member Functions

 GridFluidSolver2 ()
 Default constructor. More...
 
 GridFluidSolver2 (const Vector2UZ &resolution, const Vector2D &gridSpacing, const Vector2D &gridOrigin)
 Constructs solver with initial grid size. More...
 
 GridFluidSolver2 (const GridFluidSolver2 &)=delete
 Deleted copy constructor. More...
 
 GridFluidSolver2 (GridFluidSolver2 &&) noexcept=delete
 Deleted move constructor. More...
 
 ~GridFluidSolver2 () override=default
 Default virtual destructor. More...
 
GridFluidSolver2operator= (const GridFluidSolver2 &)=delete
 Deleted copy assignment operator. More...
 
GridFluidSolver2operator= (GridFluidSolver2 &&) noexcept=delete
 Deleted move assignment operator. More...
 
const Vector2DGetGravity () const
 Returns the gravity vector of the system. More...
 
void SetGravity (const Vector2D &newGravity)
 Sets the gravity of the system. More...
 
double GetViscosityCoefficient () const
 Returns the viscosity coefficient. More...
 
void SetViscosityCoefficient (double newValue)
 Sets the viscosity coefficient. More...
 
double GetCFL (double timeIntervalInSeconds) const
 Returns the CFL number from the current velocity field for given time interval. More...
 
double GetMaxCFL () const
 Returns the max allowed CFL number. More...
 
void SetMaxCFL (double newCFL)
 Sets the max allowed CFL number. More...
 
bool GetUseCompressedLinearSystem () const
 Returns true if the solver is using compressed linear system. More...
 
void SetUseCompressedLinearSystem (bool isOn)
 Sets whether the solver should use compressed linear system. More...
 
const AdvectionSolver2PtrGetAdvectionSolver () const
 Returns the advection solver instance. More...
 
void SetAdvectionSolver (const AdvectionSolver2Ptr &newSolver)
 Sets the advection solver. More...
 
const GridDiffusionSolver2PtrGetDiffusionSolver () const
 Returns the diffusion solver instance. More...
 
void SetDiffusionSolver (const GridDiffusionSolver2Ptr &newSolver)
 Sets the diffusion solver. More...
 
const GridPressureSolver2PtrGetPressureSolver () const
 Returns the pressure solver instance. More...
 
void SetPressureSolver (const GridPressureSolver2Ptr &newSolver)
 Sets the pressure solver. More...
 
int GetClosedDomainBoundaryFlag () const
 Returns the closed domain boundary flag. More...
 
void SetClosedDomainBoundaryFlag (int flag)
 Sets the closed domain boundary flag. More...
 
const GridSystemData2PtrGetGridSystemData () const
 Returns the grid system data. More...
 
void ResizeGrid (const Vector2UZ &newSize, const Vector2D &newGridSpacing, const Vector2D &newGridOrigin) const
 Resizes grid system data. More...
 
Vector2UZ GetResolution () const
 Returns the resolution of the grid system data. More...
 
Vector2D GetGridSpacing () const
 Returns the grid spacing of the grid system data. More...
 
Vector2D GetGridOrigin () const
 Returns the origin of the grid system data. More...
 
const FaceCenteredGrid2PtrGetVelocity () const
 Returns the velocity field. More...
 
const Collider2PtrGetCollider () const
 Returns the collider. More...
 
void SetCollider (const Collider2Ptr &newCollider)
 Sets the collider. More...
 
const GridEmitter2PtrGetEmitter () const
 Returns the emitter. More...
 
void SetEmitter (const GridEmitter2Ptr &newEmitter)
 Sets the emitter. More...
 
- Public Member Functions inherited from CubbyFlow::PhysicsAnimation
 PhysicsAnimation ()
 Default constructor. More...
 
 PhysicsAnimation (const PhysicsAnimation &)=default
 Default copy constructor. More...
 
 PhysicsAnimation (PhysicsAnimation &&) noexcept=default
 Default move constructor. More...
 
virtual ~PhysicsAnimation ()=default
 Default virtual destructor. More...
 
PhysicsAnimationoperator= (const PhysicsAnimation &)=default
 Default copy assignment operator. More...
 
PhysicsAnimationoperator= (PhysicsAnimation &&) noexcept=default
 Default move assignment operator. More...
 
bool GetIsUsingFixedSubTimeSteps () 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 GetNumberOfFixedSubTimeSteps () 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 GetCurrentFrame () const
 Returns current frame. More...
 
void SetCurrentFrame (const Frame &frame)
 Sets current frame cursor (but do not invoke update()). More...
 
double GetCurrentTimeInSeconds () const
 Returns current time in seconds. More...
 
- Public Member Functions inherited from CubbyFlow::Animation
 Animation ()=default
 Default constructor. More...
 
 Animation (const Animation &)=default
 Default copy constructor. More...
 
 Animation (Animation &&) noexcept=default
 Default move constructor. More...
 
virtual ~Animation ()=default
 Default virtual destructor. More...
 
Animationoperator= (const Animation &)=default
 Default copy assignment operator. More...
 
Animationoperator= (Animation &&) noexcept=default
 Default move assignment operator. More...
 
void Update (const Frame &frame)
 Updates animation state for given frame. More...
 

Static Public Member Functions

static Builder GetBuilder ()
 Returns builder fox GridFluidSolver2. 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 GetNumberOfSubTimeSteps (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 ScalarField2Ptr GetFluidSDF () const
 Returns the signed-distance representation of the fluid. More...
 
void ComputeGravity (double timeIntervalInSeconds)
 Computes the gravity term. More...
 
void ApplyBoundaryCondition () const
 Applies the boundary condition to the velocity field. More...
 
void ExtrapolateIntoCollider (ScalarGrid2 *grid)
 Extrapolates given field into the collider-occupied region. More...
 
void ExtrapolateIntoCollider (CollocatedVectorGrid2 *grid)
 Extrapolates given field into the collider-occupied region. More...
 
void ExtrapolateIntoCollider (FaceCenteredGrid2 *grid)
 Extrapolates given field into the collider-occupied region. More...
 
ScalarField2Ptr GetColliderSDF () const
 Returns the signed-distance field representation of the collider. More...
 
VectorField2Ptr GetColliderVelocityField () const
 Returns the velocity field of the collider. More...
 

Detailed Description

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

This is an abstract base class for grid-based 2-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 GridFluidSolver2::SetAdvectionSolver(newSolver).

Constructor & Destructor Documentation

◆ GridFluidSolver2() [1/4]

CubbyFlow::GridFluidSolver2::GridFluidSolver2 ( )

Default constructor.

◆ GridFluidSolver2() [2/4]

CubbyFlow::GridFluidSolver2::GridFluidSolver2 ( const Vector2UZ resolution,
const Vector2D gridSpacing,
const Vector2D gridOrigin 
)

Constructs solver with initial grid size.

◆ GridFluidSolver2() [3/4]

CubbyFlow::GridFluidSolver2::GridFluidSolver2 ( const GridFluidSolver2 )
delete

Deleted copy constructor.

◆ GridFluidSolver2() [4/4]

CubbyFlow::GridFluidSolver2::GridFluidSolver2 ( GridFluidSolver2 &&  )
deletenoexcept

Deleted move constructor.

◆ ~GridFluidSolver2()

CubbyFlow::GridFluidSolver2::~GridFluidSolver2 ( )
overridedefault

Default virtual destructor.

Member Function Documentation

◆ ApplyBoundaryCondition()

void CubbyFlow::GridFluidSolver2::ApplyBoundaryCondition ( ) const
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.

◆ ComputeAdvection()

virtual void CubbyFlow::GridFluidSolver2::ComputeAdvection ( double  timeIntervalInSeconds)
protectedvirtual

Computes the advection term using the advection solver.

Reimplemented in CubbyFlow::LevelSetLiquidSolver2, and CubbyFlow::PICSolver2.

◆ ComputeExternalForces()

virtual void CubbyFlow::GridFluidSolver2::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
GridFluidSolver2::ComputeGravity

Reimplemented in CubbyFlow::GridSmokeSolver2.

◆ ComputeGravity()

void CubbyFlow::GridFluidSolver2::ComputeGravity ( double  timeIntervalInSeconds)
protected

Computes the gravity term.

◆ ComputePressure()

virtual void CubbyFlow::GridFluidSolver2::ComputePressure ( double  timeIntervalInSeconds)
protectedvirtual

Computes the pressure term using the pressure solver.

◆ ComputeViscosity()

virtual void CubbyFlow::GridFluidSolver2::ComputeViscosity ( double  timeIntervalInSeconds)
protectedvirtual

Computes the viscosity term using the diffusion solver.

◆ ExtrapolateIntoCollider() [1/3]

void CubbyFlow::GridFluidSolver2::ExtrapolateIntoCollider ( ScalarGrid2 grid)
protected

Extrapolates given field into the collider-occupied region.

◆ ExtrapolateIntoCollider() [2/3]

void CubbyFlow::GridFluidSolver2::ExtrapolateIntoCollider ( CollocatedVectorGrid2 grid)
protected

Extrapolates given field into the collider-occupied region.

◆ ExtrapolateIntoCollider() [3/3]

void CubbyFlow::GridFluidSolver2::ExtrapolateIntoCollider ( FaceCenteredGrid2 grid)
protected

Extrapolates given field into the collider-occupied region.

◆ GetAdvectionSolver()

const AdvectionSolver2Ptr& CubbyFlow::GridFluidSolver2::GetAdvectionSolver ( ) const

Returns the advection solver instance.

◆ GetBuilder()

static Builder CubbyFlow::GridFluidSolver2::GetBuilder ( )
static

Returns builder fox GridFluidSolver2.

◆ GetCFL()

double CubbyFlow::GridFluidSolver2::GetCFL ( double  timeIntervalInSeconds) const

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

Parameters
[in]timeIntervalInSecondsThe time interval in seconds.

◆ GetClosedDomainBoundaryFlag()

int CubbyFlow::GridFluidSolver2::GetClosedDomainBoundaryFlag ( ) const

Returns the closed domain boundary flag.

◆ GetCollider()

const Collider2Ptr& CubbyFlow::GridFluidSolver2::GetCollider ( ) const

Returns the collider.

◆ GetColliderSDF()

ScalarField2Ptr CubbyFlow::GridFluidSolver2::GetColliderSDF ( ) const
protected

Returns the signed-distance field representation of the collider.

◆ GetColliderVelocityField()

VectorField2Ptr CubbyFlow::GridFluidSolver2::GetColliderVelocityField ( ) const
protected

Returns the velocity field of the collider.

◆ GetDiffusionSolver()

const GridDiffusionSolver2Ptr& CubbyFlow::GridFluidSolver2::GetDiffusionSolver ( ) const

Returns the diffusion solver instance.

◆ GetEmitter()

const GridEmitter2Ptr& CubbyFlow::GridFluidSolver2::GetEmitter ( ) const

Returns the emitter.

◆ GetFluidSDF()

virtual ScalarField2Ptr CubbyFlow::GridFluidSolver2::GetFluidSDF ( ) const
protectedvirtual

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 -std::numeric_limits<double>::max(), meaning that the entire volume is occupied with fluid.

Reimplemented in CubbyFlow::LevelSetLiquidSolver2, and CubbyFlow::PICSolver2.

◆ GetGravity()

const Vector2D& CubbyFlow::GridFluidSolver2::GetGravity ( ) const

Returns the gravity vector of the system.

◆ GetGridOrigin()

Vector2D CubbyFlow::GridFluidSolver2::GetGridOrigin ( ) const

Returns the origin of the grid system data.

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

◆ GetGridSpacing()

Vector2D CubbyFlow::GridFluidSolver2::GetGridSpacing ( ) 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 GetGridSystemData()->GridSpacing(), but provides a shortcut.

◆ GetGridSystemData()

const GridSystemData2Ptr& CubbyFlow::GridFluidSolver2::GetGridSystemData ( ) 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
GridSystemData2

◆ GetMaxCFL()

double CubbyFlow::GridFluidSolver2::GetMaxCFL ( ) const

Returns the max allowed CFL number.

◆ GetNumberOfSubTimeSteps()

unsigned int CubbyFlow::GridFluidSolver2::GetNumberOfSubTimeSteps ( 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 number that is greater than 1.

See also
GridFluidSolver2::GetMaxCFL

Reimplemented from CubbyFlow::PhysicsAnimation.

◆ GetPressureSolver()

const GridPressureSolver2Ptr& CubbyFlow::GridFluidSolver2::GetPressureSolver ( ) const

Returns the pressure solver instance.

◆ GetResolution()

Vector2UZ CubbyFlow::GridFluidSolver2::GetResolution ( ) const

Returns the resolution of the grid system data.

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

◆ GetUseCompressedLinearSystem()

bool CubbyFlow::GridFluidSolver2::GetUseCompressedLinearSystem ( ) const

Returns true if the solver is using compressed linear system.

◆ GetVelocity()

const FaceCenteredGrid2Ptr& CubbyFlow::GridFluidSolver2::GetVelocity ( ) 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.

◆ GetViscosityCoefficient()

double CubbyFlow::GridFluidSolver2::GetViscosityCoefficient ( ) const

Returns the viscosity coefficient.

◆ OnAdvanceTimeStep()

void CubbyFlow::GridFluidSolver2::OnAdvanceTimeStep ( double  timeIntervalInSeconds)
overrideprotectedvirtual

Called when advancing a single time-step.

Implements CubbyFlow::PhysicsAnimation.

◆ OnBeginAdvanceTimeStep()

virtual void CubbyFlow::GridFluidSolver2::OnBeginAdvanceTimeStep ( double  timeIntervalInSeconds)
protectedvirtual

Called at the beginning of a time-step.

Reimplemented in CubbyFlow::LevelSetLiquidSolver2, and CubbyFlow::PICSolver2.

◆ OnEndAdvanceTimeStep()

virtual void CubbyFlow::GridFluidSolver2::OnEndAdvanceTimeStep ( double  timeIntervalInSeconds)
protectedvirtual

Called at the end of a time-step.

Reimplemented in CubbyFlow::GridSmokeSolver2, and CubbyFlow::LevelSetLiquidSolver2.

◆ OnInitialize()

void CubbyFlow::GridFluidSolver2::OnInitialize ( )
overrideprotectedvirtual

Called when it needs to setup initial condition.

Reimplemented from CubbyFlow::PhysicsAnimation.

Reimplemented in CubbyFlow::PICSolver2.

◆ operator=() [1/2]

GridFluidSolver2& CubbyFlow::GridFluidSolver2::operator= ( const GridFluidSolver2 )
delete

Deleted copy assignment operator.

◆ operator=() [2/2]

GridFluidSolver2& CubbyFlow::GridFluidSolver2::operator= ( GridFluidSolver2 &&  )
deletenoexcept

Deleted move assignment operator.

◆ ResizeGrid()

void CubbyFlow::GridFluidSolver2::ResizeGrid ( const Vector2UZ newSize,
const Vector2D newGridSpacing,
const Vector2D newGridOrigin 
) const

Resizes grid system data.

This function resizes grid system data. You can also resize the grid by calling resize function directly from GridFluidSolver2::GetGridSystemData(), 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.

◆ SetAdvectionSolver()

void CubbyFlow::GridFluidSolver2::SetAdvectionSolver ( const AdvectionSolver2Ptr newSolver)

Sets the advection solver.

◆ SetClosedDomainBoundaryFlag()

void CubbyFlow::GridFluidSolver2::SetClosedDomainBoundaryFlag ( int  flag)

Sets the closed domain boundary flag.

◆ SetCollider()

void CubbyFlow::GridFluidSolver2::SetCollider ( const Collider2Ptr newCollider)

Sets the collider.

◆ SetDiffusionSolver()

void CubbyFlow::GridFluidSolver2::SetDiffusionSolver ( const GridDiffusionSolver2Ptr newSolver)

Sets the diffusion solver.

◆ SetEmitter()

void CubbyFlow::GridFluidSolver2::SetEmitter ( const GridEmitter2Ptr newEmitter)

Sets the emitter.

◆ SetGravity()

void CubbyFlow::GridFluidSolver2::SetGravity ( const Vector2D newGravity)

Sets the gravity of the system.

◆ SetMaxCFL()

void CubbyFlow::GridFluidSolver2::SetMaxCFL ( double  newCFL)

Sets the max allowed CFL number.

◆ SetPressureSolver()

void CubbyFlow::GridFluidSolver2::SetPressureSolver ( const GridPressureSolver2Ptr newSolver)

Sets the pressure solver.

◆ SetUseCompressedLinearSystem()

void CubbyFlow::GridFluidSolver2::SetUseCompressedLinearSystem ( bool  isOn)

Sets whether the solver should use compressed linear system.

◆ SetViscosityCoefficient()

void CubbyFlow::GridFluidSolver2::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.

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