Commit c521c124 authored by Michael Turner's avatar Michael Turner
Browse files

last commenting

parent 5c02abf1
......@@ -99,6 +99,10 @@ OPTION(NEKTAR_TEST_ALL "Include full set of regression tests to this build." OFF
# meshing and cad options
OPTION(NEKTAR_USE_OCC "Use opencascade for geometry interface." OFF)
OPTION(NEKTAR_USE_MESH "Build meshing utilities." OFF)
# if meshing is selected hard set the occ option
IF( NEKTAR_USE_MESH )
SET(NEKTAR_USE_OCC ON CACHE BOOL "Use opencascade for geometry interface." FORCE)
ENDIF()
# Build options
OPTION(NEKTAR_FULL_DEBUG "Enable Full Debugging." OFF)
......
////////////////////////////////////////////////////////////////////////////////
//
// File: SurfaceMeshing.h
// File: TetGenInterface.cpp
//
// For more information, please see: http://www.nektar.info/
//
......@@ -29,7 +29,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: cad object methods.
// Description: tetgen interface methods
//
////////////////////////////////////////////////////////////////////////////////
......@@ -116,6 +116,7 @@ void TetGenInterface::Mesh(bool Quiet, bool Quality)
}
//quiet suppresses the output of tetegen to the consol
if(Quiet)
{
tetrahedralize("pYizfennQ", &surface, &output, &additional, NULL);
......
////////////////////////////////////////////////////////////////////////////////
//
// File: SurfaceMeshing.h
// File: TetGenInterface.h
//
// For more information, please see: http://www.nektar.info/
//
......@@ -29,12 +29,12 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: cad object methods.
// Description: class for interacting with tetgen
//
////////////////////////////////////////////////////////////////////////////////
#ifndef NEKTAR_LIB_UTILITIES_MESHUTILS_TETGENINTERFACE_H
#define NEKTAR_LIB_UTILITIES_MESHUTILS_TETGENINTERFACE_H
#ifndef NEKTAR_MESHUTILS_EXTLIBINTERFACE_TETGENINTERFACE_H
#define NEKTAR_MESHUTILS_EXTLIBINTERFACE_TETGENINTERFACE_H
#include <boost/shared_ptr.hpp>
......@@ -49,15 +49,21 @@
namespace Nektar{
namespace MeshUtils{
class TetGenInterface
{
class TetGenInterface
{
public:
friend class MemoryManager<TetGenInterface>;
/**
* @brief default constructor
*/
TetGenInterface()
{
};
/**
* @brief assign parameters for meshing
*/
void Assign(const std::vector<int> &nis,
const std::map<int, MeshTriSharedPtr> &t,
const std::map<int, MeshNodeSharedPtr> &n,
......@@ -70,29 +76,43 @@ namespace MeshUtils{
meshloaded = false;
}
/**
* @brief execture meshing
*/
void Mesh(bool Quiet = true, bool Quality = false);
/**
* @brief extract mesh information
*/
void Extract(int &numtet, Array<OneD, Array<OneD, int> > &tetconnect);
private:
/**
* @brief clear previous mesh
*/
void freetet();
///tetgen objects
tetgenio surface, additional, output;
/// list of all triangles in surface mesh
std::map<int, MeshTriSharedPtr> Tris;
/// list of all nodes
std::map<int, MeshNodeSharedPtr> Nodes;
/// list of stiener points
std::vector<int> m_stienerpoints;
/// list of nodes which are surface verticies
std::vector<int> m_nodesinsurface;
/// map from meshconvert id to tetgen id
std::map<int, int> nodemap;
/// map in reverse
std::map<int, int> nodemapr;
/// has a mesh been peviously loaded
bool meshloaded;
};
};
typedef boost::shared_ptr<TetGenInterface> TetGenInterfaceSharedPtr;
typedef boost::shared_ptr<TetGenInterface> TetGenInterfaceSharedPtr;
}
}
#endif
......@@ -33,194 +33,178 @@
//
////////////////////////////////////////////////////////////////////////////////
#include <string>
#include <fstream>
#include <MeshUtils/ExtLibInterface/TriangleInterface.h>
using namespace std;
namespace Nektar{
namespace MeshUtils {
void TriangleInterface::Mesh(bool Quiet, bool Quality)
{
void TriangleInterface::Mesh(bool Quiet, bool Quality)
{
if(meshloaded)
{
freetri();
}
ASSERTL0(meshloaded==false,"Mesh must be cleared before meshing");
if(meshloaded)
{
freetri();
}
ASSERTL0(meshloaded==false,"Mesh must be cleared before meshing");
int numPoints = 0;
int numSeg = 0;
for(int i = 0; i < m_boundingloops.size(); i++)
{
numSeg+=m_boundingloops[i].size();
}
numPoints = numSeg + m_stienerpoints.size();
int numPoints = 0;
int numSeg = 0;
for(int i = 0; i < m_boundingloops.size(); i++)
{
numSeg+=m_boundingloops[i].size();
}
numPoints = numSeg + m_stienerpoints.size();
in.numberofpoints = numPoints;
in.numberofpointattributes = 0;
in.pointlist = (REAL *) malloc(in.numberofpoints * 2 * sizeof(REAL));
in.pointmarkerlist = (int *) malloc(in.numberofpoints * sizeof(int));
in.numberofpoints = numPoints;
in.numberofpointattributes = 0;
in.pointlist = (REAL *) malloc(in.numberofpoints * 2 * sizeof(REAL));
in.pointmarkerlist = (int *) malloc(in.numberofpoints * sizeof(int));
int pointc = 0;
int pointc = 0;
for(int i = 0; i < m_boundingloops.size(); i++)
for(int i = 0; i < m_boundingloops.size(); i++)
{
for(int j = 0; j < m_boundingloops[i].size(); j++)
{
for(int j = 0; j < m_boundingloops[i].size(); j++)
{
nodemap[pointc] = m_boundingloops[i][j];
nodemapr[m_boundingloops[i][j]] = pointc;
Array<OneD, NekDouble> uv = Nodes[m_boundingloops[i][j]]
->GetS(sid);
in.pointlist[pointc*2+0] = uv[0]*m_str;
in.pointlist[pointc*2+1] = uv[1];
pointc++;
}
}
nodemap[pointc] = m_boundingloops[i][j];
nodemapr[m_boundingloops[i][j]] = pointc;
Array<OneD, NekDouble> uv = Nodes[m_boundingloops[i][j]]
->GetS(sid);
for(int i = 0; i < m_stienerpoints.size(); i++)
{
nodemap[pointc] = m_stienerpoints[i];
nodemapr[m_stienerpoints[i]] = pointc;
Array<OneD, NekDouble> uv = Nodes[m_stienerpoints[i]]
->GetS(sid);
in.pointlist[pointc*2+0] = uv[0]*m_str;
in.pointlist[pointc*2+1] = uv[1];
pointc++;
}
}
in.numberofsegments = numSeg;
in.segmentlist = (int *) malloc(in.numberofsegments*2*sizeof(int));
pointc=0;
for(int i = 0; i < m_boundingloops.size(); i++)
for(int i = 0; i < m_stienerpoints.size(); i++)
{
nodemap[pointc] = m_stienerpoints[i];
nodemapr[m_stienerpoints[i]] = pointc;
Array<OneD, NekDouble> uv = Nodes[m_stienerpoints[i]]
->GetS(sid);
in.pointlist[pointc*2+0] = uv[0]*m_str;
in.pointlist[pointc*2+1] = uv[1];
pointc++;
}
in.numberofsegments = numSeg;
in.segmentlist = (int *) malloc(in.numberofsegments*2*sizeof(int));
pointc=0;
for(int i = 0; i < m_boundingloops.size(); i++)
{
for(int j = 0; j < m_boundingloops[i].size()-1; j++)
{
for(int j = 0; j < m_boundingloops[i].size()-1; j++)
{
in.segmentlist[pointc*2+0] = nodemapr[m_boundingloops[i][j]];
in.segmentlist[pointc*2+1] = nodemapr[m_boundingloops[i][j+1]];
pointc++;
}
in.segmentlist[pointc*2+0] = nodemapr[m_boundingloops[i].back()];
in.segmentlist[pointc*2+1] = nodemapr[m_boundingloops[i][0]];
in.segmentlist[pointc*2+0] = nodemapr[m_boundingloops[i][j]];
in.segmentlist[pointc*2+1] = nodemapr[m_boundingloops[i][j+1]];
pointc++;
}
in.segmentlist[pointc*2+0] = nodemapr[m_boundingloops[i].back()];
in.segmentlist[pointc*2+1] = nodemapr[m_boundingloops[i][0]];
pointc++;
}
in.numberofregions = 0;
in.numberofholes = m_centers.size()-1;
in.holelist = (REAL *) malloc(in.numberofholes*2*sizeof(REAL));
for(int i = 1; i < m_centers.size(); i++)
{
in.holelist[(i-1)*2+0] = m_centers[i][0]*m_str;
in.holelist[(i-1)*2+1] = m_centers[i][1];
}
in.numberofregions = 0;
in.numberofholes = m_centers.size()-1;
in.holelist = (REAL *) malloc(in.numberofholes*2*sizeof(REAL));
out.pointlist = (REAL *) NULL;
out.pointattributelist = (REAL *) NULL;
out.pointmarkerlist = (int *) NULL;
out.trianglelist = (int *) NULL;
out.trianglearealist = (REAL *) NULL;
out.triangleattributelist = (REAL *) NULL;
out.neighborlist = (int *) NULL;
out.segmentlist = (int *) NULL;
out.segmentmarkerlist = (int *) NULL;
out.edgelist = (int *) NULL;
out.edgemarkerlist = (int *) NULL;
if(Quiet && Quality)
{
triangulate("pzenqQYY", &in, &out, NULL);
}
else if(Quiet && !Quality)
{
triangulate("pzenQYY", &in, &out, NULL);
}
else if(!Quiet && Quality)
{
triangulate("pzenqYY", &in, &out, NULL);
}
else if(!Quiet && !Quality)
{
triangulate("pzenYY", &in, &out, NULL);
}
for(int i = 0; i < out.numberofpoints; i++)
{
out.pointlist[i*2+0] = out.pointlist[i*2+0]/m_str;
}
for(int i = 1; i < m_centers.size(); i++)
{
in.holelist[(i-1)*2+0] = m_centers[i][0]*m_str;
in.holelist[(i-1)*2+1] = m_centers[i][1];
}
out.pointlist = (REAL *) NULL;
out.pointattributelist = (REAL *) NULL;
out.pointmarkerlist = (int *) NULL;
out.trianglelist = (int *) NULL;
out.trianglearealist = (REAL *) NULL;
out.triangleattributelist = (REAL *) NULL;
out.neighborlist = (int *) NULL;
out.segmentlist = (int *) NULL;
out.segmentmarkerlist = (int *) NULL;
out.edgelist = (int *) NULL;
out.edgemarkerlist = (int *) NULL;
if(Quiet && Quality)
{
triangulate("pzenqQYY", &in, &out, NULL);
}
else if(Quiet && !Quality)
{
triangulate("pzenQYY", &in, &out, NULL);
}
else if(!Quiet && Quality)
{
triangulate("pzenqYY", &in, &out, NULL);
}
else if(!Quiet && !Quality)
{
triangulate("pzenYY", &in, &out, NULL);
}
void TriangleInterface::Extract(int &np, int &nt,
Array<OneD, Array<OneD, int> > &Connec)
for(int i = 0; i < out.numberofpoints; i++)
{
Connec = Array<OneD, Array<OneD, int> >(out.numberoftriangles);
nt = out.numberoftriangles;
np = out.numberofpoints;
for(int i = 0; i < out.numberoftriangles; i++)
{
Array<OneD, int> tri(3);
tri[0] = nodemap[out.trianglelist[i*3+0]];
tri[1] = nodemap[out.trianglelist[i*3+1]];
tri[2] = nodemap[out.trianglelist[i*3+2]];
Connec[i] = tri;
}
out.pointlist[i*2+0] = out.pointlist[i*2+0]/m_str;
}
void TriangleInterface::GetEdges(Array<OneD, Array<OneD, int> > &edgelist,
int &num)
}
void TriangleInterface::Extract(int &np, int &nt,
Array<OneD, Array<OneD, int> > &Connec)
{
Connec = Array<OneD, Array<OneD, int> >(out.numberoftriangles);
nt = out.numberoftriangles;
np = out.numberofpoints;
for(int i = 0; i < out.numberoftriangles; i++)
{
edgelist = Array<OneD, Array<OneD, int> >(out.numberofedges);
for(int i = 0; i < out.numberofedges; i++)
{
Array<OneD, int> el(2);
el[0] = nodemap[out.edgelist[i*2+0]];
el[1] = nodemap[out.edgelist[i*2+1]];
edgelist[i] = el;
}
num = out.numberofedges;
Array<OneD, int> tri(3);
tri[0] = nodemap[out.trianglelist[i*3+0]];
tri[1] = nodemap[out.trianglelist[i*3+1]];
tri[2] = nodemap[out.trianglelist[i*3+2]];
Connec[i] = tri;
}
void TriangleInterface::GetNeighbour(
Array<OneD, Array<OneD, int> > &neigbourlist)
}
void TriangleInterface::GetEdges(Array<OneD, Array<OneD, int> > &edgelist,
int &num)
{
edgelist = Array<OneD, Array<OneD, int> >(out.numberofedges);
for(int i = 0; i < out.numberofedges; i++)
{
neigbourlist = Array<OneD, Array<OneD, int> >(out.numberoftriangles);
for(int i = 0; i < out.numberoftriangles; i++)
{
Array<OneD, int> nl(3);
nl[0] = out.neighborlist[i*3+0];
nl[1] = out.neighborlist[i*3+1];
nl[2] = out.neighborlist[i*3+2];
neigbourlist[i]=nl;
}
Array<OneD, int> el(2);
el[0] = nodemap[out.edgelist[i*2+0]];
el[1] = nodemap[out.edgelist[i*2+1]];
edgelist[i] = el;
}
num = out.numberofedges;
}
void TriangleInterface::freetri()
void TriangleInterface::freetri()
{
if(meshloaded)
{
if(meshloaded)
{
free(in.pointlist);
free(in.pointmarkerlist);
free(in.segmentlist);
free(in.holelist);
free(out.pointlist);
free(out.pointattributelist);
free(out.pointmarkerlist);
free(out.trianglelist);
free(out.triangleattributelist);
free(out.trianglearealist);
free(out.neighborlist);
free(out.segmentlist);
free(out.segmentmarkerlist);
free(out.edgelist);
free(out.edgemarkerlist);
}
meshloaded = false;
free(in.pointlist);
free(in.pointmarkerlist);
free(in.segmentlist);
free(in.holelist);
free(out.pointlist);
free(out.pointattributelist);
free(out.pointmarkerlist);
free(out.trianglelist);
free(out.triangleattributelist);
free(out.trianglearealist);
free(out.neighborlist);
free(out.segmentlist);
free(out.segmentmarkerlist);
free(out.edgelist);
free(out.edgemarkerlist);
}
meshloaded = false;
}
}
}
////////////////////////////////////////////////////////////////////////////////
//
// File: SurfaceMeshing.h
// File: TriangleInterface.h
//
// For more information, please see: http://www.nektar.info/
//
......@@ -29,22 +29,18 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: cad object methods.
// Description: class for interfacing with triangle
//
////////////////////////////////////////////////////////////////////////////////
#ifndef NEKTAR_LIB_UTILITIES_MESHUTILS_TRIANGLEINTERFACE_H
#define NEKTAR_LIB_UTILITIES_MESHUTILS_TRIANGLEINTERFACE_H
#ifndef NEKTAR_MESHUTILS_EXTLIBINTERFACE_TRIANGLEINTERFACE_H
#define NEKTAR_MESHUTILS_EXTLIBINTERFACE_TRIANGLEINTERFACE_H
#include <boost/shared_ptr.hpp>
#ifdef SINGLE
#define REAL float
#else /* not SINGLE */
//horible definitions to get triangle to work
#define REAL double
#endif /* not SINGLE */
#define ANSI_DECLARATORS
#define TRILIBRARY
#define VOID int
......@@ -59,77 +55,98 @@ extern "C"{
namespace Nektar {
namespace MeshUtils {
class TriangleInterface
namespace MeshUtils {
class TriangleInterface
{
public:
friend class MemoryManager<TriangleInterface>;
/**
* @brief default constructor
*/
TriangleInterface()
{
meshloaded = false;
};
/**
* @brief assign meshing paramters
*/
void Assign(const std::vector<std::vector<int> > &boundingloops,
const std::vector<std::vector<NekDouble> > &centers,
const std::map<int, MeshNodeSharedPtr> &n,
const std::vector<int> &stiner, int i,
NekDouble str = 1.0)
{
if(meshloaded)
{
public:
friend class MemoryManager<TriangleInterface>;
TriangleInterface()
{
meshloaded = false;
};
void Assign(const std::vector<std::vector<int> > &boundingloops,
const std::vector<std::vector<NekDouble> >
&centers,
const std::map<int, MeshNodeSharedPtr> &n,
const std::vector<int> &stiner, int i,
NekDouble str = 1.0)
{
if(meshloaded)
{
freetri();
}
m_boundingloops = boundingloops;
m_centers = centers;
Nodes = n;
m_stienerpoints = stiner;
m_str = str;
sid = i;
}
~TriangleInterface()
{
if(meshloaded)
freetri();
}
void Mesh(bool Quiet = true, bool Quality = false);
void Extract(int &np, int &nt,
Array<OneD, Array<OneD, int> > &Connec);
void GetNeighbour(Array<OneD, Array<OneD, int> > &neigbourlist);
void GetEdges(Array<OneD, Array<OneD, int> > &edgelist,
int &num);
private:
void freetri();
std::vector<std::vector<int> > m_boundingloops;
std::vector<int> m_stienerpoints;
std::vector<std::vector<NekDouble> > m_centers;
std::map<int, MeshNodeSharedPtr> Nodes;
std::map<int, int> nodemap;
std::map<int, int> nodemapr;
int sid;