Lagrangian Liquid Simulation
Master Thesis project on simulation of liquids using Lagrangian approach and SPH
include/Solver.h
Go to the documentation of this file.
00001 #ifndef SOLVER_H
00002 #define SOLVER_H
00003 
00004 #include "vector"
00005 
00006 #include "ngl/TransformStack.h"
00007 #include "ngl/Obj.h"
00008 #include "ngl/BBox.h"
00009 
00010 #include "ShaderLibrary.h"
00011 #include "Neighbour.h"
00012 #include "Environment.h"
00013 #include "FluidParticle.h"
00014 
00015 typedef std::vector<FluidParticle> ParticleVector;
00016 
00026 
00027 class Solver
00028 {
00029 public:
00031     Solver();
00032 
00034     ~Solver();
00035 
00039     void updateFluid
00040             (
00041                 Environment* io_environment,
00042                 Integration* _integration
00043             );
00044 
00046     void initialiseDrawing();
00047 
00052     void render
00053             (
00054                 ngl::TransformStack _txStack,
00055                 ShaderLibrary* io_sman,
00056                 const std::string _shader
00057             );
00058 
00060     void injectParticles();
00061 
00063     std::vector<std::vector<ngl::Vector> > getPositionList();
00064 
00066     std::vector<std::string> getNameList();
00067 
00069     inline void toggleNextHoseableFluid()
00070     {
00071         m_currentHoseableFluid = ++m_currentHoseableFluid % m_hoseParticlePrototypeList.size();
00072         std::cout << "New Hoseable Fluid Id : " << m_currentHoseableFluid << "\n";
00073     }
00074 
00077     inline void setCurrentHoseableFluid(const int _v) { m_currentHoseableFluid = _v; }
00078 
00080     inline bool getEnableAutoFluidUpdate() const { return m_enableAutoFluid; }
00081 
00083     inline void toggleEnableAutoFluidUpdate() { m_enableAutoFluid ^= true; }
00084 
00086     inline ngl::Real getSmoothingLength() const { return m_smoothingLength; }
00087 
00089     inline bool getDrawHoseMarker() const { return m_drawHoseMarker; }
00090 
00092     inline ngl::Vector getHoseCenter() const { return m_hoseCenter; }
00093 
00095     inline ngl::Vector getHoseVelocity() const { return m_hoseVelocity; }
00096 
00098     inline bool getHoseWaitUntilHitBoundary() const { return m_hoseWaitUntilHitBoundary; }
00099 
00101     inline bool getHoseWaitUntilHitRBD() const { return m_hoseWaitUntilHitRBD; }
00102 
00105     inline void setHoseWaitUntilHitBoundary(const bool _v) { m_hoseWaitUntilHitBoundary = _v; }
00106 
00109     inline void setHoseWaitUntilHitRBD(const bool _v) { m_hoseWaitUntilHitRBD = _v; }
00110 
00113     inline void setDrawHoseMarker(const bool _v) { m_drawHoseMarker = _v; }
00114 
00117     inline void setHoseCenter(const ngl::Vector _v) { m_hoseCenter = _v; }
00118 
00121     inline void setHoseVelocity(const ngl::Vector _v) { m_hoseVelocity = _v; }
00122 
00125     inline void setSmoothingLength(const ngl::Real _v)
00126     {
00127         m_smoothingLength = _v;
00128         m_neighbour->setCellSize(_v);
00129     }
00130 
00132     inline std::vector<FluidParticle> getHoseParticlePrototypeList() const { return m_hoseParticlePrototypeList; }
00133 
00137     void updateRestDensityForFluid
00138                 (
00139                     const int _fluidId,
00140                     const ngl::Real _restDensity
00141                 );
00142 
00146     void updateGasConstantForFluid
00147                 (
00148                     const int _fluidId,
00149                     const ngl::Real _gasConstant
00150                 );
00151 
00155     void updateViscosityConstantForFluid
00156                 (
00157                     const int _fluidId,
00158                     const ngl::Real _viscosityConstant
00159                 );
00160 
00164     void updateSurfaceCoefficientForFluid
00165                 (
00166                     const int _fluidId,
00167                     const ngl::Real _coefficient
00168                 );
00169 
00173     void updateSurfaceThresholdForFluid
00174                 (
00175                     const int _fluidId,
00176                     const ngl::Real _threshold
00177                 );
00178 
00182     void updateInterfaceCoefficientForFluid
00183                 (
00184                     const int _fluidId,
00185                     const ngl::Real _coefficient
00186                 );
00187 
00191     void updateInterfaceThresholdForFluid
00192                 (
00193                     const int _fluidId,
00194                     const ngl::Real _threshold
00195                 );
00196 
00200     void updateInterfaceColorForFluid
00201                 (
00202                     const int _fluidId,
00203                     const ngl::Real _color
00204                 );
00205 
00206 
00207 private:
00209     std::vector<FluidParticle> m_particleList;
00210 
00212     std::vector<ParticleVector> m_neighbourForParticleList;
00213 
00215     ngl::Real m_smoothingLength;
00216 
00218     bool m_enableAutoFluid;
00219 
00221     Neighbour* m_neighbour;
00222 
00224     ngl::Real m_weightPoly;
00225 
00227     ngl::Real m_weightPolyGradient;
00228 
00230     ngl::Real m_weightPolyLaplacian;
00231 
00233     ngl::Real m_weightPressureGradient;
00234 
00236     ngl::Real m_weightViscosityLaplacian;
00237 
00239     std::vector<FluidParticle> m_hoseParticlePrototypeList;
00240 
00242     std::vector<FluidParticle> m_hoseParticleList;
00243 
00245     int m_currentHoseableFluid;
00246 
00248     ngl::Vector m_hoseInitialCenter;
00249 
00251     ngl::Vector m_hoseCenter;
00252 
00254     ngl::Vector m_hoseVelocity;
00255 
00257     bool m_drawHoseMarker;
00258 
00260     bool m_hoseWaitUntilHitBoundary;
00261 
00263     bool m_hoseWaitUntilHitRBD;
00264 
00266     int m_iteration;
00267 
00268 private:
00271     ngl::Real WKernel_Poly(const ngl::Real _separationLength);
00272 
00275     ngl::Vector WKernel_Poly_Gradient(const ngl::Vector _separationVector);
00276 
00279     ngl::Real WKernel_Poly_Laplacian(const ngl::Real _separationLength);
00280 
00283     ngl::Vector WKernel_Pressure_Gradient(const ngl::Vector _separationVector);
00284 
00287     ngl::Real WKernel_Viscosity_Laplacian(const ngl::Real _separationLength);
00288 
00291     ngl::Vector normalise(const ngl::Vector _vector);
00292 
00295     int getFluidIdFromName(const std::string _name);
00296 
00297 
00298 };
00299 
00300 #endif // SOLVER_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator