AGX Dynamics  2.35.0.1
GranularBodySystem.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGX_PHYSICS_GRANULARBODYSYSTEM_H
18 #define AGX_PHYSICS_GRANULARBODYSYSTEM_H
19 
20 #include <agx/ParticleSystem.h>
23 
24 namespace agx
25 {
26  namespace Physics
27  {
33  {
34  public:
43  {
44  KINEMATICS = 2,
45  DYNAMICS = 3
46  };
47 
48  public:
50 
54  Physics::GranularBodyPtr createParticle();
55 
59  virtual bool setUpdateTask(Task* updateTask) override;
60 
61 #if (!defined SWIG ) || ( defined SWIGCSHARP || defined SWIGJAVA)
65  const agx::Physics::GranularBodyPtrArray getParticles() const;
67 
70 #endif
71 
74 
77 
79  static void copyGranularBodyData( agx::Physics::GranularBodyPtr target, agx::Physics::GranularBodyPtr source, bool copyMaterial=true );
80 
82  virtual void setSingleParticleRadius(agx::Index particleId, agx::Real radius) override;
83 
85  void setSingleParticleAngularVelocity(agx::Index particleId, const agx::Vec3& angularVelocity );
86 
89 
92 
94  static void applyTransform( agx::Physics::GranularBodyPtr gptr, const agx::AffineMatrix4x4& transform, bool includeVelocity = false );
95 
98 
107  virtual void setParticleMass( Real mass, bool updateExistingParticles = false ) override;
108 
115  void setContactMode(agx::UInt contactMode);
116 
122  void preAllocateParticlePairContactStorage( size_t numElements );
123 
129  void preAllocateParticleGeometryContactStorage( size_t numElements );
130 
136  void preAllocateParticleStorage( size_t numElements );
137 
139 
140  protected:
142  void init();
143 
145 
146  private:
147  };
148 
149 
153  }
154 }
155 
156 
157 #endif /* AGX_PHYSICS_GRANULARBODYSYSTEM_H */
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
#define AGXPHYSICS_EXPORT
Type-specific Array used for fast access into the data held by a Buffer.
Definition: Array.h:107
const agxData::Array< EntityPtr > getInstances() const
static CpuDevice * instance()
An agx::Device is an abstract representation of a device on which data can be stored and processed.
Definition: Device.h:58
A basic particle system that contains all the storages and buffers required for basic operation and a...
agxData::EntityStorage * getParticleStorage()
Physics::ParticlePtr createParticle()
Create a new particle in the particle system.
Pointer to a entity instance of type Physics.GranularBody.
agx::Physics::GranularBodyPtrVector getGranularBodyPtrVector() const
void setSingleParticleAngularVelocity(agx::Index particleId, const agx::Vec3 &angularVelocity)
Set angular velocity for a single particle.
virtual bool setUpdateTask(Task *updateTask) override
Set the task that will be executed whenever it is time to step the simulation.
GranularBodySystem(Device *device=CpuDevice::instance())
virtual void setParticleMass(Real mass, bool updateExistingParticles=false) override
Set granular body mass and inertia.
void setMotionControl(agx::Physics::GranularBodyPtr gptr, MotionControl motionControl)
Set motion control of the granular body.
void preAllocateParticleGeometryContactStorage(size_t numElements)
Pre-allocate memory for elements via the reserve function in the storages related to particle-geometr...
agx::Vec3 getSingleParticleAngularVelocity(agx::Index particleId)
Get angular velocity for a single particle.
virtual void setSingleParticleRadius(agx::Index particleId, agx::Real radius) override
Set single particle radius given a specified id.
static bool isGranularBodySystem(agx::ParticleSystem *system)
Checks if a particle system is a granular body system by either class or by internal models.
MotionControl getMotionControl(agx::Physics::GranularBodyPtr gptr) const
Get the motion control of a granular body.
void setContactMode(agx::UInt contactMode)
Set the contact mode of the GranularBodySystem.
agx::Physics::GranularBodyPtrVector getGranularBodyPtrVector()
Physics::GranularBodyPtr createParticle()
Create a new particle in the particle system.
MotionControl
The MotionControl enumeration indicates what makes a GranularBody in the GranularBodySystem move.
static void copyGranularBodyData(agx::Physics::GranularBodyPtr target, agx::Physics::GranularBodyPtr source, bool copyMaterial=true)
Copy data from GranularBody source to target body.
const agx::Physics::GranularBodyPtrArray getParticles() const
static void applyTransform(agx::Physics::GranularBodyPtr gptr, const agx::AffineMatrix4x4 &transform, bool includeVelocity=false)
Apply a 4x4 transform on a particle.
static agx::RigidBody * convertGranularBodyToRigidBody(agx::Physics::GranularBodyPtr gptr)
Convert a granular body to a rigid body.
void preAllocateParticlePairContactStorage(size_t numElements)
Pre-allocate memory for elements via the reserve function in the storages related to particle-particl...
void preAllocateParticleStorage(size_t numElements)
Pre-allocate memory for elements via the reserve function in the particle data storage with specified...
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:55
A representation of a generic task.
Definition: Task.h:58
Vector containing 'raw' data.
Definition: agx/Vector.h:246
#define AGX_FORCE_INLINE
Definition: macros.h:58
void AGXCORE_EXPORT transform(void *target, const Format *targetFormat, const void *source, const Format *sourceFormat, size_t numElements)
Transform data between two buffers.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint32_t UInt
Definition: Integer.h:34
double Real
Definition: Real.h:42
UInt32 Index
Definition: Integer.h:52