yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #03188
Re: [yade dev] About blocked rotation
Hi Vaclac,
Have you think about vector<bool> for this purpose?
As you certainly know it's a specialized template that hold bits (instead of bools).
In fact, I have not seen the code, but in the c++ point of view, something like :
std::vector<bool> blockedDOFs;
blockedDOFs.reserve(3); // Actually, I don't remember... but something like that
blockedDOFs[0] = true;
blockedDOFs[1] = false;
blockedDOFs[2] = true;
will take the same place in memory and should maybe be easy to use.
Vincent
Le 28 janv. 2010 à 08:38, Václav Šmilauer a écrit :
>> However, it seems that, doing so, I can only manage 1 DOF as
>> blockedDOFs is a bitmask which can be chosen between these values:
> Well, read http://en.wikipedia.org/wiki/Bitmask and
> http://en.wikipedia.org/wiki/Bitwise_operation. Precisely because it is
> a bitmask, you have to set bits that correspond to RX, RY, RZ if you
> need to block just those, i.e. (8 & 16 & 32), which is binary 0b111000
> (in python) and that is decimal 56.
>
> In yade moreover, try writing State.blockedDOFs? and enter, which will
> give you
> https://www.yade-dem.org/sphinx/yade.wrapper.html#yade.wrapper.State.blockedDOFs
> and that reveals a simpler way that I put back then just for people that
> don't want to know what bitmask is, and that lest you say
>
> state.blockedDOFs=['rx','ry','rz]
>
> as well, which is the same as
>
> state.blockedDOFs=56
>
> which is the same as
>
> state.blockedDOFs=(8 & 16 & 32)
>
> which is the same as
>
> state.blockedDOFs=0b111000
>
> Prefer the 'rx','ry','rz' way, though, since those numbers are
> implementation detail and would break your code if that changed. It
> makes also the code more readable, obviously.
>
> Cheers, Vaclav
>
>
>
>
> _______________________________________________
> 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