Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Nektar::Utilities::InputNekpp Class Reference

#include <InputNekpp.h>

Inheritance diagram for Nektar::Utilities::InputNekpp:
Inheritance graph
[legend]
Collaboration diagram for Nektar::Utilities::InputNekpp:
Collaboration graph
[legend]

Public Member Functions

 InputNekpp (MeshSharedPtr m)
 Set up InputNekpp object. More...
 
virtual ~InputNekpp ()
 
virtual void Process ()
 
- Public Member Functions inherited from Nektar::Utilities::InputModule
 InputModule (FieldSharedPtr p_m)
 
void AddFile (string fileType, string fileName)
 
 InputModule (MeshSharedPtr p_m)
 
void OpenStream ()
 Open a file for input. More...
 
- Public Member Functions inherited from Nektar::Utilities::Module
 Module (FieldSharedPtr p_f)
 
virtual void Process (po::variables_map &vm)=0
 
void RegisterConfig (string key, string value)
 Register a configuration option with a module. More...
 
void PrintConfig ()
 Print out all configuration options for a module. More...
 
void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
bool GetRequireEquiSpaced (void)
 
void SetRequireEquiSpaced (bool pVal)
 
void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 
 Module (MeshSharedPtr p_m)
 
void RegisterConfig (std::string key, std::string value)
 
void PrintConfig ()
 
void SetDefaults ()
 
MeshSharedPtr GetMesh ()
 
virtual void ProcessVertices ()
 Extract element vertices. More...
 
virtual void ProcessEdges (bool ReprocessEdges=true)
 Extract element edges. More...
 
virtual void ProcessFaces (bool ReprocessFaces=true)
 Extract element faces. More...
 
virtual void ProcessElements ()
 Generate element IDs. More...
 
virtual void ProcessComposites ()
 Generate composites. More...
 
virtual void ClearElementLinks ()
 

Static Public Member Functions

static ModuleSharedPtr create (MeshSharedPtr m)
 Creates an instance of this class. More...
 

Static Public Attributes

static ModuleKey className
 ModuleKey for class. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::Utilities::InputModule
void PrintSummary ()
 Print summary of elements. More...
 
void PrintSummary ()
 Print summary of elements. More...
 
- Protected Member Functions inherited from Nektar::Utilities::Module
 Module ()
 
void ReorderPrisms (PerMap &perFaces)
 Reorder node IDs so that prisms and tetrahedra are aligned correctly. More...
 
void PrismLines (int prism, PerMap &perFaces, std::set< int > &prismsDone, std::vector< ElementSharedPtr > &line)
 
- Protected Attributes inherited from Nektar::Utilities::InputModule
set< string > m_allowedFiles
 
std::ifstream m_mshFile
 Input stream. More...
 
- Protected Attributes inherited from Nektar::Utilities::Module
FieldSharedPtr m_f
 Field object. More...
 
map< string, ConfigOptionm_config
 List of configuration values. More...
 
bool m_requireEquiSpaced
 
MeshSharedPtr m_mesh
 Mesh object. More...
 
std::map< std::string,
ConfigOption
m_config
 List of configuration values. More...
 

Detailed Description

Converter for Gmsh files.

Definition at line 49 of file InputNekpp.h.

Constructor & Destructor Documentation

Nektar::Utilities::InputNekpp::InputNekpp ( MeshSharedPtr  m)

Set up InputNekpp object.

Definition at line 56 of file InputNekpp.cpp.

56  : InputModule(m)
57 {
58 }
Nektar::Utilities::InputNekpp::~InputNekpp ( )
virtual

Definition at line 60 of file InputNekpp.cpp.

61 {
62 }

Member Function Documentation

static ModuleSharedPtr Nektar::Utilities::InputNekpp::create ( MeshSharedPtr  m)
inlinestatic

Creates an instance of this class.

Definition at line 57 of file InputNekpp.h.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

