Nektar++
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 (string key, string value)
 
void PrintConfig ()
 
void SetDefaults ()
 
MeshSharedPtr GetMesh ()
 
virtual void ProcessVertices ()
 Extract element vertices. More...
 

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 ()
 
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...
 
void ReorderPrisms (PerMap &perFaces)
 Reorder node IDs so that prisms and tetrahedra are aligned correctly. More...
 
void PrismLines (int prism, PerMap &perFaces, set< int > &prismsDone, 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...
 

Detailed Description

Converter for Gmsh files.

Definition at line 48 of file InputNekpp.h.

Constructor & Destructor Documentation

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

Set up InputNekpp object.

Definition at line 57 of file InputNekpp.cpp.

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

Definition at line 62 of file InputNekpp.cpp.

63  {
64 
65  }

Member Function Documentation

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

Creates an instance of this class.

Definition at line 56 of file InputNekpp.h.

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

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

Gmsh file contains a list of nodes and their coordinates, along with a list of elements and those nodes which define them. We read in and store the list of nodes in #m_node and store the list of elements in #m_element. Each new element is supplied with a list of entries from #m_node which defines the element. Finally some mesh statistics are printed.

Parameters
pFilenameFilename of Gmsh file to read.

Implements Nektar::Utilities::Module.

Definition at line 77 of file InputNekpp.cpp.

References ASSERTL1, Nektar::LibUtilities::SessionReader::CreateInstance(), Nektar::LibUtilities::eNodalTriElec, Nektar::LibUtilities::eNodalTriEvenlySpaced, Nektar::LibUtilities::eNodalTriFekete, Nektar::LibUtilities::ePolyEvenlySpaced, Nektar::Utilities::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(), and Nektar::SpatialDomains::MeshGraph::Read().

78  {
79  vector<string> filename;
80  filename.push_back(m_config["infile"].as<string>());
81 
86 
87  m_mesh->m_expDim = graph->GetMeshDimension ();
88  m_mesh->m_spaceDim = graph->GetSpaceDimension();
89 
90  // Copy vertices.
91  map<int, NodeSharedPtr> vIdMap;
92  int nVerts = graph->GetNvertices();
93  for (int i = 0; i < nVerts; ++i)
94  {
96  graph->GetVertex(i);
97  NodeSharedPtr n(new Node(vert->GetVid(),
98  (*vert)(0), (*vert)(1), (*vert)(2)));
99  m_mesh->m_vertexSet.insert(n);
100  vIdMap[vert->GetVid()] = n;
101  }
102 
103  map<int, EdgeSharedPtr> eIdMap;
105  map<int, FaceSharedPtr> fIdMap;
107 
108  // Load up all edges from graph
109  {
110  int nel = 0;
111  SpatialDomains::SegGeomMap tmp = graph->GetAllSegGeoms();
113  pair<EdgeSet::iterator,bool> testIns;
114  nel += tmp.size();
115 
116  for (it = tmp.begin(); it != tmp.end(); ++it)
117  {
118  pair<int, SpatialDomains::GeometrySharedPtr> tmp2(
119  it->first, boost::dynamic_pointer_cast<
120  SpatialDomains::Geometry>(it->second));
121 
122  // load up edge set in order of SegGeomMap;
123  vector<NodeSharedPtr> curve; // curved nodes if deformed
124  int id0 = it->second->GetVid(0);
125  int id1 = it->second->GetVid(1);
126  LibUtilities::PointsType ptype = it->second->GetPointsKeys()[0].GetPointsType();
127  EdgeSharedPtr ed = EdgeSharedPtr(new Edge(vIdMap[id0], vIdMap[id1],
128  curve, ptype));
129 
130  testIns = m_mesh->m_edgeSet.insert(ed);
131  (*(testIns.first))->m_id = it->second->GetEid();
132  eIdMap[it->second->GetEid()] = ed;
133  }
134  }
135 
136 
137  // load up all faces from graph
138  {
139  int nel = 0;
140  SpatialDomains::TriGeomMap tmp = graph->GetAllTriGeoms();
142  pair<FaceSet::iterator,bool> testIns;
143  nel += tmp.size();
144 
145  for (it = tmp.begin(); it != tmp.end(); ++it)
146  {
147  pair<int, SpatialDomains::GeometrySharedPtr> tmp2(
148  it->first, boost::dynamic_pointer_cast<
149  SpatialDomains::Geometry>(it->second));
150 
151  vector<NodeSharedPtr> faceVertices;
152  vector<EdgeSharedPtr> faceEdges;
153  vector<NodeSharedPtr> faceNodes;
154 
155  for(int i = 0; i < 3; ++i)
156  {
157  faceVertices.push_back(vIdMap[it->second->GetVid(i)]);
158  faceEdges.push_back(eIdMap[it->second->GetEid(i)]);
159  }
160 
161  FaceSharedPtr fac = FaceSharedPtr( new Face(faceVertices,faceNodes,faceEdges,
163  testIns = m_mesh->m_faceSet.insert(fac);
164  (*(testIns.first))->m_id = it->second->GetFid();
165  fIdMap[it->second->GetFid()] = fac;
166  }
167 
168  SpatialDomains::QuadGeomMap tmp3 = graph->GetAllQuadGeoms();
170 
171  for (it2 = tmp3.begin(); it2 != tmp3.end(); ++it2)
172  {
173  pair<int, SpatialDomains::GeometrySharedPtr> tmp2(
174  it2->first, boost::dynamic_pointer_cast<
175  SpatialDomains::Geometry>(it2->second));
176 
177  vector<NodeSharedPtr> faceVertices;
178  vector<EdgeSharedPtr> faceEdges;
179  vector<NodeSharedPtr> faceNodes;
180 
181  for(int i = 0; i < 4; ++i)
182  {
183  faceVertices.push_back(vIdMap[it2->second->GetVid(i)]);
184  faceEdges.push_back(eIdMap[it2->second->GetEid(i)]);
185  }
186 
187  FaceSharedPtr fac = FaceSharedPtr( new Face(faceVertices,faceNodes,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(),
206  "Failed to find curved edge");
207  EdgeSharedPtr edg = eIdMap[id];
208  edg->m_curveType = curve->m_ptype;
209  for(int j = 0; j < curve->m_points.size()-2; ++j)
210  {
211  NodeSharedPtr n(new Node(j, (*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(),
225  "Failed to find curved edge");
226  FaceSharedPtr fac = fIdMap[id];
227  fac->m_curveType = curve->m_ptype;
228  int Ntot = curve->m_points.size();
229 
230  if (fac->m_curveType == LibUtilities::eNodalTriFekete ||
231  fac->m_curveType == LibUtilities::eNodalTriEvenlySpaced ||
232  fac->m_curveType == LibUtilities::eNodalTriElec)
233  {
234  int N = ((int)sqrt(8.0*Ntot+1.0)-1)/2;
235  for(int j = 3+3*(N-2); j < Ntot; ++j)
236  {
237  NodeSharedPtr n(new Node(j, (*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  for(int j = 1; j < N-1; ++j)
247  {
248  for(int k = 1; k < N-1; ++k)
249  {
250  NodeSharedPtr n(new Node((j-1)*(N-2)+k-1,
251  (*curve->m_points[j*N+k])(0),
252  (*curve->m_points[j*N+k])(1),
253  (*curve->m_points[j*N+k])(2)));
254  fac->m_faceNodes.push_back(n);
255  }
256  }
257  }
258  }
259 
260  // Get hold of mesh composites and set up m_mesh->m_elements
261 
262  SpatialDomains::CompositeMap GraphComps= graph->GetComposites();
265 
266 
267  // calculate the number of element of dimension
268  // m_mesh->m_expDim in composite list so we can set up
269  // element vector of this size to allow for
270  // non-consecutive insertion to list (Might consider
271  // setting element up as a map)?
272  int nel = 0;
273  for(compIt = GraphComps.begin(); compIt != GraphComps.end(); ++compIt)
274  {
275  // Get hold of dimension
276  int dim = (*compIt->second)[0]->GetShapeDim();
277 
278  if(dim == m_mesh->m_expDim)
279  {
280  nel += (*compIt->second).size();
281  }
282  }
283  m_mesh->m_element[m_mesh->m_expDim].resize(nel);
284 
285  // loop over all composites and set up elements with edges and faces from the maps above.
286  for(compIt = GraphComps.begin(); compIt != GraphComps.end(); ++compIt)
287  {
288  // Get hold of dimension
289  int dim = (*compIt->second)[0]->GetShapeDim();
290 
291  // compIt->second is a GeometryVector
292  for(geomIt = (*compIt->second).begin();
293  geomIt != (*compIt->second).end();
294  ++geomIt)
295  {
296  ElmtConfig conf((*geomIt)->GetShapeType(),1,true,true);
297 
298  // Get hold of geometry
299  vector<NodeSharedPtr> nodeList;
300  for (int i = 0; i < (*geomIt)->GetNumVerts(); ++i)
301  {
302  nodeList.push_back(vIdMap[(*geomIt)->GetVid(i)]);
303  }
304 
305  vector<int> tags;
306  tags.push_back(compIt->first);
307 
309  CreateInstance((*geomIt)->GetShapeType(),conf,nodeList,tags);
310 
311  E->SetId((*geomIt)->GetGlobalID());
312 
313  if(dim == m_mesh->m_expDim) // load mesh into location baded on globalID
314  {
315  m_mesh->m_element[dim][(*geomIt)->GetGlobalID()] = E;
316  }
317  else // push onto vector for later usage as composite region
318  {
319  m_mesh->m_element[dim].push_back(E);
320  }
321 
322  if(dim > 1)
323  {
324  // reset edges
325  for (int i = 0; i < (*geomIt)->GetNumEdges(); ++i)
326  {
327  EdgeSharedPtr edg = eIdMap[(*geomIt)->GetEid(i)];
328  E->SetEdge(i,edg);
329  // set up link back to this element
330  edg->m_elLink.push_back(pair<ElementSharedPtr,int>(E,i));
331  }
332  }
333 
334  if(dim == 3)
335  {
336  // reset faces
337  for (int i = 0; i < (*geomIt)->GetNumFaces(); ++i)
338  {
339  FaceSharedPtr fac = fIdMap[(*geomIt)->GetFid(i)];
340  E->SetFace(i,fac);
341  // set up link back to this slement
342  fac->m_elLink.push_back(pair<ElementSharedPtr,int>(E,i));
343  }
344  }
345  }
346  }
347  ProcessEdges(false);
348  ProcessFaces(false);
350  }
static boost::shared_ptr< MeshGraph > Read(const LibUtilities::SessionReaderSharedPtr &pSession, DomainRangeShPtr &rng=NullDomainRangeShPtr)
Definition: MeshGraph.cpp:119
boost::shared_ptr< Edge > EdgeSharedPtr
Shared pointer to an edge.
Definition: MeshElements.h:318
map< string, ConfigOption > m_config
List of configuration values.
MeshSharedPtr m_mesh
Mesh object.
boost::shared_ptr< Face > FaceSharedPtr
Shared pointer to a face.
Definition: MeshElements.h:550
boost::shared_ptr< Node > NodeSharedPtr
Shared pointer to a Node.
Definition: MeshElements.h:195
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:50
boost::shared_ptr< Curve > CurveSharedPtr
Definition: Curve.hpp:62
virtual void ProcessEdges(bool ReprocessEdges=true)
Extract element edges.
boost::shared_ptr< Element > ElementSharedPtr
Shared pointer to an element.
Definition: MeshElements.h:63
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, SegGeomSharedPtr > SegGeomMap
Definition: SegGeom.h:54
std::map< int, Composite >::iterator CompositeMapIter
Definition: MeshGraph.h:113
virtual void ProcessComposites()
Generate composites.
std::map< int, Composite > CompositeMap
Definition: MeshGraph.h:112
2D Nodal Fekete Points on a Triangle
Definition: PointsType.h:69
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
#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:432
ElementFactory & GetElementFactory()
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 60 of file InputNekpp.h.