Skip to content

Making it clearer that discretization > 0 in clump functions requires spherical members

Jérôme Duriez requested to merge clumpDisc into master

If one would clump a sphere over itself, discretization attribute of e.g. O.bodies.appendClumped still enables to have a correct volume of just one sphere:

# rad = 1 # hard-coding unit radius below (enabling copy-paste into YADE terminal)
clId,memb = O.bodies.appendClumped([sphere((0,0,0),1) for idx in range(2)],discretization=100)
vol = O.bodies[clId].state.mass / O.materials[0].density
volTh = 4./3*pi
print(f'Found volume = {vol}, vs {volTh} expected')

returns:

Welcome to Yade 2023-03-07.git-4180bfe 
[..]
Found volume = 4.191871999956171, vs 4.1887902047863905 expected

However, this can not work with non-Sphere-shaped clump members (here a LevelSet-shaped body --- in the form of a sphere):

# rad = 1 # hard-coding unit radius below (enabling copy-paste into YADE terminal)
clId,memb = O.bodies.appendClumped([levelSetBody('sphere',(0,0,0),1) for idx in range(2)],discretization=100)
vol = O.bodies[clId].state.mass / O.materials[0].density
volTh = 4./3*pi
print(f'Found volume = {vol}, vs {volTh} expected')

returns:

Welcome to Yade 2023-03-07.git-4180bfe 
[..]
Found volume = 8.370910929070758, vs 4.1887902047863905 expected # we just made the sum, in spite of discretization

And I would not say it is the user's fault since there is neither a corresponding statement in the doc, nor a code warning.

This MR proposes then to update the doc and a code warning for non-Sphere cases, which now returns:

<ERROR> Clump:233 static void yade::Clump::updateProperties(const boost::shared_ptr<yade::Body>&, unsigned int): Clump member 3 is not spherical, discretization > 0 is not effective
<ERROR> Clump:233 static void yade::Clump::updateProperties(const boost::shared_ptr<yade::Body>&, unsigned int): Clump member 4 is not spherical, discretization > 0 is not effective
Found volume = 8.370910929070758, vs 4.1887902047863905 expected

Merge request reports