Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Nektar::NekMeshUtils::Module Class Referenceabstract

#include <Module.h>

Inheritance diagram for Nektar::NekMeshUtils::Module:
Inheritance graph
[legend]
Collaboration diagram for Nektar::NekMeshUtils::Module:
Collaboration graph
[legend]

Public Member Functions

NEKMESHUTILS_EXPORT Module (MeshSharedPtr p_m)
 
virtual NEKMESHUTILS_EXPORT void Process ()=0
 
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 ()
 

Protected Member Functions

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

MeshSharedPtr m_mesh
 Mesh object. More...
 
std::map< std::string,
ConfigOption
m_config
 List of configuration values. More...
 

Detailed Description

Abstract base class for mesh converter modules. Each subclass implements the Process() function, which in some way alters the mesh #m.

Definition at line 157 of file NekMeshUtils/Module/Module.h.

Constructor & Destructor Documentation

NEKMESHUTILS_EXPORT Nektar::NekMeshUtils::Module::Module ( MeshSharedPtr  p_m)
inline

Definition at line 160 of file NekMeshUtils/Module/Module.h.

160 : m_mesh(p_m) {}

Member Function Documentation

void Nektar::NekMeshUtils::Module::ClearElementLinks ( )
virtual

clear all element link information from mesh entities to be able to reprocess new mesh

Definition at line 454 of file NekMeshUtils/Module/Module.cpp.

References Nektar::iterator, and m_mesh.

Referenced by Nektar::NekMeshUtils::VolumeMesh::Process(), Nektar::Utilities::ProcessOptiExtract::Process(), and Nektar::Utilities::ProcessLinkCheck::Process().

455 {
456  EdgeSet::iterator eit;
457 
458  for(eit = m_mesh->m_edgeSet.begin(); eit != m_mesh->m_edgeSet.end(); eit++)
459  {
460  (*eit)->m_elLink.clear();
461  }
462 
463  FaceSet::iterator fit;
464 
465  for(fit = m_mesh->m_faceSet.begin(); fit != m_mesh->m_faceSet.end(); fit++)
466  {
467  (*fit)->m_elLink.clear();
468  }
469 }
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
NEKMESHUTILS_EXPORT MeshSharedPtr Nektar::NekMeshUtils::Module::GetMesh ( )
inline

Definition at line 166 of file NekMeshUtils/Module/Module.h.

References m_mesh.

167  {
168  return m_mesh;
169  }
void Nektar::NekMeshUtils::Module::PrintConfig ( )

Print out all configuration options for a module.

Definition at line 868 of file NekMeshUtils/Module/Module.cpp.

References Nektar::iterator, and m_config.

869 {
871 
872  if (m_config.size() == 0)
873  {
874  cerr << "No configuration options for this module." << endl;
875  return;
876  }
877 
878  for (it = m_config.begin(); it != m_config.end(); ++it)
879  {
880  cerr << setw(10) << it->first << ": " << it->second.desc
881  << endl;
882  }
883 }
std::map< std::string, ConfigOption > m_config
List of configuration values.
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
void Nektar::NekMeshUtils::Module::PrismLines ( int  prism,
PerMap perFaces,
std::set< int > &  prismsDone,
std::vector< ElementSharedPtr > &  line 
)
protected

Definition at line 789 of file NekMeshUtils/Module/Module.cpp.

References Nektar::iterator, and m_mesh.

Referenced by ReorderPrisms().

793 {
794  int i;
795  set<int>::iterator it = prismsDone.find(prism);
796  PerMap::iterator it2;
797 
798  if (it == prismsDone.end())
799  {
800  return;
801  }
802 
803  // Remove this prism from the list.
804  prismsDone.erase(it);
805  line.push_back(m_mesh->m_element[3][prism]);
806 
807  // Now find prisms connected to this one through a triangular face.
808  for (i = 1; i <= 3; i += 2)
809  {
810  FaceSharedPtr f = m_mesh->m_element[3][prism]->GetFace(i);
811  int nextId;
812 
813  // See if this face is periodic.
814  it2 = perFaces.find(f->m_id);
815 
816  if (it2 != perFaces.end())
817  {
818  int id2 = it2->second.first->m_id;
819  nextId = it2->second.first->m_elLink[0].first->GetId();
820  perFaces.erase(it2);
821  perFaces.erase(id2);
822  PrismLines(nextId, perFaces, prismsDone, line);
823  }
824 
825  // Nothing else connected to this face.
826  if (f->m_elLink.size() == 1)
827  {
828  continue;
829  }
830 
831  nextId = f->m_elLink[0].first->GetId();
832  if (nextId == m_mesh->m_element[3][prism]->GetId())
833  {
834  nextId = f->m_elLink[1].first->GetId();
835  }
836 
837  PrismLines(nextId, perFaces, prismsDone, line);
838  }
839 }
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
NEKMESHUTILS_EXPORT void PrismLines(int prism, PerMap &perFaces, std::set< int > &prismsDone, std::vector< ElementSharedPtr > &line)
boost::shared_ptr< Face > FaceSharedPtr
Definition: Face.h:153
virtual NEKMESHUTILS_EXPORT void Nektar::NekMeshUtils::Module::Process ( )
pure virtual
void Nektar::NekMeshUtils::Module::ProcessComposites ( )
virtual

Generate composites.

Generate a list of composites (groups of elements) from tag IDs stored in mesh vertices/edges/faces/elements.

Each element is assigned to a composite ID by an input module. First we scan the element list and generate a list of composite IDs. We then generate the composite objects and populate them with a second scan through the element list.

Definition at line 404 of file NekMeshUtils/Module/Module.cpp.

References Nektar::iterator, and m_mesh.

