← Back to team overview

yade-users team mailing list archive

Re: [Question #690655]: Testing the implémentation of a new contact law

 

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

Jan Stránský proposed the following answer:
The approach using just Yade (here using a static method):

// file yade/pkg/dem/MyModel.hpp ////////////////
...
class Law2_ScGeom_MyPhys_Something : public LawFunctor {
   static Real computeNormalForce(Real stiffness, Real penetrationDepth);
   YADE_CLASS_BASE_DOC_ATTRS_CTOR_PY(Law2_ScGeom_MyPhys_Something, LawFunctor,"...",
      ...
      .staticmethod("computeNormalForce")
      ...
   );
   ...
};
...

// file yade/pkg/dem/MyModel.cpp ////////////////
...
   Real Law2_ScGeom_MyPhys_Something :: computeNormalForce(Real stiffness, Real penetrationDepth) {
       return stiffness * penetrationDepth;
   }
...
   Law2_ScGeom_MyPhys_Something :: go(...) {
      ...
      fn = computeNormalForce(...)
      ...
   }
...
///////////////

Then in yade terminal:
law2 = Law2_ScGeom_MyPhys_Something
law2.computeNormalForce(1e6,1e-3)

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