Lagrangian Liquid Simulation
Master Thesis project on simulation of liquids using Lagrangian approach and SPH
Solver Class Reference

creates fluid particles and perform SPH fluid simulation at every iteration More...

#include <Solver.h>

Collaboration diagram for Solver:

List of all members.

Public Member Functions

 Solver ()
 ctor
 ~Solver ()
 dtor
void updateFluid (Environment *io_environment, Integration *_integration)
 update the fluid state at each timestep interval
void initialiseDrawing ()
 initialise opengl drawing
void render (ngl::TransformStack _txStack, ShaderLibrary *io_sman, const std::string _shader)
 display the particle spheres
void injectParticles ()
 inject/pumps in hose particles into the simulation
std::vector< std::vector
< ngl::Vector > > 
getPositionList ()
 return a 2d list of the position of particles, used for caching
std::vector< std::string > getNameList ()
 return the list of fluid names, used for caching
void toggleNextHoseableFluid ()
 toggle between the fluids to determine which one will be used by the hose
void setCurrentHoseableFluid (const int _v)
 set the current hoseable fluid id
bool getEnableAutoFluidUpdate () const
 returns wherether automatic fluid update is enabled
void toggleEnableAutoFluidUpdate ()
 toggles the state of the automatic fluid update flag
ngl::Real getSmoothingLength () const
 return the smoothing length of the neighbour search
bool getDrawHoseMarker () const
 return the flag of whether to draw hose marker
ngl::Vector getHoseCenter () const
 return the centre of the hose
ngl::Vector getHoseVelocity () const
 return the velocity of the hose
bool getHoseWaitUntilHitBoundary () const
 return whether the hose particles wait until they first hit the boundary before they act as fluid
bool getHoseWaitUntilHitRBD () const
 toggles whether the hose particles wait until they first hit RBDs before they act as fluid
void setHoseWaitUntilHitBoundary (const bool _v)
 set whether the hose particles wait until they first hit the boundary before they act as fluid
void setHoseWaitUntilHitRBD (const bool _v)
 set whether the hose particles wait until they first hit RBDs before they act as fluid
void setDrawHoseMarker (const bool _v)
 set flag of whether to draw hose marker
void setHoseCenter (const ngl::Vector _v)
 set the centre of the hose
void setHoseVelocity (const ngl::Vector _v)
 return the velocity of the hose
void setSmoothingLength (const ngl::Real _v)
 set the smoothing kernel length
std::vector< FluidParticlegetHoseParticlePrototypeList () const
 return the list of fluid prototypes
void updateRestDensityForFluid (const int _fluidId, const ngl::Real _restDensity)
 update rest density of a fluid
void updateGasConstantForFluid (const int _fluidId, const ngl::Real _gasConstant)
 update gas constant of a fluid
void updateViscosityConstantForFluid (const int _fluidId, const ngl::Real _viscosityConstant)
 update viscosity constant of a fluid
void updateSurfaceCoefficientForFluid (const int _fluidId, const ngl::Real _coefficient)
 update surface coefficient of a fluid
void updateSurfaceThresholdForFluid (const int _fluidId, const ngl::Real _threshold)
 update surface threshold of a fluid
void updateInterfaceCoefficientForFluid (const int _fluidId, const ngl::Real _coefficient)
 update interface coefficient of a fluid
void updateInterfaceThresholdForFluid (const int _fluidId, const ngl::Real _threshold)
 update interface threshold of a fluid
void updateInterfaceColorForFluid (const int _fluidId, const ngl::Real _color)
 update interface color of a fluid

Private Member Functions

ngl::Real WKernel_Poly (const ngl::Real _separationLength)
 calculate the poly 6 kernel
ngl::Vector WKernel_Poly_Gradient (const ngl::Vector _separationVector)
 calculate the poly 6 gradient kernel
ngl::Real WKernel_Poly_Laplacian (const ngl::Real _separationLength)
 calculate the poly 6 laplacian kernel
ngl::Vector WKernel_Pressure_Gradient (const ngl::Vector _separationVector)
 calculate the pressure (spiky) gradient kernel
ngl::Real WKernel_Viscosity_Laplacian (const ngl::Real _separationLength)
 calculate the viscosity laplacian kernel
ngl::Vector normalise (const ngl::Vector _vector)
 normalise a vector
int getFluidIdFromName (const std::string _name)
 get a particle fluid id from its name

Private Attributes

std::vector< FluidParticlem_particleList
 list of particles making up the fluid simulation
std::vector< ParticleVectorm_neighbourForParticleList
 the big list of neighbours of each particle
ngl::Real m_smoothingLength
 smoothing kernel length