Referenced by Nektar::Utilities::InputMCF::Process(), Nektar::Utilities::InputSem::Process(), Nektar::Utilities::InputGmsh::Process(), Nektar::Utilities::InputNekpp::Process(), Nektar::Utilities::InputNek5000::Process(), Nektar::NekMeshUtils::VolumeMesh::Process(), Nektar::Utilities::ProcessOptiExtract::Process(), Nektar::Utilities::InputTec::Process(), Nektar::Utilities::ProcessExtrude::Process(), Nektar::Utilities::InputSwan::Process(), Nektar::Utilities::InputVtk::Process(), Nektar::Utilities::InputPly::Process(), Nektar::Utilities::InputStar::Process(), Nektar::Utilities::InputNek::Process(), Nektar::NekMeshUtils::SurfaceMesh::Process(), Nektar::Utilities::ProcessTetSplit::Process(), Nektar::Utilities::ProcessLinkCheck::Process(), Nektar::Utilities::ProcessExtractTetPrismInterface::Process(), Nektar::NekMeshUtils::Generator2D::Process(), Nektar::Utilities::ProcessJac::Process(), and Nektar::Utilities::ProcessBL::Process().

405 {
406  m_mesh->m_composite.clear();
407 
408  // For each element, check to see if a composite has been
409  // created. If not, create a new composite. Otherwise, add the
410  // element to the composite.
411  for (int d = 0; d <= m_mesh->m_expDim; ++d)
412  {
413  vector<ElementSharedPtr> &elmt = m_mesh->m_element[d];
414 
415  for (int i = 0; i < elmt.size(); ++i)
416  {
418  unsigned int tagid = elmt[i]->GetTagList()[0];
419 
420  it = m_mesh->m_composite.find(tagid);
421 
422  if (it == m_mesh->m_composite.end())
423  {
424  CompositeSharedPtr tmp = boost::shared_ptr<Composite>(
425  new Composite());
426  pair<CompositeMap::iterator, bool> testIns;
427  tmp->m_id = tagid;
428  tmp->m_tag = elmt[i]->GetTag();
429  if(m_mesh->m_faceLabels.count(tmp->m_id) != 0)
430  {
431  tmp->m_label = m_mesh->m_faceLabels[tmp->m_id];
432  }
433 
434  testIns = m_mesh->m_composite.insert(
435  pair<unsigned int, CompositeSharedPtr>(tagid,tmp));
436  it = testIns.first;
437  }
438 
439  if (elmt[i]->GetTag() != it->second->m_tag)
440  {
441  cout << "Different types of elements in same composite!" << endl;
442  cout << " -> Composite uses " << it->second->m_tag << endl;
443  cout << " -> Element uses " << elmt[i]->GetTag() << endl;
444  cout << "Have you specified physical volumes and surfaces?" << endl;
445  }
446  it->second->m_items.push_back(elmt[i]);
447  }
448  }
449 }
boost::shared_ptr< Composite > CompositeSharedPtr
Shared pointer to a composite.
Definition: Composite.h:121
boost::shared_ptr< GeometryVector > Composite
Definition: MeshGraph.h:114
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
void Nektar::NekMeshUtils::Module::ProcessEdges ( bool  ReprocessEdges = true)
virtual

Extract element edges.

Create a unique set of mesh edges from elements stored in Mesh::element.

All elements are first scanned and a list of unique, enumerated edges produced in #m_edgeSet. Since each element generated its edges independently, we must now ensure that each element only uses edge objects from the #m_edgeSet set This ensures there are no duplicate edge objects. Finally, we scan the list of elements for 1-D boundary elements which correspond to an edge in #m_edgeSet. For such elements, we set its edgeLink to reference the corresponding edge in #m_edgeSet.

This routine only proceeds if the expansion dimension is 2 or 3.

Definition at line 178 of file NekMeshUtils/Module/Module.cpp.

References Nektar::iterator, and m_mesh.

Referenced by Nektar::Utilities::InputMCF::Process(), Nektar::Utilities::InputSem::Process(), Nektar::Utilities::InputGmsh::Process(), Nektar::Utilities::InputNekpp::Process(), Nektar::Utilities::InputNek5000::Process(), Nektar::NekMeshUtils::VolumeMesh::Process(), Nektar::Utilities::InputTec::Process(), Nektar::Utilities::ProcessExtrude::Process(), Nektar::Utilities::InputSwan::Process(), Nektar::Utilities::InputVtk::Process(), Nektar::Utilities::InputPly::Process(), Nektar::Utilities::InputStar::Process(), Nektar::Utilities::InputNek::Process(), Nektar::NekMeshUtils::SurfaceMesh::Process(), Nektar::Utilities::ProcessLinkCheck::Process(), Nektar::Utilities::ProcessJac::Process(), Nektar::Utilities::ProcessTetSplit::Process(), Nektar::Utilities::ProcessExtractTetPrismInterface::Process(), Nektar::NekMeshUtils::Generator2D::Process(), Nektar::Utilities::ProcessBL::Process(), and ReorderPrisms().

