Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Nektar::NekMeshUtils::TriangleInterface Class Reference

class for interfacing with external library triangle More...

#include <TriangleInterface.h>

Collaboration diagram for Nektar::NekMeshUtils::TriangleInterface:
Collaboration graph
[legend]

Public Member Functions

 TriangleInterface ()
 default constructor More...
 
void Assign (std::vector< std::vector< NodeSharedPtr > > &boundingloops, std::vector< Array< OneD, NekDouble > > &centers, int i, NekDouble str=1.0)
 assign meshing paramters More...
 
void AssignStiener (std::vector< NodeSharedPtr > stiner)
 
void Mesh (bool Quality=false)
 Execute meshing. More...
 
void Extract (std::vector< std::vector< NodeSharedPtr > > &Connec)
 Extract mesh. More...
 

Private Member Functions

void SetUp ()
 Clear memory. More...
 

Private Attributes

std::vector< std::vector
< NodeSharedPtr > > 
m_boundingloops
 List of bounding nodes to the surface. More...
 
std::vector< NodeSharedPtrm_stienerpoints
 List of additional nodes. More...
 
std::vector< Array< OneD,
NekDouble > > 
m_centers
 Coordinates of the centers of the loops. More...
 
std::map< int, NodeSharedPtrnodemap
 Map from NekMesh id to triangle id. More...
 
int sid
 ID of the surface. More...
 
NekDouble m_str
 Stretching factor of parameter plane. More...
 
DelaunayTriangle dt
 Triangle data strucutres. More...
 

Friends

class MemoryManager< TriangleInterface >
 

Detailed Description

class for interfacing with external library triangle

Definition at line 55 of file TriangleInterface.h.

Constructor & Destructor Documentation

Nektar::NekMeshUtils::TriangleInterface::TriangleInterface ( )
inline

default constructor

Definition at line 63 of file TriangleInterface.h.

63 {};

Member Function Documentation

void Nektar::NekMeshUtils::TriangleInterface::Assign ( std::vector< std::vector< NodeSharedPtr > > &  boundingloops,
std::vector< Array< OneD, NekDouble > > &  centers,
int  i,
NekDouble  str = 1.0 
)
inline

assign meshing paramters

Definition at line 68 of file TriangleInterface.h.

References m_boundingloops, m_centers, m_str, and sid.

72  {
73  m_boundingloops = boundingloops;
74  m_centers = centers;
75  m_str = str;
76  sid = i;
77  }
std::vector< Array< OneD, NekDouble > > m_centers
Coordinates of the centers of the loops.
std::vector< std::vector< NodeSharedPtr > > m_boundingloops
List of bounding nodes to the surface.
NekDouble m_str
Stretching factor of parameter plane.
void Nektar::NekMeshUtils::TriangleInterface::AssignStiener ( std::vector< NodeSharedPtr stiner)
inline

Definition at line 79 of file TriangleInterface.h.

References m_stienerpoints.

80  {
81  m_stienerpoints = stiner;
82  }
std::vector< NodeSharedPtr > m_stienerpoints
List of additional nodes.
void Nektar::NekMeshUtils::TriangleInterface::Extract ( std::vector< std::vector< NodeSharedPtr > > &  Connec)

Extract mesh.

Definition at line 193 of file TriangleInterface.cpp.

References ASSERTL0, and Nektar::iterator.

