← Back to team overview

yade-dev team mailing list archive

Re: 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_ptr<MatchMaker>,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@xxxxxxxxxxxxxxxxxxx
> > 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@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~yade-dev
> More help   : https://help.launchpad.net/ListHelp



Follow ups

References