← Back to team overview

yade-users team mailing list archive

Re: [Question #690684]: definition of iphys in the .hpp file related to a contact law

 

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

    Status: Open => Answered

Jan Stránský proposed the following answer:
TLTR: 
- put all attributes in "simple brackets"
- use .def and .staticmethod to use C++ functions in python and therefore to enable python testing

More details:
"simple brackets":
it is inside a macro, that makes the values public attributes of the class. You can then access them from the class and also from other parts of the C++ code. It has also other advantages:
- readable / assignable from python
- adds python docstrings
- adds it to automatically built documentation
- saved / loaded with O.save / O.load
- ... ?

.def, .staticmethod
is to expose methods (functions) to python (referenced are already existing/declared methods, e.g. funcG)

.def_readonly:
in python it is to return values of the class attributes, but you cannot set them from python.
("simple brackets" can be both read and assigned)
References existing objects, e.g. omega.
The point is to prevent accidental change of some "computed" values. E.g. omega is a function of kappaD, so changing omega alone is not meaningful.
It has disadvantage that it is not saved / loaded with O.save / O.load
Do not bother with .def_readonly for now.

cheers
Jan

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