← Back to team overview

yade-users team mailing list archive

Re: [Question #690825]: writing a yade class

 

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

    Status: Open => Answered

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

> I want to write a specific Yade Class to test a new contact law
defined by hpp and cpp files.

You have basically two options:

a)
(Discussed in [4], #3)
write the "equation code" externally and then you do not need to bother with Yade at all (probably would be even more difficult if Yade was incorporated).
This way,the code is easy to test externally, is lightweight, can be used not only with Yade......
It is also easily testable as a C++ program (as I wrote, I have no real experience, I use Python)
Than the Yade class just use equations from these external files.

b)
(Discussed in [4], #4)
write "normal Yade class", but structure it such that it uses a lot of functions. Each function is then independently testable (so there should be no need of "insert regular prints")
Basically it would be like to make all functions from a) approach as static methods of "normal yade classes".
Can be tested very similarly as a), but the testing can be done in Python (which is IMO much easier and more flexible).

After a while I think that b) is the way to go.
Unless you have special needs like reusing the code in another DEM code etc. which I suppose is not the case.

> I will insert regular prints

for development stage, this is probably OK, but is not "clean" solution
for the final code. (now the logging would come :-)

using b) correctly, this should not be necessary.

> What is the syntax for a yade class ??

syntax is standard C++..
Usually Yade macros are used, but they are not necessary btw., but helps to unify the code of"end" classes, make interaction with Python "out of the box", helps saving/loading...
But the macros are again standard C++ :-)

> some examples i could get inspiration from ?

already discussed Cpm* [1], Frict* [2] and Bubble* [3]
material/IPhys/Ip2/Law2 "stack".

For really testing as such, I don't know about examples of "sub-class
testing" not using actual Yade simulations..

> In which folder do i store this Yade Class ??

the easiest is probably yade/pkg/dem directory (both a) and b)
approaches)

cheers
Jan

PS: do not be discouraged, it is simply completely new field, so it
takes time to get familiar with it :-)

[1] https://answers.launchpad.net/yade/+question/690684
[2] https://answers.launchpad.net/yade/+question/690280
[3] https://answers.launchpad.net/yade/+question/690708
[4] https://answers.launchpad.net/yade/+question/690655

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