looking for the InCylinder folder

Asked by Christian Sommerfeld

Hi All,

I am new at Yade and i try to insert a InCone-subclass, but i don't to find the correct direction in the yade-folders, where every In-subclass is saved.

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Christian Sommerfeld
Solved:
Last query:
Last reply:
Revision history for this message
Anton Gladky (gladky-anton) said :
#1

Hi Christian,

you want to create one more facet-geometry like facetBox or facetCylinder, or you want to create a new geometry of body like box or cylinders?

Anton

Revision history for this message
Christian Sommerfeld (sommerfeld-m) said :
#2

Hi Anton,

Sorry that I answer so late! I need a new geometry like a box or a cylinder and it should be a cone.

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#3

You will have to implement this. It would an interesting feature!
It needs to define normal, penetration depth, contact point, and shear velocity at contacts between cone and spheres.

Revision history for this message
Christian Sommerfeld (sommerfeld-m) said :
#4

Hi,
i already implemented some code into the _pack Predicates.cpp-file, but i do not know, which file i have to change as well?

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#5

To start with that, you can take an example of shape and see how it is
defined. Let us consider boxes:
- Box.hpp/cpp
- Bo1_Box_Aabb.*

Then interactions with boxes:
- Ig2_Box_Sphere_ScGeom.*

Basically, you need to write the same code for cones. There is no
obligation to split in three files, you can write everything in one hpp
and one cpp if it is more convenient.
A few other things can be also in separate functions, like computing the
mass and inertia matrix of arbitrary cone, but it is not required for
testing (you can always assign inertia in the testing script).

Revision history for this message
Christian Sommerfeld (sommerfeld-m) said :
#6

Thank you! I will try to create it. Afterwards i will give a response if it works

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#7

Good luck!
You may start with paper and pen, to define unit normal, contact point, penetration depth and shear velocity at sphere-cone contacts.
The rest is only implementation, we can assist you for this last step.

Revision history for this message
Christian Sommerfeld (sommerfeld-m) said :
#8

First of all i created a new hpp and a new cpp file named cone.hpp and cone.cpp with the same code like in the cylinder.hpp and cylinder.cpp to check if it is still working, when i only changed the name. Furthermore, i implemented the following code into the _packPredicates.cpp file:

class inCone: public Predicate{
 Vector3r c1,c2,c12; Real radius,ht;
public:
 inCone(const Vector3r& _c1, const Vector3r& _c2, Real _radius){c1=_c1; c2=_c2; c12=c2-c1; radius=_radius; ht=c12.norm(); }
 bool operator()(const Vector3r& pt, Real pad=0.) const {
  Real u=(pt.dot(c12)-c1.dot(c12))/(ht*ht); // normalized coordinate along the c1--c2 axis
  if((u*ht<0+pad) || (u*ht>ht-pad)) return false; // out of cylinder along the axis
  Real axisDist=((pt-c1).cross(pt-c2)).norm()/ht;
  if(axisDist>radius-pad) return false;
  return true;
 }
 py::tuple aabb() const {
  // see http://www.gamedev.net/community/forums/topic.asp?topic_id=338522&forum_id=20&gforum_id=0 for the algorithm
  const Vector3r& A(c1); const Vector3r& B(c2);
  Vector3r k(
   sqrt((pow(A[1]-B[1],2)+pow(A[2]-B[2],2)))/ht,
   sqrt((pow(A[0]-B[0],2)+pow(A[2]-B[2],2)))/ht,
   sqrt((pow(A[0]-B[0],2)+pow(A[1]-B[1],2)))/ht);
  Vector3r mn=A.cwise().min(B), mx=A.cwise().max(B);
  return vvec2tuple((mn-radius*k).eval(),(mx+radius*k).eval());
 }
};

 py::class_<inCone,py::bases<Predicate> >("inCone","Cone predicate",py::init<const Vector3r&,const Vector3r&,Real>(py::args("centerBottom","centerTop","radius"),"Ctor taking centers of the lateral walls (as 3-tuples) and radius."));

what is the same code as for inCylinder