179 {
180  if (m_mesh->m_expDim < 2) return;
181 
182  if(ReprocessEdges)
183  {
184  vector<ElementSharedPtr> &elmt = m_mesh->m_element[m_mesh->m_expDim];
185 
186  m_mesh->m_edgeSet.clear();
187 
188  // Clear all edge links
189 
190  // Scan all elements and generate list of unique edges
191  for (int i = 0, eid = 0; i < elmt.size(); ++i)
192  {
193  for (int j = 0; j < elmt[i]->GetEdgeCount(); ++j)
194  {
195  pair<EdgeSet::iterator,bool> testIns;
196  EdgeSharedPtr ed = elmt[i]->GetEdge(j);
197  testIns = m_mesh->m_edgeSet.insert(ed);
198 
199  if (testIns.second)
200  {
201  EdgeSharedPtr ed2 = *testIns.first;
202  ed2->m_id = eid++;
203  ed2->m_elLink.push_back(
204  pair<ElementSharedPtr,int>(elmt[i],j));
205  }
206  else
207  {
208  EdgeSharedPtr e2 = *(testIns.first);
209  elmt[i]->SetEdge(j, e2);
210  if (e2->m_edgeNodes.size() == 0 &&
211  ed->m_edgeNodes.size() > 0)
212  {
213  e2->m_curveType = ed->m_curveType;
214  e2->m_edgeNodes = ed->m_edgeNodes;
215 
216  // Reverse nodes if appropriate.
217  if (e2->m_n1->m_id != ed->m_n1->m_id)
218  {
219  reverse(e2->m_edgeNodes.begin(),
220  e2->m_edgeNodes.end());
221  }
222  }
223 
224  e2->m_parentCAD = ed->m_parentCAD;
225 
226  // Update edge to element map.
227  e2->m_elLink.push_back(
228  pair<ElementSharedPtr,int>(elmt[i],j));
229  }
230  }
231  }
232  }
233 
234  // Create links for 1D elements
235  for (int i = 0; i < m_mesh->m_element[1].size(); ++i)
236  {
237  ElementSharedPtr elmt = m_mesh->m_element[1][i];
238  NodeSharedPtr v0 = elmt->GetVertex(0);
239  NodeSharedPtr v1 = elmt->GetVertex(1);
240  vector<NodeSharedPtr> edgeNodes;
241  EdgeSharedPtr E = boost::shared_ptr<Edge>(
242  new Edge(v0, v1, edgeNodes, elmt->GetConf().m_edgeCurveType));
243 
244  EdgeSet::iterator it = m_mesh->m_edgeSet.find(E);
245  if (it == m_mesh->m_edgeSet.end())
246  {
247  cerr << "Cannot find corresponding element edge for "
248  << "1D element " << i << endl;
249  abort();
250  }
251  elmt->SetEdgeLink(*it);
252 
253  // Update 2D element boundary map.
254  pair<ElementSharedPtr, int> eMap = (*it)->m_elLink.at(0);
255  eMap.first->SetBoundaryLink(eMap.second, i);
256 
257  // Update vertices
258  elmt->SetVertex(0, (*it)->m_n1, false);
259  elmt->SetVertex(1, (*it)->m_n2, false);
260 
261  // Copy curvature to edge.
262  if ((*it)->m_edgeNodes.size() > 0)
263  {
264  ElementSharedPtr edge = elmt;
265  if (edge->GetVertex(0) == (*it)->m_n1)
266  {
267  edge->SetVolumeNodes((*it)->m_edgeNodes);
268  }
269  elmt->SetCurveType((*it)->m_curveType);
270  }
271  }
272 }
boost::shared_ptr< Node > NodeSharedPtr
Definition: Node.h:50
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
boost::shared_ptr< Element > ElementSharedPtr
Definition: Edge.h:49
void Nektar::NekMeshUtils::Module::ProcessElements ( )
virtual

Generate element IDs.

Enumerate elements stored in Mesh::element.

For all elements of equal dimension to the mesh dimension, we enumerate sequentially. All other elements in the list should be of lower dimension and have ID set by a corresponding edgeLink or faceLink (as set in ProcessEdges or ProcessFaces).

Definition at line 386 of file NekMeshUtils/Module/Module.cpp.

References m_mesh.

Referenced by Nektar::Utilities::InputMCF::Process(), Nektar::Utilities::InputGmsh::Process(), Nektar::Utilities::InputSem::Process(), Nektar::Utilities::InputNek5000::Process(), Nektar::NekMeshUtils::VolumeMesh::Process(), Nektar::Utilities::InputTec::Process(), Nektar::Utilities::InputSwan::Process(), Nektar::Utilities::InputVtk::Process(), Nektar::Utilities::InputPly::Process(), Nektar::Utilities::ProcessExtrude::Process(), Nektar::Utilities::InputStar::Process(), Nektar::Utilities::InputNek::Process(), Nektar::NekMeshUtils::SurfaceMesh::Process(), Nektar::NekMeshUtils::Generator2D::Process(), Nektar::Utilities::ProcessTetSplit::Process(), Nektar::Utilities::ProcessExtractTetPrismInterface::Process(), Nektar::Utilities::ProcessJac::Process(), Nektar::Utilities::ProcessLinkCheck::Process(), Nektar::Utilities::ProcessBL::Process(), and ReorderPrisms().

387 {
388  int cnt = 0;
389  for (int i = 0; i < m_mesh->m_element[m_mesh->m_expDim].size(); ++i)
390  {
391  m_mesh->m_element[m_mesh->m_expDim][i]->SetId(cnt++);
392  }
393 }
void Nektar::NekMeshUtils::Module::ProcessFaces ( bool  ReprocessFaces = true)
virtual

Extract element faces.

Create a unique set of mesh faces from elements stored in Mesh::element.

All elements are scanned and a unique list of enumerated faces is produced in #m_faceSet. Since elements created their own faces independently, we examine each element only uses face objects from #m_faceSet. Duplicate faces of those in #m_face are replaced with the corresponding entry in #m_faceSet. Finally, we scan the list of elements for 2-D boundary faces which correspond to faces in #m_faceSet. For such elements, we set its faceLink to reference the corresponding face in #m_faceSet.

This routine only proceeds if the expansion dimension is 3.

Definition at line 290 of file NekMeshUtils/Module/Module.cpp.

References Nektar::iterator, and m_mesh.

