← Back to team overview

yade-dev team mailing list archive

Re: How to change the macros

 

> Hi, Anton,
> I have to change the "body" of the class:
>
 class WireMat: public FrictMat {
    public:
        virtual shared_ptr<State> newAssocState() const { return
shared_ptr<State>(new WireState); }
        virtual bool stateTypeOk(State* s) const { return
(bool)dynamic_cast<WireState*>(s); }
        void postLoad(WireMat&);
    DECLARE_LOGGER;
    YADE_CLASS_BASE_DOC_ATTRS_CTOR(WireMat,FrictMat,"Material for use with
the Wire classes",
        ((Real,diameter,0.0027,," (Diameter of the single wire in [m] (the
diameter is used to compute the cross-section area of the wire)."))

 ((vector<Vector2r>,strainStressValues1,,Attr::triggerPostLoad,"Piecewise
linear definition of the stress-strain curve by set of points
(strain[-]>0,stress[Pa]>0) for one single wire. Tension only is considered
and the point (0,0) is not needed!"))

        /************************I've add a other vector in order to take
account of my two curves*****************************/


 ((vector<Vector2r>,strainStressValues2,,Attr::triggerPostLoad,"Piecewise
linear definition of the stress-strain curve by set of points
(strain[-]>0,stress[Pa]>0) for one double wire. Tension only is considered
and the point (0,0) is not needed!"))
        ((bool,isDoubleTwist,false,,"Type of the mesh. If true two particles
of the same material which body ids differ by one will be considered as
double-twisted interaction."))
        /*((Real,lambdaEps,0.4,,"Parameter between 0 and 1 to reduce the
failure strain of the double-twisted wire (as used by [Bertrand2008]_).
[-]"))
        ((Real,lambdak,0.21,,"Parameter between 0 and 1 to compute the
elastic stiffness of the double-twisted wire (as used by [Bertrand2008]_):
$k^D=2(\\lambda_k k_h + (1-\\lambda_k)k^S)$. [-]"))*/
        ((vector,lambda,,Attr::triggerPostLoad,/*it contain the two lamdaEps
and lambdak in order to not have to modify the form of the fonction(don't
want to change the number of
parameters*/,lambda[0]=lambdaEps,lambda[1]=lambdak))
        ((Real,as,0,Attr::readonly,"Cross-section area of a single wire used
for the computation of the limit normal contact forces. [m²]"))
        ,
        createIndex();
    );
    REGISTER_CLASS_INDEX(WireMat,FrictMat);


But it can't work with YADE_CLASS_BASE_DOC_ATTRS_CTOR() because of the
number of parameters so I've try to modify serialiazable.hpp in order to
have a new fuction with the number of parameters I need:


/********************** USER MACROS START HERE ********************/

// attrs is (type,name,init-value,docstring)
#define YADE_CLASS_BASE_DOC(klass,base,doc)
YADE_CLASS_BASE_DOC_ATTRS_INIT_CTOR_PY(klass,base,doc,,,,)
#define YADE_CLASS_BASE_DOC_ATTRS(klass,base,doc,attrs)
YADE_CLASS_BASE_DOC_ATTRS_INIT_CTOR_PY(klass,base,doc,attrs,,,)
#define YADE_CLASS_BASE_DOC_ATTRS_CTOR(klass,base,doc,attrs,ctor)
YADE_CLASS_BASE_DOC_ATTRS_INIT_CTOR_PY(klass,base,doc,attrs,,ctor,)

/*********************Adding a macro to have additional
attributes****************************************/
#define
YADE_CLASS_BASE_DOC_ATTRS_attrs_CTOR(klass,base,doc,attrs,attrs,ctor)
YADE_CLASS_BASE_DOC_ATTRS_attrs_INIT_CTOR_PY(klass,base,doc,attrs,attrs,,ctor,)
#define YADE_CLASS_BASE_DOC_ATTRS_CTOR_PY(klass,base,doc,attrs,ctor,py)
YADE_CLASS_BASE_DOC_ATTRS_INIT_CTOR_PY(klass,base,doc,attrs,,ctor,py)
#define
YADE_CLASS_BASE_DOC_ATTRS_INIT_CTOR_PY(klass,base,doc,attrs,inits,ctor,py)
YADE_CLASS_BASE_DOC_ATTRS_DEPREC_INIT_CTOR_PY(klass,base,doc,attrs,,inits,ctor,py)

Thanks.
> Anna
>
>

Follow ups

References