<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Hi Ryan,<br>
your code seems to be correct (by the way I am not a great expert of Gmsh source code).<br>
<br>
I was thinking that maybe the problem is in the geometry definition: element orientations should be consistent all around the surface (triangle normals should point outward). Maybe some of your elements have opposite orientation and thus volume mesh cannot
be generated?<br>
<br>
On which geometry are you testing your program? If you have tried to generate the mesh using the GUI and you have succeeded, probably it's because Gmsh makes a check on orientation.<br>
<br>
Simone<br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF710128"><font face="Tahoma" color="#000000" size="2"><b>De :</b> rjdurscher@gmail.com [rjdurscher@gmail.com] de la part de Ryan Durscher [dursch@ufl.edu]<br>
<b>Envoyé :</b> samedi 22 août 2015 6.00<br>
<b>À :</b> Simone GREMMO [531257]<br>
<b>Cc :</b> Gmsh; gmsh@geuz.org<br>
<b>Objet :</b> Re: [Gmsh] c++ API - Import mesh vertices and elements<br>
</font><br>
</div>
<div></div>
<div>
<div dir="ltr">
<div>
<div>Simone, <br>
<br>
Please see below for sample code. I have tried commenting out those line, but it resulted in the same issue. The error I am seeing is :<br>
<br>
"Initializing memorypools.<br>
tetrahedron per block: 8188.<br>
Size of a point: 128 bytes.<br>
Size of a tetrahedron: 96 (96) bytes.<br>
Size of a shellface: 216 (216) bytes.<br>
Error: The point set is trivial."<br>
<br>
</div>
<div>These are tetgen outputs with the "The point set is trivial" being a result of the 0 nodes being input into it. Incidentally if I call refineMesh it properly refines the surface mesh I am inputting into the gmshModel if I comment out the region stuff.
From the GUI in order to get a volume mesh I have to use the elementary entities -> add -> volume then select the surface mesh (generated from step *** in the code). This creates a *.geo file which I cant figure out how to replicate though the API. The form
of the *.geo file is:<br>
<br>
Discrete Face(1) = {};<br>
Surface Loop(3) = {1};<br>
Volume(3) = {3};<br>
Physical Surface(1) = {1};<br>
<br>
</div>
<div>I have been staring at this for a while now and any help would be greatly appreciated.<br>
<br>
</div>
<div>Thanks, <br>
</div>
<div>Ryan <br>
</div>
<div><br>
<br>
// Gmsh headers<br>
#include "Gmsh.h"<br>
#include "GModel.h"<br>
#include "GEntity.h"<br>
#include "discreteFace.h"<br>
#include "discreteRegion.h"<br>
#include "MTriangle.h"<br>
#include "MFace.h"<br>
<br>
</div>
// *verts is a 3*numVerts array of coordinates verts(3*i + 0) = x, verts(3*i + 1) = y, and verts(3*i + 3) = z<br>
</div>
// *conn is a 3*numTris array - define the triangles connectivity <br>
<div>
<div>
<div>
<div>
<div>int gmsh_Volume_Mesh(int numVerts,<br>
int numTris,<br>
double *verts,<br>
int *conn)<br>
{<br>
// Initialize variables<br>
int i,j;<br>
<br>
printf("USING GMSH\n");<br>
<br>
GmshInitialize();<br>
GmshSetOption("Mesh","Algorithm",1.);<br>
GmshSetOption("General","Verbosity", 100.);<br>
<br>
//Create Gmsh model and set the factory<br>
GModel *modelGmsh = new GModel;<br>
modelGmsh->setFactory("Gmsh");<br>
<br>
// Create a discrete face<br>
GFace *interFace = new discreteFace(modelGmsh,1);<br>
<br>
// Pack triangle verts into vertex vector<br>
std::vector<MVertex*> vertex;<br>
vertex.resize((int) numVerts);<br>
for (i = 0 ; i < numVerts ; i ++) {<br>
<br>
vertex[i] = new MVertex(verts[3*i + 0],<br>
verts[3*i + 1],<br>
verts[3*i + 2],<br>
interFace,<br>
i+1); // Want index to start at 1<br>
// Add vertex to face<br>
interFace->addMeshVertex(vertex[i]);<br>
}<br>
<br>
// Pack connectivity of triangles into face<br>
for (i = 0; i < numTris; i++) {<br>
interFace->addTriangle(new MTriangle(vertex[conn[3*i + 0]-1],<br>
vertex[conn[3*i + 1]-1],<br>
vertex[conn[3*i + 2]-1]));/*,<br>
i+1,2));*/<br>
}<br>
<br>
printf("Number of elements in face = %d\n",interFace->getNumMeshElements());<br>
<br>
// Add face to model<br>
modelGmsh->add(interFace);<br>
<br>
// ****** modelGmsh->writeGEO("test.geo");<br>
// ****** modelGmsh->writeMSH("test.msh");<br>
<br>
// Create face loop - only 1 surface<br>
std::vector<GFace*> interfaceFace; //in my case the surface is given in one piece only<br>
interfaceFace.push_back(interFace);<br>
std::vector <std::vector<GFace*> > interfaceLoop;<br>
interfaceLoop.push_back(interfaceFace);<br>
<br>
// Create a physical region<br>
GRegion *regionInterface = modelGmsh->addVolume(interfaceLoop);<br>
<br>
//Add a volume physical entity<br>
regionInterface->addPhysicalEntity(1);<br>
<br>
//Add the region to the model<br>
modelGmsh->add(regionInterface);<br>
<br>
modelGmsh->writeGEO("test.geo");<br>
modelGmsh->writeMSH("test.msh");<br>
<br>
//Mesh the model<br>
//modelGmsh->refineMesh(1); // Refining the surface mesh works fine if I comment out the region stuff<br>
modelGmsh->mesh(3);<br>
<br>
/*printf("Num Regions = %d\n",gmshmodel->getNumRegions());<br>
printf("Num Faces = %d\n",gmshmodel->getNumFaces());<br>
printf("Num Edges = %d\n",gmshmodel->getNumEdges());<br>
printf("Num Verts = %d\n",gmshmodel->getNumVertices());*/<br>
<br>
delete modelGmsh;<br>
<br>
GmshFinalize();<br>
<br>
printf("Done meshing\n");<br>
}<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>