Momentum Scripting v1
Loading...
Searching...
No Matches
MOMENTUM_NAMESPACE::GranularBodySystem Class Reference

#include <GranularBodySystem.h>

Public Types

enum  LatticeType { SQUARE_PACK = 0 , HEXAGONAL_CLOSE_PACK = 1 }
 

Public Member Functions

std::shared_ptr< GranularBodycreateGranularBody (double radius, const Material *material)
 
GranularBodyVector filterBodiesInGeometry (const Geometry *geometry, const GranularBodyVector &granularBodies, bool onlyCheckForMidPoint) const
 
std::shared_ptr< DataBufferAccessorgetDataBufferAccessor ()
 
GranularBodyVector getGranularBodies () const
 
GranularBodyVector getGranularBodies (const std::vector< unsigned int > &ids) const
 
GranularBodyVector getGranularBodiesInsideGeometry (const Geometry *geometry, bool onlyCheckForMidPoint) const
 
std::shared_ptr< GranularBodygetGranularBody (unsigned int id) const
 
double getRotationalEnergy () const
 
double getTotalEnergy () const
 
double getTranslationalEnergy () const
 
bool loadFile (const std::string &filename, const Material *initialMaterial, const AffineMatrix4x4 &offset=AffineMatrix4x4())
 
bool loadFileGetBodies (const std::string &filename, const Material *initialMaterial, GranularBodyVector &granularBodies, const AffineMatrix4x4 &offset=AffineMatrix4x4())
 
int removeGranularBodiesInsideGeometry (const Geometry *geometry, bool onlyCheckForMidPoint)
 
GranularBodyVector spawnGranularBodyLatticeInBound (const Vec3 &min, const Vec3 &max, const ParticleDistribution *distribution, const Vec3 &spacing, double jitterFactor, const Material *material, LatticeType latticeType=SQUARE_PACK)
 
GranularBodyVector spawnGranularBodyLatticeInBound (const Vec3 &min, const Vec3 &max, double radius, const Vec3 &spacing, double jitterFactor, const Material *material, LatticeType latticeType=SQUARE_PACK)
 
GranularBodyVector spawnGranularBodyLatticeInGeometry (const Geometry *geometry, const ParticleDistribution *distribution, const Vec3 &spacing, double jitterFactor, const Material *material, LatticeType latticeType=SQUARE_PACK)
 
GranularBodyVector spawnGranularBodyLatticeInGeometry (const Geometry *geometry, double radius, const Vec3 &spacing, double jitterFactor, const Material *material, LatticeType latticeType=SQUARE_PACK)
 
bool writeFile (const std::string &filename, const GranularBodyVector &granularBodies) const
 
bool writeFileFromGeometry (const std::string &filename, const GranularBodyVector &granularBodies, const Geometry *geometry) const
 

Detailed Description

The GranularBodySystem class acts as a container for all the active GranularBodies in the simulation.

Member Enumeration Documentation

◆ LatticeType

Enumerator
SQUARE_PACK 

Arranges created Granular Bodies in a Square lattice.

HEXAGONAL_CLOSE_PACK 

Arranges created Granular Bodies in a Hexagonal Close Packed Lattice.

Member Function Documentation

◆ createGranularBody()

std::shared_ptr< GranularBody > MOMENTUM_NAMESPACE::GranularBodySystem::createGranularBody ( double  radius,
const Material material 
)

Create a new GranularBody in the simulation.

Parameters
radiusThe desired radius of the GranularBody.
materialThe desired material of the GranularBody. The material density will be used to calculate the mass of the body.

Only available in simulation mode

◆ filterBodiesInGeometry()

GranularBodyVector MOMENTUM_NAMESPACE::GranularBodySystem::filterBodiesInGeometry ( const Geometry geometry,
const GranularBodyVector granularBodies,
bool  onlyCheckForMidPoint 
) const

Return a subset of specified granular bodies that intersect with a specified geometry.

Parameters
geometry- The geometry that will be used in the intersection test.
onlyCheckForMidPoint- True if only the midpoint of the granular body should be used in the intersection test, false if the radius should be included.
granularBodies- vector containing all granular bodies that should be tested against the specified geometry.
Returns
vector containing the subset of the specified granular bodies that intersect with the specified geometry.