But when i want to create an inCone with the following code:

from yade import pack
pred=pack.inCone(centerBottom=(0,0,-.1),centerTop=(0,0,.1),radius=.05)

i get the following error:

AttributeError Traceback (most recent call last)

/usr/lib/yade-daily/py/yade/__init__.pyc in <module>()
----> 1
      2
      3
      4
      5

AttributeError: 'module' object has no attribute 'inCone'

and iḿ not sure what i have to do, because there isnt any direction and file like this
/usr/lib/yade-daily/py/yade/__init__.pyc

which is

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#9

Just short comments before looking the details:
1- there is no need to implement anything in packPredicates in order to add a new shape. The classes I listed above are enough.
2- the word "cylinder" in packPredicates does not refer to the class defined in Cylinder.hpp/cpp, they are really independant things. So, if you want to test that simple renaming of "cylinder" shape works, better don't play with predicates at all.

For the error you get: did you declare a python binding as in _packPredicates.cpp:342?

python::class_<inCylinder,python::bases<Predicate> >("inCylinder","Cylinder predicate",python::init<const Vector3r&,const Vector3r&,Real>(python::args("centerBottom","centerTop","radius"),"Ctor taking centers of the lateral walls (as 3-tuples) and radius."));

If yes, does is work if you type:
pred=pack.inCylinder(...

Else, you maybe forgot to import the relevant module.

Revision history for this message
Christian Sommerfeld (sommerfeld-m) said :
#10

Thank you for your fast answer,

yes i declared a phyton binding like the phyton binding for cylinder:

 py::class_<inCylinder,py::bases<Predicate> >("inCylinder","Cylinder predicate",py::init<const Vector3r&,const Vector3r&,Real>(py::args("centerBottom","centerTop","radius"),"Ctor taking centers of the lateral walls (as 3-tuples) and radius."));
 py::class_<inCone,py::bases<Predicate> >("inCone","Cone predicate",py::init<const Vector3r&,const Vector3r&,Real>(py::args("centerBottom","centerTop","radius"),"Ctor taking centers of the lateral walls (as 3-tuples) and radius."));

and when i type:
pred=pack.inCylinder(... it is still working. I get this error only when i try it with inCone.

Ah ok, when there is not a need to implement it in packPredicate, is there another command what i can use?

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#11

For the error, you should double check names, make sure you run the version you just compiled, etc. There must be a small mistake somewhere.

For the "another command" part. Just don't use predicates. Create a cone, place a sphere inside it, add gravity, run. This would be your test script for testing the cone shape.

Revision history for this message
Christian Sommerfeld (sommerfeld-m) said :
#12

Is it possible, that i can not create new code because i use yade-daily? Or is there a command, which i have to type inside the terminal to compile the new code? i took a look for a command at the manual and the homepage, but i can not find anything.

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#13

If you don't compile it cannot work...
How did you obtain the source code files you are modifying?
Check this: https://www.yade-dem.org/doc/installation.html#source-code

Revision history for this message
Christian Sommerfeld (sommerfeld-m) said :
#14

i followed the installation advice and downloaded all prerequisites. Afterwards i wrote into the terminal:

sudo apt-get install scons freeglut3-dev libloki-dev \
libboost-date-time-dev libboost-filesystem-dev libboost-thread-dev \
libboost-regex-dev fakeroot dpkg-dev build-essential g++ \
libboost-iostreams-dev liblog4cxx10-dev python-dev libboost-python-dev ipython \
python-matplotlib libsqlite3-dev python-numpy python-tk gnuplot doxygen \
libgts-dev python-pygraphviz libvtk5-dev python-scientific bzr bzrtools libeigen2-dev \
binutils-gold python-xlib python-qt4 pyqt4-dev-tools \
libqglviewer-qt4-dev python-imaging libjs-jquery python-sphinx

and it was still working.

Revision history for this message
Christian Sommerfeld (sommerfeld-m) said :
#15

Now i am a little bit confused because i read:

If you prefer to use the newest yade version and you do not "hack" the code, yade-daily is the best choice for you.
Installed once, you will get the updates automatically without recompiling the code.
Yade-daily is compiled automatically on build-servers of Launchpad, getting the code from the latest trunk version.

Or is there also a possibility to compile it an my computer?

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#16

>If you prefer to use the newest yade version and you do not "hack" the code

You ARE hacking the code. You need to read the "source code" paragraph that I linked above.

Revision history for this message
Christian Sommerfeld (sommerfeld-m) said :
#17

Hi,

now I tried t install yade-0.70.0 with the following comment:

scons PREFIX=yade-0.70.0/YADE-0.70.0 and I got the following error:

scons: Reading SConscript files ...
@@@ Using profile default (scons.profile-default) @@@
Eigen 2 math library will be used
Yade version is `0.70.0' (0.70.0), installed files will be suffixed with `-0.70.0'.
All intermediary files will be in `/home/ubuntu/build-0.70.0'.
Checking whether c++ compiler "g++" works...yes
Finding libstdc++ library... (cached) /usr/lib/i386-linux-gnu/libstdc++.so.6
Checking for pthread_exit(NULL) in C library pthread... yes
Checking for Python development files... ok
Checking for C++ header file numpy/ndarrayobject.h... yes
Checking for required python modules... (cached) all ok
Checking boost libraries... Failures: boost_program_options
Checking for C++ header file boost/foreach.hpp... yes
Checking for C++ header file Eigen/Core... yes
Checking for C++ header file loki/NullType.h... yes

One of the essential libraries above was not found, unable to continue.

Check `/home/ubuntu/build-0.70.0/config.log' for possible causes, note that there are options that you may need to customize:

Afterwards I downloaded different versions of boost, because there are some problems with boost, but I can not handle it in this way. Is there a special way to fix the problem with boost?

Revision history for this message
Anton Gladky (gladky-anton) said :
#18

How did you install boost? From packages or by compiling from the source?

Anton

Revision history for this message
Christian Sommerfeld (sommerfeld-m) said :
#19

After I downloaded it I installed boost from packages for yade-daily first.

Revision history for this message
Christian Sommerfeld (sommerfeld-m) said :
#20

Is there no possibility to handle this problem?

Revision history for this message
Christian Sommerfeld (sommerfeld-m) said :
#21

if it is helpful i can add the error message from the config.log :

  |#include<boost/program_options.hpp>
  |int main(void){boost::program_options::options_description o;;}
g++ -o /home/ubuntu/build-0.70.0/.sconf_temp/conftest_12.o -c -I/usr/include/vtk-5.0 -I/usr/include/vtk-5.2 -I/usr/include/vtk-5.4 -I/usr/include/vtk-5.6 -I/usr/include/vtk -I/usr/include/eigen2 -I/home/ubuntu/build-0.70.0/include -I/usr/include/python2.7 /home/ubuntu/build-0.70.0/.sconf_temp/conftest_12.cpp
g++ -o /home/ubuntu/build-0.70.0/.sconf_temp/conftest_12 -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions -L. -lpython2.7 /home/ubuntu/build-0.70.0/.sconf_temp/conftest_12.o -lpthread -lpthread -ldl -lutil -lboost_system -lboost_thread -lboost_date_time -lboost_filesystem -lboost_iostreams -lboost_regex -lboost_serialization -lboost_program_options-mt
/usr/bin/ld: error: cannot find -lboost_program_options-mt
/home/ubuntu/build-0.70.0/.sconf_temp/conftest_12.o:conftest_12.cpp:function main: error: undefined reference to 'boost::program_options::options_description::m_default_line_length'
/home/ubuntu/build-0.70.0/.sconf_temp/conftest_12.o:conftest_12.cpp:function main: error: undefined reference to 'boost::program_options::options_description::m_default_line_length'
/home/ubuntu/build-0.70.0/.sconf_temp/conftest_12.o:conftest_12.cpp:function main: error: undefined reference to 'boost::program_options::options_description::options_description(unsigned int, unsigned int)'
collect2: ld returned 1 exit status
/home/ubuntu/build-0.70.0/.sconf_temp/conftest_13.cpp <-
  |#include<boost/python.hpp>
  |int main(void){boost::python::scope();;}
g++ -o /home/ubuntu/build-0.70.0/.sconf_temp/conftest_13.o -c -I/usr/include/vtk-5.0 -I/usr/include/vtk-5.2 -I/usr/include/vtk-5.4 -I/usr/include/vtk-5.6 -I/usr/include/vtk -I/usr/include/eigen2 -I/home/ubuntu/build-0.70.0/include -I/usr/include/python2.7 /home/ubuntu/build-0.70.0/.sconf_temp/conftest_13.cpp
g++ -o /home/ubuntu/build-0.70.0/.sconf_temp/conftest_13 -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions -L. -lpython2.7 /home/ubuntu/build-0.70.0/.sconf_temp/conftest_13.o -lpthread -lpthread -ldl -lutil -lboost_system -lboost_thread -lboost_date_time -lboost_filesystem -lboost_iostreams -lboost_regex -lboost_serialization -lboost_python
scons: Configure: Failures: boost_program_options

scons: Configure: Checking for C++ header file boost/foreach.hpp...
/home/ubuntu/build-0.70.0/.sconf_temp/conftest_14.cpp <-
  |
/home/ubuntu/build-0.70.0/.sconf_temp/conftest_13.cpp <-
  |#include<boost/python.hpp>
  |int main(void){boost::python::scope();;}
g++ -o /home/ubuntu/build-0.70.0/.sconf_temp/conftest_13.o -c -I/usr/include/vtk-5.0 -I/usr/include/vtk-5.2 -I/usr/include/vtk-5.4 -I/usr/include/vtk-5.6 -I/usr/include/vtk -I/usr/include/eigen2 -I/home/ubuntu/build-0.70.0/include -I/usr/include/python2.7 /home/ubuntu/build-0.70.0/.sconf_temp/conftest_13.cpp
g++ -o /home/ubuntu/build-0.70.0/.sconf_temp/conftest_13 -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions -L. -lpython2.7 /home/ubuntu/build-0.70.0/.sconf_temp/conftest_13.o -lpthread -lpthread -ldl -lutil -lboost_system -lboost_thread -lboost_date_time -lboost_filesystem -lboost_iostreams -lboost_regex -lboost_serialization -lboost_python
scons: Configure: Failures: boost_program_options

scons: Configure: Checking for C++ header file boost/foreach.hpp...
/home/ubuntu/build-0.70.0/.sconf_temp/conftest_14.cpp <-
  |

Revision history for this message
Christian Sommerfeld (sommerfeld-m) said :
#22

It seems that there is a problem with boost program-options

Revision history for this message
Christian Jakob (jakob-ifgt) said :
#23

The problem is here:

/usr/bin/ld: error: cannot find -lboost_program_options-mt

I googled your problem, maybe this can help you:

http://www.linuxquestions.org/questions/programming-9/problem-linking-with-boost-libraries-872970/

it has something to do with libboost ... I dont know, just guessing ...

If it helps, I can send you output from "aptitude search libboost", but i am using debian, so package names can be different on your ubuntu linux ...

me@debian ~/YADE/trunk >aptitude search libboost
i libboost-all-dev - Boost C++ Libraries development files (ALL, default version)
i libboost-date-time-dev - date-time libraries based on generic programming (default version)
i A libboost-date-time1.42-dev - Sammlung von Bibliotheken für Datum/Zeit, basierend auf
i A libboost-date-time1.42.0 - Sammlung von Bibliotheken für Datum/Zeit, basierend auf
p libboost-dbg - Boost C++ Libraries with debug symbols
i libboost-dev - Boost C++ Libraries development files (default version)
p libboost-doc - Boost C++ Libraries documentation (default version)
i libboost-filesystem-dev - filesystem operations in C++ (default version)
i A libboost-filesystem1.42-dev - Dateisystemoperationen (portable Pfade, Iterationen über Verzeichnisse)
i A libboost-filesystem1.42.0 - Dateisystemoperationen (portable Pfade, Iterationen über Verzeichnisse)
i A libboost-graph-dev - generic graph components and algorithms in C++ (default version)
i A libboost-graph-parallel-dev - generic graph components and algorithms in C++ (default version)
i A libboost-graph-parallel1.42-dev - generic graph components and algorithms in C++
i A libboost-graph-parallel1.42.0 - generic graph components and algorithms in C++
i A libboost-graph1.42-dev - Generische Graphenkomponenten und Algorithmen in C++
i A libboost-graph1.42.0 - Generische Graphenkomponenten und Algorithmen in C++
i libboost-iostreams-dev - Boost.Iostreams Library development files (default version)
i A libboost-iostreams1.42-dev - Boost.Iostreams Library development files
i libboost-iostreams1.42.0 - Boost.Iostreams-Bibliothek
i A libboost-math-dev - Boost.Math Library development files (default version)
i A libboost-math1.42-dev - Boost.Math Library development files
i A libboost-math1.42.0 - Bibliothek Boost.Math
i A libboost-mpi-dev - C++ interface to the Message Passing Interface (MPI) (default version)
i A libboost-mpi-python-dev - Python interface to the Message Passing Interface (MPI) (default version)
p libboost-mpi-python1.42-dev - C++ interface to the Message Passing Interface (MPI), Python Bindings
p libboost-mpi-python1.42.0 - C++ interface to the Message Passing Interface (MPI), Python Bindings
i A libboost-mpi1.42-dev - C++ interface to the Message Passing Interface (MPI)
i A libboost-mpi1.42.0 - C++ interface to the Message Passing Interface (MPI)
i A libboost-program-options-dev - program options library for C++ (default version)
i A libboost-program-options1.42-dev - C++-Bibliothek für Programmoptionen
i A libboost-program-options1.42.0 - C++-Bibliothek für Programmoptionen
i libboost-python-dev - Boost.Python Library development files (default version)
i A libboost-python1.42-dev - Boost.Python Library development files
i A libboost-python1.42.0 - Die Bibliothek Boost.Python
i libboost-regex-dev - regular expression library for C++ (default version)
i A libboost-regex1.42-dev - C++-Bibliothek für reguläre Ausdrücke
i A libboost-regex1.42.0 - C++-Bibliothek für reguläre Ausdrücke
i A libboost-serialization-dev - serialization library for C++ (default version)
i A libboost-serialization1.42-dev - serialization library for C++
i A libboost-serialization1.42.0 - serialization library for C++
i A libboost-signals-dev - managed signals and slots library for C++ (default version)
i A libboost-signals1.42-dev - C++-Bibliothek für verwaltete Signale und »Slots«
i A libboost-signals1.42.0 - C++-Bibliothek für verwaltete Signale und »Slots«
i A libboost-system-dev - Operating system (e.g. diagnostics support) library (default version)
i A libboost-system1.42-dev - Betriebssystemsbibliothek (etwa Unterstützung der Diagnostik)
i A libboost-system1.42.0 - Betriebssystemsbibliothek (etwa Unterstützung der Diagnostik)
i A libboost-test-dev - components for writing and executing test suites (default version)
i A libboost-test1.42-dev - components for writing and executing test suites
i A libboost-test1.42.0 - components for writing and executing test suites
i libboost-thread-dev - portable C++ multi-threading (default version)
i A libboost-thread1.42-dev - Portierbares C++-Multi-Threading
i A libboost-thread1.42.0 - Portierbares C++-Multi-Threading
i A libboost-wave-dev - C99/C++ preprocessor library (default version)
i A libboost-wave1.42-dev - C99/C++ preprocessor library
i A libboost-wave1.42.0 - C99/C++ preprocessor library
p libboost1.42-all-dev - Boost C++ Libraries development files (ALL)
p libboost1.42-dbg - Boost C++ Libraries with debug symbols
i A libboost1.42-dev - Boost C++ Libraries development files
p libboost1.42-doc - Boost.org libraries documentation

hope it helps,

christian

Revision history for this message
Christian Sommerfeld (sommerfeld-m) said :
#24

Now i solved my problem. Thank you for your help!