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

2-D Particle-in-Cell (PIC) implementation. More...

#include <jet/pic_solver2.h>

Inheritance diagram for jet::PicSolver2:
jet::GridFluidSolver2 jet::PhysicsAnimation jet::Animation jet::ApicSolver2 jet::FlipSolver2

Classes

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

Public Member Functions

 PicSolver2 ()
 Default constructor. More...
 
 PicSolver2 (const Size2 &resolution, const Vector2D &gridSpacing, const Vector2D &gridOrigin)
 Constructs solver with initial grid size. More...
 
virtual ~PicSolver2 ()
 Default destructor. More...
 
ScalarGrid2Ptr signedDistanceField () const
 Returns the signed-distance field of particles. More...
 
const ParticleSystemData2PtrparticleSystemData () const
 Returns the particle system data. More...
 
const ParticleEmitter2PtrparticleEmitter () const
 Returns the particle emitter. More...
 
void setParticleEmitter (const ParticleEmitter2Ptr &newEmitter)
 Sets the particle emitter. More...
 
- Public Member Functions inherited from jet::GridFluidSolver2
 GridFluidSolver2 ()
 Default constructor. More...
 
 GridFluidSolver2 (const Size2 &resolution, const Vector2D &gridSpacing, const Vector2D &gridOrigin)
 Constructs solver with initial grid size. More...
 
virtual ~GridFluidSolver2 ()
 Default destructor. More...
 
const Vector2Dgravity () const
 Returns the gravity vector of the system. More...
 