58  {
60  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
void Nektar::Utilities::InputNekpp::Process ( )
virtual

Implements Nektar::Utilities::Module.

Definition at line 67 of file InputNekpp.cpp.

References ASSERTL1, Nektar::LibUtilities::SessionReader::CreateInstance(), Nektar::LibUtilities::NekFactory< tKey, tBase, >::CreateInstance(), Nektar::NekMeshUtils::curve, Nektar::LibUtilities::eNodalTriElec, Nektar::LibUtilities::eNodalTriEvenlySpaced, Nektar::LibUtilities::eNodalTriFekete, Nektar::LibUtilities::ePolyEvenlySpaced, Nektar::NekMeshUtils::GetElementFactory(), Nektar::iterator, Nektar::Utilities::Module::m_config, Nektar::Utilities::Module::m_mesh, Nektar::Utilities::Module::ProcessComposites(), Nektar::Utilities::Module::ProcessEdges(), Nektar::Utilities::Module::ProcessFaces(), Nektar::SpatialDomains::MeshGraph::Read(), and Nektar::NekMeshUtils::vert.

68 {
69  vector<string> filename;
70  filename.push_back(m_config["infile"].as<string>());
71 
76 
77  m_mesh->m_expDim = graph->GetMeshDimension();
78  m_mesh->m_spaceDim = graph->GetSpaceDimension();
79 
80  // Copy vertices.
81  map<int, NodeSharedPtr> vIdMap;
82  const SpatialDomains::PointGeomMap vertset = graph->GetVertSet();
83  SpatialDomains::PointGeomMap::const_iterator vit;
84 
85  for (vit = vertset.begin(); vit != vertset.end(); ++vit)
86  {
88  NodeSharedPtr n(
89  new Node(vert->GetVid(), (*vert)(0), (*vert)(1), (*vert)(2)));
90  m_mesh->m_vertexSet.insert(n);
91  vIdMap[vert->GetVid()] = n;
92  }
93 
94  map<int, EdgeSharedPtr> eIdMap;
96  map<int, FaceSharedPtr> fIdMap;
98 
99  // Load up all edges from graph
100  {
101  int nel = 0;
102  SpatialDomains::SegGeomMap tmp = graph->GetAllSegGeoms();
104  pair<EdgeSet::iterator, bool> testIns;
105  nel += tmp.size();
106 
107  for (it = tmp.begin(); it != tmp.end(); ++it)
108  {
109  pair<int, SpatialDomains::GeometrySharedPtr> tmp2(
110  it->first,
111  boost::dynamic_pointer_cast<SpatialDomains::Geometry>(
112  it->second));
113 
114  // load up edge set in order of SegGeomMap;
115  vector<NodeSharedPtr> curve; // curved nodes if deformed
116  int id0 = it->second->GetVid(0);
117  int id1 = it->second->GetVid(1);
119  it->second->GetPointsKeys()[0].GetPointsType();
120  EdgeSharedPtr ed =
121  EdgeSharedPtr(new Edge(vIdMap[id0], vIdMap[id1], curve, ptype));
122 
123  testIns = m_mesh->m_edgeSet.insert(ed);
124  (*(testIns.first))->m_id = it->second->GetEid();
125  eIdMap[it->second->GetEid()] = ed;
126  }
127  }
128 
129  // load up all faces from graph
130  {
131  int nel = 0;
132  SpatialDomains::TriGeomMap tmp = graph->GetAllTriGeoms();
134  pair<FaceSet::iterator, bool> testIns;
135  nel += tmp.size();
136 
137  for (it = tmp.begin(); it != tmp.end(); ++it)
138  {
139  pair<int, SpatialDomains::GeometrySharedPtr> tmp2(
140  it->first,
141  boost::dynamic_pointer_cast<SpatialDomains::Geometry>(
142  it->second));
143 
144  vector<NodeSharedPtr> faceVertices;
145  vector<EdgeSharedPtr> faceEdges;
146  vector<NodeSharedPtr> faceNodes;
147 
148  for (int i = 0; i < 3; ++i)
149  {
150  faceVertices.push_back(vIdMap[it->second->GetVid(i)]);
151  faceEdges.push_back(eIdMap[it->second->GetEid(i)]);
152  }
153 
154  FaceSharedPtr fac =
155  FaceSharedPtr(new Face(faceVertices,
156  faceNodes,
157  faceEdges,
159  testIns = m_mesh->m_faceSet.insert(fac);
160  (*(testIns.first))->m_id = it->second->GetFid();
161  fIdMap[it->second->GetFid()] = fac;
162  }
163 
164  SpatialDomains::QuadGeomMap tmp3 = graph->GetAllQuadGeoms();
166 
167  for (it2 = tmp3.begin(); it2 != tmp3.end(); ++it2)
168  {
169  pair<int, SpatialDomains::GeometrySharedPtr> tmp2(
170  it2->first,
171  boost::dynamic_pointer_cast<SpatialDomains::Geometry>(
172  it2->second));
173 
174  vector<NodeSharedPtr> faceVertices;
175  vector<EdgeSharedPtr> faceEdges;
176  vector<NodeSharedPtr> faceNodes;
177 
178  for (int i = 0; i < 4; ++i)
179  {
180  faceVertices.push_back(vIdMap[it2->second->GetVid(i)]);
181  faceEdges.push_back(eIdMap[it2->second->GetEid(i)]);
182  }
183 
184  FaceSharedPtr fac =
185  FaceSharedPtr(new Face(faceVertices,
186  faceNodes,
187  faceEdges,
189  testIns = m_mesh->m_faceSet.insert(fac);
190  (*(testIns.first))->m_id = it2->second->GetFid();
191  fIdMap[it2->second->GetFid()] = fac;
192  }
193  }
194 
195  // Set up curved information
196 
197  // Curved Edges
198  SpatialDomains::CurveMap &curvedEdges = graph->GetCurvedEdges();
200 
201  for (it = curvedEdges.begin(); it != curvedEdges.end(); ++it)
202  {
203  SpatialDomains::CurveSharedPtr curve = it->second;
204  int id = curve->m_curveID;
205  ASSERTL1(eIdMap.find(id) != eIdMap.end(), "Failed to find curved edge");
206  EdgeSharedPtr edg = eIdMap[id];
207  edg->m_curveType = curve->m_ptype;
208  for (int j = 0; j < curve->m_points.size() - 2; ++j)
209  {
210  NodeSharedPtr n(new Node(j,
211  (*curve->m_points[j + 1])(0),
212  (*curve->m_points[j + 1])(1),
213  (*curve->m_points[j + 1])(2)));
214  edg->m_edgeNodes.push_back(n);
215  }
216  }
217 
218  // Curved Faces
219  SpatialDomains::CurveMap &curvedFaces = graph->GetCurvedFaces();
220  for (it = curvedFaces.begin(); it != curvedFaces.end(); ++it)
221  {
222  SpatialDomains::CurveSharedPtr curve = it->second;
223  int id = curve->m_curveID;
224  ASSERTL1(fIdMap.find(id) != fIdMap.end(), "Failed to find curved edge");
225  FaceSharedPtr fac = fIdMap[id];
226  fac->m_curveType = curve->m_ptype;
227  int Ntot = curve->m_points.size();
228 
229  if (fac->m_curveType == LibUtilities::eNodalTriFekete ||
230  fac->m_curveType == LibUtilities::eNodalTriEvenlySpaced ||
231  fac->m_curveType == LibUtilities::eNodalTriElec)
232  {
233  int N = ((int)sqrt(8.0 * Ntot + 1.0) - 1) / 2;
234  for (int j = 3 + 3 * (N - 2); j < Ntot; ++j)
235  {
236  NodeSharedPtr n(new Node(j,
237  (*curve->m_points[j])(0),
238  (*curve->m_points[j])(1),
239  (*curve->m_points[j])(2)));
240  fac->m_faceNodes.push_back(n);
241  }
242  }
243  else // quad face.
244  {
245  int N = (int)sqrt((double)Ntot);
246 
247  for (int j = 1; j < N - 1; ++j)
248  {
249  for (int k = 1; k < N - 1; ++k)
250  {
251  NodeSharedPtr n(new Node((j - 1) * (N - 2) + k - 1,
252  (*curve->m_points[j * N + k])(0),
253  (*curve->m_points[j * N + k])(1),
254  (*curve->m_points[j * N + k])(2)));
255  fac->m_faceNodes.push_back(n);
256  }
257  }
258  }
259  }
260 
261  // Get hold of mesh composites and set up m_mesh->m_elements
262  SpatialDomains::CompositeMap GraphComps = graph->GetComposites();
265 
266  // loop over all composites and set up elements with edges
267  // and faces from the maps above.
268  for (compIt = GraphComps.begin(); compIt != GraphComps.end(); ++compIt)
269  {
270  // Get hold of dimension
271  int dim = (*compIt->second)[0]->GetShapeDim();
272 
273  // compIt->second is a GeometryVector
274  for (geomIt = (*compIt->second).begin();
275  geomIt != (*compIt->second).end();
276  ++geomIt)
277  {
278  ElmtConfig conf((*geomIt)->GetShapeType(), 1, true, true, false);
279 
280  // Get hold of geometry
281  vector<NodeSharedPtr> nodeList;
282  for (int i = 0; i < (*geomIt)->GetNumVerts(); ++i)
283  {
284  nodeList.push_back(vIdMap[(*geomIt)->GetVid(i)]);
285  }
286 
287  vector<int> tags;
288  tags.push_back(compIt->first);
289 
291  (*geomIt)->GetShapeType(), conf, nodeList, tags);
292 
293  E->SetId((*geomIt)->GetGlobalID());
294  m_mesh->m_element[dim].push_back(E);
295 
296  if (dim == 1)
297  {
298  EdgeSharedPtr edg = eIdMap[(*geomIt)->GetGlobalID()];
299  E->SetVolumeNodes(edg->m_edgeNodes);
300  }
301 
302  if (dim > 1)
303  {
304  // reset edges
305  for (int i = 0; i < (*geomIt)->GetNumEdges(); ++i)
306  {
307  EdgeSharedPtr edg = eIdMap[(*geomIt)->GetEid(i)];
308  E->SetEdge(i, edg);
309  // set up link back to this element
310  edg->m_elLink.push_back(pair<ElementSharedPtr, int>(E, i));
311  }
312 
313  if (dim == 2)
314  {
315  FaceSharedPtr fac = fIdMap[(*geomIt)->GetGlobalID()];
316  E->SetVolumeNodes(fac->m_faceNodes);
317  }
318  }
319 
320  if (dim == 3)
321  {
322  // reset faces
323  for (int i = 0; i < (*geomIt)->GetNumFaces(); ++i)
324  {
325  FaceSharedPtr fac = fIdMap[(*geomIt)->GetFid(i)];
326  E->SetFace(i, fac);
327  // set up link back to this slement
328  fac->m_elLink.push_back(pair<ElementSharedPtr, int>(E, i));
329  }
330  }
331  }
332  }
333 
334  // set up composite labels if they exist
335  m_mesh->m_faceLabels = graph->GetCompositesLabels();
336 
337  ProcessEdges(false);
338  ProcessFaces(false);
340 }
tBaseSharedPtr CreateInstance(tKey idKey BOOST_PP_COMMA_IF(MAX_PARAM) BOOST_PP_ENUM_BINARY_PARAMS(MAX_PARAM, tParam, x))
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:162
static boost::shared_ptr< MeshGraph > Read(const LibUtilities::SessionReaderSharedPtr &pSession, DomainRangeShPtr &rng=NullDomainRangeShPtr)
Definition: MeshGraph.cpp:121
map< string, ConfigOption > m_config
List of configuration values.
MeshSharedPtr m_mesh
Mesh object.
ElementFactory & GetElementFactory()
Definition: Element.cpp:47
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
boost::shared_ptr< Curve > CurveSharedPtr
Definition: Curve.hpp:62
virtual void ProcessEdges(bool ReprocessEdges=true)
Extract element edges.
std::vector< GeometrySharedPtr >::iterator GeometryVectorIter
Definition: Geometry.h:58
std::map< int, TriGeomSharedPtr > TriGeomMap
Definition: TriGeom.h:62
1D Evenly-spaced points using Lagrange polynomial
Definition: PointsType.h:63
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
std::map< int, PointGeomSharedPtr > PointGeomMap
Definition: MeshGraph.h:111
std::map< int, SegGeomSharedPtr > SegGeomMap
Definition: SegGeom.h:54
std::map< int, Composite >::iterator CompositeMapIter
Definition: MeshGraph.h:116
boost::shared_ptr< Node > NodeSharedPtr
Definition: Node.h:50
virtual void ProcessComposites()
Generate composites.
std::map< int, Composite > CompositeMap
Definition: MeshGraph.h:115
2D Nodal Fekete Points on a Triangle
Definition: PointsType.h:69
boost::shared_ptr< Edge > EdgeSharedPtr
Shared pointer to an edge.
Definition: Edge.h:196
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
std::map< int, QuadGeomSharedPtr > QuadGeomMap
Definition: QuadGeom.h:57
virtual void ProcessFaces(bool ReprocessFaces=true)
Extract element faces.
boost::unordered_map< int, CurveSharedPtr > CurveMap
Definition: Curve.hpp:63
2D Evenly-spaced points on a Triangle
Definition: PointsType.h:70
boost::shared_ptr< Element > ElementSharedPtr
Definition: Edge.h:52
boost::shared_ptr< Face > FaceSharedPtr
Shared pointer to a face.
Definition: Face.h:378
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:191
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:442
boost::shared_ptr< PointGeom > PointGeomSharedPtr
Definition: Geometry.h:60
2D Nodal Electrostatic Points on a Triangle
Definition: PointsType.h:68

Member Data Documentation

ModuleKey Nektar::Utilities::InputNekpp::className
static
Initial value:

ModuleKey for class.

Definition at line 62 of file InputNekpp.h.