Referenced by Nektar::Utilities::InputMCF::Process(), Nektar::Utilities::InputSem::Process(), Nektar::Utilities::InputGmsh::Process(), Nektar::Utilities::InputNekpp::Process(), Nektar::Utilities::InputNek5000::Process(), Nektar::NekMeshUtils::VolumeMesh::Process(), Nektar::Utilities::ProcessOptiExtract::Process(), Nektar::Utilities::InputTec::Process(), Nektar::Utilities::ProcessExtrude::Process(), Nektar::Utilities::InputSwan::Process(), Nektar::Utilities::InputVtk::Process(), Nektar::Utilities::InputPly::Process(), Nektar::Utilities::InputStar::Process(), Nektar::Utilities::InputNek::Process(), Nektar::NekMeshUtils::SurfaceMesh::Process(), Nektar::Utilities::ProcessExtractTetPrismInterface::Process(), Nektar::Utilities::ProcessLinkCheck::Process(), Nektar::Utilities::ProcessTetSplit::Process(), Nektar::Utilities::ProcessJac::Process(), Nektar::NekMeshUtils::Generator2D::Process(), Nektar::Utilities::ProcessBL::Process(), and ReorderPrisms().

291 {
292  if (m_mesh->m_expDim < 3) return;
293 
294  if(ReprocessFaces)
295  {
296  vector<ElementSharedPtr> &elmt = m_mesh->m_element[m_mesh->m_expDim];
297 
298  m_mesh->m_faceSet.clear();
299 
300  // Scan all elements and generate list of unique faces
301  for (int i = 0, fid = 0; i < elmt.size(); ++i)
302  {
303  for (int j = 0; j < elmt[i]->GetFaceCount(); ++j)
304  {
305  pair<FaceSet::iterator,bool> testIns;
306  testIns = m_mesh->m_faceSet.insert(elmt[i]->GetFace(j));
307 
308  if (testIns.second)
309  {
310  (*(testIns.first))->m_id = fid++;
311  (*(testIns.first))->m_elLink.push_back(
312  pair<ElementSharedPtr,int>(elmt[i],j));
313  }
314  else
315  {
316  elmt[i]->SetFace(j,*testIns.first);
317  // Update face to element map.
318  (*(testIns.first))->m_elLink.push_back(
319  pair<ElementSharedPtr,int>(elmt[i],j));
320  }
321  }
322  }
323  }
324 
325  // Create links for 2D elements
326  for (int i = 0; i < m_mesh->m_element[2].size(); ++i)
327  {
328  ElementSharedPtr elmt = m_mesh->m_element[2][i];
329  vector<NodeSharedPtr> vertices = elmt->GetVertexList();
330  vector<NodeSharedPtr> faceNodes;
331  vector<EdgeSharedPtr> edgeList = elmt->GetEdgeList();
332  FaceSharedPtr F = boost::shared_ptr<Face>(
333  new Face(vertices, faceNodes, edgeList,
334  elmt->GetConf().m_faceCurveType));
335 
336  FaceSet::iterator it = m_mesh->m_faceSet.find(F);
337  if (it == m_mesh->m_faceSet.end())
338  {
339  cout << "Cannot find corresponding element face for 2D "
340  << "element " << i << endl;
341  abort();
342  }
343 
344  elmt->SetFaceLink(*it);
345 
346  // Set edges/vertices
347  for (int j = 0; j < elmt->GetVertexCount(); ++j)
348  {
349  elmt->SetVertex(j, (*it)->m_vertexList[j], false);
350  elmt->SetEdge(j, (*it)->m_edgeList[j], false);
351  }
352 
353  EdgeSet tmp(edgeList.begin(),edgeList.end());
354 
355  for (int j = 0; j < elmt->GetEdgeCount(); ++j)
356  {
357  EdgeSharedPtr e = elmt->GetEdge(j);
358  EdgeSet::iterator f = tmp.find(e);
359  if(f != tmp.end())
360  {
361  e->m_parentCAD = (*f)->m_parentCAD;
362  }
363  }
364 
365  // Update 3D element boundary map.
366  pair<ElementSharedPtr, int> eMap = (*it)->m_elLink.at(0);
367  eMap.first->SetBoundaryLink(eMap.second, i);
368 
369  // Copy face curvature
370  if ((*it)->m_faceNodes.size() > 0)
371  {
372  elmt->SetVolumeNodes((*it)->m_faceNodes);
373  elmt->SetCurveType((*it)->m_curveType);
374  }
375  }
376 }
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
boost::shared_ptr< Element > ElementSharedPtr
Definition: Edge.h:49
boost::unordered_set< EdgeSharedPtr, EdgeHash > EdgeSet
Definition: Edge.h:162
boost::shared_ptr< Face > FaceSharedPtr
Definition: Face.h:153
void Nektar::NekMeshUtils::Module::ProcessVertices ( )
virtual

Extract element vertices.

Create a unique set of mesh vertices from elements stored in Mesh::element.

Each element is processed in turn and the vertices extracted and inserted into #m_vertexSet, which at the end of the routine contains all unique vertices in the mesh.

Definition at line 138 of file NekMeshUtils/Module/Module.cpp.

References m_mesh.

Referenced by Nektar::Utilities::InputMCF::Process(), Nektar::Utilities::InputSem::Process(), Nektar::Utilities::InputGmsh::Process(), Nektar::NekMeshUtils::VolumeMesh::Process(), Nektar::Utilities::InputSwan::Process(), Nektar::Utilities::InputVtk::Process(), Nektar::Utilities::InputPly::Process(), Nektar::NekMeshUtils::SurfaceMesh::Process(), Nektar::Utilities::ProcessLinkCheck::Process(), Nektar::NekMeshUtils::Generator2D::Process(), Nektar::Utilities::ProcessTetSplit::Process(), Nektar::Utilities::ProcessExtractTetPrismInterface::Process(), Nektar::Utilities::ProcessJac::Process(), Nektar::Utilities::ProcessBL::Process(), Nektar::Utilities::InputTec::ReadZone(), and Nektar::Utilities::InputStar::SetupElements().

