Nektar++
CADSystem.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: CADSystem.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: cad object methods.
32 //
33 ////////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef NekMeshUtils_CADSYSTEM_CADSYSTEM
36 #define NekMeshUtils_CADSYSTEM_CADSYSTEM
37 
40 
42 
44 
45 #include "CADObject.h"
46 
47 namespace Nektar
48 {
49 namespace NekMeshUtils
50 {
51 
52 // forward declorators
53 class CADVert;
54 typedef std::shared_ptr<CADVert> CADVertSharedPtr;
55 class CADCurve;
56 typedef std::shared_ptr<CADCurve> CADCurveSharedPtr;
57 class CADSurf;
58 typedef std::shared_ptr<CADSurf> CADSurfSharedPtr;
59 
60 /**
61  * @brief Base class for CAD interface system.
62  *
63  * A class which can load and interact with CAD for Nektar++.
64  * This class contains maps to subclasses surface and curves.
65  */
66 class CADSystem
67 {
68 public:
69  friend class MemoryManager<CADSystem>;
70 
71  /**
72  * @brief Default constructor.
73  */
74  CADSystem(std::string name) : m_name(name)
75  {
76  m_2d = false;
77  m_cfiMesh = false;
78  m_verbose = false;
79  }
80 
81  virtual ~CADSystem()
82  {
83  }
84 
85  /**
86  * @brief Return the name of the CAD file.
87  */
88  std::string GetName()
89  {
90  return m_name;
91  }
92 
93  void Set2D()
94  {
95  m_2d = true;
96  }
97 
98  bool Is2D()
99  {
100  return m_2d;
101  }
102 
103  void SetNACA(std::string i)
104  {
105  m_naca = i;
106  }
107 
108  void SetCFIMesh()
109  {
110  m_cfiMesh = true;
111  }
112 
113  void SetVerbose()
114  {
115  m_verbose = true;
116  }
117 
118  /**
119  * @brief Initialises CAD and makes surface, curve and vertex maps.
120  *
121  * @return true if completed successfully
122  */
123  virtual bool LoadCAD() = 0;
124 
125  /**
126  * @brief Returns bounding box of the domain.
127  *
128  * Gets the bounding box of the domain by considering the start and end
129  * points of each curve in the geometry.
130  *
131  * @return Array with 6 entries: xmin, xmax, ymin, ymax, zmin and zmax.
132  */
134 
135  /**
136  * @brief Get the number of surfaces.
137  */
139  {
140  return m_surfs.size();
141  }
142 
143  /**
144  * @brief Get the number of curves.
145  */
147  {
148  return m_curves.size();
149  }
150 
151  /**
152  * @brief Gets a curve from the map.
153  */
154  CADCurveSharedPtr GetCurve(int i)
155  {
156  auto search = m_curves.find(i);
157  ASSERTL1(search != m_curves.end(), "curve does not exist");
158 
159  return search->second;
160  }
161 
162  /**
163  * @brief Gets a surface from the map.
164  */
165  CADSurfSharedPtr GetSurf(int i)
166  {
167  auto search = m_surfs.find(i);
168  ASSERTL1(search != m_surfs.end(), "surface does not exist");
169 
170  return search->second;
171  }
172 
173  /**
174  * @brief Gets a vert from the map.
175  */
176  CADVertSharedPtr GetVert(int i)
177  {
178  auto search = m_verts.find(i);
179  ASSERTL1(search != m_verts.end(), "vert does not exist");
180 
181  return search->second;
182  }
183 
184  /**
185  * @brief Gets map of all vertices
186  */
187  std::map<int, CADVertSharedPtr> GetVerts()
188  {
189  return m_verts;
190  }
191 
192  /**
193  * @brief Gets number of vertices
194  */
196  {
197  return m_verts.size();
198  }
199 
200  /**
201  * @brief Return the vector of translation from one curve to another to
202  * allow
203  * for periodic mesh generation in 2D.
204  */
206  int first, int second);
207 
208 protected:
209  /// Name of cad file
210  std::string m_name;
211  /// Map of curves
212  std::map<int, CADCurveSharedPtr> m_curves;
213  /// Map of surfaces
214  std::map<int, CADSurfSharedPtr> m_surfs;
215  /// Map of vertices
216  std::map<int, CADVertSharedPtr> m_verts;
217  /// Verbosity
218  bool m_verbose;
219  /// 2D cad flag
220  bool m_2d;
221  /// Will the CAD be used with a CFI mesh flag
222  bool m_cfiMesh;
223  /// string of 4 digit NACA code to be created
224  std::string m_naca;
225 
226  /**
227  * @brief Reports basic properties to screen.
228  */
229  void Report()
230  {
231  std::cout << std::endl << "CAD report:" << std::endl;
232  std::cout << "\tCAD has: " << m_verts.size() << " verts." << std::endl;
233  std::cout << "\tCAD has: " << m_curves.size() << " curves."
234  << std::endl;
235  std::cout << "\tCAD has: " << m_surfs.size() << " surfaces."
236  << std::endl;
237  }
238 };
239 
240 typedef std::shared_ptr<CADSystem> CADSystemSharedPtr;
243 
245 }
246 }
247 
248 #endif
std::shared_ptr< CADSurf > CADSurfSharedPtr
Definition: CADCurve.h:51
LibUtilities::NekFactory< std::string, CADSystem, std::string > EngineFactory
Definition: CADSystem.h:242
int GetNumVerts()
Gets number of vertices.
Definition: CADSystem.h:195
int GetNumCurve()
Get the number of curves.
Definition: CADSystem.h:146
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
std::shared_ptr< CADVert > CADVertSharedPtr
Definition: CADCurve.h:49
Base class for CAD interface system.
Definition: CADSystem.h:66
std::map< int, CADVertSharedPtr > GetVerts()
Gets map of all vertices.
Definition: CADSystem.h:187
std::shared_ptr< CADSystem > CADSystemSharedPtr
Definition: CADSystem.h:240
int GetNumSurf()
Get the number of surfaces.
Definition: CADSystem.h:138
std::string m_name
Name of cad file.
Definition: CADSystem.h:210
std::map< int, CADCurveSharedPtr > m_curves
Map of curves.
Definition: CADSystem.h:212
void Report()
Reports basic properties to screen.
Definition: CADSystem.h:229
std::map< int, CADVertSharedPtr > m_verts
Map of vertices.
Definition: CADSystem.h:216
CADSystem(std::string name)
Default constructor.
Definition: CADSystem.h:74
std::string m_naca
string of 4 digit NACA code to be created
Definition: CADSystem.h:224
std::shared_ptr< CADCurve > CADCurveSharedPtr
Definition: CADCurve.h:219
virtual Array< OneD, NekDouble > GetBoundingBox()=0
Returns bounding box of the domain.
NEKMESHUTILS_EXPORT Array< OneD, NekDouble > GetPeriodicTranslationVector(int first, int second)
Return the vector of translation from one curve to another to allow for periodic mesh generation in 2...
Definition: CADSystem.cpp:71
virtual bool LoadCAD()=0
Initialises CAD and makes surface, curve and vertex maps.
bool m_cfiMesh
Will the CAD be used with a CFI mesh flag.
Definition: CADSystem.h:222
CADCurveSharedPtr GetCurve(int i)
Gets a curve from the map.
Definition: CADSystem.h:154
EngineFactory & GetEngineFactory()
Definition: CADSystem.cpp:47
void SetNACA(std::string i)
Definition: CADSystem.h:103
#define NEKMESHUTILS_EXPORT
std::map< int, CADSurfSharedPtr > m_surfs
Map of surfaces.
Definition: CADSystem.h:214
std::string GetName()
Return the name of the CAD file.
Definition: CADSystem.h:88
CADSurfSharedPtr GetSurf(int i)
Gets a surface from the map.
Definition: CADSystem.h:165
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:250
CADVertSharedPtr GetVert(int i)
Gets a vert from the map.
Definition: CADSystem.h:176
Provides a generic Factory class.
Definition: NekFactory.hpp:103