bool m_enableAutoFluid
 flag to control automatic movement of the fluid
Neighbourm_neighbour
 the neighbouring structure for the fluid particles
ngl::Real m_weightPoly
 pre-calculated part of the poly 6 kernel
ngl::Real m_weightPolyGradient
 pre-calculated part of the poly 6 gradient kernel
ngl::Real m_weightPolyLaplacian
 pre-calculated part of the poly 6 laplacian kernel
ngl::Real m_weightPressureGradient
 pre-calculated part of the pressure gradient kernel
ngl::Real m_weightViscosityLaplacian
 pre-calculated part of the viscosity laplacian kernel
std::vector< FluidParticlem_hoseParticlePrototypeList
 list of particles, one per fluid that is used as a prototype when creating a hose
std::vector< FluidParticlem_hoseParticleList
 list of particles making up the hose model
int m_currentHoseableFluid
 the current fluid id that is injected when hose is applied
ngl::Vector m_hoseInitialCenter
 the initial position of the hose particles
ngl::Vector m_hoseCenter
 the current position where hose particles are injected into the scene
ngl::Vector m_hoseVelocity
 the velocity of hose particles
bool m_drawHoseMarker
 toggles whether to draw hose marker
bool m_hoseWaitUntilHitBoundary
 toggles whether the hose particles wait until they first hit the boundary before they act as fluid
bool m_hoseWaitUntilHitRBD
 toggles whether the hose particles wait until they first hit RBDs before they act as fluid
int m_iteration
 iteration counter

Detailed Description

creates fluid particles and perform SPH fluid simulation at every iteration

Definition at line 27 of file Solver.h.


Constructor & Destructor Documentation

Solver::~Solver ( )

dtor

Definition at line 45 of file Solver.cpp.

References m_neighbour.

{
    //clean up
    std::cout << "Fluid Solver Cleanup" << std::endl;

    //delete objects
    delete m_neighbour;
}

Member Function Documentation

bool Solver::getDrawHoseMarker ( ) const [inline]

return the flag of whether to draw hose marker

Definition at line 89 of file Solver.h.

References m_drawHoseMarker.

{ return m_drawHoseMarker; }

Here is the caller graph for this function:

bool Solver::getEnableAutoFluidUpdate ( ) const [inline]

returns wherether automatic fluid update is enabled

Definition at line 80 of file Solver.h.

References m_enableAutoFluid.

{ return m_enableAutoFluid; }

Here is the caller graph for this function:

int Solver::getFluidIdFromName ( const std::string  _name) [private]

get a particle fluid id from its name

Parameters:
[in]_namethe fluid name

Definition at line 112 of file Solver.cpp.

References m_hoseParticlePrototypeList.

{
    //assume id to be of the first fluid
    int id = 0;

    //loop through hose prototype list
    for (int i = 0; i < m_hoseParticlePrototypeList.size(); i++)
    {
        //compare names
        if (m_hoseParticlePrototypeList[i].getName() == _name)
        {
            id = i;
            break;
        }
    }

    return id;
}
ngl::Vector Solver::getHoseCenter ( ) const [inline]

return the centre of the hose

Definition at line 92 of file Solver.h.

References m_hoseCenter.

{ return m_hoseCenter; }

Here is the caller graph for this function:

std::vector<FluidParticle> Solver::getHoseParticlePrototypeList ( ) const [inline]

return the list of fluid prototypes

Definition at line 132 of file Solver.h.

References m_hoseParticlePrototypeList.

Here is the caller graph for this function:

ngl::Vector Solver::getHoseVelocity ( ) const [inline]

return the velocity of the hose

Definition at line 95 of file Solver.h.

References m_hoseVelocity.

{ return m_hoseVelocity; }

Here is the caller graph for this function:

bool Solver::getHoseWaitUntilHitBoundary ( ) const [inline]

return whether the hose particles wait until they first hit the boundary before they act as fluid

Definition at line 98 of file Solver.h.

References m_hoseWaitUntilHitBoundary.

Here is the caller graph for this function:

bool Solver::getHoseWaitUntilHitRBD ( ) const [inline]

toggles whether the hose particles wait until they first hit RBDs before they act as fluid

Definition at line 101 of file Solver.h.

References m_hoseWaitUntilHitRBD.

Here is the caller graph for this function:

std::vector< std::string > Solver::getNameList ( )

return the list of fluid names, used for caching

Definition at line 434 of file Solver.cpp.

References m_hoseParticlePrototypeList.

{
    std::vector<std::string> list;
    list.reserve(m_hoseParticlePrototypeList.size());

    for (int i = 0; i < m_hoseParticlePrototypeList.size(); ++i) list.push_back(m_hoseParticlePrototypeList[i].getName());

    return list;
}

