← Back to team overview

yade-users team mailing list archive

Re: [Question #690872]: Adding a method in the yade class files associated to a new contact law

 

Question #690872 on Yade changed:
https://answers.launchpad.net/yade/+question/690872

    Status: Open => Answered

Jan Stránský proposed the following answer:
> They use .def() with all the parameters then ... staticmethod

all the parameters is not important, I think it is there for python docstrings and default parameters, you can use just
.def("pythonMethodName", &VsmPhys::someMethod)
.staticmethod("pythonMethodName")

> They use .def() ... then the declaration of staticmethod

it is not declaration, just conversion to Python. The
&VsmPhys::someMethod has to be declared in the class before, like
"static Real funcG(...)" in CpmPhys

> so how should i modify this ...
> I hope this is clear enough

sorry, I did not get the point :-)

specifically for CpmPhys::funcG, have a look how it is:
- declared in .hpp file [1]
- exposed to python [2,3] (as mentioned before, py::arg stuff is not needed)
- defined in .cpp file [4]
- used in Law2::go [5]

is that what you were asking?

cheers
Jan

[1] https://gitlab.com/yade-dev/trunk/-/blob/master/pkg/dem/ConcretePM.hpp#L151
[2] https://gitlab.com/yade-dev/trunk/-/blob/master/pkg/dem/ConcretePM.hpp#L202
[3] https://gitlab.com/yade-dev/trunk/-/blob/master/pkg/dem/ConcretePM.hpp#L203
[4] https://gitlab.com/yade-dev/trunk/-/blob/master/pkg/dem/ConcretePM.cpp#L168
[5] https://gitlab.com/yade-dev/trunk/-/blob/master/pkg/dem/ConcretePM.cpp#L421

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.