Momentum Scripting v1
Loading...
Searching...
No Matches
GranularBodySystem.h
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 without having a written signed agreement with Algoryx Simulation AB.
9
10Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
11from using this software, unless otherwise stated in written agreements with
12Algoryx Simulation AB.
13*/
14
15#ifndef MOMENTUM_GRANULARBODYSYSTEM_H
16#define MOMENTUM_GRANULARBODYSYSTEM_H
17
18#include "momentum_namespace.h"
19#include "momentum_export.h"
20
21#include <memory>
22
23#include "Vec3.h"
24#include "AffineMatrix4x4.h"
25#include "GranularBody.h"
26#include "DataBufferAccessor.h"
27
28
29#ifndef SWIG
31namespace agx
32{
33 namespace Physics
34 {
35 class GranularBodySystem;
36 class GranularBodyPtr;
37 }
38}
39
40namespace agxSDK
41{
42 class Simulation;
43}
44
46#endif
47
48namespace MOMENTUM_NAMESPACE
49{
50 class Geometry;
51 class ParticleDistribution;
52
56 class MOMENTUM_EXPORT GranularBodySystem
57 {
58 public:
59#ifndef SWIG
63
65
68 GranularBodySystem( agx::Physics::GranularBodySystem* );
70#endif
71
73 {
74 SQUARE_PACK = 0,
75 HEXAGONAL_CLOSE_PACK = 1
76 };
77
83
89 GranularBodyVector getGranularBodies( const std::vector<unsigned int>& ids ) const;
90
96 std::shared_ptr<GranularBody> getGranularBody( unsigned int id ) const;
97
102
106 double getRotationalEnergy() const;
107
111 double getTotalEnergy() const;
112
117 std::shared_ptr<DataBufferAccessor> getDataBufferAccessor();
118
131 const GranularBodyVector& granularBodies,
132 bool onlyCheckForMidPoint ) const;
133
144 bool onlyCheckForMidPoint ) const;
145
160 bool writeFile( const std::string& filename,
161 const GranularBodyVector& granularBodies ) const;
162
178 bool writeFileFromGeometry( const std::string& filename,
179 const GranularBodyVector& granularBodies,
180 const Geometry* geometry ) const;
181
182#ifndef AGX_MOMENTUM_ANALYSIS_API
184 void applyAirResistance( double dragCoefficient, double viscousCoeffcient );
186
200 const Vec3& max,
201 double radius,
202 const Vec3& spacing,
203 double jitterFactor,
204 const Material* material,
205 LatticeType latticeType = SQUARE_PACK );
206
220 const Vec3& max,
221 const ParticleDistribution* distribution,
222 const Vec3& spacing,
223 double jitterFactor,
224 const Material* material,
225 LatticeType latticeType = SQUARE_PACK );
226
241 double radius,
242 const Vec3& spacing,
243 double jitterFactor,
244 const Material* material,
245 LatticeType latticeType = SQUARE_PACK );
246
261 const ParticleDistribution* distribution,
262 const Vec3& spacing,
263 double jitterFactor,
264 const Material* material,
265 LatticeType latticeType = SQUARE_PACK );
266
274 std::shared_ptr<GranularBody> createGranularBody( double radius, const Material* material );
275
282 int removeGranularBodiesInsideGeometry( const Geometry* geometry, bool onlyCheckForMidPoint );
283
296 bool loadFileGetBodies( const std::string& filename,
297 const Material* initialMaterial,
298 GranularBodyVector& granularBodies,
299 const AffineMatrix4x4& offset = AffineMatrix4x4() );
300
311 bool loadFile( const std::string& filename,
312 const Material* initialMaterial,
313 const AffineMatrix4x4& offset = AffineMatrix4x4() );
314
315#endif
316
317#ifndef SWIG
319 agx::Physics::GranularBodySystem* m_granularBodySystem;
321#endif
322 };
323}
324
325#endif
Matrix class for rigid transformations (translation, rotation).
Definition: AffineMatrix4x4.h:51
A class describing a Geometry.
Definition: Geometry.h:44
The GranularBodySystem class acts as a container for all the active GranularBodies in the simulation.
Definition: GranularBodySystem.h:57
LatticeType
Definition: GranularBodySystem.h:73
GranularBodyVector getGranularBodies(const std::vector< unsigned int > &ids) const
Get GranularBodies given a vector of ids.
std::shared_ptr< DataBufferAccessor > getDataBufferAccessor()
Return the low level data buffer accessor for the GranularBodySystem that contains structured array d...
int removeGranularBodiesInsideGeometry(const Geometry *geometry, bool onlyCheckForMidPoint)
Remove Granular Bodies that are partially or wholly inside the specified Geometry.
GranularBodyVector filterBodiesInGeometry(const Geometry *geometry, const GranularBodyVector &granularBodies, bool onlyCheckForMidPoint) const
Return a subset of specified granular bodies that intersect with a specified geometry.
bool writeFile(const std::string &filename, const GranularBodyVector &granularBodies) const
Write granular bodies that intersect with a specified geometry to a file with format according to fil...
GranularBodyVector getGranularBodiesInsideGeometry(const Geometry *geometry, bool onlyCheckForMidPoint) const
Return all granular bodies that intersect with a specified geometry.
GranularBodyVector spawnGranularBodyLatticeInBound(const Vec3 &min, const Vec3 &max, const ParticleDistribution *distribution, const Vec3 &spacing, double jitterFactor, const Material *material, LatticeType latticeType=SQUARE_PACK)
Creates a lattice of particles in a axis aligned bound created by two position.
GranularBodyVector getGranularBodies() const
Get the active GranularBodies in the simulation.
bool writeFileFromGeometry(const std::string &filename, const GranularBodyVector &granularBodies, const Geometry *geometry) const
Write granular bodies that intersect with a specified geometry to a file with format according to fil...
bool loadFileGetBodies(const std::string &filename, const Material *initialMaterial, GranularBodyVector &granularBodies, const AffineMatrix4x4 &offset=AffineMatrix4x4())
Load GranularBodies from the specified .agx file into the current simulation and insert the loaded gr...
GranularBodyVector spawnGranularBodyLatticeInGeometry(const Geometry *geometry, double radius, const Vec3 &spacing, double jitterFactor, const Material *material, LatticeType latticeType=SQUARE_PACK)
Creates a lattice of particles in a geometry given in the SpaceClaim scene.
GranularBodyVector spawnGranularBodyLatticeInGeometry(const Geometry *geometry, const ParticleDistribution *distribution, const Vec3 &spacing, double jitterFactor, const Material *material, LatticeType latticeType=SQUARE_PACK)
Creates a lattice of particles in a geometry given in the SpaceClaim scene.
bool loadFile(const std::string &filename, const Material *initialMaterial, const AffineMatrix4x4 &offset=AffineMatrix4x4())
Load GranularBodies from the specified .agx file into the current simulation.
GranularBodyVector spawnGranularBodyLatticeInBound(const Vec3 &min, const Vec3 &max, double radius, const Vec3 &spacing, double jitterFactor, const Material *material, LatticeType latticeType=SQUARE_PACK)
Creates a lattice of particles in a axis aligned bound created by two position.
std::shared_ptr< GranularBody > createGranularBody(double radius, const Material *material)
Create a new GranularBody in the simulation.
std::shared_ptr< GranularBody > getGranularBody(unsigned int id) const
Get a GranularBody in the simulation given an id.
A class describing a Material which is attached to a Geometry.
Definition: Material.h:41
A wrapper class for a ParticleDistribution of ParticleModels.
Definition: ParticleDistribution.h:74
A 3 dimensional vector which can be used to define a point or a vector and contains basic arithmetic.
Definition: Vec3.h:40
Namespace for Momentum Scripting API.
Definition: AffineMatrix4x4.h:29
std::vector< std::shared_ptr< GranularBody > > GranularBodyVector
A vector with objects of the type GranularBody .
Definition: GranularBody.h:362
std::shared_ptr< GranularBody > GranularBodyPtr
Definition: GranularBody.h:362
Definition: SceneGraph.h:29