Here is the caller graph for this function:

std::vector< std::vector< ngl::Vector > > Solver::getPositionList ( )

return a 2d list of the position of particles, used for caching

Definition at line 404 of file Solver.cpp.

References m_hoseParticlePrototypeList, and m_particleList.

{
    std::vector<std::vector<ngl::Vector> > positionList;

    //loop through the prototype list that contains 1 particle prototype for each fluid
    for (int i = 0; i < m_hoseParticlePrototypeList.size(); ++i)
    {
        //get name
        std::string name = m_hoseParticlePrototypeList[i].getName();
        std::vector<ngl::Vector> list;
        list.reserve(m_particleList.size());

        //loop through particle list
        for (int j = 0; j < m_particleList.size(); ++j)
        {
            //search for particles having this name
            if (m_particleList[j].getName() == name)
            {
                //add this particle's position to list
                list.push_back(m_particleList[j].getPosition());
            }
        }

        //add this fluid's position list to the big list
        positionList.push_back(list);
    }

    return positionList;
}

Here is the caller graph for this function:

ngl::Real Solver::getSmoothingLength ( ) const [inline]

return the smoothing length of the neighbour search

Definition at line 86 of file Solver.h.

References m_smoothingLength.

{ return m_smoothingLength; }

Here is the caller graph for this function:

void Solver::initialiseDrawing ( )

initialise opengl drawing

Definition at line 54 of file Solver.cpp.

{
    ngl::VBOPrimitives* prim = ngl::VBOPrimitives::instance();

    //create vbo for particle sphere
    prim->createVBOSphere("particleSphere", 0.17, 10);
}

Here is the caller graph for this function:

void Solver::injectParticles ( )

inject/pumps in hose particles into the simulation

Definition at line 131 of file Solver.cpp.

References m_currentHoseableFluid, m_hoseCenter, m_hoseInitialCenter, m_hoseParticleList, m_hoseParticlePrototypeList, m_hoseVelocity, m_hoseWaitUntilHitBoundary, m_hoseWaitUntilHitRBD, m_neighbour, m_particleList, m_smoothingLength, Neighbour::reInitialise(), Configuration::s_nextParticleId, Particle::setId(), Particle::setPosition(), Particle::setVelocity(), FluidParticle::setWaitUntilFirstHitBoundary(), and FluidParticle::setWaitUntilFirstHitRBD().

{
    std::vector<FluidParticle> l;

    //get translate in hose center
    ngl::Vector translatedVector = m_hoseCenter - m_hoseInitialCenter;

    //get prototype particle from hose prototype list
    FluidParticle prototypeParticle = m_hoseParticlePrototypeList[m_currentHoseableFluid];

    //loop through hose particles and add particles to solver particle list
    for (int i = 0; i < m_hoseParticleList.size(); i++)
    {
        //create particle from prototype particle
        FluidParticle p(prototypeParticle);

        //set id of new particle
        p.setId(Configuration::s_nextParticleId++);

        //set position of new particle = hose particle(i) + translatedVector
        p.setPosition(m_hoseParticleList[i].getPosition() + translatedVector);

        //set velocity of new particle
        p.setVelocity(m_hoseVelocity);

        //set wait until first hit properties
        p.setWaitUntilFirstHitBoundary(m_hoseWaitUntilHitBoundary);
        p.setWaitUntilFirstHitRBD(m_hoseWaitUntilHitRBD);

        //add new particle to particle list
        m_particleList.push_back(p);
    }

    std::cout << "Hose for fluid : " << m_currentHoseableFluid << "\tnew particle count : " << m_particleList.size() << "\n";

    //reinitialise neighbour structure due to new particles being added
    m_neighbour->reInitialise(m_particleList.size(), m_smoothingLength);
}

Here is the call graph for this function:

Here is the caller graph for this function:

ngl::Vector Solver::normalise ( const ngl::Vector  _vector) [private]

normalise a vector

Parameters:
[in]_vectorthe vector to normalise

Definition at line 103 of file Solver.cpp.

{
    ngl::Vector v = _vector;
    if (_vector.length() > 0.0001f) v.normalize();

    return v;
}

Here is the caller graph for this function:

void Solver::render ( ngl::TransformStack  _txStack,
ShaderLibrary io_sman,
const std::string  _shader 
)

display the particle spheres

Parameters:
[in]_txStackthe transformation stack used to maintain opengl states
[in,out]io_smanthe shader library
[in]_shaderthe shader used to display the spheres

Definition at line 378 of file Solver.cpp.

