Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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 (NekMeshUtils::MeshSharedPtr m)
 Set up InputNekpp object. More...
 
virtual ~InputNekpp ()
 
virtual void Process ()
 
- Public Member Functions inherited from Nektar::NekMeshUtils::InputModule
NEKMESHUTILS_EXPORT InputModule (MeshSharedPtr p_m)
 
NEKMESHUTILS_EXPORT void OpenStream ()
 Open a file for input. More...
 
- Public Member Functions inherited from Nektar::NekMeshUtils::Module
NEKMESHUTILS_EXPORT Module (MeshSharedPtr p_m)
 
NEKMESHUTILS_EXPORT void RegisterConfig (std::string key, std::string value)
 Register a configuration option with a module. More...
 
NEKMESHUTILS_EXPORT void PrintConfig ()
 Print out all configuration options for a module. More...
 
NEKMESHUTILS_EXPORT void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
NEKMESHUTILS_EXPORT MeshSharedPtr GetMesh ()
 
virtual NEKMESHUTILS_EXPORT void ProcessVertices ()
 Extract element vertices. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessEdges (bool ReprocessEdges=true)
 Extract element edges. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessFaces (bool ReprocessFaces=true)
 Extract element faces. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessElements ()
 Generate element IDs. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessComposites ()
 Generate composites. More...
 
virtual NEKMESHUTILS_EXPORT void ClearElementLinks ()
 

Static Public Member Functions

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

Static Public Attributes

static NekMeshUtils::ModuleKey className
 ModuleKey for class. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::NekMeshUtils::InputModule
NEKMESHUTILS_EXPORT void PrintSummary ()
 Print summary of elements. More...
 
- Protected Member Functions inherited from Nektar::NekMeshUtils::Module
NEKMESHUTILS_EXPORT void ReorderPrisms (PerMap &perFaces)
 Reorder node IDs so that prisms and tetrahedra are aligned correctly. More...
 
NEKMESHUTILS_EXPORT void PrismLines (int prism, PerMap &perFaces, std::set< int > &prismsDone, std::vector< ElementSharedPtr > &line)
 
- Protected Attributes inherited from Nektar::NekMeshUtils::InputModule
io::filtering_istream m_mshFile
 Input stream. More...
 
std::ifstream m_mshFileStream
 Input stream. More...
 
- Protected Attributes inherited from Nektar::NekMeshUtils::Module
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 ( NekMeshUtils::MeshSharedPtr  m)

Set up InputNekpp object.

Definition at line 58 of file InputNekpp.cpp.

58  : InputModule(m)
59 {
60 }
NEKMESHUTILS_EXPORT InputModule(MeshSharedPtr p_m)
Nektar::Utilities::InputNekpp::~InputNekpp ( )
virtual

Definition at line 62 of file InputNekpp.cpp.

63 {
64 }

Member Function Documentation

static NekMeshUtils::ModuleSharedPtr Nektar::Utilities::InputNekpp::create ( NekMeshUtils::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::NekMeshUtils::Module.

Definition at line 69 of file InputNekpp.cpp.

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

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

Member Data Documentation

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

ModuleKey for class.

Definition at line 62 of file InputNekpp.h.