◆ getDataBufferAccessor()

std::shared_ptr< DataBufferAccessor > MOMENTUM_NAMESPACE::GranularBodySystem::getDataBufferAccessor ( )

Return the low level data buffer accessor for the GranularBodySystem that contains structured array data for GranularBody position, velocity, force, contact data, etc.

◆ getGranularBodies() [1/2]

GranularBodyVector MOMENTUM_NAMESPACE::GranularBodySystem::getGranularBodies ( ) const

Get the active GranularBodies in the simulation.

Returns
the active GranularBodies in the simulation

◆ getGranularBodies() [2/2]

GranularBodyVector MOMENTUM_NAMESPACE::GranularBodySystem::getGranularBodies ( const std::vector< unsigned int > &  ids) const

Get GranularBodies given a vector of ids.

Parameters
ids- a vector containing ids for the Granular Bodies to extract.
Returns
a vector of GranularBodies corresponding to the ids in the specified vector.

◆ getGranularBodiesInsideGeometry()

GranularBodyVector MOMENTUM_NAMESPACE::GranularBodySystem::getGranularBodiesInsideGeometry ( const Geometry geometry,
bool  onlyCheckForMidPoint 
) const

Return all granular bodies that intersect with a specified geometry.

Parameters
geometry- The geometry that will be used in the intersection test.
onlyCheckForMidPoint- True if only the midpoint of the granular body should be used in the intersection test, false if the radius should be included.
Returns
vector containing the subset of the specified granular bodies that are inside the specified geometry.

◆ getGranularBody()

std::shared_ptr< GranularBody > MOMENTUM_NAMESPACE::GranularBodySystem::getGranularBody ( unsigned int  id) const

Get a GranularBody in the simulation given an id.

Will return nullptr if no GranularBody with specified id exists.

Parameters
theid of the GranularBody to extract.
Returns
the GranularBody with specified id, otherwise nullptr.

◆ getRotationalEnergy()

double MOMENTUM_NAMESPACE::GranularBodySystem::getRotationalEnergy ( ) const
Returns
the rotational energy for all GranularBodies in the simulation

◆ getTotalEnergy()

double MOMENTUM_NAMESPACE::GranularBodySystem::getTotalEnergy ( ) const
Returns
the total energy for all GranularBodies in the simulation

◆ getTranslationalEnergy()

double MOMENTUM_NAMESPACE::GranularBodySystem::getTranslationalEnergy ( ) const
Returns
the translational energy for all GranularBodies in the simulation

◆ loadFile()

bool MOMENTUM_NAMESPACE::GranularBodySystem::loadFile ( const std::string &  filename,
const Material initialMaterial,
const AffineMatrix4x4 offset = AffineMatrix4x4() 
)

Load GranularBodies from the specified .agx file into the current simulation.

Parameters
filename- The specified file in .agx format containing granular data to be loaded into the simulation
initialMaterial- The initial material that will be set to the loaded granular bodies.
offset- The initial transform that will be applied to all particles that are loaded from the specified file.
Returns
true if the specified .agx file was successfully loaded, false otherwise.

◆ loadFileGetBodies()

bool MOMENTUM_NAMESPACE::GranularBodySystem::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 granular into a specified reference vector.

Parameters
filename- The specified file in .agx format containing granular data to be loaded into the simulation
initialMaterial- The initial material that will be set to the loaded granular bodies.
granularBodies- A reference vector that the loaded granular bodies will be inserted to.
offset- The initial transform that will be applied to all particles that are loaded from the specified file.
Returns
true if the specified .agx file was successfully loaded, false otherwise.

◆ removeGranularBodiesInsideGeometry()

int MOMENTUM_NAMESPACE::GranularBodySystem::removeGranularBodiesInsideGeometry ( const Geometry geometry,
bool  onlyCheckForMidPoint 
)

Remove Granular Bodies that are partially or wholly inside the specified Geometry.

