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 //