yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #01713
Re: How to declare the global variable?
> I want to calculate the total number of cohesive contacts in my
> model.
> How can I declare the global variable for that?
No globals, sorry. You can make a variable static in some of your
classes, but it is discouraged in general (e.g. you would not be able to
use O.switchWorld() consistently). You have to update that number
somehow, anyways.
If you need that number just once in a while, count the interactions
like this:
long n=0;
FOREACH(const shared_ptr<Interaction>& I, *rootBody->interaction){ if(I->isReal()) n++; }
In python, you can use O.interactions.countReal().
HTH, Vaclav
Follow ups
References