References ShaderLibrary::updateColor(), and ShaderLibrary::updateModel().

{
    ngl::VBOPrimitives* prim = ngl::VBOPrimitives::instance();

    _txStack.pushTransform();
    {
        for (int i = 0; i < m_particleList.size(); ++i)
        {
            _txStack.getCurrentTransform().setPosition(m_particleList[i].getPosition().m_x, m_particleList[i].getPosition().m_y, m_particleList[i].getPosition().m_z);

            //pass vertex info to shader
            io_sman->updateModel(_shader, _txStack.getCurrAndGlobal().getMatrix(), false);

            //pass color info to shader
            io_sman->updateColor(_shader, m_particleList[i].getColour(), false);

            prim->draw("particleSphere");
        }
    }
    _txStack.popTransform();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Solver::setCurrentHoseableFluid ( const int  _v) [inline]

set the current hoseable fluid id

Parameters:
[in]_vthe fluid id

Definition at line 77 of file Solver.h.

References m_currentHoseableFluid.

Here is the caller graph for this function:

void Solver::setDrawHoseMarker ( const bool  _v) [inline]

set flag of whether to draw hose marker

Parameters:
[in]_vthe new value

Definition at line 113 of file Solver.h.

References m_drawHoseMarker.

{ m_drawHoseMarker = _v; }

Here is the caller graph for this function:

void Solver::setHoseCenter ( const ngl::Vector  _v) [inline]

set the centre of the hose

Parameters:
[in]_vthe new value

Definition at line 117 of file Solver.h.

References m_hoseCenter.

{ m_hoseCenter = _v; }

Here is the caller graph for this function:

void Solver::setHoseVelocity ( const ngl::Vector  _v) [inline]

return the velocity of the hose

Parameters:
[in]_vthe new value

Definition at line 121 of file Solver.h.

References m_hoseVelocity.

{ m_hoseVelocity = _v; }

Here is the caller graph for this function:

void Solver::setHoseWaitUntilHitBoundary ( const bool  _v) [inline]

set whether the hose particles wait until they first hit the boundary before they act as fluid

Parameters:
[in]_vthe new flag

Definition at line 105 of file Solver.h.

References m_hoseWaitUntilHitBoundary.

Here is the caller graph for this function:

void Solver::setHoseWaitUntilHitRBD ( const bool  _v) [inline]

set whether the hose particles wait until they first hit RBDs before they act as fluid

Parameters:
[in]_vthe new flag

Definition at line 109 of file Solver.h.

References m_hoseWaitUntilHitRBD.

Here is the caller graph for this function:

void Solver::setSmoothingLength ( const ngl::Real  _v) [inline]

set the smoothing kernel length

Parameters:
[in]_vupdated smoothing length

Definition at line 125 of file Solver.h.

References m_neighbour, m_smoothingLength, and Neighbour::setCellSize().

Here is the call graph for this function:

Here is the caller graph for this function:

void Solver::toggleEnableAutoFluidUpdate ( ) [inline]

toggles the state of the automatic fluid update flag

Definition at line 83 of file Solver.h.

References m_enableAutoFluid.

{ m_enableAutoFluid ^= true; }

Here is the caller graph for this function:

void Solver::toggleNextHoseableFluid ( ) [inline]

toggle between the fluids to determine which one will be used by the hose

Definition at line 69 of file Solver.h.

References m_currentHoseableFluid, and m_hoseParticlePrototypeList.

    {
        m_currentHoseableFluid = ++m_currentHoseableFluid % m_hoseParticlePrototypeList.size();
        std::cout << "New Hoseable Fluid Id : " << m_currentHoseableFluid << "\n";
    }

Here is the caller graph for this function:

void Solver::updateFluid ( Environment io_environment,
Integration _integration 
)

update the fluid state at each timestep interval

Parameters:
[in,out]io_environmentthe environment that holds the list of obstacles
[in]_integrationthe integration object for the simulation

Definition at line 171 of file Solver.cpp.

References Environment::checkAndResolveCollision(), FluidParticle::getDensity(), Particle::getId(), Particle::getMass(), Particle::getPosition(), FluidParticle::getPressure(), Particle::getVelocity(), Integration::integrateNext(), Configuration::s_accelerationOfFreeFall, and Environment::updateObstacles().

{
    //clear neighbour map
    m_neighbour->clearHashmap();

#pragma omp parallel
{
    //refresh neighbour list
    m_neighbour->refreshHashmap(m_particleList);
}

#pragma omp parallel
{
#pragma omp for schedule(dynamic, 50)
    //density-pressure calculations
    for (int i = 0; i < m_particleList.size(); ++i)
    {
        //get neighbours of current particle
        std::vector<FluidParticle> neighbourList = m_neighbour->determineNeighbours(m_particleList[i].getPosition());

        //calculate density and pressure
        ngl::Real density = 0.0;
        for (int j = 0; j < neighbourList.size(); j++)
        {
            //accumulate density
            density += neighbourList[j].getMass() * WKernel_Poly((m_particleList[i].getPosition() - neighbourList[j].getPosition()).length());
        }
        m_particleList[i].setDensity(density);

        //calculate pressure
        m_particleList[i].calculatePressure();
    }

#pragma omp for schedule(dynamic, 50)
    //force calculations
    for (int i = 0; i < m_particleList.size(); ++i)
    {
        //reset net forces accumulate
        m_particleList[i].resetForce();

        //get neighbours of current particle
        std::vector<FluidParticle> neighbourList = m_neighbour->determineNeighbours(m_particleList[i].getPosition());

        //calculate internal forces of current particle
        ngl::Real massPerDensity = 0;
        ngl::Vector separationVector = 0;
        ngl::Real separationLength = 0.0;

        ngl::Vector pressure = 0;
        ngl::Vector viscosity = 0;

        ngl::Vector surfaceGradient = 0;
        ngl::Real surfaceLaplacian = 0;

        ngl::Vector surfaceTensionGradient = 0;
        ngl::Real surfaceTensionLaplacian = 0;
        ngl::Vector interfaceTensionGradient = 0;
        ngl::Real interfaceTensionLaplacian = 0;

        //apply fluid rules if enabled
        if (m_particleList[i].fluidRulesEnabled())
        {
            for (int j = 0; j < neighbourList.size(); j++)
            {
                //get neighbour
                FluidParticle neighbour = neighbourList[j];

                //pre-calculate some repetitive values
                massPerDensity = neighbour.getMass() / neighbour.getDensity();
                separationVector = m_particleList[i].getPosition() - neighbour.getPosition();
                separationLength = separationVector.length();

                //add in pressure and viscosity force only for neighbours, not the current particle itself
                if (neighbour.getId() != m_particleList[i].getId())
                {
                    //accumulate pressure force component
                    pressure = pressure +
                               (
                                       ((m_particleList[i].getPressure() / pow(m_particleList[i].getDensity(), 2)) + (neighbour.getPressure() / pow(neighbour.getDensity(), 2))) *
                                       neighbour.getMass() *
                                       WKernel_Pressure_Gradient(separationVector)
                                       );

                    //accumulate viscous force component
                    viscosity = viscosity +
                                (
                                        /*((currentParticle.getViscosityConstant() + neighbour.getViscosityConstant()) / 2.0) **/
                                        massPerDensity *
                                        (neighbour.getVelocity() - m_particleList[i].getVelocity()) *
                                        WKernel_Viscosity_Laplacian(separationLength)
                                        );
                }

                //accumulate surface tension-interface force component
                surfaceGradient = WKernel_Poly_Gradient(separationVector);
                surfaceLaplacian = WKernel_Poly_Laplacian(separationLength);

                //accumulate surface gradient
                surfaceTensionGradient = surfaceTensionGradient +
                                         (
                                                 massPerDensity *
                                                 m_particleList[i].getSurfaceColorCoefficient() *
                                                 surfaceGradient
                                                 );

                //accumulate surface laplacian
                surfaceTensionLaplacian = surfaceTensionLaplacian +
                                          (
                                                  massPerDensity *
                                                  m_particleList[i].getSurfaceColorCoefficient() *
                                                  surfaceLaplacian
                                                  );

                //accumulate interface gradient
                interfaceTensionGradient = surfaceTensionGradient +
                                           (
                                                   massPerDensity *
                                                   m_particleList[i].getInterfaceColorCoefficient() *
                                                   surfaceGradient
                                                   );

                //accumulate interface laplacian
                interfaceTensionLaplacian = surfaceTensionLaplacian +
                                            (
                                                    massPerDensity *
                                                    m_particleList[i].getInterfaceColorCoefficient() *
                                                    surfaceLaplacian
                                                    );

            }
        }

        //calculate pressure force
        m_particleList[i].setPressureForce(-1.0 * m_particleList[i].getDensity() * pressure);

        //calculate viscosity force
        m_particleList[i].setViscosityForce(viscosity * m_particleList[i].getViscosityConstant());

        //calculate surface tension force
        m_particleList[i].setSurfaceTensionForce(0.0);
        if (surfaceTensionGradient.length() > m_particleList[i].getSurfaceTensionThreshold())
        {
            m_particleList[i].setSurfaceTensionForce(-1.0 * m_particleList[i].getSurfaceTensionCoefficient() * normalise(surfaceTensionGradient) * surfaceTensionLaplacian);
        }

        //calculate interface tension force
        m_particleList[i].setInterfaceTensionForce(0.0);
        if (interfaceTensionGradient.length() > m_particleList[i].getInterfaceTensionThreshold())
        {
            m_particleList[i].setInterfaceTensionForce(-1.0 * m_particleList[i].getInterfaceTensionCoefficient() * normalise(interfaceTensionGradient) * interfaceTensionLaplacian);
        }

        //calculate gravity force (=density * g)
        m_particleList[i].setGravityForce(new ngl::Vector(0, m_particleList[i].getDensity() * Configuration::s_accelerationOfFreeFall, 0));

        //calculate acceleration (= force / mass)
        m_particleList[i].accumulateNetForce(m_particleList[i].getPressureForce());
        m_particleList[i].accumulateNetForce(m_particleList[i].getViscosityForce());
        m_particleList[i].accumulateNetForce(m_particleList[i].getSurfaceTensionForce());
        m_particleList[i].accumulateNetForce(m_particleList[i].getInterfaceTensionForce());
        m_particleList[i].accumulateNetForce(m_particleList[i].getGravityForce());
        m_particleList[i].updateAcceleration(m_particleList[i].getNetForce() / m_particleList[i].getDensity());
    }

#pragma omp for schedule(dynamic, 50)
    //fluid integration and movement
    for (int i = 0; i < m_particleList.size(); ++i)
    {
        if (m_particleList[i].getMoveable())
        {
            //determine next (position, velocity) of particle
            _integration->integrateNext(m_particleList[i]);
        }
    }

#pragma omp single
    //obstacles movement
    io_environment->updateObstacles(_integration);

#pragma omp for schedule(dynamic, 50)
    //collision check and resolution for fluid particles
    for (int i = 0; i < m_particleList.size(); ++i)
    {
        //check and resolve collision against obstacles and boundary
        bool hitBoundary = false; bool hitRBD = false;
        io_environment->checkAndResolveCollision(m_particleList[i], hitBoundary, hitRBD, false);

        //update first time hit issues
        m_particleList[i].updateHitForTheFirstTime(hitBoundary, hitRBD);
    }
}

//    //increment iteration counter
//    iteration++;
//    std::cout << iteration << "\n";

//    if ((iteration % 1001) == 0)
//    {
//        time_t now; time(&now);
//        printf("%s\n", ctime(&now));
//    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Solver::updateGasConstantForFluid ( const int  _fluidId,
const ngl::Real  _gasConstant 
)

update gas constant of a fluid

Parameters:
[in]_fluidIdthe fluid to update
[in]_gasConstantthe new gas constant

Definition at line 464 of file Solver.cpp.

{
    //loop for particles of the concerned fluid
    for (int i = 0; i < m_particleList.size(); ++i)
    {
        if (getFluidIdFromName(m_particleList[i].getName()) == _fluidId)
        {
            //found particles of the concerned fluid -> update it
            m_particleList[i].setGasConstant(_gasConstant);
        }
    }

    m_hoseParticlePrototypeList[_fluidId].setGasConstant(_gasConstant);
}

Here is the caller graph for this function:

void Solver::updateInterfaceCoefficientForFluid ( const int  _fluidId,
const ngl::Real  _coefficient 
)

update interface coefficient of a fluid

Parameters:
[in]_fluidIdthe fluid to update
[in]_coefficientthe new coefficient

Definition at line 540 of file Solver.cpp.

{
    //loop for particles of the concerned fluid
    for (int i = 0; i < m_particleList.size(); ++i)
    {
        if (getFluidIdFromName(m_particleList[i].getName()) == _fluidId)
        {
            //found particles of the concerned fluid -> update it
            m_particleList[i].setInterfaceTensionCoefficient(_coefficient);
        }
    }

    m_hoseParticlePrototypeList[_fluidId].setInterfaceTensionCoefficient(_coefficient);
}

Here is the caller graph for this function:

void Solver::updateInterfaceColorForFluid ( const int  _fluidId,
const ngl::Real  _color 
)

update interface color of a fluid

Parameters:
[in]_fluidIdthe fluid to update
[in]_colorthe new color

Definition at line 578 of file Solver.cpp.

{
    //loop for particles of the concerned fluid
    for (int i = 0; i < m_particleList.size(); ++i)
    {
        if (getFluidIdFromName(m_particleList[i].getName()) == _fluidId)
        {
            //found particles of the concerned fluid -> update it
            m_particleList[i].setInterfaceColorCoefficient(_color);
        }
    }

    m_hoseParticlePrototypeList[_fluidId].setInterfaceColorCoefficient(_color);
}

Here is the caller graph for this function:

void Solver::updateInterfaceThresholdForFluid ( const int  _fluidId,
const ngl::Real  _threshold 
)

update interface threshold of a fluid

Parameters:
[in]_fluidIdthe fluid to update
[in]_thresholdthe new threshold

Definition at line 559 of file Solver.cpp.

{
    //loop for particles of the concerned fluid
    for (int i = 0; i < m_particleList.size(); ++i)
    {
        if (getFluidIdFromName(m_particleList[i].getName()) == _fluidId)
        {
            //found particles of the concerned fluid -> update it
            m_particleList[i].setInterfaceTensionThreshold(_threshold);
        }
    }

    m_hoseParticlePrototypeList[_fluidId].setInterfaceTensionThreshold(_threshold);
}

Here is the caller graph for this function:

void Solver::updateRestDensityForFluid ( const int  _fluidId,
const ngl::Real  _restDensity 
)

update rest density of a fluid

Parameters:
[in]_fluidIdthe fluid to update
[in]_restDensitythe new density

Definition at line 445 of file Solver.cpp.

{
    //loop for particles of the concerned fluid
    for (int i = 0; i < m_particleList.size(); ++i)
    {
        if (getFluidIdFromName(m_particleList[i].getName()) == _fluidId)
        {
            //found particles of the concerned fluid -> update it
            m_particleList[i].setMaterialRestDensity(_restDensity);
        }
    }

    m_hoseParticlePrototypeList[_fluidId].setMaterialRestDensity(_restDensity);
}

Here is the caller graph for this function:

void Solver::updateSurfaceCoefficientForFluid ( const int  _fluidId,
const ngl::Real  _coefficient 
)

update surface coefficient of a fluid

Parameters:
[in]_fluidIdthe fluid to update
[in]_coefficientthe new coefficient

Definition at line 502 of file Solver.cpp.

{
    //loop for particles of the concerned fluid
    for (int i = 0; i < m_particleList.size(); ++i)
    {
        if (getFluidIdFromName(m_particleList[i].getName()) == _fluidId)
        {
            //found particles of the concerned fluid -> update it
            m_particleList[i].setSurfaceTensionCoefficient(_coefficient);
        }
    }

    m_hoseParticlePrototypeList[_fluidId].setSurfaceTensionCoefficient(_coefficient);
}

Here is the caller graph for this function:

void Solver::updateSurfaceThresholdForFluid ( const int  _fluidId,
const ngl::Real  _threshold 
)

update surface threshold of a fluid

Parameters:
[in]_fluidIdthe fluid to update
[in]_thresholdthe new threshold

Definition at line 521 of file Solver.cpp.

{
    //loop for particles of the concerned fluid
    for (int i = 0; i < m_particleList.size(); ++i)
    {
        if (getFluidIdFromName(m_particleList[i].getName()) == _fluidId)
        {
            //found particles of the concerned fluid -> update it
            m_particleList[i].setSurfaceTensionThreshold(_threshold);
        }
    }

    m_hoseParticlePrototypeList[_fluidId].setSurfaceTensionThreshold(_threshold);
}

Here is the caller graph for this function:

void Solver::updateViscosityConstantForFluid ( const int  _fluidId,
const ngl::Real  _viscosityConstant 
)

update viscosity constant of a fluid

Parameters:
[in]_fluidIdthe fluid to update
[in]_viscosityConstantthe new viscosity constant

Definition at line 483 of file Solver.cpp.

{
    //loop for particles of the concerned fluid
    for (int i = 0; i < m_particleList.size(); ++i)
    {
        if (getFluidIdFromName(m_particleList[i].getName()) == _fluidId)
        {
            //found particles of the concerned fluid -> update it
            m_particleList[i].setViscosityConstant(_viscosityConstant);
        }
    }

    m_hoseParticlePrototypeList[_fluidId].setViscosityConstant(_viscosityConstant);
}

Here is the caller graph for this function:

ngl::Real Solver::WKernel_Poly ( const ngl::Real  _separationLength) [private]

calculate the poly 6 kernel

Parameters:
[in]_separationLengththe separation distance between a particle and its neighbour

Definition at line 62 of file Solver.cpp.

References m_smoothingLength, and m_weightPoly.

{
    ngl::Real weight = m_weightPoly * (pow(pow(m_smoothingLength, 2) - pow(_separationLength, 2), 3));

    return weight;
}
ngl::Vector Solver::WKernel_Poly_Gradient ( const ngl::Vector  _separationVector) [private]

calculate the poly 6 gradient kernel

Parameters:
[in]_separationVectorthe separation vector between a particle and its neighbour

Definition at line 69 of file Solver.cpp.

References m_smoothingLength, and m_weightPolyGradient.

{
    ngl::Vector weight = 0;
    ngl::Real separationLength = _separationVector.length();

    weight = m_weightPolyGradient * _separationVector * pow(pow(m_smoothingLength, 2) - pow(separationLength, 2), 2);

    return weight;
}
ngl::Real Solver::WKernel_Poly_Laplacian ( const ngl::Real  _separationLength) [private]

calculate the poly 6 laplacian kernel

Parameters:
[in]_separationLengththe separation distance between a particle and its neighbour

Definition at line 79 of file Solver.cpp.

References m_smoothingLength, and m_weightPolyLaplacian.

{
    ngl::Real weight = m_weightPolyLaplacian * (pow(m_smoothingLength, 2) - pow(_separationLength, 2)) * ((3.0 * pow(m_smoothingLength, 2)) - (7.0 * pow(_separationLength, 2)));

    return weight;
}
ngl::Vector Solver::WKernel_Pressure_Gradient ( const ngl::Vector  _separationVector) [private]

calculate the pressure (spiky) gradient kernel

Parameters:
[in]_separationVectorthe separation vector between a particle and its neighbour

Definition at line 86 of file Solver.cpp.

References m_smoothingLength, m_weightPressureGradient, and normalise().

{
    ngl::Vector weight = 0;
    ngl::Real separationLength = _separationVector.length();

    weight = m_weightPressureGradient * pow(m_smoothingLength - separationLength, 2) * normalise(_separationVector);

    return weight;
}

Here is the call graph for this function:

ngl::Real Solver::WKernel_Viscosity_Laplacian ( const ngl::Real  _separationLength) [private]

calculate the viscosity laplacian kernel

Parameters:
[in]_separationLengththe separation distance between a particle and its neighbour

Definition at line 96 of file Solver.cpp.

References m_smoothingLength, and m_weightViscosityLaplacian.

{
    ngl::Real weight = m_weightViscosityLaplacian * (m_smoothingLength - _separationLength);

    return weight;
}

Member Data Documentation

the current fluid id that is injected when hose is applied

Definition at line 245 of file Solver.h.

bool Solver::m_drawHoseMarker [private]

toggles whether to draw hose marker

Definition at line 257 of file Solver.h.

bool Solver::m_enableAutoFluid [private]

flag to control automatic movement of the fluid

Definition at line 218 of file Solver.h.

ngl::Vector Solver::m_hoseCenter [private]

the current position where hose particles are injected into the scene

Definition at line 251 of file Solver.h.

ngl::Vector Solver::m_hoseInitialCenter [private]

the initial position of the hose particles

Definition at line 248 of file Solver.h.

std::vector<FluidParticle> Solver::m_hoseParticleList [private]

list of particles making up the hose model

Definition at line 242 of file Solver.h.

list of particles, one per fluid that is used as a prototype when creating a hose

Definition at line 239 of file Solver.h.

ngl::Vector Solver::m_hoseVelocity [private]

the velocity of hose particles

Definition at line 254 of file Solver.h.

toggles whether the hose particles wait until they first hit the boundary before they act as fluid

Definition at line 260 of file Solver.h.

toggles whether the hose particles wait until they first hit RBDs before they act as fluid

Definition at line 263 of file Solver.h.

int Solver::m_iteration [private]

iteration counter

Definition at line 266 of file Solver.h.

the neighbouring structure for the fluid particles

Definition at line 221 of file Solver.h.

the big list of neighbours of each particle

Definition at line 212 of file Solver.h.

std::vector<FluidParticle> Solver::m_particleList [private]

list of particles making up the fluid simulation

Definition at line 209 of file Solver.h.

ngl::Real Solver::m_smoothingLength [private]

smoothing kernel length

Definition at line 215 of file Solver.h.

ngl::Real Solver::m_weightPoly [private]

pre-calculated part of the poly 6 kernel

Definition at line 224 of file Solver.h.

ngl::Real Solver::m_weightPolyGradient [private]

pre-calculated part of the poly 6 gradient kernel

Definition at line 227 of file Solver.h.

ngl::Real Solver::m_weightPolyLaplacian [private]

pre-calculated part of the poly 6 laplacian kernel

Definition at line 230 of file Solver.h.

ngl::Real Solver::m_weightPressureGradient [private]

pre-calculated part of the pressure gradient kernel

Definition at line 233 of file Solver.h.

pre-calculated part of the viscosity laplacian kernel

Definition at line 236 of file Solver.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator