Re: [Yade-dev] bool MatchMaker
Hi Bruno I think in terms of performance it might be better to keep MatchMaker in IP2 rather to add some in the Law functor. Further I think maybe we could get rid of includeMoment=True/False in the Law functor. My suggestion is MatchMaker for eta, krot and ktwist. This makes as well more sense if looking at the use of various materials. includeMoment can then be set by the Ip2 functor (it can be an internal variable of the Ip2) by checking if krot or ktwist are defined. What do you think about this suggestion? If you are happy I would try it? Good suggestions. You are welcome to try it. A moment flag in each interaction would be nice indeed. They would have a default depending on material properties, and could be manipulated globally, just like contact friction: setContactMoment(True/False). B ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp
Re: [Yade-dev] bool MatchMaker
Hi Klaus, There are other problems in this line. * The parameter itself has to be declared as a matchMaker. For instance Ip2_FrictMat_FrictMat_MindlinPhys::en is a MatchMaker (or None, then default code is used). includeMoment is not a MatchMaker, so it will not work. * The code itself has to use the object as a MatchMaker, not as a builtin type, for instance in HertzMinlin.cpp: Real logE = log((*en)(mat1-id,mat2-id)); instead of Real logE = log(en); So, it will clearly not work to pick a random attribute of an engine and make it a MatchMaker in a python script. It needs to be already anticipated by the c++ side. * The last thing, is that MM are indeed only returning scalar values, but it should not be a problem to convert Real to bool. I see that we don't have a real example script for matchMakers. That is bad... Bruno On 28/08/13 04:18, Klaus Thoeni wrote: Hi guys it seems that MatchMakers are working with Real only. I tried something like this: O.engines=[ ... [Law2_ScGeom_MindlinPhys_Mindlin(includeMoment=MatchMaker(matches=((mat1,mat1,True), (mat1,mat2,False] ... ] which gives the following error: TypeError: No registered converter was able to produce a C++ rvalue of type bool from this Python object of type MatchMaker When looking into the code it is obvious because the whole class is defined for Real only. Is there a workaround for Booleans? If not, any idea how to implement it? Thanks Klaus ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp -- ___ Bruno Chareyre Associate Professor ENSE³ - Grenoble INP Lab. 3SR BP 53 38041 Grenoble cedex 9 Tél : +33 4 56 52 86 21 Fax : +33 4 76 82 70 43 ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp
Re: [Yade-dev] bool MatchMaker
Hi Bruno On Wednesday 28 August 2013 12:07:40 Bruno Chareyre wrote: Hi Klaus, There are other problems in this line. * The parameter itself has to be declared as a matchMaker. For instance Ip2_FrictMat_FrictMat_MindlinPhys::en is a MatchMaker (or None, then default code is used). includeMoment is not a MatchMaker, so it will not work. * The code itself has to use the object as a MatchMaker, not as a builtin type, for instance in HertzMinlin.cpp: Real logE = log((*en)(mat1-id,mat2-id)); instead of Real logE = log(en); So, it will clearly not work to pick a random attribute of an engine and make it a MatchMaker in a python script. It needs to be already anticipated by the c++ side. I completely forgot about it but changing this should not be a problem. The definition just needs to be changed to: (shared_ptrMatchMaker,includeMoment,,,bool to consider rolling resistance) * The last thing, is that MM are indeed only returning scalar values, but it should not be a problem to convert Real to bool. I could use 0 and 1 instead of False and True in the python script: includeMoment=MatchMaker(matches=((mat1,mat1,1), (mat1,mat2,0 In the code we can use something like this to convert the Real to a Boolean: ((*includeMoment)(mat1-id,mat2-id) != 0) but this probably brakes the conventional way: includeMoment=True What do you think? I see that we don't have a real example script for matchMakers. That is bad... This script for example shows the use of MatchMaker: examples/spheresFactory.py Bruno On 28/08/13 04:18, Klaus Thoeni wrote: Hi guys it seems that MatchMakers are working with Real only. I tried something like this: O.engines=[ ... [Law2_ScGeom_MindlinPhys_Mindlin(includeMoment=MatchMaker(matches=((mat1,m at1,True), (mat1,mat2,False] ... ] which gives the following error: TypeError: No registered converter was able to produce a C++ rvalue of type bool from this Python object of type MatchMaker When looking into the code it is obvious because the whole class is defined for Real only. Is there a workaround for Booleans? If not, any idea how to implement it? Thanks Klaus ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp -- ___ Bruno Chareyre Associate Professor ENSE³ - Grenoble INP Lab. 3SR BP 53 38041 Grenoble cedex 9 Tél : +33 4 56 52 86 21 Fax : +33 4 76 82 70 43 ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp
Re: [Yade-dev] bool MatchMaker
I completely forgot about it but changing this should not be a problem. The definition just needs to be changed to: (shared_ptrMatchMaker,includeMoment,,,bool to consider rolling resistance) Yes. I could use 0 and 1 instead of False and True in the python script: includeMoment=MatchMaker(matches=((mat1,mat1,1), (mat1,mat2,0 In the code we can use something like this to convert the Real to a Boolean: ((*includeMoment)(mat1-id,mat2-id) != 0) but this probably brakes the conventional way: includeMoment=True What do you think? I don't see what it would break. Remember to keep the behavior unchanged in case includeMoment is none (in c++ the pointer will be null). This script for example shows the use of MatchMaker: examples/spheresFactory.py Yes the only one, but it more an example of SphereFactory. B ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp
Re: [Yade-dev] bool MatchMaker
I completely forgot about it but changing this should not be a problem. The definition just needs to be changed to: (shared_ptrMatchMaker,includeMoment,,,bool to consider rolling resistance) Yes. I could use 0 and 1 instead of False and True in the python script: includeMoment=MatchMaker(matches=((mat1,mat1,1), (mat1,mat2,0 In the code we can use something like this to convert the Real to a Boolean: ((*includeMoment)(mat1-id,mat2-id) != 0) but this probably brakes the conventional way: includeMoment=True What do you think? I don't see what it would break. Remember to keep the behavior unchanged in case includeMoment is none (in c++ the pointer will be null). Well, ((*includeMoment)(mat1-id,mat2-id) != 0) should work as well for the case if includeMoment is none which corresponds to the default (false) at the moment. But includeMoment=True or False in the python script should give a problem or at least a compiler warning in ((*includeMoment)(mat1-id,mat2-id) != 0), because conversion of bool with int. Don't you think so? Another option is to make MatchMakers for krot and ktwist and set them to 0 so the moment will be 0. It might be an easier solution but not the most efficient. ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp
Re: [Yade-dev] bool MatchMaker
Another option is to make MatchMakers for krot and ktwist and set them to 0 so the moment will be 0. It might be an easier solution but not the most efficient. The best thing I can imagine is to add a MatchMaker that would not replace includeMoment, let's call it momentMatch here. if (includeMoment (!momentMatch || (*momentMatch)(mat1,mat2)){ // ... the moment code } Sounds good to me, thanks for that. BTW, don't you think it would make sense to make MatchMakers for most of the parameters in the IP2 functors? It would give more flexibility when working with different materials. ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp
Re: [Yade-dev] bool MatchMaker
BTW, don't you think it would make sense to make MatchMakers for most of the parameters in the IP2 functors? It would give more flexibility when working with different materials. It would surely make sense. It has not done because it is tedious work to put them everywhere. So, they have been included on a case by case basis when someone needed such flexibility for a non-trivial situation. Another question is performance. I don't know if the impact is completely negligeable. Bruno ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp
Re: [Yade-dev] bool MatchMaker
Following your discussion. I would appreciate such possibility, too. Alex -Ursprüngliche Nachricht- Von: Yade-dev [mailto:yade-dev-bounces+alexander.eulitz=iwf.tu-berlin...@lists.launchpad.net] Im Auftrag von Klaus Thoeni Gesendet: Mittwoch, 28. August 2013 14:20 An: yade-dev@lists.launchpad.net Betreff: Re: [Yade-dev] bool MatchMaker Another option is to make MatchMakers for krot and ktwist and set them to 0 so the moment will be 0. It might be an easier solution but not the most efficient. The best thing I can imagine is to add a MatchMaker that would not replace includeMoment, let's call it momentMatch here. if (includeMoment (!momentMatch || (*momentMatch)(mat1,mat2)){ // ... the moment code } Sounds good to me, thanks for that. BTW, don't you think it would make sense to make MatchMakers for most of the parameters in the IP2 functors? It would give more flexibility when working with different materials. ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp ___ Mailing list: https://launchpad.net/~yade-dev Post to : yade-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp