AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
GranularBodySystem.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#ifndef AGX_PHYSICS_GRANULARBODYSYSTEM_H
18#define AGX_PHYSICS_GRANULARBODYSYSTEM_H
19
20#include <agx/ParticleSystem.h>
23
24namespace agx
25{
26 namespace Physics
27 {
33 {
34 public:
43 {
44 KINEMATICS = 2,
45 DYNAMICS = 3
46 };
47
48 public:
49 GranularBodySystem(Device *device = CpuDevice::instance());
50
54 Physics::GranularBodyPtr createParticle();
55
59 virtual bool setUpdateTask(Task* updateTask) override;
60
63
64#if (!defined SWIG ) || ( defined SWIGCSHARP || defined SWIGJAVA)
68 const agx::Physics::GranularBodyPtrArray getParticles() const;
70
73#endif
74
77
80
82 static void copyGranularBodyData( agx::Physics::GranularBodyPtr target, agx::Physics::GranularBodyPtr source, bool copyMaterial=true );
83
85 virtual void setSingleParticleRadius(agx::Index particleId, agx::Real radius) override;
86
88 void setSingleParticleAngularVelocity(agx::Index particleId, const agx::Vec3& angularVelocity );
89
92
95
97 static void applyTransform( agx::Physics::GranularBodyPtr gptr, const agx::AffineMatrix4x4& transform, bool includeVelocity = false );
98
101
110 virtual void setParticleMass( Real mass, bool updateExistingParticles = false ) override;
111
118 void setContactMode(agx::UInt contactMode);
119
125 void preAllocateParticlePairContactStorage( size_t numElements );
126
133
139 void preAllocateParticleStorage( size_t numElements );
140
141
154 const GranularBodyPtrVector& granularBodies,
155 bool onlyCheckForMidPoint) const;
156
167 bool onlyCheckForMidPoint) const;
168
169
171
172 protected:
174 void init();
175
177
178 private:
179 };
180
181
185 }
186}
187
188
189#endif /* AGX_PHYSICS_GRANULARBODYSYSTEM_H */
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#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
The geometry representation used by the collision detection engine.
Definition: Geometry.h:92
Type-specific Array used for fast access into the data held by a Buffer.
Definition: Array.h:107
const agxData::Array< EntityPtr > getInstances() const
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.
GranularBodyPtrVector filterBodiesInGeometry(const agxCollide::Geometry *geometry, const GranularBodyPtrVector &granularBodies, bool onlyCheckForMidPoint) const
Return a subset of specified granular bodies that intersect with a specified geometry.
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.
GranularBodyPtrVector getGranularBodiesInsideGeometry(const agxCollide::Geometry *geometry, bool onlyCheckForMidPoint) const
Return all granular bodies that intersect with a specified geometry.
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.
agx::Real calculateTotalKineticEnergy() const
calculate total kinetic energy of the granular body system
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:49
A representation of a generic task.
Definition: Task.h:57
Vector containing 'raw' data.
Definition: agx/Vector.h:246
#define AGX_FORCE_INLINE
Definition: macros.h:58
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint64_t UInt
Definition: Integer.h:27
double Real
Definition: Real.h:41
UInt32 Index
Definition: Integer.h:44