Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InputNek.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: InputNek.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: Nektar file format converter.
33 //
34 ////////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef UTILITIES_PREPROCESSING_MESHCONVERT_INPUTNEK
37 #define UTILITIES_PREPROCESSING_MESHCONVERT_INPUTNEK
38 
39 #include "Module.h"
40 
41 namespace Nektar
42 {
43  namespace Utilities
44  {
45  /**
46  * Wrapper structure for high-order mesh information stored in a hsf
47  * file.
48  */
49  struct HOSurf
50  {
51  HOSurf(vector<unsigned int> pVertId,
52  vector<NodeSharedPtr> pSurfVerts) :
53  vertId(pVertId), surfVerts(pSurfVerts) {}
54 
55  HOSurf(vector<unsigned int> pVertId) : vertId(pVertId) {}
56 
57  /**
58  * Felisa vertex ids for this face. Comparing these to those
59  * stored in the rea file determines the orientation of the face.
60  */
61  vector<unsigned int> vertId;
62 
63  /**
64  * Vector of surface nodal points. These are electrostatically
65  * distributed.
66  */
67  vector<NodeSharedPtr> surfVerts;
68 
69  void Rotate (int i);
70  void Reflect();
71  };
72 
73  typedef boost::shared_ptr<HOSurf> HOSurfSharedPtr;
74 
75  enum NekCurve
76  {
79  };
80 
81  /**
82  * Hash class for high-order surfaces.
83  */
84  struct HOSurfHash : std::unary_function<HOSurfSharedPtr, std::size_t>
85  {
86  /**
87  * Calculate hash of a given high-order surface p by taking
88  * successive hashes of the vertex IDs.
89  */
90  std::size_t operator()(HOSurfSharedPtr const& p) const
91  {
92  std::size_t seed = 0;
93  std::vector<unsigned int> ids = p->vertId;
94  std::sort(ids.begin(), ids.end());
95  for (int i = 0; i < ids.size(); ++i)
96  {
97  boost::hash_combine(seed, ids[i]);
98  }
99  return seed;
100  }
101  };
102 
103  bool operator==(HOSurfSharedPtr const &p1, HOSurfSharedPtr const &p2);
104 
105  typedef boost::unordered_set<HOSurfSharedPtr, HOSurfHash> HOSurfSet;
106 
107  /**
108  * Converter class for Nektar session files.
109  */
110  class InputNek : public InputModule
111  {
112  public:
113  InputNek(MeshSharedPtr p_m);
114  virtual ~InputNek();
115  virtual void Process();
116 
117  /// Creates an instance of this class.
120  }
121  /// %ModuleKey for class.
123 
124  private:
125  void LoadHOSurfaces();
126  int GetNnodes (LibUtilities::ShapeType elType);
127 
128  /**
129  * Maps a curve tag to a filename containing surface information.
130  */
131  std::map<string, pair<NekCurve, string> > curveTags;
132 
133  /**
134  * Maps a curve tag to the high-order surface data for that tag.
135  */
136  std::map<string, HOSurfSet> hoData;
137 
138  /**
139  * Maps ordering of hsf standard element to Nektar++ ordering.
140  */
141  std::map<unsigned int,unsigned int> hoMap;
142  };
143  }
144 }
145 
146 #endif