← 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

    Status: Open => Answered

Jan Stránský proposed the following answer:
Below is a skeleton.

For testing, here just a value is printed, probably there are some frameworks for C++ testing, but I have no experience with them.
I prefer creating python interface and test python code calling the C++ code. Which is also possible with Yade actually.. it really depends on your expectations and the definition of "without the run of a yade simulation"..

MyModelEquations.hpp and MyModelEquations.cpp are Yade-independent files declaring and defining the "model equations"
test.cpp is the testing file.
MyModel.hpp and MyModel.cpp are the skeleton of actual Yade files.


// file yade/pkg/dem/MyModelEquations.hpp ///////////////////////
double computeNormalForce(double stiffness, double penetrationDepth);

// file yade/pkg/dem/MyModelEquations.cpp ///////////////////////
#include "MyModelEquations.hpp"
double computeNormalForce(double stiffness, double penetrationDepth) {
   return stiffness * penetrationDepth;
}

// file test.cpp ///////////////////////
#include<iostream>
#include "/path/to/yade/pkg/dem/MyModelEquations.hpp"

int main() {
   double stiffness = 1e9;
   double penetrationDepth = 1e-3;
   double force = computeNormalForce(stiffness,penetrationDepth);
   std::cout << force << std::endl;
}

// file yade/pkg/dem/MyModel.hpp ///////////////////////
...
class Law2_ScGeom_MyPhys_Something : public LawFunctor {
   ...
}

// file yade/pkg/dem/MyModel.cpp ///////////////////////
#include "MyModelEquations.hpp"
...
Law2_ScGeom_MyPhys_Something :: go(...) {
   ...
   fn = computeNormalForce(...)
   ...
}
...

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