Core 1.0
DiscSystem Class Reference

A particle system constrained to an implicit surface. More...

#include <discsystem.h>

Public Member Functions

 DiscSystem (const AnalyticScalarField *, const double &, int)
 Creates a particle system constrained to an implicit surface.
 ~DiscSystem ()
 Destroy a particle system.
void Steps (int=1)
 Update the particle system.
void Cast ()
 Cast all the particles on the implicit surface.
Circle operator() (int) const
 Get the i-th particle.
Circle & operator() (int)
 Get the i-th particle.
void AddParticle (const Vector &, const double &)
 Insert a new particle in the list.
int Size () const
 Get the number of particles.

Protected Member Functions

bool Cast (int)
 Cast a particle on the implicit surface.
bool Step (int)
 Particle update.
int Closest (int, int *, double *) const
 Find the neighbors closest to a particle.
void Compute (int, Vector &, double &, bool &, bool &, int, int *)
 Computes the position and radius derivatives with respect to time.
void SplitParticle (int)
 Split a particle into two slighly perturbed ones.
void DeleteParticle (int)
 Delete a particle.

Protected Attributes

DynamicArrayIndex subd
 Voxel subdivision of space required for an efficient determination of neighbor relations between particles.
QVector< Circle > particles
 Array of particles.
double time_step = 1.0
 Step size for numerical integration.
const AnalyticScalarField * function = nullptr
 Reference to function.
double ir = 1.0
 Initial radius.

Static Protected Attributes

static const double Alpha = 6.0
 Amplitude of the repulsion energy between two particles.
static const double Beta = 10.0
 Used in computation of the variation of radius.
static const double Gamma = 4.0
 Equilibrium speed.
static const double Delta = 0.7
 Percentage of nominal radius, used as minimum radius.
static const double Rho = 10.0
 Coefficient for radius term.
static const double WH_PHI = 10.0
 For gradient feedback term.
static const double WH_NY = 0.5
 Fraction of the equilibrium energy above which a particle larger than its nominal radius may split.
static const double DeltaT = 0.1
 Time step.
static const double sigma = 1.5
 Coefficient for splitting particles.
static const double epsilon = 0.001
 Gradient epsilon for vanishing gradient.

Detailed Description

A particle system constrained to an implicit surface.

This class implements Witkin-Heckbert particle system over an implicit surface. It may be used to generate a cloud of vertices located almost uniformly over the implicit surface.

Constructor & Destructor Documentation

◆ DiscSystem()

DiscSystem::DiscSystem ( const AnalyticScalarField * f,
const double & r,
int n )

Creates a particle system constrained to an implicit surface.

Parameters
fImplicit surface class.
rRadius of the particles.
nSpatial subdivision used to speed up particle update.

◆ ~DiscSystem()

DiscSystem::~DiscSystem ( )

Destroy a particle system.

This function destroys the internal acceleration data-structures but does not destroy the implicit function.

Member Function Documentation

◆ AddParticle()

void DiscSystem::AddParticle ( const Vector & p,
const double & r )

Insert a new particle in the list.

This function hides the particles-poll mechanism that keeps track of indices of previously deleted indices to be reused. The gradient of the field function at the location of the particle is computed internally.

Parameters
pCenter of new particle.
rRadius of particle.

◆ Cast() [1/2]

void DiscSystem::Cast ( )

Cast all the particles on the implicit surface.

The particles whose gradient vanishes are deleted, the number of particles may therefore decrease.

◆ Cast() [2/2]

bool DiscSystem::Cast ( int i)
protected

Cast a particle on the implicit surface.

The particle is destroyed if gradient vanishes to null.

Parameters
iParticle identifier.
Returns
True if the particle has been deleted: the last particle of the set has then taken the index i.

◆ Closest()

int DiscSystem::Closest ( int id,
int * cc,
double * ll ) const
protected

Find the neighbors closest to a particle.

These are saved in a cache to improve speed in calculations of repulsion forces.

Only the particles of the neighboring cells of the spatial subdivision, whose normal is roughly in the same direction as the one of the particle, are considered. At most DiscSystem::CLOSEST_CACHE_SIZE neighbors are kept, the closest ones.

Parameters
idIndex of the particle.
ccReturned indexes of the closest particles, which should have room for DiscSystem::CLOSEST_CACHE_SIZE entries.
llReturned squared distances to the closest particles, normalized by the square of the sum of the largest radius and of twice the smallest radius of the pair, with the same size as cc.
Returns
The number of closest particles stored in the cache.

◆ Compute()

void DiscSystem::Compute ( int id,
Vector & delta_P,
double & delta_rad,
bool & split_flag,
bool & death_flag,
int ncl,
int * close )
protected

Computes the position and radius derivatives with respect to time.

Parameters
idIndex of particle (should be called with \( c_i[k] \) as argument).
delta_PVariation of the position of the particle (projected to tangent plane).
delta_radVariation of the radius of the particle.
split_flagSplitting flag.
death_flagDeath flag.
nclNumber of closest particles.
closeId of closest particles.

◆ DeleteParticle()

void DiscSystem::DeleteParticle ( int id)
protected

Delete a particle.

Parameters
idIndex.

◆ SplitParticle()

void DiscSystem::SplitParticle ( int i)
protected

Split a particle into two slighly perturbed ones.

Parameters
iIndex of particle.

◆ Step()

bool DiscSystem::Step ( int i)
protected

Particle update.

Find the closest neighbors, and then computes Witkin and Hekbert parameters. Particle's behavior is modified according to those parameters.

Parameters
iIndex of particle.
Returns
True if the particle has been deleted: the last particle of the set has then taken the index i.

◆ Steps()

void DiscSystem::Steps ( int n = 1)

Update the particle system.

Iteratively update all particles.

During an iteration particles may be deleted, if they are too small or if the gradient vanishes, or may be split into two particles: the number of particles, DiscSystem::Size(), is therefore not constant. A particle which takes the place of a deleted one, and a particle which has just been created, are updated in the same iteration.

Parameters
nNumber of iterations.