Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MeshGraph2D.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: MeshGraph2D.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_MESHGRAPH2D_H
37 #define NEKTAR_SPATIALDOMAINS_MESHGRAPH2D_H
38 
40 #include <SpatialDomains/TriGeom.h>
42 
44 
45 class TiXmlDocument;
46 
47 namespace Nektar
48 {
49  namespace SpatialDomains
50  {
51  typedef boost::shared_ptr<QuadGeom> SharedQuadGeomPtr;
52  typedef std::vector< SharedQuadGeomPtr > QuadGeomVector;
53 
54  class MeshGraph2D:
55  public MeshGraph
56  {
57 
58  public:
59 
63 
64  SPATIAL_DOMAINS_EXPORT void ReadGeometry(const std::string &infilename);
65  SPATIAL_DOMAINS_EXPORT void ReadGeometry(TiXmlDocument &doc);
66 
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 
83 #ifdef OLD
84  inline bool GetGeofac_defined(void)
85  {
86  return m_geoFacDefined;
87  }
88 #endif
89 
90  void GenXGeoFac();
91 
92  inline int GetNseggeoms() const
93  {
94  return int(m_segGeoms.size());
95  }
96 
98  const int vert, const int elmt) const
99  {
100  if(shape == LibUtilities::eTriangle)
101  {
102  ASSERTL2(m_triGeoms.find(elmt) != m_triGeoms.end(),
103  "eid is out of range");
104 
105  return m_triGeoms.find(elmt)->second->GetVid(vert);
106  }
107  else
108  {
109  ASSERTL2(m_quadGeoms.find(elmt) != m_quadGeoms.end(),
110  "eid is out of range");
111 
112  return m_quadGeoms.find(elmt)->second->GetVid(vert);
113  }
114  }
115 
117  const int edge, const int elmt) const
118  {
119  if(shape == LibUtilities::eTriangle)
120  {
121  ASSERTL2(m_triGeoms.find(elmt) != m_triGeoms.end(),
122  "eid is out of range");
123 
124  return m_triGeoms.find(elmt)->second->GetEid(edge);
125  }
126  else
127  {
128  ASSERTL2(m_quadGeoms.find(elmt) != m_quadGeoms.end(),
129  "eid is out of range");
130 
131  return m_quadGeoms.find(elmt)->second->GetEid(edge);
132  }
133  }
134 
135  inline StdRegions::Orientation GetEorientFromElmt(LibUtilities::ShapeType shape,const int edge, const int elmt) const
136  {
137  if(shape == LibUtilities::eTriangle)
138  {
139  ASSERTL2(m_triGeoms.find(elmt) != m_triGeoms.end(),
140  "eid is out of range");
141 
142  return m_triGeoms.find(elmt)->second->GetEorient(edge);
143  }
144  else
145  {
146  ASSERTL2(m_quadGeoms.find(elmt) != m_quadGeoms.end(),
147  "eid is out of range");
148 
149  return m_quadGeoms.find(elmt)->second->GetEorient(edge);
150  }
151  }
152 
153 
154  inline StdRegions::Orientation GetCartesianEorientFromElmt(LibUtilities::ShapeType shape,const int edge, const int elmt) const
155  {
156  StdRegions::Orientation returnval;
157 
158  if(shape == LibUtilities::eTriangle)
159  {
160  ASSERTL2(m_triGeoms.find(elmt) != m_triGeoms.end(),
161  "eid is out of range");
162 
163  returnval = m_triGeoms.find(elmt)->second->GetEorient(edge);
164  }
165  else
166  {
167  ASSERTL2(m_quadGeoms.find(elmt) != m_quadGeoms.end(),
168  "eid is out of range");
169 
170  returnval = m_quadGeoms.find(elmt)->second->GetEorient(edge);
171  }
172 
173  // swap orientation if on edge 2 & 3 (if quad)
174  if(edge >= 2)
175  {
176  if(returnval == StdRegions::eForwards)
177  {
178  returnval = StdRegions::eBackwards;
179  }
180  else
181  {
182  returnval = StdRegions::eForwards;
183  }
184  }
185  return returnval;
186  }
187 
189  {
190  return int(m_meshComposites.size());
191  }
192 
193  int GetNumCompositeItems(int whichComposite)
194  {
195  int returnval = -1;
196 
197  try
198  {
199  returnval = int(m_meshComposites[whichComposite]->size());
200  }
201  catch(...)
202  {
203  std::ostringstream errStream;
204  errStream << "Unable to access composite item [" << whichComposite << "].";
205  NEKERROR(ErrorUtil::efatal, errStream.str());
206  }
207 
208  return returnval;
209  }
210 
211  /// \brief Return the elements (shared ptrs) that have this edge.
212 
213  //ElementEdgeVectorSharedPtr GetElementsFromEdge(SegGeomSharedPtr edge);
215 
217 
218  /** \brief Return the BasisKey corresponding to an edge of an element
219  * If the expansion is a triangle the Modified_B direction is modified to be one-dimensional Modified_A,GaussLobattoLegendre.
220  **/
221  SPATIAL_DOMAINS_EXPORT LibUtilities::BasisKey GetEdgeBasisKey(SegGeomSharedPtr edge, const std::string variable = "DefaultVar");
222 
223  protected:
224  void ReadEdges (TiXmlDocument &doc);
225  void ReadElements (TiXmlDocument &doc);
226  void ReadComposites(TiXmlDocument &doc);
227  void ResolveGeomRef(const std::string &prevToken, const std::string &token,
228  Composite& composite);
229 
230 #ifdef OLD
231  bool m_geoFacDefined;
232 #endif
233 
234  private:
235 
236  };
237 
238  typedef boost::shared_ptr<MeshGraph2D> MeshGraph2DSharedPtr;
239 
240  };
241 };
242 
243 #endif //NEKTAR_SPATIALDOMAINS_MESHGRAPH2D_H
244