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:
[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=std::string())
 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, ConfigOptionm_config
 List of configuration values. More...
 

Detailed Description

Converter for Gmsh files.

Definition at line 48 of file InputNekpp.h.

Constructor & Destructor Documentation

◆ InputNekpp()

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

Set up InputNekpp object.

Definition at line 57 of file InputNekpp.cpp.

57  : InputModule(m)
58 {
59 }
NEKMESHUTILS_EXPORT InputModule(MeshSharedPtr p_m)

◆ ~InputNekpp()

Nektar::Utilities::InputNekpp::~InputNekpp ( )
virtual

Definition at line 61 of file InputNekpp.cpp.

62 {
63 }

Member Function Documentation

◆ create()

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

Creates an instance of this class.

Definition at line 56 of file InputNekpp.h.

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

57  {
59  }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.

◆ Process()

void Nektar::Utilities::InputNekpp::Process ( )
virtual

Implements Nektar::NekMeshUtils::Module.

Definition at line 68 of file InputNekpp.cpp.

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

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

Member Data Documentation

◆ className

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

ModuleKey for class.

Definition at line 61 of file InputNekpp.h.