Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] "About conserving the boundary polyhedron while tetrahedral discretization"

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] "About conserving the boundary polyhedron while tetrahedral discretization"


Chronological Thread 
  • From: Burak ER <>
  • To:
  • Subject: Re: [cgal-discuss] "About conserving the boundary polyhedron while tetrahedral discretization"
  • Date: Fri, 25 Oct 2013 16:13:42 +0300

Thank you,

This solved my problem.

Burak ER

Cum, 2013-10-25 tarihinde 12:03 +0200 saatinde, Sebastien Loriot
(GeometryFactory) yazdı:
> You need to protect the edges of your box.
>
> One solution is to do like this example:
> http://doc.cgal.org/latest/Mesh_3/index.html#Mesh_3MeshingDomainswithSharpFeatures
>
> or to protect them by hand.
>
> Sebastien.
>
> On 10/25/2013 11:20 AM, Burak ER wrote:
> > Sorry for the not working link. You can find it here.
> > <http://s16.postimg.org/pv4ehn3et/Screenshot_from_2013_10_25_12_17_21.png>
> >
> > Cum, 2013-10-25 tarihinde 12:14 +0300 saatinde, Burak ER yazdı:
> >> Dear Sebastian,
> >>
> >> This may not be a minimal example. I have created a python interface
> >> for my application. Within this interface I divide the off file into
> >> tetrahedrons with CGAL c++ api on the background. I use this
> >> generation code on the c++ side;
> >>
> >> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
> >> #include <CGAL/Mesh_triangulation_3.h>
> >> #include <CGAL/Mesh_complex_3_in_triangulation_3.h>
> >> #include <CGAL/Mesh_criteria_3.h>
> >> #include <CGAL/Polyhedral_mesh_domain_3.h>
> >> #include <CGAL/make_mesh_3.h>
> >> #include <CGAL/refine_mesh_3.h>
> >> #include <iostream>
> >> // IO
> >> #include <CGAL/IO/Polyhedron_iostream.h>
> >>
> >> // Domain
> >> typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
> >> typedef CGAL::Polyhedron_3<K> Polyhedron;
> >> typedef CGAL::Polyhedral_mesh_domain_3<Polyhedron, K> Mesh_domain;
> >>
> >> // Triangulation
> >> typedef CGAL::Mesh_triangulation_3<Mesh_domain>::type Tr;
> >> typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr> C3t3;
> >>
> >> // Criteria
> >> typedef CGAL::Mesh_criteria_3<Tr> Mesh_criteria;
> >>
> >> // To avoid verbose function and named parameters call
> >> using namespace CGAL::parameters;
> >>
> >> class MeshElement;
> >>
> >> void Mesh(void)
> >> {
> >>
> >> boost::filesystem::path mypath(filename);
> >> std::ifstream input(filename.data());
> >>
> >> if(mypath.extension()!=boost::filesystem::path(".off")){
> >> std::string errormessage ="Invalid extension is specified with the
> >> mesh file";
> >> throw std::invalid_argument(errormessage);
> >> }
> >>
> >> // Create input polyhedron
> >> Polyhedron polyhedron;
> >>
> >> input >> polyhedron;
> >>
> >> // Create domain
> >> Mesh_domain domain(polyhedron);
> >>
> >> // Mesh criteria (no cell_size set)
> >> Mesh_criteria criteria(facet_angle, facet_size,
> >> facet_distance,/*facet_topology*/
> >> cell_radius_edge_ratio, cell_size);
> >>
> >> // Mesh generation
> >> c3t3.clear();
> >>
> >> c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria, no_perturb(),
> >> no_exude());
> >>
> >> elems.clear();// clear our vector
> >>
> >> interfacingpairs.clear();
> >>
> >> handlemap.clear();
> >>
> >> elems.resize(c3t3.number_of_cells_in_complex()); // resize it as the
> >> new number of elements
> >>
> >> size_t i=0;
> >> /*
> >> * This is not a nice way to index elements
> >> * we could use cell_with_info structure of cgal but really how to
> >> use that? No tutorial, no example at all on its document!!!
> >> *
> >> * */
> >> for(C3t3::Cells_in_complex_iterator
> >> it=c3t3.cells_begin();it!=c3t3.cells_end();it++){
> >>
> >> //Create new elements
> >>
> >> //share_ptr handles deletion of the newly created element
> >> elems[i]=shared_ptr<MeshElement>(new Linear4NodeTetMeshElem(it));
> >>
> >> //Give an index to handle
> >> handlemap[it]=i;
> >> i++;
> >> }
> >> // Add interactions
> >> for(C3t3::Cells_in_complex_iterator
> >> it=c3t3.cells_begin();it!=c3t3.cells_end();it++){
> >>
> >> //For each neighbor of the currrent iterator
> >> for(int j=0;j<4;j++)
> >> {
> >>
> >> C3t3::Cell_handle neigh=it->neighbor(j);
> >>
> >> /*Check if we have this neighbor handle*/
> >> if(c3t3.is_in_complex(neigh))
> >> {
> >> size_t indexel=handlemap[it];
> >> size_t indexneigh=handlemap[neigh];
> >>
> >> //Get element and its neighbors from element list
> >> shared_ptr<MeshElement> el;
> >> shared_ptr<MeshElement> neighel;
> >> //Change the ordering of the elements
> >> if(indexel<indexneigh){
> >> el=elems[indexel];
> >> neighel=elems[indexneigh];}
> >> else{
> >> neighel=elems[indexel];
> >> el=elems[indexneigh];
> >> }
> >>
> >>
> >> nodePairsIndices indiceofpairs;
> >>
> >> //Get shared node list
> >> indiceofpairs=getNodeCon(el,neighel);
> >>
> >> //check if there is a face share
> >> if(indiceofpairs.size()>=3)
> >> {
> >> //Create the pair
> >> ElementPair pair(el,neighel,indiceofpairs);
> >>
> >> //Add it into the interfacing pair list
> >> if(!interfacingpairs[pair])
> >> {
> >>
> >> interfacingpairs[pair]=shared_ptr<ElementPair>(new
> >> ElementPair(el,neighel,indiceofpairs));
> >>
> >> }
> >> }
> >> }
> >> }
> >>
> >> }
> >> std::cout<<"Meshing is complete "<<std::endl;
> >> std::cout<<"Number of tetrahedral elements "<<elems.size()<<std::endl;
> >> std::cout<<"Number of interaction elements
> >> "<<interfacingpairs.size()<<std::endl;
> >> }
> >>
> >> Using this function and the off file in the attachment;
> >>
> >> When I use the parameters as
> >> facet_angle=33,
> >> facet_distance=.6,
> >> facet_size=0.6,
> >> cell_radius_edge_ratio=0.11,
> >> cell_size=1e-3
> >>
> >> The result is 5580 elements and they are distributed as here <http://>
> >> where you can see the empty parts on the boundary of the plate.
> >>
> >> Also slight change on the cell_radius_edge_ratio=0.15 makes it even
> >> worser as here.
> >> <http://s14.postimg.org/o8j6yl07l/Screenshot_from_2013_10_25_12_08_06.png>
> >>
> >> What do you think the problem is?
> >>
> >> Burak
> >>
> >> Cum, 2013-10-25 tarihinde 09:28 +0200 saatinde, Sebastien Loriot
> >> (GeometryFactory) yazdı:
> >>> It might help if you share a minimal example showing the pb.
> >>>
> >>> Sebastien.
> >>>
> >>> On 10/25/2013 09:26 AM, Burak ER wrote:
> >>> > Dear Cgal Users,
> >>> >
> >>> > I really need help on this problem. Still waiting for an answer.
> >>> >
> >>> > Thank you in advance.
> >>> >
> >>> > Burak ER
> >>> >
> >>> > Pzt, 2013-10-21 tarihinde 18:40 +0300 saatinde, Burak ER yazdı:
> >>> >> Dear Cgal Users,
> >>> >>
> >>> >> I am trying to mesh a rectengular prism domain from an off file into
> >>> >> tetrahedral elements using cgal. But whatever parameters I use within
> >>> >> criteria structure, I get a mesh where the boundaries are not
> >>> >> conserved
> >>> >> rather they are "uneven".
> >>> >>
> >>> >> What may cause that? How to force keeping boundaries exact while
> >>> >> meshing?
> >>> >>
> >>> >> Thank you in advance.
> >>> >>
> >>> >> --
> >>> >> Burak ER
> >>> >>
> >>> >> Research Assistant
> >>> >> Mechanical Engineering Department
> >>> >> Bursa Technical University
> >>> >>
> >>> >>
> >>> >>
> >>> >
> >>>
> >>>
> >>
> >>
> >>
> > --
> > Burak ER
> > <
> >
> > <mailto:>>
> >
> >
> > Bu elektronik posta ve ekleri sadece adreste belirtilen kisi veya
> > kurulusun kullanimi icin gonderilmektedir. Bu mesaj tarafiniza
> > yanlislikla ulasirsa, lutfen gonderen kisiyi bilgilendiriniz ve mesaji
> > sisteminizden siliniz. Mesajda ve eklerinde yer alan bilgilerin her ne
> > sekilde olursa olsun ucuncu kisiler ile paylasilmasi hukuki ve cezai
> > sorumluluk dogurabilir. Bursa Teknik Universitesi'nin, bu mesaj ve
> > eklerinin icerigi ve yayimi ile ilgili hicbir sorumlulugu
> > bulunmamaktadir.
> >
> > This email and the attachments are sent to the individual or entity
> > defined in the address field only. If you are not the intended
> > recipient or have received the message in error, please notify the
> > sender and remove the message from your system immediately. Sharing the
> > information in the message or the attachments with the 3rd parties may
> > cause legal rules and penalties to apply. Bursa Technical University has
> > no responsibility on the submission of this message and the attachments.
>
>

--
Burak ER
<>





Archive powered by MHonArc 2.6.18.

Top of Page