chrono::particlefactory::ChRandomShapeCreatorFromFamilies Class Reference

Description

Class for generating spheres from different families, each with given probability.

It 'mixes' different ChRandomShapeGenerator sources (among these you can also put other ChRandomShapeCreatorFromFamilies to create tree-like families). This can be used to make bi-modal or multi-modal distributions, for example suppose that you need a mixture of 30% spheres, with their own size distribution, and 70% cubes, with their own distribution.

#include <ChRandomShapeCreator.h>

Inheritance diagram for chrono::particlefactory::ChRandomShapeCreatorFromFamilies:
Collaboration diagram for chrono::particlefactory::ChRandomShapeCreatorFromFamilies:

Public Types

enum  eChFamilyProbabilityMode { PARTICLE_PROBABILITY, MASS_PROBABILITY }
 

Public Member Functions

virtual std::shared_ptr< ChBodyRandomGenerate (ChCoordsys<> mcoords) override
 Function that creates a random ChBody particle each time it is called.
 
void Reset ()
 Call this BEFORE adding a set of samples via AddSample()
 
void AddFamily (std::shared_ptr< ChRandomShapeCreator > family_generator, double mprobability)
 Call this multiple times to add a set of samples. More...
 
void Setup ()
 Call this when you finished adding samples via AddSample()
 
void SetProbabilityMode (eChFamilyProbabilityMode mymode)
 Choose how the probability of each family must be considered: either in terms of number of particles, as by default, or either in terms of mass.
 
eChFamilyProbabilityMode GetProbabilityMode ()
 Report if the probability of each family is in terms of n.of particles or mass.
 
std::vector< double > & GetObtainedPercentuals ()
 For debugging. More...
 
- Public Member Functions inherited from chrono::particlefactory::ChRandomShapeCreator
virtual std::shared_ptr< ChBodyRandomGenerateAndCallbacks (ChCoordsys<> mcoords)
 This function does RandomGenerate and also executes the the custom callback, if provided. More...
 
void RegisterAddBodyCallback (std::shared_ptr< AddBodyCallback > callback)
 Set the callback function to execute at each each particle generation.
 
void SetAddCollisionShape (bool addcoll)
 Set if the created particles must include the collision shape(s). More...
 
void SetAddVisualizationAsset (bool addvisual)
 Set if the created particles must include the visualization asset(s). More...
 

Additional Inherited Members

- Protected Attributes inherited from chrono::particlefactory::ChRandomShapeCreator
std::shared_ptr< AddBodyCallbackcallback_post_creation
 
bool add_collision_shape
 
bool add_visualization_asset
 

Member Function Documentation

◆ AddFamily()

void chrono::particlefactory::ChRandomShapeCreatorFromFamilies::AddFamily ( std::shared_ptr< ChRandomShapeCreator family_generator,
double  mprobability 
)
inline

Call this multiple times to add a set of samples.

Each sample is a body with a given probability. Finally, use Setup() after you used AddSample N times The sum of probabilities should be 1; otherwise will be normalized.

◆ GetObtainedPercentuals()

std::vector<double>& chrono::particlefactory::ChRandomShapeCreatorFromFamilies::GetObtainedPercentuals ( )
inline

For debugging.

For various reasons (ex. very odd masses in generated particles), especially with a small number of particles, the desired percentuals of masses or n.of particles for the families are only approximated. Use this vector to get the actual percentuals obtained so far.


The documentation for this class was generated from the following file:
  • /builds/uwsbel/chrono/src/chrono/particlefactory/ChRandomShapeCreator.h