Subject: CGAL users discussion list
List archive
- From: Stephane Tayeb <>
- To:
- Subject: Re: [cgal-discuss] Neighbours list in 3D meshing
- Date: Thu, 29 Apr 2010 14:33:27 +0200
Ianic wrote:
Good day to you,
Hi Yan,
I would like to use the CGAL 3D meshing capabilities for a subsequent finite
element analysis. Our FE code needs to read in information about the
neighbors of every element in the mesh. So I would like to add this bit of
output as a separate .neigh file to complement the .mesh file. The format
that I have in my mind is what a tetgen mesher generates:
********************************************
* First line: <# of tetrahedra> <# of nei. per tet (always 4) >
* Remaining lines list of # of neighbors:
<tetrahedron #> <neighbor1> <neighbor2> <neighbor3> <neighbor4>
...
A .neigh file associates with each tetrahedron its neighbors (adjacent
tetrahedra), which are indices into the corresponding .ele file. An index of
-1 indicates no neighbor (because the tetrahedron is on a boundary of mesh
domain). The first neighbor of tetrahedron i is opposite the first corner of
tetrahedron i, and so on. It is output by TetGen when -n switch is used. ********************************************
Obviously, in my case there is no .ele file, but a corresponding section of
.mesh file. Could you please give me a hint as to how to do this? I am new
to CGAL and don't know yet how to iterate over cells and obtain the
necessary connectivity data.
The mesh is stored in an object called c3t3 (of class Mesh_complex_3_in_triangulation_3).
If you have a look at the documentation of concept MeshComplex_3InTriangulation_3 you should find how to iterate over cells. To navigate from one Cell_handle to its neighbors, you could have a look in the Triangulation_3 manual.
Here is an incomplete bunch of code which may help you:
=======================
for ( C3T3::Cell_iterator cit = c3t3.cells_begin() ;
cit != c3t3.cells_end() ; ++cit ) {
const C3T3::Cell_handle& c = cit;
// Iterate over c neighbors
for ( int i=0 ; i<4 ; ++i ) {
const C3T3::Cell_handle& neighbor = c->neighbor(i);
if ( c3t3.is_in_complex(neighbor) { ... }
[...]
}
}
=======================
Also, a question that I have is this - is it correct to assume that in the
.mesh file cell indices are implicitly included by means of order in which
cells are listed in a file?
I'm not sure to understand what you mean. The mesh file is constructed using the above Cell_iterator. Hence, the implicit indice of each cell (in the .mesh file) corresponds to its position following this iterator.
And the last question - I work with CGAL on Windows and I have noticed that
the mesh output is not unique. If I run it several times, it has roughly the
same amount of vertices and cells, but they slightly differ every time. Is
it a feature or a bug? :-)
This is probably not a bug. There are two sources of randomness in the mesh generation algorithm:
- the initial points of the mesh are discovered shooting random rays.
- the sliver perturbation algorithm (CGAL v3.6) contains some randomness.
If you insert the initial points by yourself and if you don't use sliver perturbation, then the output mesh should not differ from one run to another one.
Sincerely,
Yan
Best,
Stéphane.
--
Stephane Tayeb
Software engineer - INRIA Sophia Antipolis
Geometrica Project-Team
- [cgal-discuss] Neighbours list in 3D meshing, Ianic, 04/29/2010
- Re: [cgal-discuss] Neighbours list in 3D meshing, Stephane Tayeb, 04/29/2010
- Re: [cgal-discuss] Neighbours list in 3D meshing, Mariette Yvinec, 04/29/2010
- [cgal-discuss] Re: Neighbours list in 3D meshing, Ianic, 04/29/2010
- [cgal-discuss] Re: Neighbours list in 3D meshing, Ianic, 04/29/2010
- [cgal-discuss] Re: Neighbours list in 3D meshing, Ianic, 04/29/2010
- Re: [cgal-discuss] Re: Neighbours list in 3D meshing, Stephane Tayeb, 04/29/2010
- [cgal-discuss] Re: Neighbours list in 3D meshing, Ianic, 04/29/2010
- Re: [cgal-discuss] Re: Neighbours list in 3D meshing, Stephane Tayeb, 04/29/2010
- [cgal-discuss] Re: Neighbours list in 3D meshing, Ianic, 04/29/2010
- [cgal-discuss] Re: Neighbours list in 3D meshing, Ianic, 04/29/2010
- Re: [cgal-discuss] Neighbours list in 3D meshing, Stephane Tayeb, 04/29/2010
Archive powered by MHonArc 2.6.16.