SphRepresentation.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013-2015, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_PARTICLES_SPHREPRESENTATION_H
#define SURGSIM_PARTICLES_SPHREPRESENTATION_H
#include <Eigen/Core>
#include <vector>
#include "SurgSim/Math/Vector.h"
#include "SurgSim/Particles/Representation.h"
namespace SurgSim
{
namespace DataStructures
{
template <class T, size_t N>
class Grid;
}; // namespace DataStructures
namespace Particles
{
SURGSIM_STATIC_REGISTRATION(SphRepresentation);
class SphRepresentation : public Representation
{
public:
SURGSIM_CLASSNAME(SurgSim::Particles::SphRepresentation);
explicit SphRepresentation(const std::string& name);
virtual ~SphRepresentation();
void setMassPerParticle(double particleMass);
double getMassPerParticle() const;
void setDensity(double density);
double getDensity() const;
void setGasStiffness(double stiffness);
double getGasStiffness() const;
void setSurfaceTension(double surfaceTension);
double getSurfaceTension() const;
void setGravity(const SurgSim::Math::Vector3d& gravity);
SurgSim::Math::Vector3d getGravity() const;
void setViscosity(double viscosity);
double getViscosity() const;
void setKernelSupport(double support);
double getKernelSupport() const;
void setStiffness(double stiffness);
double getStiffness() const;
void setDamping(double damping);
double getDamping() const;
void setFriction(double friction);
double getFriction() const;
protected:
bool doInitialize() override;
bool doUpdate(double dt) override;
bool doHandleCollisions(double dt, const SurgSim::Collision::ContactMapType& collisions) override;
void computeVelocityAndPosition(double dt);
Eigen::Matrix<double, Eigen::Dynamic, 3, Eigen::RowMajor> m_normal;
Eigen::Matrix<double, Eigen::Dynamic, 3, Eigen::RowMajor> m_acceleration;
Math::Vector m_density;
Math::Vector m_pressure;
double m_mass;
double m_densityReference;
double m_gasStiffness;
double m_surfaceTension;
double m_stiffness;
double m_damping;
double m_friction;
SurgSim::Math::Vector3d m_gravity;
double m_viscosity;
double m_h;
double m_hSquared;
double m_kernelPoly6;
double m_kernelPoly6Gradient;
double m_kernelSpikyGradient;
double m_kernelViscosityLaplacian;
double m_kernelPoly6Laplacian;
std::shared_ptr<SurgSim::DataStructures::Grid<size_t, 3>> m_grid;
private:
void computeNeighbors();
void computeDensityAndPressureField();
void computeNormalField();
void computeAccelerations();
};
}; // namespace Particles
}; // namespace SurgSim
#endif // SURGSIM_PARTICLES_SPHREPRESENTATION_H
SurgSim::Particles::SphRepresentation::m_kernelViscosityLaplacian
double m_kernelViscosityLaplacian
Definition: SphRepresentation.h:181
SurgSim::Particles::SphRepresentation::m_surfaceTension
double m_surfaceTension
Surface tension.
Definition: SphRepresentation.h:168
Representation.h
SurgSim::Particles::SphRepresentation::m_pressure
Math::Vector m_pressure
Particles&#39; pressure.
Definition: SphRepresentation.h:164
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Particles::SphRepresentation::m_gasStiffness
double m_gasStiffness
Stiffness of the gas considered.
Definition: SphRepresentation.h:167
SurgSim::Particles::SphRepresentation::m_friction
double m_friction
Collision sliding friction coefficient.
Definition: SphRepresentation.h:171
SurgSim::Particles::SphRepresentation::m_density
Math::Vector m_density
Particles&#39; density.
Definition: SphRepresentation.h:163
SurgSim::Particles::SphRepresentation::m_normal
Eigen::Matrix< double, Eigen::Dynamic, 3, Eigen::RowMajor > m_normal
Particles&#39; normal.
Definition: SphRepresentation.h:161
SurgSim::Particles::SphRepresentation::m_kernelSpikyGradient
double m_kernelSpikyGradient
Definition: SphRepresentation.h:180
SurgSim::Particles::SphRepresentation::m_acceleration
Eigen::Matrix< double, Eigen::Dynamic, 3, Eigen::RowMajor > m_acceleration
Particles&#39; acceleration.
Definition: SphRepresentation.h:162
SurgSim::Particles::SphRepresentation::m_damping
double m_damping
Collision damping.
Definition: SphRepresentation.h:170
SurgSim::Particles::Representation
The Representation class defines the base class for all Particle System.
Definition: Representation.h:40
SurgSim::Particles::SphRepresentation::m_hSquared
double m_hSquared
Definition: SphRepresentation.h:177
SurgSim::Particles::SphRepresentation::m_h
double m_h
Kernels parameter (support length and its powers)
Definition: SphRepresentation.h:176
SurgSim::Particles::Particles
DataStructures::Vertices< ParticleData > Particles
Definition: Particles.h:53
SurgSim::Particles::SphRepresentation::m_kernelPoly6Laplacian
double m_kernelPoly6Laplacian
Definition: SphRepresentation.h:182
SurgSim::Math::Vector
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
A dynamic size column vector.
Definition: Vector.h:68
SURGSIM_CLASSNAME
#define SURGSIM_CLASSNAME(ClassName)
Declare the class name of a class with the appropriate function header, do not use quotes...
Definition: Macros.h:21
SurgSim::Particles::SphRepresentation::m_mass
double m_mass
Mass per particle (determine the density of particle per m3)
Definition: SphRepresentation.h:165
SurgSim::Particles::SphRepresentation::m_gravity
SurgSim::Math::Vector3d m_gravity
3D Gravity vector
Definition: SphRepresentation.h:172
SurgSim::Collision::ContactMapType
std::unordered_map< std::shared_ptr< SurgSim::Collision::Representation >, std::list< std::shared_ptr< SurgSim::Collision::Contact > > > ContactMapType
Definition: Representation.h:47
SurgSim::Particles::SphRepresentation::m_densityReference
double m_densityReference
Density of the reference gas.
Definition: SphRepresentation.h:166
Vector.h
Definitions of small fixed-size vector types.
SurgSim::Particles::SphRepresentation::m_kernelPoly6Gradient
double m_kernelPoly6Gradient
Definition: SphRepresentation.h:179
SurgSim::Math::Vector3d
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
SurgSim::Particles::SphRepresentation::m_stiffness
double m_stiffness
Collision stiffness.
Definition: SphRepresentation.h:169
SurgSim::Particles::SphRepresentation::m_viscosity
double m_viscosity
Viscosity coefficient.
Definition: SphRepresentation.h:173
SurgSim::Particles::SphRepresentation::m_kernelPoly6
double m_kernelPoly6
Definition: SphRepresentation.h:178
SurgSim::Particles::SphRepresentation::m_grid
std::shared_ptr< SurgSim::DataStructures::Grid< size_t, 3 > > m_grid
Grid acceleration to evaluate the kernels locally (storing the particles&#39; index)
Definition: SphRepresentation.h:185
SurgSim::Particles::SphRepresentation
SphRepresentation is a Representation dedicated to Smoothed-Particles Hydrodynamics (SPH)...
Definition: SphRepresentation.h:46