← Back to team overview

yade-dev team mailing list archive

Re: need help on ClumpTemplate

 

Thanks Bruno for your comment, I fixed it already (and some other things).

Some explanations for the purpose of ClumpTemplate:
I want to have an analogon for PFC command "clump template make", where a user can create clump templates, e.g.:

numCM1 = 2	#number of clump members
relRadList1 = [1,1]
relPosList1 = [[1,1,1],[0,0,0]]

numCM2 = 3	#number of clump members
relRadList2 = [.5,1,.5]
relPosList2 = [[1,0,0],[0,0,0],[-1,0,0]]

id_template1 = O.bodies.makeClumpTemplate(numCM1,relRadList1,relePosList1,label='dyad') id_template2 = O.bodies.makeClumpTemplate(numCM2,relRadList2,relePosList2,label='peanut')

Later (part 4) there will be a replaceByClumps() method, where templates are used. Example for replacing 50 percent with 'dyads' and 30 percent with 'peanuts':

O.bodies.replaceByClumps(2,'dyad',.5,'peanut',.3)

I know, that clump template could also be just on python side, but I think it is more comfortable for users to use it this way. What do you think?
Maybe some day clump templates can be stored along with O.save() ... ?!

Cheers,

Christian.

P.S. I see another problem in the code: pos and rad are initiated with

std::vector<Real> rad;
std::vector<Vector3r> pos;

in hpp. How can I set the length of the vector, after construction of the object in makeClumpTemplate() in yadeWrapper ?

shared_ptr<ClumpTemplate> ct=shared_ptr<ClumpTemplate>(new ClumpTemplate());
ct->rad ???
ct->pos ???


Zitat von Bruno Chareyre <bruno.chareyre@xxxxxxxxxxx>:

class ClumpTemplate {
          ClumpTemplate ct;


The problem is you are trying to define a class which contains itself,
the compiler goes crazy.
"This is a class that contains an object of the class that contains an
object of the class that contains an object of the class that contains
an object of the class that contains an object of the class..." and so on.

It is in fact possible to write:

class ClumpTemplate {
           ClumpTemplate* ct;

Because you can point to a class even if it is incompletely defined (as
soon as it is declared, actually).
But a real question is, why do you have to do that?

Bruno

_______________________________________________
Mailing list: https://launchpad.net/~yade-dev
Post to     : yade-dev@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~yade-dev
More help   : https://help.launchpad.net/ListHelp






Follow ups

References