Lagrangian Liquid Simulation
Master Thesis project on simulation of liquids using Lagrangian approach and SPH
|
creates fluid particles and perform SPH fluid simulation at every iteration More...
#include <Solver.h>
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< FluidParticle > | getHoseParticlePrototypeList () 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< FluidParticle > | m_particleList |
list of particles making up the fluid simulation | |
std::vector< ParticleVector > | m_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 | |
Neighbour * | m_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< FluidParticle > | m_hoseParticlePrototypeList |
list of particles, one per fluid that is used as a prototype when creating a hose | |
std::vector< FluidParticle > | m_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 |
creates fluid particles and perform SPH fluid simulation at every iteration
Solver::Solver | ( | ) |
ctor
Definition at line 12 of file Solver.cpp.
References Configuration::initialiseFluidSolver(), m_currentHoseableFluid, m_drawHoseMarker, m_enableAutoFluid, m_hoseCenter, m_hoseParticleList, m_hoseParticlePrototypeList, m_hoseVelocity, m_hoseWaitUntilHitBoundary, m_hoseWaitUntilHitRBD, m_iteration, m_neighbour, m_particleList, m_smoothingLength, m_weightPoly, m_weightPolyGradient, m_weightPolyLaplacian, m_weightPressureGradient, and m_weightViscosityLaplacian.
{ //create particles and initialise parameters Configuration::initialiseFluidSolver ( m_smoothingLength, m_particleList, m_hoseParticlePrototypeList, m_hoseParticleList, m_hoseCenter, m_hoseVelocity, m_drawHoseMarker, m_hoseWaitUntilHitBoundary, m_hoseWaitUntilHitRBD ); //precompute kernel weight multipliers m_weightPoly = (315.0 / (64.0 * ngl::PI * pow(m_smoothingLength, 9))); m_weightPolyGradient = (-945.0 / (32.0 * ngl::PI * pow(m_smoothingLength, 9))); m_weightPolyLaplacian = (-945.0 / (32.0 * ngl::PI * pow(m_smoothingLength, 9))); m_weightPressureGradient = (-45.0 / (ngl::PI * pow(m_smoothingLength, 6))); m_weightViscosityLaplacian = (45.0 / (ngl::PI * pow(m_smoothingLength, 6))); //initialise parameters m_enableAutoFluid = true; m_currentHoseableFluid = 0; //create neighbouring structure m_neighbour = new Neighbour(m_particleList.size(), m_smoothingLength); m_iteration = 0; }
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; }
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; }
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; }
int Solver::getFluidIdFromName | ( | const std::string | _name | ) | [private] |
get a particle fluid id from its name
[in] | _name | the 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; }
std::vector<FluidParticle> Solver::getHoseParticlePrototypeList | ( | ) | const [inline] |
return the list of fluid prototypes
Definition at line 132 of file Solver.h.
References m_hoseParticlePrototypeList.
{ return m_hoseParticlePrototypeList; }
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; }
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.
{ return m_hoseWaitUntilHitBoundary; }
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.
{ return m_hoseWaitUntilHitRBD; }
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; }
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; }
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; }
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); }
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); }
ngl::Vector Solver::normalise | ( | const ngl::Vector | _vector | ) | [private] |
normalise a vector
[in] | _vector | the vector to normalise |
Definition at line 103 of file Solver.cpp.
{ ngl::Vector v = _vector; if (_vector.length() > 0.0001f) v.normalize(); return v; }
void Solver::render | ( | ngl::TransformStack | _txStack, |
ShaderLibrary * | io_sman, | ||
const std::string | _shader | ||
) |
display the particle spheres
[in] | _txStack | the transformation stack used to maintain opengl states |
[in,out] | io_sman | the shader library |
[in] | _shader | the 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(); }
void Solver::setCurrentHoseableFluid | ( | const int | _v | ) | [inline] |
set the current hoseable fluid id
[in] | _v | the fluid id |
Definition at line 77 of file Solver.h.
References m_currentHoseableFluid.
{ m_currentHoseableFluid = _v; }
void Solver::setDrawHoseMarker | ( | const bool | _v | ) | [inline] |
set flag of whether to draw hose marker
[in] | _v | the new value |
Definition at line 113 of file Solver.h.
References m_drawHoseMarker.
{ m_drawHoseMarker = _v; }
void Solver::setHoseCenter | ( | const ngl::Vector | _v | ) | [inline] |
set the centre of the hose
[in] | _v | the new value |
Definition at line 117 of file Solver.h.
References m_hoseCenter.
{ m_hoseCenter = _v; }
void Solver::setHoseVelocity | ( | const ngl::Vector | _v | ) | [inline] |
return the velocity of the hose
[in] | _v | the new value |
Definition at line 121 of file Solver.h.
References m_hoseVelocity.
{ m_hoseVelocity = _v; }
void Solver::setHoseWaitUntilHitBoundary | ( | const bool | _v | ) | [inline] |
set whether the hose particles wait until they first hit the boundary before they act as fluid
[in] | _v | the new flag |
Definition at line 105 of file Solver.h.
References m_hoseWaitUntilHitBoundary.
{ m_hoseWaitUntilHitBoundary = _v; }
void Solver::setHoseWaitUntilHitRBD | ( | const bool | _v | ) | [inline] |
set whether the hose particles wait until they first hit RBDs before they act as fluid
[in] | _v | the new flag |
Definition at line 109 of file Solver.h.
References m_hoseWaitUntilHitRBD.
{ m_hoseWaitUntilHitRBD = _v; }
void Solver::setSmoothingLength | ( | const ngl::Real | _v | ) | [inline] |
set the smoothing kernel length
[in] | _v | updated smoothing length |
Definition at line 125 of file Solver.h.
References m_neighbour, m_smoothingLength, and Neighbour::setCellSize().
{ m_smoothingLength = _v; m_neighbour->setCellSize(_v); }
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; }
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"; }
void Solver::updateFluid | ( | Environment * | io_environment, |
Integration * | _integration | ||
) |
update the fluid state at each timestep interval
[in,out] | io_environment | the environment that holds the list of obstacles |
[in] | _integration | the 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)); // } }
void Solver::updateGasConstantForFluid | ( | const int | _fluidId, |
const ngl::Real | _gasConstant | ||
) |
update gas constant of a fluid
[in] | _fluidId | the fluid to update |
[in] | _gasConstant | the 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); }
void Solver::updateInterfaceCoefficientForFluid | ( | const int | _fluidId, |
const ngl::Real | _coefficient | ||
) |
update interface coefficient of a fluid
[in] | _fluidId | the fluid to update |
[in] | _coefficient | the 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); }
void Solver::updateInterfaceColorForFluid | ( | const int | _fluidId, |
const ngl::Real | _color | ||
) |
update interface color of a fluid
[in] | _fluidId | the fluid to update |
[in] | _color | the 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); }
void Solver::updateInterfaceThresholdForFluid | ( | const int | _fluidId, |
const ngl::Real | _threshold | ||
) |
update interface threshold of a fluid
[in] | _fluidId | the fluid to update |
[in] | _threshold | the 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); }
void Solver::updateRestDensityForFluid | ( | const int | _fluidId, |
const ngl::Real | _restDensity | ||
) |
update rest density of a fluid
[in] | _fluidId | the fluid to update |
[in] | _restDensity | the 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); }
void Solver::updateSurfaceCoefficientForFluid | ( | const int | _fluidId, |
const ngl::Real | _coefficient | ||
) |
update surface coefficient of a fluid
[in] | _fluidId | the fluid to update |
[in] | _coefficient | the 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); }
void Solver::updateSurfaceThresholdForFluid | ( | const int | _fluidId, |
const ngl::Real | _threshold | ||
) |
update surface threshold of a fluid
[in] | _fluidId | the fluid to update |
[in] | _threshold | the 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); }
void Solver::updateViscosityConstantForFluid | ( | const int | _fluidId, |
const ngl::Real | _viscosityConstant | ||
) |
update viscosity constant of a fluid
[in] | _fluidId | the fluid to update |
[in] | _viscosityConstant | the 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); }
ngl::Real Solver::WKernel_Poly | ( | const ngl::Real | _separationLength | ) | [private] |
calculate the poly 6 kernel
[in] | _separationLength | the 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
[in] | _separationVector | the 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
[in] | _separationLength | the 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
[in] | _separationVector | the 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; }
ngl::Real Solver::WKernel_Viscosity_Laplacian | ( | const ngl::Real | _separationLength | ) | [private] |
calculate the viscosity laplacian kernel
[in] | _separationLength | the 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; }
int Solver::m_currentHoseableFluid [private] |
bool Solver::m_drawHoseMarker [private] |
bool Solver::m_enableAutoFluid [private] |
ngl::Vector Solver::m_hoseCenter [private] |
ngl::Vector Solver::m_hoseInitialCenter [private] |
std::vector<FluidParticle> Solver::m_hoseParticleList [private] |
std::vector<FluidParticle> Solver::m_hoseParticlePrototypeList [private] |
ngl::Vector Solver::m_hoseVelocity [private] |
bool Solver::m_hoseWaitUntilHitBoundary [private] |
bool Solver::m_hoseWaitUntilHitRBD [private] |
int Solver::m_iteration [private] |
Neighbour* Solver::m_neighbour [private] |
std::vector<ParticleVector> Solver::m_neighbourForParticleList [private] |
std::vector<FluidParticle> Solver::m_particleList [private] |
ngl::Real Solver::m_smoothingLength [private] |
ngl::Real Solver::m_weightPoly [private] |
ngl::Real Solver::m_weightPolyGradient [private] |
ngl::Real Solver::m_weightPolyLaplacian [private] |
ngl::Real Solver::m_weightPressureGradient [private] |
ngl::Real Solver::m_weightViscosityLaplacian [private] |