195 {
196  Connec.clear();
197  for (int i = 0; i < dt.out.numberoftriangles; i++)
198  {
200  n1 = nodemap.find(dt.out.trianglelist[i * 3 + 0]);
201  n2 = nodemap.find(dt.out.trianglelist[i * 3 + 1]);
202  n3 = nodemap.find(dt.out.trianglelist[i * 3 + 2]);
203 
204  ASSERTL0(n1 != nodemap.end() && n2 != nodemap.end() &&
205  n3 != nodemap.end(),
206  "node index error");
207 
208  vector<NodeSharedPtr> tri(3);
209  tri[0] = n1->second;
210  tri[1] = n2->second;
211  tri[2] = n3->second;
212  Connec.push_back(tri);
213  }
214 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
std::map< int, NodeSharedPtr > nodemap
Map from NekMesh id to triangle id.
DelaunayTriangle dt
Triangle data strucutres.
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
void Nektar::NekMeshUtils::TriangleInterface::Mesh ( bool  Quality = false)

Execute meshing.

Definition at line 46 of file TriangleInterface.cpp.

References ASSERTL0.

47 {
48  SetUp();
49 
50  int numPoints = 0;
51  int numSeg = 0;
52  for (int i = 0; i < m_boundingloops.size(); i++)
53  {
54  numSeg += m_boundingloops[i].size();
55  }
56  numPoints = numSeg + m_stienerpoints.size();
57 
58  stringstream ss;
59  ss << "3 points required for triangulation, " << numPoints << " provided";
60 
61  ASSERTL0(numPoints > 2, ss.str());
62 
63  dt.in.numberofpoints = numPoints;
64  dt.in.numberofpointattributes = 0;
65  dt.in.pointlist = new double[dt.in.numberofpoints * 2];
66  dt.in.pointmarkerlist = new int [dt.in.numberofpoints];
67 
68  int pointc = 0;
69 
70  for (int i = 0; i < m_boundingloops.size(); i++)
71  {
72  for (int j = 0; j < m_boundingloops[i].size(); j++, pointc++)
73  {
74  nodemap[pointc] = m_boundingloops[i][j];
75 
76  Array<OneD, NekDouble> uv =
77  m_boundingloops[i][j]->GetCADSurfInfo(sid);
78  dt.in.pointlist[pointc * 2 + 0] = uv[0] * m_str;
79  dt.in.pointlist[pointc * 2 + 1] = uv[1];
80  }
81  }
82 
83  for (int i = 0; i < m_stienerpoints.size(); i++, pointc++)
84  {
85  nodemap[pointc] = m_stienerpoints[i];
86 
87  Array<OneD, NekDouble> uv = m_stienerpoints[i]->GetCADSurfInfo(sid);
88  dt.in.pointlist[pointc * 2 + 0] = uv[0] * m_str;
89  dt.in.pointlist[pointc * 2 + 1] = uv[1];
90  }
91 
92  dt.in.numberofsegments = numSeg;
93  dt.in.segmentlist = new int[dt.in.numberofsegments * 2];
94  pointc = 0;
95  for (int i = 0; i < m_boundingloops.size(); i++, pointc++)
96  {
97  int first = pointc;
98  for (int j = 0; j < m_boundingloops[i].size() - 1; j++, pointc++)
99  {
100  dt.in.segmentlist[pointc * 2 + 0] = pointc;
101  dt.in.segmentlist[pointc * 2 + 1] = pointc + 1;
102  }
103  dt.in.segmentlist[pointc * 2 + 0] = pointc;
104  dt.in.segmentlist[pointc * 2 + 1] = first;
105  }
106 
107  dt.in.numberofregions = 0;
108  dt.in.numberofholes = m_centers.size() - 1;
109  dt.in.holelist = new double[dt.in.numberofholes * 2];
110 
111  for (int i = 1; i < m_centers.size(); i++)
112  {
113  dt.in.holelist[(i - 1) * 2 + 0] = m_centers[i][0] * m_str;
114  dt.in.holelist[(i - 1) * 2 + 1] = m_centers[i][1];
115  }
116 
117  string cmd;
118  if (Quality)
119  {
120  cmd = "pqY";
121  }
122  else if (!Quality)
123  {
124  cmd = "pY";
125  }
126  char *cstr = new char[cmd.length() + 1];
127  strcpy(cstr, cmd.c_str());
128 
129  dt.triangulate(cstr);
130 }
std::vector< Array< OneD, NekDouble > > m_centers
Coordinates of the centers of the loops.
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
std::vector< std::vector< NodeSharedPtr > > m_boundingloops
List of bounding nodes to the surface.
std::map< int, NodeSharedPtr > nodemap
Map from NekMesh id to triangle id.
std::vector< NodeSharedPtr > m_stienerpoints
List of additional nodes.
DelaunayTriangle dt
Triangle data strucutres.
NekDouble m_str
Stretching factor of parameter plane.
void Nektar::NekMeshUtils::TriangleInterface::SetUp ( )
private

Clear memory.

Definition at line 132 of file TriangleInterface.cpp.

133 {
134  dt.in.pointlist = (double *)NULL;
135  dt.in.pointattributelist = (double *)NULL;
136  dt.in.pointmarkerlist = (int *)NULL;
137  dt.in.numberofpoints = 0;
138  dt.in.numberofpointattributes = 0;
139  //
140  dt.in.trianglelist = (int *)NULL;
141  dt.in.triangleattributelist = (double *)NULL;
142  dt.in.trianglearealist = (double *)NULL;
143  dt.in.neighborlist = (int *)NULL;
144  dt.in.numberoftriangles = 0;
145  dt.in.numberofcorners = 0;
146  dt.in.numberoftriangleattributes = 0;
147  //
148  dt.in.segmentlist = (int *)NULL;
149  dt.in.segmentmarkerlist = (int *)NULL;
150  dt.in.numberofsegments = 0;
151  //
152  dt.in.holelist = (double *)NULL;
153  dt.in.numberofholes = 0;
154  //
155  dt.in.regionlist = (double *)NULL;
156  dt.in.numberofregions = 0;
157  //
158  dt.in.edgelist = (int *)NULL;
159  dt.in.edgemarkerlist = (int *)NULL;
160  dt.in.normlist = (double *)NULL;
161  dt.in.numberofedges = 0;
162  //
163  dt.out.pointlist = (double *)NULL;
164  dt.out.pointattributelist = (double *)NULL;
165  dt.out.pointmarkerlist = (int *)NULL;
166  dt.out.numberofpoints = 0;
168  //
169  dt.out.trianglelist = (int *)NULL;
170  dt.out.triangleattributelist = (double *)NULL;
171  dt.out.trianglearealist = (double *)NULL;
172  dt.out.neighborlist = (int *)NULL;
174  dt.out.numberofcorners = 0;
176  //
177  dt.out.segmentlist = (int *)NULL;
178  dt.out.segmentmarkerlist = (int *)NULL;
179  dt.out.numberofsegments = 0;
180  //
181  dt.out.holelist = (double *)NULL;
182  dt.out.numberofholes = 0;
183  //
184  dt.out.regionlist = (double *)NULL;
185  dt.out.numberofregions = 0;
186  //
187  dt.out.edgelist = (int *)NULL;
188  dt.out.edgemarkerlist = (int *)NULL;
189  dt.out.normlist = (double *)NULL;
190  dt.out.numberofedges = 0;
191 }
DelaunayTriangle dt
Triangle data strucutres.

Friends And Related Function Documentation

friend class MemoryManager< TriangleInterface >
friend

Definition at line 58 of file TriangleInterface.h.

Member Data Documentation

DelaunayTriangle Nektar::NekMeshUtils::TriangleInterface::dt
private

Triangle data strucutres.

Definition at line 113 of file TriangleInterface.h.

std::vector<std::vector<NodeSharedPtr> > Nektar::NekMeshUtils::TriangleInterface::m_boundingloops
private

List of bounding nodes to the surface.

Definition at line 101 of file TriangleInterface.h.

Referenced by Assign().

std::vector<Array<OneD, NekDouble> > Nektar::NekMeshUtils::TriangleInterface::m_centers
private

Coordinates of the centers of the loops.

Definition at line 105 of file TriangleInterface.h.

Referenced by Assign().

std::vector<NodeSharedPtr> Nektar::NekMeshUtils::TriangleInterface::m_stienerpoints
private

List of additional nodes.

Definition at line 103 of file TriangleInterface.h.

Referenced by AssignStiener().

NekDouble Nektar::NekMeshUtils::TriangleInterface::m_str
private

Stretching factor of parameter plane.

Definition at line 111 of file TriangleInterface.h.

Referenced by Assign().

std::map<int, NodeSharedPtr> Nektar::NekMeshUtils::TriangleInterface::nodemap
private

Map from NekMesh id to triangle id.

Definition at line 107 of file TriangleInterface.h.

int Nektar::NekMeshUtils::TriangleInterface::sid
private

ID of the surface.

Definition at line 109 of file TriangleInterface.h.

Referenced by Assign().