Nektar++
TriangleInterface.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: TriangleInterface.h
4 //
5 // For more information, please see: http://www.nektar.info/
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: class for interfacing with triangle
32 //
33 ////////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef NEKTAR_MESHUTILS_EXTLIBINTERFACE_TRIANGLEINTERFACE_H
36 #define NEKTAR_MESHUTILS_EXTLIBINTERFACE_TRIANGLEINTERFACE_H
37 
38 #include <memory>
39 
43 
44 #define ANSI_DECLARATORS
45 #define REAL double
46 #define VOID void
47 extern "C"
48 {
49  #include <triangle.h>
50 }
51 
52 namespace Nektar
53 {
54 namespace NekMeshUtils
55 {
56 
57 /**
58  * @brief class for interfacing with external library triangle
59  */
61 {
62 public:
64 
65  /**
66  * @brief default constructor
67  */
69 
70  /**
71  * @brief assign meshing paramters
72  */
73  void Assign(std::vector<std::vector<NodeSharedPtr> > &boundingloops,
74  std::vector<Array<OneD, NekDouble> > &centers,
75  int i,
76  NekDouble str = 1.0)
77  {
78  m_boundingloops = boundingloops;
79  m_centers = centers;
80  m_str = str;
81  sid = i;
82  }
83 
84  void AssignStiener(std::vector<NodeSharedPtr> stiner)
85  {
86  m_stienerpoints = stiner;
87  }
88 
89  /**
90  * @brief Execute meshing
91  */
92  void Mesh(bool Quality = false);
93 
94  /**
95  * @brief Extract mesh
96  */
97  void Extract(std::vector<std::vector<NodeSharedPtr> > &Connec);
98 
99 private:
100  /**
101  * @brief Clear memory
102  */
103  void SetUp();
104 
106  {
107  public:
108  void Run(char* cmd)
109  {
110  triangulate(cmd, &in, &out, NULL);
111  }
112  struct triangulateio in, out;
113  };
114 
115  /// List of bounding nodes to the surface
116  std::vector<std::vector<NodeSharedPtr> > m_boundingloops;
117  /// List of additional nodes
118  std::vector<NodeSharedPtr> m_stienerpoints;
119  /// Coordinates of the centers of the loops
120  std::vector<Array<OneD, NekDouble> > m_centers;
121  /// Map from NekMesh id to triangle id
122  std::map<int, NodeSharedPtr> nodemap;
123  /// ID of the surface
124  int sid;
125  /// Stretching factor of parameter plane
127  /// Triangle data strucutres
129 };
130 
131 typedef std::shared_ptr<TriangleInterface> TriangleInterfaceSharedPtr;
132 }
133 }
134 
135 #endif
std::vector< Array< OneD, NekDouble > > m_centers
Coordinates of the centers of the loops.
void Mesh(bool Quality=false)
Execute meshing.
class for interfacing with external library triangle
void Extract(std::vector< std::vector< NodeSharedPtr > > &Connec)
Extract mesh.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
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.
double NekDouble
void AssignStiener(std::vector< NodeSharedPtr > stiner)
std::shared_ptr< TriangleInterface > TriangleInterfaceSharedPtr
void Assign(std::vector< std::vector< NodeSharedPtr > > &boundingloops, std::vector< Array< OneD, NekDouble > > &centers, int i, NekDouble str=1.0)
assign meshing paramters