← Back to team overview

yade-users team mailing list archive

Re: [Question #690280]: Implementing a new contact law very different from the usual ones

 

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

Jan Stránský proposed the following answer:
Hello,

for next time, I suggest to open separate question for each problem. It
would left the conversation clean and also (therefore) could be useful
for future readers.

for implementing a new law in C++, you do not need any high level of C++
knowledge, but obviously you need to know the syntax and basic
structures (shared_ptr, static_cast).

Basically you can copy-paste all the Frict* code, changing "Frict" to a
different suitable name, e.g. SurfTenson, so FrictMat -> SurfTensionMat
etc.

If it works, then you can start to modify the logic inside.


> CREATE_LOGGER

you do not need loggers (at least for the beginning)

> can you explain all this

please be more specific what is "all this"

> <<shared_ptr>> ??

[1]

> int id1 = contact->getId1(), id2 = contact->getId2();
> getId1?? getId2 ??

this should be self-explanatory, or? id1 is id1 of the contact, id2 is
id2 of the contact

> FrictPhys* phys = static_cast<FrictPhys*>(ip.get());"
> Can you comment about these statements ? static_cast ?? ig.get, ip.get() ??

ip is of type shared_ptr<FrictPhys>
ip.get() returns ordinary pointer from the shared pointer
static_cast casts it to the type FrictMat (in case it is a derived class), static **here** means it is performed at compile time

> what is LawFunctor ??

it is the base class of specific Law2 subclasses

> what does this mean ?

again, please be more specific

> what is YADE_CLASS_BASE_DOC_ATTRS_CTOR_PY ??

a macro [2]

> FUNCTOR2D ??

it tells Yade that this class (Law2_ScGeom_FrictPhys_CundallStrack in
this case) deals with the combination of ScGeom and FrictPhys

cheers
Jan

[1] https://yade-dem.org/doc/prog.html#shared-pointers
[2] https://yade-dem.org/doc/prog.html#yade-class-base-doc-macro-family

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