139 {
140  vector<ElementSharedPtr> &elmt = m_mesh->m_element[m_mesh->m_expDim];
141 
142  m_mesh->m_vertexSet.clear();
143 
144  for (int i = 0, vid = 0; i < elmt.size(); ++i)
145  {
146  for (int j = 0; j < elmt[i]->GetVertexCount(); ++j)
147  {
148  pair<NodeSet::iterator,bool> testIns =
149  m_mesh->m_vertexSet.insert(elmt[i]->GetVertex(j));
150 
151  if (testIns.second)
152  {
153  (*(testIns.first))->m_id = vid++;
154  }
155  else
156  {
157  elmt[i]->SetVertex(j,*testIns.first);
158  }
159  }
160  }
161 }
void Nektar::NekMeshUtils::Module::RegisterConfig ( std::string  key,
std::string  value 
)

Register a configuration option with a module.

Definition at line 844 of file NekMeshUtils/Module/Module.cpp.

References Nektar::iterator, and m_config.

845 {
847  if (it == m_config.end())
848  {
849  cerr << "WARNING: Unrecognised config option " << key
850  << ", proceeding anyway." << endl;
851  }
852 
853  it->second.beenSet = true;
854 
855  if (it->second.isBool)
856  {
857  it->second.value = "1";
858  }
859  else
860  {
861  it->second.value = val;
862  }
863 }
std::map< std::string, ConfigOption > m_config
List of configuration values.
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
void Nektar::NekMeshUtils::Module::ReorderPrisms ( PerMap perFaces)
protected

Reorder node IDs so that prisms and tetrahedra are aligned correctly.

Orientation of prism lines (i.e. a large prism which has been split into subprisms) cannot be guaranteed when elements are created one-by-one, or when periodic boundary conditions are used. This routine uses the following strategy:

  • Destroy the existing node numbering.
  • Detect a line of prisms using the PrismLines routine.
  • For each line, renumber node IDs consistently so that highest ID per-element corresponds to the line of collapsed coordinate points.
  • Recreate each prism in the line using the new ordering, and apply the existing OrientPrism routine to orient nodes accordingly.
  • When all prism lines are processed, recreate all tetrahedra using the existing orientation code.
  • Finally renumber any other nodes (i.e. those belonging to hexahedra).

The last step is to eliminate duplicate edges/faces and reenumerate.

NOTE: This routine does not copy face-interior high-order information yet!

Definition at line 497 of file NekMeshUtils/Module/Module.cpp.

References ASSERTL0, ASSERTL1, Nektar::LibUtilities::NekFactory< tKey, tBase, >::CreateInstance(), Nektar::LibUtilities::ePrism, Nektar::LibUtilities::eTetrahedron, Nektar::NekMeshUtils::GetElementFactory(), Nektar::iterator, m_mesh, PrismLines(), ProcessEdges(), ProcessElements(), and ProcessFaces().

Referenced by Nektar::Utilities::ProcessPerAlign::Process().