Parameters
geometry- The specified geometry that the Granular Bodies will be compared against.
onlyCheckForMidPoint- Set to True/False if only the midpoint of the Granular Body will be compared against the Geometry.
Returns
The number of Granular Bodies that was removed in the operation

◆ spawnGranularBodyLatticeInBound() [1/2]

GranularBodyVector MOMENTUM_NAMESPACE::GranularBodySystem::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.

Parameters
minThe minimum position of the bound that will be used to create the Granular Bodies.
maxThe maximum position of the bound that will be used to create the Granular Bodies.
distribution- The distribution table to use when generating the Granular Bodies.
spacingThe spacing between the midpoints of the granular bodies that will be created.
jitterFactorThe fraction of the radius that will be used to randomly perturb the positions of the create particles in order to create noise.
materialThe material that will be used on the created granular bodies.
latticeTypeThe type of lattice that is to be created. Given by the LATTICE_TYPE.
Returns
A vector of the created Granular Bodies.

◆ spawnGranularBodyLatticeInBound() [2/2]

GranularBodyVector MOMENTUM_NAMESPACE::GranularBodySystem::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.

Parameters
minThe minimum position of the bound that will be used to create the Granular Bodies.
maxThe maximum position of the bound that will be used to create the Granular Bodies.
radiusThe radius of the Granular Bodies that will be created.
spacingThe spacing between the midpoints of the granular bodies that will be created.
jitterFactorThe fraction of the radius that will be used to randomly perturb the positions of the create particles in order to create noise.
materialThe material that will be used on the created granular bodies.
latticeTypeThe type of lattice that is to be created. Given by the LATTICE_TYPE.
Returns
A vector of the created Granular Bodies.

◆ spawnGranularBodyLatticeInGeometry() [1/2]

GranularBodyVector MOMENTUM_NAMESPACE::GranularBodySystem::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.

Note
The geometry should have Sensor set to True to remove collisions with the geometry or set the Collisions property to False.
Parameters
geometry- The geometry that will be used to create a particle lattice inside it's bounds.
distribution- The distribution table to use when generating the Granular Bodies.
spacing- The spacing between the midpoints of the granular bodies that will be created.
jitterFactor- The fraction of the radius that will be used to randomly perturb the positions of the create particles in order to create noise.
material- The material that will be used on the created granular bodies.
latticeType- The type of lattice that is to be created. Given by the LATTICE_TYPE.
Returns
A vector of the created Granular Bodies.

◆ spawnGranularBodyLatticeInGeometry() [2/2]

GranularBodyVector MOMENTUM_NAMESPACE::GranularBodySystem::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.

Note
The geometry should have Sensor set to True to remove collisions with the geometry or set the Collisions property to False.
Parameters
geometry- The geometry that will be used to create a particle lattice inside it's bounds.
radius- The radius of the Granular Bodies that will be created.
spacing- The spacing between the midpoints of the granular bodies that will be created.
jitterFactor- The fraction of the radius that will be used to randomly perturb the positions of the create particles in order to create noise.
material- The material that will be used on the created granular bodies.
latticeType- The type of lattice that is to be created. Given by the LATTICE_TYPE.
Returns
A vector of the created Granular Bodies.

◆ writeFile()

bool MOMENTUM_NAMESPACE::GranularBodySystem::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 file extension:

'.agx' - Will write granular bodies to a binary .agx file. ( Default )

'.csv' - Will write granular data in .csv format.

Parameters
filename- The specified file in .agx format that the specified granular data to be stored to.
granularBodies- A vector containing the granular bodies will be stored in in the specified file.
Returns
true if the granular data could be written to the specified file, false otherwise.

◆ writeFileFromGeometry()

bool MOMENTUM_NAMESPACE::GranularBodySystem::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 file extension:

'.agx' - Will write granular bodies to a binary .agx file. ( Default )

'.csv' - Will write granular data in .csv format.

Parameters
filename- The specified file in .agx format that the specified granular data to be stored to.
granularBodies- A vector containing the granular bodies will be tested against the geometry.
geometry- The geometry that will be used in the intersection tests to determine which of the specified granular bodies that will be stored to the .agx file.
Returns
true if the granular data could be written to the specified file, false otherwise.