Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MeshGraph3D.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: MeshGraph3D.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 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description:
33 //
34 //
35 ////////////////////////////////////////////////////////////////////////////////
36 #ifndef NEKTAR_SPATIALDOMAINS_MESHGRAPH3D_H
37 #define NEKTAR_SPATIALDOMAINS_MESHGRAPH3D_H
38 
40 #include <SpatialDomains/TriGeom.h>
42 #include <boost/unordered_map.hpp>
43 
44 namespace Nektar
45 {
46  namespace SpatialDomains
47  {
48  class SegGeom;
49  class QuadGeom;
50  class TetGeom;
51  class PyrGeom;
52  class PrismGeom;
53  class HexGeom;
54 
55  class MeshGraph3D: public MeshGraph
56  {
57  public:
58 
62 
63  SPATIAL_DOMAINS_EXPORT void ReadGeometry(const std::string &infilename);
64  SPATIAL_DOMAINS_EXPORT void ReadGeometry(TiXmlDocument &doc);
65 
68 
69  inline int GetCoordim(void){
70  return GetSpaceDimension();
71  }
72 
73  inline const TriGeomMap &GetTrigeoms(void) const
74  {
75  return m_triGeoms;
76  }
77 
78  inline const QuadGeomMap &GetQuadgeoms(void) const
79  {
80  return m_quadGeoms;
81  }
82 
84 
85  inline int GetNseggeoms() const
86  {
87  return int(m_segGeoms.size());
88  }
89 
91  const int vert, const int elmt) const
92  {
93  if(shape == LibUtilities::eTriangle)
94  {
95  ASSERTL2(m_triGeoms.find(elmt) != m_triGeoms.end(),
96  "eid is out of range");
97 
98  return m_triGeoms.find(elmt)->second->GetVid(vert);
99  }
100  else
101  {
102  ASSERTL2(m_quadGeoms.find(elmt) != m_quadGeoms.end(),
103  "eid is out of range");
104 
105  return m_quadGeoms.find(elmt)->second->GetVid(vert);
106  }
107  }
108 
110  const int edge, const int elmt) const
111  {
112  if(shape == LibUtilities::eTriangle)
113  {
114  ASSERTL2(m_triGeoms.find(elmt) != m_triGeoms.end(),
115  "eid is out of range");
116 
117  return m_triGeoms.find(elmt)->second->GetEid(edge);
118  }
119  else
120  {
121  ASSERTL2(m_quadGeoms.find(elmt) != m_quadGeoms.end(),
122  "eid is out of range");
123 
124  return m_quadGeoms.find(elmt)->second->GetEid(edge);
125  }
126  }
127 
128  inline StdRegions::Orientation GetEorientFromElmt(LibUtilities::ShapeType shape,const int edge, const int elmt) const
129  {
130  if(shape == LibUtilities::eTriangle)
131  {
132  ASSERTL2(m_triGeoms.find(elmt) != m_triGeoms.end(),
133  "eid is out of range");
134 
135  return m_triGeoms.find(elmt)->second->GetEorient(edge);
136  }
137  else
138  {
139  ASSERTL2(m_quadGeoms.find(elmt) != m_quadGeoms.end(),
140  "eid is out of range");
141 
142  return m_quadGeoms.find(elmt)->second->GetEorient(edge);
143  }
144  }
145 
146 
147  inline StdRegions::Orientation GetCartesianEorientFromElmt(LibUtilities::ShapeType shape,const int edge, const int elmt) const
148  {
149  StdRegions::Orientation returnval;
150 
151  if(shape == LibUtilities::eTriangle)
152  {
153  ASSERTL2(m_triGeoms.find(elmt) != m_triGeoms.end(),
154  "eid is out of range");
155 
156  returnval = m_triGeoms.find(elmt)->second->GetEorient(edge);
157  }
158  else
159  {
160  ASSERTL2(m_quadGeoms.find(elmt) != m_quadGeoms.end(),
161  "eid is out of range");
162 
163  returnval = m_quadGeoms.find(elmt)->second->GetEorient(edge);
164  }
165 
166  // swap orientation if on edge 2 & 3 (if quad)
167  if(edge >= 2)
168  {
169  if(returnval == StdRegions::eForwards)
170  {
171  returnval = StdRegions::eBackwards;
172  }
173  else
174  {
175  returnval = StdRegions::eForwards;
176  }
177  }
178  return returnval;
179  }
180 
182  {
183  return int(m_meshComposites.size());
184  }
185 
186  int GetNumCompositeItems(int whichComposite)
187  {
188  int returnval = -1;
189 
190  try
191  {
192  returnval = int(m_meshComposites[whichComposite]->size());
193  }
194  catch(...)
195  {
196  std::ostringstream errStream;
197  errStream << "Unable to access composite item [" << whichComposite << "].";
198  NEKERROR(ErrorUtil::efatal, errStream.str());
199  }
200 
201  return returnval;
202  }
203 
204  /// \brief Return the elements (shared ptrs) that have this face.
206 
207  /// \brief Return the BasisKey corresponding to a face of an element
208  SPATIAL_DOMAINS_EXPORT LibUtilities::BasisKey GetFaceBasisKey(Geometry2DSharedPtr face, const int flag, const std::string variable = "DefaultVar");
209 
210  protected:
211  void ReadEdges (TiXmlDocument &doc);
212  void ReadFaces (TiXmlDocument &doc);
213  void ReadElements (TiXmlDocument &doc);
214  void ReadComposites(TiXmlDocument &doc);
215  void ResolveGeomRef(const std::string &prevToken, const std::string &token,
216  Composite& composite);
217 
218  private:
219  void PopulateFaceToElMap(Geometry3DSharedPtr element, int kNfaces);
220  boost::unordered_map<int, ElementFaceVectorSharedPtr> m_faceToElMap;
221 
222  };
223 
224  typedef boost::shared_ptr<MeshGraph3D> MeshGraph3DSharedPtr;
225 
226  }; // end of namespace
227 }; // end of namespace
228 
229 #endif //NEKTAR_SPATIALDOMAINS_MESHGRAPH3D_H
230 
231 //
232 // $Log: MeshGraph3D.h,v $
233 // Revision 1.12 2008/09/23 18:19:56 pvos
234 // Updates for working ProjectContField3D demo
235 //
236 // Revision 1.11 2008/08/26 02:23:09 ehan
237 // Added GetElementFromFace()
238 //
239 // Revision 1.10 2008/06/30 19:34:37 ehan
240 // Fixed infinity recursive-loop error.
241 //
242 // Revision 1.9 2008/06/11 21:34:42 delisi
243 // Removed TriFaceComponent, QuadFaceComponent, and EdgeComponent.
244 //
245 // Revision 1.8 2008/06/11 16:10:12 delisi
246 // Added the 3D reader.
247 //
248 // Revision 1.7 2008/06/09 21:33:04 jfrazier
249 // Moved segment vector to base MeshGraph class since it is used by all derived types.
250 //
251 // Revision 1.6 2008/05/30 00:33:48 delisi
252 // Renamed StdRegions::ShapeType to StdRegions::ExpansionType.
253 //
254 // Revision 1.5 2008/05/29 19:07:39 delisi
255 // Removed the Write(..) methods, so it is only in the base MeshGraph class. Also, added a line to set the global ID of the geometry object for every element read in.
256 //
257 // Revision 1.4 2008/02/03 05:05:16 jfrazier
258 // Initial checkin of 3D components.
259 //
260 // Revision 1.3 2007/07/20 02:15:09 bnelson
261 // Replaced boost::shared_ptr with Nektar::ptr
262 //
263 // Revision 1.2 2006/07/02 17:16:17 sherwin
264 //
265 // Modifications to make MultiRegions work for a connected domain in 2D (Tris)
266 //
267 // Revision 1.1 2006/05/04 18:59:02 kirby
268 // *** empty log message ***
269 //
270 // Revision 1.6 2006/03/25 00:58:29 jfrazier
271 // Many changes dealing with fundamental structure and reading/writing.
272 //
273 // Revision 1.5 2006/03/12 07:42:03 sherwin
274 //
275 // Updated member names and StdRegions call. Still has not been compiled
276 //
277 // Revision 1.4 2006/03/04 20:26:05 bnelson
278 // Added comments after #endif.
279 //
280 // Revision 1.3 2006/02/19 01:37:34 jfrazier
281 // Initial attempt at bringing into conformance with the coding standard. Still more work to be done. Has not been compiled.
282 //
283 //
boost::shared_ptr< MeshGraph3D > MeshGraph3DSharedPtr
Definition: MeshGraph3D.h:224
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:185
int GetSpaceDimension() const
Dimension of the space (can be a 1D curve in 3D space).
Definition: MeshGraph.h:457
boost::shared_ptr< ElementFaceVector > ElementFaceVectorSharedPtr
Definition: MeshGraph.h:138
int GetVidFromElmt(LibUtilities::ShapeType shape, const int vert, const int elmt) const
Definition: MeshGraph3D.h:90
void ReadFaces(TiXmlDocument &doc)
void PopulateFaceToElMap(Geometry3DSharedPtr element, int kNfaces)
Given a 3D geometry object #element, populate the face to element map m_faceToElMap which maps faces ...
void ReadGeometry(const std::string &infilename)
Read will read the meshgraph vertices given a filename.
Definition: MeshGraph3D.cpp:64
const QuadGeomMap & GetQuadgeoms(void) const
Definition: MeshGraph3D.h:78
boost::unordered_map< int, ElementFaceVectorSharedPtr > m_faceToElMap
Definition: MeshGraph3D.h:220
Geometry2DSharedPtr GetGeometry2D(int gID)
void ResolveGeomRef(const std::string &prevToken, const std::string &token, Composite &composite)
SegGeomSharedPtr GetSegGeom(int eID)
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
ElementFaceVectorSharedPtr GetElementsFromFace(Geometry2DSharedPtr face)
Return the elements (shared ptrs) that have this face.
std::map< int, TriGeomSharedPtr > TriGeomMap
Definition: TriGeom.h:62
void ReadComposites(TiXmlDocument &doc)
StdRegions::Orientation GetEorientFromElmt(LibUtilities::ShapeType shape, const int edge, const int elmt) const
Definition: MeshGraph3D.h:128
boost::shared_ptr< SegGeom > SegGeomSharedPtr
Definition: Geometry2D.h:60
boost::shared_ptr< DomainRange > DomainRangeShPtr
Definition: MeshGraph.h:157
void ReadElements(TiXmlDocument &doc)
boost::shared_ptr< GeometryVector > Composite
Definition: MeshGraph.h:114
int GetNumCompositeItems(int whichComposite)
Definition: MeshGraph3D.h:186
boost::shared_ptr< Geometry2D > Geometry2DSharedPtr
Definition: Geometry2D.h:59
LibUtilities::BasisKey GetFaceBasisKey(Geometry2DSharedPtr face, const int flag, const std::string variable="DefaultVar")
Return the BasisKey corresponding to a face of an element.
std::map< int, QuadGeomSharedPtr > QuadGeomMap
Definition: QuadGeom.h:57
void ReadEdges(TiXmlDocument &doc)
static DomainRangeShPtr NullDomainRangeShPtr
Definition: MeshGraph.h:158
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed t...
Definition: ErrorUtil.hpp:240
int GetEidFromElmt(LibUtilities::ShapeType shape, const int edge, const int elmt) const
Definition: MeshGraph3D.h:109
Base class for a spectral/hp element mesh.
Definition: MeshGraph.h:186
StdRegions::Orientation GetCartesianEorientFromElmt(LibUtilities::ShapeType shape, const int edge, const int elmt) const
Definition: MeshGraph3D.h:147
const TriGeomMap & GetTrigeoms(void) const
Definition: MeshGraph3D.h:73
Describes the specification for a Basis.
Definition: Basis.h:50
#define SPATIAL_DOMAINS_EXPORT
boost::shared_ptr< Geometry3D > Geometry3DSharedPtr
Definition: Geometry3D.h:52