498 {
499  // Loop over elements and extract any that are prisms.
500  int i, j, k;
501 
502  if (m_mesh->m_expDim < 3)
503  {
504  return;
505  }
506 
507  map<int, int> lines;
508  set<int> prismsDone, tetsDone;
509  PerMap::iterator pIt;
510 
511  // Compile list of prisms and tets.
512  for (i = 0; i < m_mesh->m_element[3].size(); ++i)
513  {
514  ElementSharedPtr el = m_mesh->m_element[3][i];
515 
516  if (el->GetConf().m_e == LibUtilities::ePrism)
517  {
518  prismsDone.insert(i);
519  }
520  else if (el->GetConf().m_e == LibUtilities::eTetrahedron)
521  {
522  tetsDone.insert(i);
523  }
524  }
525 
526  // Destroy existing node numbering.
528  for (it = m_mesh->m_vertexSet.begin(); it != m_mesh->m_vertexSet.end(); ++it)
529  {
530  (*it)->m_id = -1;
531  }
532 
533  // Counter for new node IDs.
534  int nodeId = 0;
535  int prismTris[2][3] = {{0,1,4}, {3,2,5}};
536 
537  // Warning flag for high-order curvature information.
538  bool warnCurvature = false;
539 
540  // facesDone tracks face IDs inside prisms which have already been
541  // aligned.
542  boost::unordered_set<int> facesDone;
544 
545  // Loop over prisms until we've found all lines of prisms.
546  while (prismsDone.size() > 0)
547  {
548  vector<ElementSharedPtr> line;
549 
550  // Call PrismLines to identify all prisms connected to
551  // prismDone.begin() and place them in line[].
552  PrismLines(*prismsDone.begin(), perFaces, prismsDone, line);
553 
554  // Loop over each prism, figure out which line of vertices
555  // contains the vertex with highest ID.
556  for (i = 0; i < line.size(); ++i)
557  {
558  // Copy tags and nodes from existing element.
559  vector<int> tags = line[i]->GetTagList();
560  vector<NodeSharedPtr> nodes = line[i]->GetVertexList();
561 
562  // See if either face of this prism has been renumbered
563  // already.
564  FaceSharedPtr f[2] = {
565  line[i]->GetFace(1), line[i]->GetFace(3)
566  };
567 
568  fIt[0] = facesDone.find(f[0]->m_id);
569  fIt[1] = facesDone.find(f[1]->m_id);
570 
571  // See if either of these faces is periodic. If it is, then
572  // assign ids accordingly.
573  for (j = 0; j < 2; ++j)
574  {
575  pIt = perFaces.find(f[j]->m_id);
576 
577  if (pIt == perFaces.end())
578  {
579  continue;
580  }
581 
582  fIt2 = facesDone.find(pIt->second.first->m_id);
583 
584  if (fIt[j] == facesDone.end() &&
585  fIt2 != facesDone.end())
586  {
587  fIt[j] = fIt2;
588  }
589  }
590 
591  if (fIt[0] != facesDone.end() &&
592  fIt[1] != facesDone.end())
593  {
594  // Should not be the case that both faces have already
595  // been renumbered.
596  ASSERTL0(false, "Renumbering error!");
597  }
598  else if (fIt[0] == facesDone.end() &&
599  fIt[1] == facesDone.end())
600  {
601  // Renumber both faces.
602  for (j = 0; j < 2; ++j)
603  {
604  for (k = 0; k < 3; ++k)
605  {
606  NodeSharedPtr n = nodes[prismTris[j][k]];
607  if (n->m_id == -1)
608  {
609  n->m_id = nodeId++;
610  }
611  }
612  }
613 
614  facesDone.insert(f[0]->m_id);
615  facesDone.insert(f[1]->m_id);
616  }
617  else
618  {
619  // Renumber face. t identifies the face not yet
620  // numbered, o identifies the other face.
621  int t = fIt[0] == facesDone.end() ? 0 : 1;
622  int o = (t+1) % 2;
623  ASSERTL1(fIt[o] != facesDone.end(),"Renumbering error");
624 
625  // Determine which of the three vertices on the 'other'
626  // face corresponds to the highest ID - this signifies
627  // the singular point of the line of prisms.
628  int tmp1[3] = {
629  nodes[prismTris[o][0]]->m_id,
630  nodes[prismTris[o][1]]->m_id,
631  nodes[prismTris[o][2]]->m_id
632  };
633  int tmp2[3] = {0,1,2};
634 
635  if (tmp1[0] > tmp1[1])
636  {
637  swap(tmp1[0], tmp1[1]);
638  swap(tmp2[0], tmp2[1]);
639  }
640 
641  if (tmp1[1] > tmp1[2])
642  {
643  swap(tmp1[1], tmp1[2]);
644  swap(tmp2[1], tmp2[2]);
645  }
646 
647  if (tmp1[0] > tmp1[2])
648  {
649  swap(tmp1[0], tmp1[2]);
650  swap(tmp2[0], tmp2[2]);
651  }
652 
653  // Renumber this face so that highest ID matches.
654  for (j = 0; j < 3; ++j)
655  {
656  NodeSharedPtr n = nodes[prismTris[t][tmp2[j]]];
657  if (n->m_id == -1)
658  {
659  n->m_id = nodeId++;
660  }
661  }
662 
663  facesDone.insert(f[t]->m_id);
664  }
665 
666  for (j = 0; j < 6; ++j)
667  {
668  ASSERTL1(nodes[j]->m_id != -1, "Renumbering error");
669  }
670 
671  // Recreate prism with the new ordering.
672  ElmtConfig conf(LibUtilities::ePrism, 1, false, false, true);
674  LibUtilities::ePrism, conf, nodes, tags);
675 
676  // Now transfer high-order information back into
677  // place. TODO: Face curvature.
678  for (j = 0; j < 9; ++j)
679  {
680  EdgeSharedPtr e1 = line[i]->GetEdge(j);
681  for (k = 0; k < 9; ++k)
682  {
683  EdgeSharedPtr e2 = el->GetEdge(k);
684  if (e1->m_n1 == e2->m_n1 && e1->m_n2 == e2->m_n2)
685  {
686  e2->m_edgeNodes = e1->m_edgeNodes;
687  }
688  else if (e1->m_n1 == e2->m_n1 && e1->m_n2 == e2->m_n2)
689  {
690  e2->m_edgeNodes = e1->m_edgeNodes;
691  std::reverse(e2->m_edgeNodes.begin(),
692  e2->m_edgeNodes.end());
693  }
694  }
695  }
696 
697  // Warn users that we're throwing away face curvature
698  if (!warnCurvature)
699  {
700  for (j = 0; j < 5; ++j)
701  {
702  if (line[i]->GetFace(j)->m_faceNodes.size() > 0)
703  {
704  warnCurvature = true;
705  break;
706  }
707  }
708  }
709 
710  // Replace old prism.
711  m_mesh->m_element[3][line[i]->GetId()] = el;
712  }
713  }
714 
715  if (warnCurvature)
716  {
717  cerr << "[ReorderPrisms] WARNING: Face curvature detected in "
718  << "some prisms; this will be ignored in further module "
719  << "evaluations."
720  << endl;
721  }
722 
723  // Loop over periodic faces, enumerate vertices.
724  for (pIt = perFaces.begin(); pIt != perFaces.end(); ++pIt)
725  {
726  FaceSharedPtr f2 = pIt->second.first;
727  FaceSharedPtr f1 = perFaces[f2->m_id].first;
728  vector<int> perVerts = pIt->second.second;
729  int nVerts = perVerts.size();
730 
731  // Number periodic vertices first.
732  for (j = 0; j < nVerts; ++j)
733  {
734  NodeSharedPtr n1 = f1->m_vertexList[j];
735  NodeSharedPtr n2 = f2->m_vertexList[perVerts[j]];
736 
737  if (n1->m_id == -1 && n2->m_id == -1)
738  {
739  n1->m_id = nodeId++;
740  n2->m_id = nodeId++;
741  }
742  else if (n1->m_id != -1 && n2->m_id != -1)
743  {
744  continue;
745  }
746  else
747  {
748  ASSERTL0(false, "Periodic face renumbering error");
749  }
750  }
751  }
752 
753  // Recreate tets.
754  set<int>::iterator it2;
755  for (it2 = tetsDone.begin(); it2 != tetsDone.end(); ++it2)
756  {
757  ElementSharedPtr el = m_mesh->m_element[3][*it2];
758  vector<NodeSharedPtr> nodes = el->GetVertexList();
759  vector<int> tags = el->GetTagList();
760 
761  for (i = 0; i < 4; ++i)
762  {
763  if (nodes[i]->m_id == -1)
764  {
765  nodes[i]->m_id = nodeId++;
766  }
767  }
768 
769  // Recreate tet.
770  ElmtConfig conf(LibUtilities::eTetrahedron, 1, false, false, true);
771  m_mesh->m_element[3][*it2] = GetElementFactory().CreateInstance(
772  LibUtilities::eTetrahedron, conf, nodes, tags);
773  }
774 
775  // Enumerate rest of vertices.
776  for (it = m_mesh->m_vertexSet.begin(); it != m_mesh->m_vertexSet.end(); ++it)
777  {
778  if ((*it)->m_id == -1)
779  {
780  (*it)->m_id = nodeId++;
781  }
782  }
783 
784  ProcessEdges ();
785  ProcessFaces ();
786  ProcessElements();
787 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
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
ElementFactory & GetElementFactory()
Definition: Element.cpp:47
virtual NEKMESHUTILS_EXPORT void ProcessFaces(bool ReprocessFaces=true)
Extract element faces.
virtual NEKMESHUTILS_EXPORT void ProcessElements()
Generate element IDs.
boost::shared_ptr< Node > NodeSharedPtr
Definition: Node.h:50
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
NEKMESHUTILS_EXPORT void PrismLines(int prism, PerMap &perFaces, std::set< int > &prismsDone, std::vector< ElementSharedPtr > &line)
virtual NEKMESHUTILS_EXPORT void ProcessEdges(bool ReprocessEdges=true)
Extract element edges.
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
void Nektar::NekMeshUtils::Module::SetDefaults ( )