void setGravity (const Vector2D &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 AdvectionSolver2PtradvectionSolver () const
 Returns the advection solver instance. More...
 
void setAdvectionSolver (const AdvectionSolver2Ptr &newSolver)
 Sets the advection solver. More...
 
const GridDiffusionSolver2PtrdiffusionSolver () const
 Returns the diffusion solver instance. More...
 
void setDiffusionSolver (const GridDiffusionSolver2Ptr &newSolver)
 Sets the diffusion solver. More...
 
const GridPressureSolver2PtrpressureSolver () const
 Returns the pressure solver instance. More...
 
void setPressureSolver (const GridPressureSolver2Ptr &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 GridSystemData2PtrgridSystemData () const
 Returns the grid system data. More...
 
void resizeGrid (const Size2 &newSize, const Vector2D &newGridSpacing, const Vector2D &newGridOrigin)
 Resizes grid system data. More...
 
Size2 resolution () const
 Returns the resolution of the grid system data. More...
 
Vector2D gridSpacing () const
 Returns the grid spacing of the grid system data. More...
 
Vector2D gridOrigin () const
 Returns the origin of the grid system data. More...
 
const FaceCenteredGrid2Ptrvelocity () const
 Returns the velocity field. More...
 
const Collider2Ptrcollider () const
 Returns the collider. More...
 
void setCollider (const Collider2Ptr &newCollider)
 Sets the collider. More...
 
const GridEmitter2Ptremitter () const
 Returns the emitter. More...
 
void setEmitter (const GridEmitter2Ptr &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 PicSolver2. More...
 
- Static Public Member Functions inherited from jet::GridFluidSolver2
static Builder builder ()
 Returns builder fox GridFluidSolver2. More...
 

Protected Member Functions

void onInitialize () override
 Initializes the simulator. More...
 
void onBeginAdvanceTimeStep (double timeIntervalInSeconds) override
 Invoked before a simulation time-step begins. More...
 
void computeAdvection (double timeIntervalInSeconds) override
 Computes the advection term of the fluid solver. More...
 
ScalarField2Ptr fluidSdf () const override
 Returns the signed-distance field of the fluid. More...
 
virtual void transferFromParticlesToGrids ()
 Transfers velocity field from particles to grids. More...
 
virtual void transferFromGridsToParticles ()
 Transfers velocity field from grids to particles. More...
 
virtual void moveParticles (double timeIntervalInSeconds)
 Moves particles. More...
 
- Protected Member Functions inherited from jet::GridFluidSolver2
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 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...
 
void computeGravity (double timeIntervalInSeconds)
 Computes the gravity term. More...
 
void applyBoundaryCondition ()
 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 colliderSdf () const
 Returns the signed-distance field representation of the collider. More...
 
VectorField2Ptr colliderVelocityField () const
 Returns the velocity field of the collider. More...
 

Protected Attributes

Array2< char > _uMarkers
 
Array2< char > _vMarkers
 

Detailed Description

2-D Particle-in-Cell (PIC) implementation.

This class implements 2-D Particle-in-Cell (PIC) method by inheriting GridFluidSolver2. Since it is a grid-particle hybrid method, the solver also has a particle system to track fluid particles.

See also
Zhu, Yongning, and Robert Bridson. "Animating sand as a fluid." ACM Transactions on Graphics (TOG). Vol. 24. No. 3. ACM, 2005.

Constructor & Destructor Documentation

◆ PicSolver2() [1/2]

jet::PicSolver2::PicSolver2 ( )

Default constructor.

◆ PicSolver2() [2/2]

jet::PicSolver2::PicSolver2 ( const Size2 resolution,
const Vector2D gridSpacing,
const Vector2D gridOrigin 
)

Constructs solver with initial grid size.

◆ ~PicSolver2()

virtual jet::PicSolver2::~PicSolver2 ( )
virtual

Default destructor.

Member Function Documentation

◆ builder()

static Builder jet::PicSolver2::builder ( )
static

Returns builder fox PicSolver2.

◆ computeAdvection()

void jet::PicSolver2::computeAdvection ( double  timeIntervalInSeconds)
overrideprotectedvirtual

Computes the advection term of the fluid solver.

Reimplemented from jet::GridFluidSolver2.

◆ fluidSdf()

ScalarField2Ptr jet::PicSolver2::fluidSdf ( ) const
overrideprotectedvirtual

Returns the signed-distance field of the fluid.

Reimplemented from jet::GridFluidSolver2.

◆ moveParticles()

virtual void jet::PicSolver2::moveParticles ( double  timeIntervalInSeconds)
protectedvirtual

Moves particles.

◆ onBeginAdvanceTimeStep()

void jet::PicSolver2::onBeginAdvanceTimeStep ( double  timeIntervalInSeconds)
overrideprotectedvirtual

Invoked before a simulation time-step begins.

Reimplemented from jet::GridFluidSolver2.

◆ onInitialize()

void jet::PicSolver2::onInitialize ( )
overrideprotectedvirtual

Initializes the simulator.

Reimplemented from jet::GridFluidSolver2.

◆ particleEmitter()

const ParticleEmitter2Ptr& jet::PicSolver2::particleEmitter ( ) const

Returns the particle emitter.

◆ particleSystemData()

const ParticleSystemData2Ptr& jet::PicSolver2::particleSystemData ( ) const

Returns the particle system data.

◆ setParticleEmitter()

void jet::PicSolver2::setParticleEmitter ( const ParticleEmitter2Ptr newEmitter)

Sets the particle emitter.

◆ signedDistanceField()

ScalarGrid2Ptr jet::PicSolver2::signedDistanceField ( ) const

Returns the signed-distance field of particles.

◆ transferFromGridsToParticles()

virtual void jet::PicSolver2::transferFromGridsToParticles ( )
protectedvirtual

Transfers velocity field from grids to particles.

Reimplemented in jet::FlipSolver2, and jet::ApicSolver2.

◆ transferFromParticlesToGrids()

virtual void jet::PicSolver2::transferFromParticlesToGrids ( )
protectedvirtual

Transfers velocity field from particles to grids.

Reimplemented in jet::FlipSolver2, and jet::ApicSolver2.

Member Data Documentation

◆ _uMarkers

Array2<char> jet::PicSolver2::_uMarkers
protected

◆ _vMarkers

Array2<char> jet::PicSolver2::_vMarkers
protected

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