yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #03459
Re: macros for exposing classes to python
First one... : I did not get exactly if we have, by using these
YADE_..., to suppress all the declarations (appearing elsewher in the
.hpp) of the attributes that are defined through these macros.
Yes, you have to. The macros YADE_... are declarations and
initializations. The difference between registered and non-registered
data will correspond to different type of variables in the macro. A good
example of the different situations is pasted below.
Because I suppressed these declarations, and I get now plenty of
error messages at the compilation, blaming that all these variables
do not exist / were not declared...
You made a small mistake probably.
And directly the second one, do we have to suppress the constructor as
it was before ? Because I also get :
/home/3S-LAB/jduriez/yade/pkg/dem/Engine/GlobalEngine/NormalInelasticityLaw.hpp:34:
error: 'NormalInelasticityLaw::NormalInelasticityLaw()' cannot be
overloaded
Yes again. YADE_... contains the declaration and definition of the
constructor. You have to remove it from the hpp and cpp when the macro
is in place.
Bruno
_______________
class PeriIsoCompressor: public GlobalEngine{
Real avgStiffness; Real maxDisplPerStep; Vector3r sumForces, sigma;
Real currUnbalanced;
public:
void action(Scene*);
YADE_CLASS_BASE_DOC_ATTRS_CTOR_PY(PeriIsoCompressor,GlobalEngine,"Compress/decompress
cloud of spheres by controlling periodic cell size until it reaches
prescribed average stress, then moving to next stress value in given
stress series.",
((vector<Real>,stresses,,"Stresses that should be reached, one
after another"))
((Real,charLen,-1.,"Characteristic length, should be something
like mean particle diameter (default -1=invalid value))"))
((Real,maxSpan,-1.,"Maximum body span in terms of bbox, to
prevent periodic cell getting too small. |ycomp|"))
((Real,maxUnbalanced,1e-4,"if actual unbalanced force is smaller
than this number, the packing is considered stable,"))
((int,globalUpdateInt,20,"how often to recompute average stress,
stiffness and unbalanced force"))
((size_t,state,0,"Where are we at in the stress series"))
((string,doneHook,"","Python command to be run when reaching the
last specified stress"))
((bool,keepProportions,true,"Exactly keep proportions of the
cell (stress is controlled based on average, not its components")),
/*ctor*/
currUnbalanced=-1;
avgStiffness=-1;
maxDisplPerStep=-1;
sumForces=Vector3r::ZERO;
sigma=Vector3r::ZERO;
,
/*py*/
.def_readonly("currUnbalanced",&PeriIsoCompressor::currUnbalanced,"Current
value of unbalanced force")
.def_readonly("sigma",&PeriIsoCompressor::sigma,"Current
stress value")
);
DECLARE_LOGGER;
};
REGISTER_SERIALIZABLE(PeriIsoCompressor);
References