Sets default configuration options for those which have not been set.

Definition at line 889 of file NekMeshUtils/Module/Module.cpp.

References Nektar::iterator, and m_config.

890 {
892 
893  for (it = m_config.begin(); it != m_config.end(); ++it)
894  {
895  if (!it->second.beenSet)
896  {
897  it->second.value = it->second.defValue;
898  }
899  }
900 }
std::map< std::string, ConfigOption > m_config
List of configuration values.
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator

Member Data Documentation

std::map<std::string, ConfigOption> Nektar::NekMeshUtils::Module::m_config
protected

List of configuration values.

Definition at line 188 of file NekMeshUtils/Module/Module.h.

Referenced by Nektar::Utilities::ProcessBL::BoundaryLayer2D(), Nektar::Utilities::ProcessBL::BoundaryLayer3D(), Nektar::NekMeshUtils::Generator2D::Generator2D(), Nektar::NekMeshUtils::HOSurfaceMesh::HOSurfaceMesh(), Nektar::Utilities::InputStar::InitCCM(), Nektar::NekMeshUtils::InputModule::InputModule(), Nektar::Utilities::InputNek::InputNek(), Nektar::Utilities::InputStar::InputStar(), Nektar::NekMeshUtils::InputModule::OpenStream(), Nektar::NekMeshUtils::OutputModule::OpenStream(), Nektar::Utilities::OutputGmsh::OutputGmsh(), Nektar::NekMeshUtils::OutputModule::OutputModule(), Nektar::Utilities::OutputNekpp::OutputNekpp(), PrintConfig(), Nektar::Utilities::InputMCF::Process(), Nektar::Utilities::ProcessCurvedEdges::Process(), Nektar::Utilities::InputNekpp::Process(), Nektar::Utilities::InputSem::Process(), Nektar::NekMeshUtils::VolumeMesh::Process(), Nektar::NekMeshUtils::HOSurfaceMesh::Process(), Nektar::NekMeshUtils::ProcessLoadCAD::Process(), Nektar::NekMeshUtils::ProcessLoadOctree::Process(), Nektar::Utilities::ProcessOptiExtract::Process(), Nektar::Utilities::ProcessPerAlign::Process(), Nektar::Utilities::ProcessExtrude::Process(), Nektar::Utilities::InputVtk::Process(), Nektar::Utilities::OutputVtk::Process(), Nektar::Utilities::ProcessSpherigon::Process(), Nektar::Utilities::OutputNekpp::Process(), Nektar::Utilities::ProcessLinear::Process(), Nektar::Utilities::InputNek::Process(), Nektar::NekMeshUtils::Generator2D::Process(), Nektar::Utilities::ProcessTetSplit::Process(), Nektar::Utilities::ProcessDetectSurf::Process(), Nektar::Utilities::ProcessExtractSurf::Process(), Nektar::Utilities::ProcessInsertSurface::Process(), Nektar::Utilities::ProcessJac::Process(), Nektar::Utilities::ProcessScalar::Process(), Nektar::Utilities::OutputGmsh::Process(), Nektar::Utilities::ProcessVarOpti::Process(), Nektar::Utilities::ProcessBL::ProcessBL(), Nektar::Utilities::ProcessCurve::ProcessCurve(), Nektar::Utilities::ProcessCurvedEdges::ProcessCurvedEdges(), Nektar::Utilities::ProcessCyl::ProcessCyl(), Nektar::Utilities::ProcessDetectSurf::ProcessDetectSurf(), Nektar::Utilities::ProcessExtractSurf::ProcessExtractSurf(), Nektar::Utilities::ProcessExtrude::ProcessExtrude(), Nektar::Utilities::ProcessInsertSurface::ProcessInsertSurface(), Nektar::Utilities::ProcessJac::ProcessJac(), Nektar::Utilities::ProcessLinear::ProcessLinear(), Nektar::NekMeshUtils::ProcessLoadCAD::ProcessLoadCAD(), Nektar::NekMeshUtils::ProcessLoadOctree::ProcessLoadOctree(), Nektar::Utilities::ProcessOptiExtract::ProcessOptiExtract(), Nektar::Utilities::ProcessPerAlign::ProcessPerAlign(), Nektar::Utilities::ProcessScalar::ProcessScalar(), Nektar::Utilities::ProcessSpherigon::ProcessSpherigon(), Nektar::Utilities::ProcessTetSplit::ProcessTetSplit(), Nektar::Utilities::ProcessVarOpti::ProcessVarOpti(), RegisterConfig(), SetDefaults(), Nektar::Utilities::InputStar::SetupElements(), Nektar::Utilities::ProcessCyl::v_GenerateEdgeNodes(), Nektar::Utilities::ProcessCurve::v_GenerateEdgeNodes(), Nektar::NekMeshUtils::VolumeMesh::VolumeMesh(), Nektar::Utilities::OutputNekpp::WriteXmlCurves(), Nektar::Utilities::OutputNekpp::WriteXmlEdges(), Nektar::Utilities::OutputNekpp::WriteXmlElements(), Nektar::Utilities::OutputNekpp::WriteXmlFaces(), and Nektar::Utilities::OutputNekpp::WriteXmlNodes().

