Discussion:
[deprecated list] How to declare the global variable?
Anton Gladky
2009-08-10 11:25:44 UTC
Permalink
Hi,

I want to calculate the total number of cohesive contacts in my model.
How can I declare the global variable for that?

Thank you
______________________________
[ENG] Best Regards
[GER] Mit freundlichen GrÌßen
[RUS] С МаОлучшОЌО пПжелаМОяЌО
[UKR] З МайкращОЌО пПбажаММяЌО

Anton Gladkyy
Václav Šmilauer
2009-08-10 11:41:55 UTC
Permalink
Post by Anton Gladky
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


_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users-oU9gvf+***@public.gmane.org
Unsubscribe : https://launchpad.net/~yade-users
More help : https://help.launchpad.net/ListHelp
Anton Gladky
2009-08-10 11:56:34 UTC
Permalink
Ok, thank you.

I think it should work for me.
______________________________
[ENG] Best Regards
[GER] Mit freundlichen GrÌßen
[RUS] С МаОлучшОЌО пПжелаМОяЌО
[UKR] З МайкращОЌО пПбажаММяЌО

Anton Gladkyy
Post by Václav Šmilauer
Post by Anton Gladky
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
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
_______________________________________________
Mailing list: https://launchpad.net/~yade-users<https://launchpad.net/%7Eyade-users>
Unsubscribe : https://launchpad.net/~yade-users<https://launchpad.net/%7Eyade-users>
More help : https://help.launchpad.net/ListHelp
Loading...