TetGen and third party libraries
Hello everyone,
For those who were yesterday in the workshop in Grenoble you have seen this for sure during Anton's presentation about linking external libraries.
I just compiled TetGen and linked the libraries to YADE ("-- Found TETGEN: /usr/include" line appears when using cmake), but after compilation I just can't call TetGen's functions.
I probably forgot a step there, Any suggestions ?
Thanks !
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Yade Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Anton Gladky
- Solved:
- Last query:
- Last reply:
Revision history for this message
|
#1 |
Hello Hicham,
please be more specific on "I just can't call TetGen's functions", e.g.
what compilaton error you get or so
thanks
Jan
2014-07-10 12:46 GMT+02:00 Hicham BENNIOU <
<email address hidden>>:
> New question #251458 on Yade:
> https:/
>
> Hello everyone,
>
> For those who were yesterday in the workshop in Grenoble you have seen
> this for sure during Anton's presentation about linking external libraries.
>
> I just compiled TetGen and linked the libraries to YADE ("-- Found TETGEN:
> /usr/include" line appears when using cmake), but after compilation I just
> can't call TetGen's functions.
>
> I probably forgot a step there, Any suggestions ?
>
> Thanks !
>
> --
> You received this question notification because you are a member of
> yade-users, which is an answer contact for Yade.
>
> _______
> Mailing list: https:/
> Post to : <email address hidden>
> Unsubscribe : https:/
> More help : https:/
>
Revision history for this message
|
#2 |
Hi Jan,
I get no compilation error, it goes smoothly and YADE runs correctly, but when I try to call "tetrahedralize()" function for example I get an error :
NameError: name 'tetrahedralize' is not defined
Revision history for this message
|
#3 |
Hi Hicham,
thanks for the info. Did you define the tetrahedralize function in some
.cpp file inside BOOST_PYTHON_
thanks
Jan
2014-07-10 13:17 GMT+02:00 Hicham BENNIOU <
<email address hidden>>:
> Question #251458 on Yade changed:
> https:/
>
> Status: Answered => Open
>
> Hicham BENNIOU is still having a problem:
> Hi Jan,
>
> I get no compilation error, it goes smoothly and YADE runs correctly,
> but when I try to call "tetrahedralize()" function for example I get an
> error :
>
> NameError: name 'tetrahedralize' is not defined
>
> --
> You received this question notification because you are a member of
> yade-users, which is an answer contact for Yade.
>
> _______
> Mailing list: https:/
> Post to : <email address hidden>
> Unsubscribe : https:/
> More help : https:/
>
Revision history for this message
|
#4 |
Then I guess I skipped a step ?
Here's exactly what I've done :
- Compiling TetGen : Done (I checked for /usr/lib/libtet.a and usr/include/
- Adding FindTetGen.cmake to /trunk/cMake : Done
Here's what's inside the file :
FIND_LIBRARY(
FIND_PATH(
INCLUDE_
LINK_LIBRARIES(
INCLUDE(
FIND_PACKAGE_
- Adding the line "INCLUDE(
-Compiling YADE : compiles and runs fine
thanks
Hicham
Revision history for this message
|
#5 |
Hi Hicham,
there is a patch, which is linking TETGEN:
Subject: [PATCH] Add TetGen coupling.
---
CMakeLists.txt | 17 +++++++++
cMake/
pkg/dem/Shop.hpp | 8 ++++
pkg/dem/
py/_utils.cpp | 2 +
5 files changed, 146 insertions(+)
create mode 100644 cMake/FindTetGe
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a299e46..70b4a92 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,6 +18,7 @@
# ENABLE_LBMFLOW: enable LBMFLOW-option, LBM_ENGINE (OFF by default)
# ENABLE_
for details (OFF by default)
# ENABLE_
+# ENABLE_TETGEN: enable TETGEN option (OFF by default)
# runtimePREFIX: used for packaging, when install directory is not
the same is runtime directory (/usr/local by default)
# CHUNKSIZE: set >1, if you want several sources to be compiled at
once. Increases compilation speed and RAM-consumption during it (1 by
default).
# VECTORIZE: enables vectorization and alignment in Eigen3 library,
experimental (OFF by default)
@@ -126,6 +127,7 @@ OPTION(
(experimental)" ${DEFAULT})
OPTION(ENABLE_SPH "Enable SPH" OFF)
OPTION(
OPTION(
experimental), see [Mani2013] for details" OFF)
+OPTION(
OPTION(
variables (only Body::groupMask yet implemented) (experimental). Use
-DMASK_
OFF)
#=====
@@ -320,6 +322,16 @@ ELSE(ENABLE_
SET(
ENDIF(
#=====
+IF(ENABLE_TETGEN)
+ FIND_PACKAGE(TetGen REQUIRED)
+ ADD_DEFINITIONS
+ ADD_DEFINITIONS
+ INCLUDE_
+ SET(CONFIGURED_
+ELSE(ENABLE_
+ SET(DISABLED_FEATS "${DISABLED_FEATS} TETGEN")
+ENDIF(
+#=====
IF(ENABLE_GL2PS)
FIND_
IF(GL2PS_FOUND)
@@ -478,6 +490,11 @@ IF(ENABLE_GUI)
ENDIF(ENABLE_GUI)
#=====
+IF(ENABLE_TETGEN)
+ TARGET_
+ENDIF(
+#=====
+
IF (NOT (PY_minieigen))
ADD_
SET_
diff --git a/cMake/
new file mode 100644
index 0000000..ab8c0a6
--- /dev/null
+++ b/cMake/
@@ -0,0 +1,17 @@
+# Try to find the TetGen librairies
+# TETGEN_FOUND - system has TetGen lib
+# TETGEN_INCLUDE_DIR - the TetGen include directory
+# TETGEN_LIBRARIES - Libraries needed to use TetGen
+# TETGEN_DEFINITIONS - Compiler switches required for using gnutls
+
+IF (TETGEN_INCLUDE_DIR AND TETGEN_LIBRARIES)
+ SET(TETGEN_
+ENDIF (TETGEN_INCLUDE_DIR AND TETGEN_LIBRARIES)
+
+SET(TETGEN_
+FIND_PATH(
+FIND_LIBRARY(
+MESSAGE(STATUS "TetGen lib: " ${TETGEN_
+
+INCLUDE(
+FIND_PACKAGE_
TETGEN_INCLUDE_DIR TETGEN_LIBRARIES)
diff --git a/pkg/dem/Shop.hpp b/pkg/dem/Shop.hpp
index ef45538..f766971 100644
--- a/pkg/dem/Shop.hpp
+++ b/pkg/dem/Shop.hpp
@@ -15,6 +15,9 @@
#include<
+#ifdef TETGEN
+#include "tetgen.h"
+#endif
class Scene;
class Body;
@@ -148,4 +151,9 @@ class Shop{
static void growParticles(Real multiplier, bool updateMass,
bool dynamicOnly, unsigned int discretization);
//! Change of size of a single sphere or a clump
static void growParticle(
bool updateMass);
+
+#ifdef TETGEN
+ //! Test function to show how TetGen works
+ static py::list addTetgenBody();
+#endif
};
diff --git a/pkg/dem/
index 3182128..02dc616 100644
--- a/pkg/dem/
+++ b/pkg/dem/
@@ -53,6 +53,11 @@
#define FOREACH BOOST_FOREACH
#endif
+#ifdef TETGEN
+#include <yade/pkg/
+#include <yade/core/
+#endif
+
CREATE_
/*! Flip periodic cell by given number of cells.
@@ -515,3 +520,100 @@ void Shop::growParti
multiplier, bool updateMass)
else contact->refR2 = rad;
}
}
+
+py::list Shop::addTetgen
+{
+ const Scene* scene=Omega:
+ py::list ret;
+ tetgenio in, out;
+ tetgenio::facet *f;
+ tetgenio::polygon *p;
+
+ // All indices start from 1.
+ in.firstnumber = 1;
+
+ // Points
+ std::vector<
+
+ pointsV.
+ pointsV.
+ pointsV.
+ pointsV.
+ pointsV.
+
+ // Facets
+ std::vector<
+ facetsV.
+ facetsV.
+ facetsV.
+ facetsV.
+ facetsV.
+ facetsV.
+
+ // Add points
+ in.numberofpoints = pointsV.size();
+ in.pointlist = new REAL[in.
+ for (int d = 0; d < in.numberofpoints; d++) {
+ in.pointlist[3*d+0] = pointsV[d][0];
+ in.pointlist[3*d+1] = pointsV[d][1];
+ in.pointlist[3*d+2] = pointsV[d][2];
+ }
+
+ // Add facets
+ in.numberoffacets = facetsV.size();
+ in.facetlist = new tetgenio:
+ in.facetmarkerlist = new int[in.
+
+ for (int d = 0; d < in.numberoffacets; d++) {
+ f = &in.facetlist[d];
+ f->numberofpolygons = 1;
+ f->polygonlist = new tetgenio:
+ f->numberofholes = 0;
+ f->holelist = NULL;
+ p = &f->polygonlist[0];
+ p->numberofvertices = 3;
+ p->vertexlist = new int[p->
+ p->vertexlist[0] = facetsV[d][0];
+ p->vertexlist[1] = facetsV[d][1];
+ p->vertexlist[2] = facetsV[d][2];
+ }
+
+ tetrahedralize(
+
+ std::list<Vector3i> allTriag;
+ for (int d = 0; d < out.numberoftet
+ std::vector<int> v;
+ v.push_
+ v.push_
+ v.push_
+ v.push_
+ std::sort (v.begin(), v.end());
+ allTriag.
+ allTriag.
+ allTriag.
+ allTriag.
+ }
+ allTriag.unique();
+ std::cout<
+ for (std::list<
allTriag.end(); ++it) {
+ Vector3r v[3];
+ v[0]=Vector3r(
0],out.
+ v[1]=Vector3r(
0],out.
+ v[2]=Vector3r(
0],out.
+
+ Vector3r icc = Shop::inscribed
+ shared_ptr<Facet> iFacet(new Facet);
+ iFacet->color = Vector3r(
+ for (int j=0; j<3; ++j) {
+ iFacet-
+ }
+ iFacet-
+ shared_ptr<Body> b(new Body);
+ b->state-
+ b->state-
+ b->shape = iFacet;
+ b->shape->wire = true;
+ ret.append(
+ }
+ return ret;
+}
diff --git a/py/_utils.cpp b/py/_utils.cpp
index 2de0a43..019f815 100644
--- a/py/_utils.cpp
+++ b/py/_utils.cpp
@@ -389,6 +389,7 @@ py::tuple Shop__normalShe
compressionPosi
py::list Shop__getStress
py::list Shop__getBodyId
Shop::getBodyId
+py::list Shop__addTetgen
Real shiftBodies(
shared_
@@ -495,6 +496,7 @@ BOOST_PYTHON_
py:
and return Love-Weber stress tensor:\n\n
$\\sigma_
all interactions, with $f$ the contact force and $l$ the branch vector
(joining centers of the bodies). Stress is negativ for repulsive
contact forces, i.e. compression. $V$ can be passed to the function.
If it is not, it will be equal to one in non-periodic cases, or equal
to the volume of the cell in periodic cases.");
py:
and return Love-Weber capillary stress tensor:\n\n
$\\sigma^
sum is over all interactions, with $l$ the branch vector (joining
centers of the bodies) and $f^{cap}$ is the capillary force. $V$ can
be passed to the function. If it is not, it will be equal to one in
non-periodic cases, or equal to the volume of the cell in periodic
cases. Only the CapillaryPhys interaction type is supported
presently.");
py:
a list of body-ids, which contacts the given body.");
+ py::def(
py:
ration in interactions (with :yref:`ScGeom`) of two
:yref:`
r_2)/r_1+r_2}$, where $u_N$ is the current overlap distance and $r_1$,
$r_2$ are radii of the two spheres in contact.");
py:
bodies listed in ids without updating their velocities.");
py:
and rotational velocities of bodies to zero. Applied to all bodies by
default. To calm only some bodies, use mask parameter, it will calm
only bodies with groupMask compatible to given value");
--
2.0.0
Anton
2014-07-10 13:36 GMT+02:00 Jan Stránský <email address hidden>:
> Question #251458 on Yade changed:
> https:/
>
> Status: Open => Answered
>
> Jan Stránský proposed the following answer:
> Hi Hicham,
> thanks for the info. Did you define the tetrahedralize function in some
> .cpp file inside BOOST_PYTHON_
> thanks
> Jan
>
>
>
> 2014-07-10 13:17 GMT+02:00 Hicham BENNIOU <
> <email address hidden>>:
>
>> Question #251458 on Yade changed:
>> https:/
>>
>> Status: Answered => Open
>>
>> Hicham BENNIOU is still having a problem:
>> Hi Jan,
>>
>> I get no compilation error, it goes smoothly and YADE runs correctly,
>> but when I try to call "tetrahedralize()" function for example I get an
>> error :
>>
>> NameError: name 'tetrahedralize' is not defined
>>
>> --
>> You received this question notification because you are a member of
>> yade-users, which is an answer contact for Yade.
>>
>> _______
>> Mailing list: https:/
>> Post to : <email address hidden>
>> Unsubscribe : https:/
>> More help : https:/
>>
>
> --
> You received this question notification because you are a member of
> yade-users, which is an answer contact for Yade.
>
> _______
> Mailing list: https:/
> Post to : <email address hidden>
> Unsubscribe : https:/
> More help : https:/
Revision history for this message
|
#6 |
Thanks Anton,
I guess all I have to do now is to add these fixes.
Cheers
Hicham
Revision history for this message
|
#7 |
Thanks Anton Gladky, that solved my question.
Revision history for this message
|
#8 |
I would not use static linkage if it is possible.
Anton
2014-07-10 14:36 GMT+02:00 Hicham BENNIOU
<email address hidden>:
> Question #251458 on Yade changed:
> https:/
>
> Status: Answered => Solved
>
> Hicham BENNIOU confirmed that the question is solved:
> Thanks Anton,
>
> I guess all I have to do now is to add these fixes.
>
> Cheers
> Hicham