MeshSharedPtr Nektar::NekMeshUtils::Module::m_mesh
protected

Mesh object.

Definition at line 186 of file NekMeshUtils/Module/Module.h.

Referenced by Nektar::Utilities::ProcessVarOpti::Analytics(), Nektar::Utilities::ProcessBL::BoundaryLayer2D(), Nektar::Utilities::ProcessBL::BoundaryLayer3D(), ClearElementLinks(), Nektar::Utilities::ProcessSpherigon::FindNormalFromPlyFile(), Nektar::Utilities::InputTec::GenElement2D(), Nektar::Utilities::InputStar::GenElement2D(), Nektar::Utilities::InputTec::GenElement3D(), Nektar::Utilities::InputStar::GenElement3D(), GetMesh(), Nektar::Utilities::InputSem::insertEdge(), Nektar::Utilities::ProcessLinear::Invalid(), Nektar::Utilities::InputNek::LoadHOSurfaces(), Nektar::NekMeshUtils::Generator2D::MakeBL(), Nektar::NekMeshUtils::Generator2D::MakeBLPrep(), Nektar::NekMeshUtils::InputModule::PrintSummary(), PrismLines(), Nektar::Utilities::InputMCF::Process(), Nektar::Utilities::ProcessCurvedEdges::Process(), Nektar::Utilities::InputNekpp::Process(), Nektar::Utilities::InputGmsh::Process(), Nektar::Utilities::InputSem::Process(), Nektar::NekMeshUtils::HOSurfaceMesh::Process(), Nektar::NekMeshUtils::VolumeMesh::Process(), Nektar::Utilities::InputNek5000::Process(), Nektar::NekMeshUtils::ProcessLoadCAD::Process(), Nektar::NekMeshUtils::ProcessLoadOctree::Process(), Nektar::Utilities::ProcessPerAlign::Process(), Nektar::Utilities::InputTec::Process(), Nektar::Utilities::OutputSTL::Process(), Nektar::Utilities::ProcessOptiExtract::Process(), Nektar::Utilities::InputSwan::Process(), Nektar::Utilities::OutputVtk::Process(), Nektar::Utilities::InputVtk::Process(), Nektar::Utilities::ProcessExtrude::Process(), Nektar::Utilities::InputStar::Process(), Nektar::Utilities::ProcessSpherigon::Process(), Nektar::Utilities::OutputNekpp::Process(), Nektar::Utilities::ProcessLinear::Process(), Nektar::Utilities::InputNek::Process(), Nektar::NekMeshUtils::SurfaceMesh::Process(), Nektar::Utilities::ProcessTetSplit::Process(), Nektar::Utilities::ProcessScalar::Process(), Nektar::Utilities::ProcessLinkCheck::Process(), Nektar::NekMeshUtils::Generator2D::Process(), Nektar::Utilities::ProcessJac::Process(), Nektar::Utilities::ProcessDetectSurf::Process(), Nektar::Utilities::ProcessExtractTetPrismInterface::Process(), Nektar::Utilities::ProcessInsertSurface::Process(), Nektar::Utilities::ProcessExtractSurf::Process(), Nektar::Utilities::ProcessBL::Process(), Nektar::Utilities::OutputGmsh::Process(), Nektar::Utilities::ProcessVarOpti::Process(), ProcessComposites(), ProcessEdges(), ProcessElements(), ProcessFaces(), ProcessVertices(), Nektar::Utilities::InputPly::ReadPly(), Nektar::Utilities::InputTec::ReadZone(), ReorderPrisms(), Nektar::NekMeshUtils::SurfaceMesh::Report(), Nektar::NekMeshUtils::Generator2D::Report(), Nektar::Utilities::InputStar::SetupElements(), Nektar::Utilities::OutputNekpp::WriteXmlComposites(), Nektar::Utilities::OutputNekpp::WriteXmlConditions(), Nektar::Utilities::OutputNekpp::WriteXmlCurves(), Nektar::Utilities::OutputNekpp::WriteXmlDomain(), Nektar::Utilities::OutputNekpp::WriteXmlEdges(), Nektar::Utilities::OutputNekpp::WriteXmlElements(), Nektar::Utilities::OutputNekpp::WriteXmlExpansions(), Nektar::Utilities::OutputNekpp::WriteXmlFaces(), and Nektar::Utilities::OutputNekpp::WriteXmlNodes().