Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
Nektar::Utilities::InputTec Class Reference

Converter for VTK files. More...

#include <InputStarTec.h>

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

Public Member Functions

 InputTec (MeshSharedPtr m)
 
virtual ~InputTec ()
 
virtual void Process ()
 Populate and validate required data structures. More...
 
void ReadZone (int &nComposite)
 
- 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
 

Protected Member Functions

void GenElement3D (vector< NodeSharedPtr > &Nodes, int i, vector< int > &ElementFaces, vector< vector< int > > &FaceNodes, int ncomposite, bool DoOrient)
 
void GenElement2D (vector< NodeSharedPtr > &Nodes, int i, vector< int > &ElementFaces, vector< vector< int > > &FaceNodes, int ncomposite)
 
Array< OneD, int > SortEdgeNodes (vector< NodeSharedPtr > &Nodes, vector< int > &ElementFaces, vector< vector< int > > &FaceNodes)
 
Array< OneD, int > SortFaceNodes (vector< NodeSharedPtr > &Nodes, vector< int > &ElementFaces, vector< vector< int > > &FaceNodes)
 
void ResetNodes (vector< NodeSharedPtr > &Nodes, Array< OneD, vector< int > > &ElementFaces, vector< vector< int > > &FaceNodes)
 
- 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)
 

Additional Inherited Members

- 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 VTK files.

Definition at line 47 of file InputStarTec.h.

Constructor & Destructor Documentation

Nektar::Utilities::InputTec::InputTec ( MeshSharedPtr  m)

Definition at line 61 of file InputStarTec.cpp.

61  : InputModule(m)
62  {
63 
64  }
Nektar::Utilities::InputTec::~InputTec ( )
virtual

Definition at line 66 of file InputStarTec.cpp.

67  {
68 
69  }

Member Function Documentation

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

Creates an instance of this class.

Definition at line 51 of file InputStarTec.h.

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

51  {
53  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
void Nektar::Utilities::InputTec::GenElement2D ( vector< NodeSharedPtr > &  Nodes,
int  i,
vector< int > &  ElementFaces,
vector< vector< int > > &  FaceNodes,
int  ncomposite 
)
protected

Definition at line 676 of file InputStarTec.cpp.

References ASSERTL0, Nektar::LibUtilities::NekFactory< tKey, tBase, >::CreateInstance(), Nektar::LibUtilities::eQuadrilateral, Nektar::LibUtilities::eTriangle, Nektar::Utilities::GetElementFactory(), Nektar::Utilities::Module::m_mesh, and SortEdgeNodes().

Referenced by ReadZone().

680  {
682  // set up Node list
683 
684  if(ElementFaces.size() == 3)
685  {
686  elType = LibUtilities::eTriangle;
687  }
688  else if(ElementFaces.size() == 4)
689  {
691  }
692  else
693  {
694  ASSERTL0(false,"Not set up for elements which are not Tets or Prism");
695  }
696 
697  // Create element tags
698  vector<int> tags;
699  tags.push_back(nComposite);
700 
701  // make unique node list
702  vector<NodeSharedPtr> nodeList;
703  Array<OneD, int> Nodes = SortEdgeNodes(VertNodes, ElementFaces, FaceNodes);
704  for(int j = 0; j < Nodes.num_elements(); ++j)
705  {
706  nodeList.push_back(VertNodes[Nodes[j]]);
707  }
708 
709  // Create element
710  ElmtConfig conf(elType,1,true,true);
712  nodeList,tags);
713 
714  m_mesh->m_element[E->GetDim()].push_back(E);
715  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
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
MeshSharedPtr m_mesh
Mesh object.
boost::shared_ptr< Element > ElementSharedPtr
Shared pointer to an element.
Definition: MeshElements.h:63
Array< OneD, int > SortEdgeNodes(vector< NodeSharedPtr > &Nodes, vector< int > &ElementFaces, vector< vector< int > > &FaceNodes)
ElementFactory & GetElementFactory()
void Nektar::Utilities::InputTec::GenElement3D ( vector< NodeSharedPtr > &  Nodes,
int  i,
vector< int > &  ElementFaces,
vector< vector< int > > &  FaceNodes,
int  ncomposite,
bool  DoOrient 
)
protected

Definition at line 717 of file InputStarTec.cpp.

References ASSERTL0, Nektar::LibUtilities::NekFactory< tKey, tBase, >::CreateInstance(), Nektar::LibUtilities::ePrism, Nektar::LibUtilities::ePyramid, Nektar::LibUtilities::eTetrahedron, Nektar::Utilities::GetElementFactory(), Nektar::Utilities::Module::m_mesh, and SortFaceNodes().

Referenced by ReadZone().

721  {
723  // set up Node list
724  Array<OneD, int> Nodes = SortFaceNodes(VertNodes, ElementFaces, FaceNodes);
725  int nnodes = Nodes.num_elements();
726  map<LibUtilities::ShapeType,int> domainComposite;
727 
728 
729  // Set Nodes -- Not sure we need this so could
730  //m_mesh->m_node = VertNodes;
731 
732  // element type
733  if(nnodes == 4)
734  {
736  }
737  else if(nnodes == 5)
738  {
739  elType = LibUtilities::ePyramid;
740  }
741  else if(nnodes == 6)
742  {
743  elType = LibUtilities::ePrism;
744  }
745  else
746  {
747 
748  ASSERTL0(false,"Not set up for elements which are not Tets or Prism");
749  }
750 
751  // Create element tags
752  vector<int> tags;
753  tags.push_back(nComposite);
754 
755  // make unique node list
756  vector<NodeSharedPtr> nodeList;
757  for(int j = 0; j < Nodes.num_elements(); ++j)
758  {
759  nodeList.push_back(VertNodes[Nodes[j]]);
760  }
761 
762 
763  // Create element
764  if(elType != LibUtilities::ePyramid)
765  {
766  ElmtConfig conf(elType,1,true,true,DoOrient);
768  nodeList,tags);
769 
770  m_mesh->m_element[E->GetDim()].push_back(E);
771  }
772  else
773  {
774  cout << "Warning: Pyramid detected " << endl;
775  }
776  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
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
MeshSharedPtr m_mesh
Mesh object.
Array< OneD, int > SortFaceNodes(vector< NodeSharedPtr > &Nodes, vector< int > &ElementFaces, vector< vector< int > > &FaceNodes)
boost::shared_ptr< Element > ElementSharedPtr
Shared pointer to an element.
Definition: MeshElements.h:63
ElementFactory & GetElementFactory()
void Nektar::Utilities::InputTec::Process ( )
virtual

Populate and validate required data structures.

Tecplot file Polyhedron format contains a list of nodes, a node count per face, the node ids, Element ids that are on the left of each face and Element ids which are on the right of each face. There are then a series of zone of each surface. In the case of a surface the number of nodes is not provided indicating it is a 2D zone

Parameters
pFilenameFilename of Tecplot file to read.

Implements Nektar::Utilities::Module.

Definition at line 82 of file InputStarTec.cpp.

References Nektar::Utilities::Module::m_mesh, Nektar::Utilities::InputModule::m_mshFile, Nektar::Utilities::InputModule::OpenStream(), Nektar::Utilities::InputModule::PrintSummary(), Nektar::Utilities::Module::ProcessComposites(), Nektar::Utilities::Module::ProcessEdges(), Nektar::Utilities::Module::ProcessElements(), Nektar::Utilities::Module::ProcessFaces(), and ReadZone().

83  {
84  m_mesh->m_expDim = 3;
85  m_mesh->m_spaceDim = 3;
86 
87  if (m_mesh->m_verbose)
88  {
89  cout << "InputStarTec: Start reading file..." << endl;
90  }
91 
92  string line, word;
93 
94  // Open the file stream.
95  OpenStream();
96 
97  int nComposite = 0;
98 
99  // read first zone (Hopefully 3D)
100  while (!m_mshFile.eof())
101  {
102  getline(m_mshFile, line);
103  if(line.find("ZONE") != string::npos)
104  {
105  ReadZone(nComposite);
106  break;
107  }
108  }
109 
110  // read remaining 2D zones
111  while (!m_mshFile.eof())
112  {
113  if(line.find("ZONE") != string::npos)
114  {
115  ReadZone(nComposite);
116  }
117  }
118 
119  PrintSummary();
120  m_mshFile.close();
121 
122  ProcessEdges();
123  ProcessFaces();
124  ProcessElements();
126  }
std::ifstream m_mshFile
Input stream.
MeshSharedPtr m_mesh
Mesh object.
virtual void ProcessEdges(bool ReprocessEdges=true)
Extract element edges.
virtual void ProcessElements()
Generate element IDs.
virtual void ProcessComposites()
Generate composites.
void PrintSummary()
Print summary of elements.
void ReadZone(int &nComposite)
virtual void ProcessFaces(bool ReprocessFaces=true)
Extract element faces.
void OpenStream()
Open a file for input.
void Nektar::Utilities::InputTec::ReadZone ( int &  nComposite)

Definition at line 128 of file InputStarTec.cpp.

References ASSERTL0, GenElement2D(), GenElement3D(), Nektar::iterator, Nektar::Utilities::Module::m_mesh, Nektar::Utilities::InputModule::m_mshFile, Nektar::Utilities::Module::ProcessVertices(), and ResetNodes().

Referenced by Process().

129  {
130  int i;
131  string line,tag;
132  int nfaces, nnodes, nelements;
133  int start,end;
134  stringstream s;
135  NekDouble value;
136  streampos pos;
137  static int zcnt=1;
138 
139  // Read Zone Header
140  nnodes = nfaces = nelements = 0;
141  while (!m_mshFile.eof())
142  {
143  pos = m_mshFile.tellg();
144 
145  getline(m_mshFile, line);
146 
147  boost::to_upper(line);
148 
149  // cehck to see if readable data.
150  if(sscanf(line.c_str(),"%lf",&value) == 1)
151  {
152  m_mshFile.seekg(pos);
153  break;
154  }
155 
156  if ((line.find("NODES") != string::npos)&&
157  (line.find("TOTALNUMFACENODES") == string::npos))
158  {
159  s.clear();
160  s.str(line);
161 
162  tag = s.str();
163  start = tag.find("NODES=");
164  end = tag.find_first_of(',',start);
165  nnodes = atoi(tag.substr(start+6,end).c_str());
166  }
167 
168  if ((line.find("FACES") != string::npos)&&
169  (line.find("NUMCONNECTEDBOUNDARYFACES") == string::npos))
170  {
171  s.clear();
172  s.str(line);
173 
174  tag = s.str();
175  start = tag.find("FACES=");
176  end = tag.find_first_of(',',start);
177  nfaces = atoi(tag.substr(start+6,end).c_str());
178  }
179 
180  if (line.find("ELEMENTS") != string::npos)
181  {
182  s.clear();
183  s.str(line);
184 
185  tag = s.str();
186  start = tag.find("ELEMENTS=");
187  end = tag.find_first_of(',',start);
188  nelements = atoi(tag.substr(start+9,end).c_str());
189  }
190 
191  if (line.find("ZONETYPE") != string::npos)
192  {
193  s.clear();
194  s.str(line);
195 
196  if((line.find("FEPOLYGON") == string::npos)&&
197  (line.find("FEPOLYHEDRON") == string::npos))
198  {
199  ASSERTL0(false,"Routine only set up for FEPolygon or FEPolyhedron");
200  }
201  }
202  }
203  if(!nnodes) // No zone found
204  {
205  return;
206  }
207 
208  cout << "Setting up zone "<< zcnt++;
209 
210  vector<NekDouble> x,y,z;
211 
212  // Read in Nodes
213  for(i = 0; i < nnodes; ++i)
214  {
215  m_mshFile >> value;
216  x.push_back(value);
217  }
218 
219  for(i = 0; i < nnodes; ++i)
220  {
221  m_mshFile >> value;
222  y.push_back(value);
223  }
224 
225  for(i = 0; i < nnodes; ++i)
226  {
227  m_mshFile >> value;
228  z.push_back(value);
229  }
230 
231  std::vector<NodeSharedPtr> Nodes;
232  for(i = 0; i < nnodes; ++i)
233  {
234  Nodes.push_back(boost::shared_ptr<Node>(new Node(i,x[i],y[i],z[i])));
235  }
236 
237  // Read Node count per face
238  getline(m_mshFile, line);
239  if(line.find("node count per face") == string::npos)
240  {
241  if(line.find("face nodes") == string::npos)
242  {
243  getline(m_mshFile,line);
244  }
245  }
246 
247  s.clear();
248  s.str(line);
249 
250  vector<int> Nodes_per_face;
251  if(line.find("node count per face") != string::npos)
252  {
253  int nodes;
254  for(i = 0; i < nfaces; ++i)
255  {
256  m_mshFile>> nodes;
257  ASSERTL0(nodes <= 4,"Can only handle meshes with "
258  "up to four nodes per face");
259  Nodes_per_face.push_back(nodes);
260  }
261  // Read next line
262  getline(m_mshFile, line);
263  }
264 
265  // Read face nodes;
266  if(line.find("face nodes") == string::npos)
267  {
268  getline(m_mshFile,line);
269  }
270  s.clear();
271  s.str(line);
272 
273  vector<vector<int> > FaceNodes;
274 
275  if(line.find("face nodes") != string::npos)
276  {
277 
278  for(i = 0; i < nfaces; ++i)
279  {
280  // check to see if Nodes_per_face is defined and
281  // if not assume 2 nodes for 2D case
282  int nodes = (Nodes_per_face.size())? Nodes_per_face[i]: 2;
283 
284  int nodeID;
285  vector<int> Fnodes;
286  for(int j = 0; j < nodes; ++j)
287  {
288 
289  m_mshFile>> nodeID;
290 
291  Fnodes.push_back(nodeID-1);
292  }
293 
294  FaceNodes.push_back(Fnodes);
295  }
296 
297  }
298  else
299  {
300  ASSERTL0(false,"Failed to find face node section");
301  }
302 
303  // Read left elements
304  Array<OneD, vector< int> > ElementFaces(nelements);
305 
306  // check to see if next line contains left elements
307  getline(m_mshFile, line);
308  if(line.find("left elements") == string::npos)
309  {
310  getline(m_mshFile,line);
311  }
312 
313  if(line.find("left elements") != string::npos)
314  {
315  int elmtID;
316 
317  for(i = 0; i < nfaces; ++i)
318  {
319  m_mshFile>> elmtID;
320 
321  if(elmtID > 0)
322  {
323  ElementFaces[elmtID-1].push_back(i);
324  }
325  }
326  }
327  else
328  {
329  ASSERTL0(false,"Left element not found");
330  }
331 
332 
333  // check to see if next line contains right elements
334  getline(m_mshFile, line);
335  if(line.find("right elements") == string::npos)
336  {
337  getline(m_mshFile, line);
338  }
339 
340  if(line.find("right elements") != string::npos)
341 
342  {
343  int elmtID;
344 
345  for(i = 0; i < nfaces; ++i)
346  {
347  m_mshFile>> elmtID;
348 
349  if(elmtID > 0)
350  {
351  ElementFaces[elmtID-1].push_back(i);
352  }
353  }
354 
355  // read to end of line
356  getline(m_mshFile, line);
357  }
358  else
359  {
360  ASSERTL0(false,"Left element not found");
361  }
362 
363 
364 
365  if(Nodes_per_face.size()) // 3D Zone
366  {
367  cout << " (3D) "<< endl;
368 
369  // Reset node ordering so that all prism faces have
370  // consistent numbering for singular vertex re-ordering
371  ResetNodes(Nodes,ElementFaces,FaceNodes);
372 
373  m_mesh->m_node = Nodes;
374 
375  // create Prisms/Pyramids first
376  for(i = 0; i < nelements; ++i)
377  {
378  if(ElementFaces[i].size() > 4)
379  {
380  GenElement3D(Nodes,i,ElementFaces[i],FaceNodes,nComposite,true);
381  }
382  }
383 
384  nComposite++;
385 
386  // create Tets second
387  for(i = 0; i < nelements; ++i)
388  {
389  if(ElementFaces[i].size() == 4)
390  {
391  GenElement3D(Nodes,i,ElementFaces[i],FaceNodes,nComposite,true);
392  }
393 
394  }
395  nComposite++;
396 
397  ProcessVertices();
398  }
399  else // 2D Zone
400  {
401  cout << " (2D)" << endl;
402 
403  // find ids of VertNodes from m_mesh->m_vertexSet so that we can identify
404  for(i = 0; i < Nodes.size(); ++i)
405  {
406  NodeSet::iterator it = m_mesh->m_vertexSet.find(Nodes[i]);
407 
408  if (it == m_mesh->m_vertexSet.end())
409  {
410  ASSERTL0(false,"Failed to find face vertex in 3D list");
411  }
412  else
413  {
414  Nodes[i] = *it;
415  }
416  }
417 
418  for(i = 0; i < nelements; ++i)
419  {
420  GenElement2D(Nodes,i,ElementFaces[i],FaceNodes,nComposite);
421  }
422 
423  nComposite++;
424  }
425  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
std::ifstream m_mshFile
Input stream.
void ResetNodes(vector< NodeSharedPtr > &Nodes, Array< OneD, vector< int > > &ElementFaces, vector< vector< int > > &FaceNodes)
MeshSharedPtr m_mesh
Mesh object.
virtual void ProcessVertices()
Extract element vertices.
void GenElement3D(vector< NodeSharedPtr > &Nodes, int i, vector< int > &ElementFaces, vector< vector< int > > &FaceNodes, int ncomposite, bool DoOrient)
double NekDouble
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
void GenElement2D(vector< NodeSharedPtr > &Nodes, int i, vector< int > &ElementFaces, vector< vector< int > > &FaceNodes, int ncomposite)
void Nektar::Utilities::InputTec::ResetNodes ( vector< NodeSharedPtr > &  Nodes,
Array< OneD, vector< int > > &  ElementFaces,
vector< vector< int > > &  FaceNodes 
)
protected

Definition at line 433 of file InputStarTec.cpp.

References ASSERTL1, Nektar::iterator, Nektar::Utilities::PrismLineFaces(), and SortFaceNodes().

Referenced by ReadZone().

436  {
437  int i,j;
438  Array<OneD,int> NodeReordering(Vnodes.size(),-1);
439  int face1_map[3] = {0,1,4};
440  int face3_map[3] = {3,2,5};
441  int nodeid = 0;
442  map<int,bool> FacesRenumbered;
443 
444  // Determine Prism triangular face connectivity.
445  vector<vector<int> > FaceToPrisms(FaceNodes.size());
446  vector<vector<int> > PrismToFaces(ElementFaces.num_elements());
447  map<int,int> Prisms;
448  map<int,int>::iterator PrismIt;
449 
450  // generate map of prism-faces to prisms and prism to
451  // triangular-faces as well as ids of each prism.
452  for(i = 0; i < ElementFaces.num_elements(); ++i)
453  {
454  // Find Prism (and pyramids!).
455  if(ElementFaces[i].size() == 5)
456  {
457  vector<int> LocTriFaces;
458  // Find triangular faces
459  for(j = 0; j < ElementFaces[i].size(); ++j)
460  {
461  if(FaceNodes[ElementFaces[i][j]].size() == 3)
462  {
463  LocTriFaces.push_back(j);
464  }
465  }
466 
467  if(LocTriFaces.size() == 2) //prism otherwise a pyramid
468  {
469  Prisms[i] = i;
470 
471  PrismToFaces[i].push_back(ElementFaces[i][LocTriFaces[0]]);
472  PrismToFaces[i].push_back(ElementFaces[i][LocTriFaces[1]]);
473 
474  FaceToPrisms[ElementFaces[i][LocTriFaces[0]]].push_back(i);
475  FaceToPrisms[ElementFaces[i][LocTriFaces[1]]].push_back(i);
476  }
477  }
478  }
479 
480 
481  vector<bool> FacesDone(FaceNodes.size(),false);
482  vector<bool> PrismDone(ElementFaces.num_elements(),false);
483 
484  // For every prism find the list of prismatic elements
485  // that represent an aligned block of cells. Then renumber
486  // these blocks consecutativiesly
487  for(PrismIt = Prisms.begin(); PrismIt != Prisms.end(); ++PrismIt)
488  {
489  int elmtid = PrismIt->first;
490  map<int,int> facelist;
491  map<int,int>::iterator faceIt;
492 
493 
494  if(PrismDone[elmtid])
495  {
496  continue;
497  }
498  else
499  {
500  // Generate list of faces in list
501  PrismLineFaces(elmtid, facelist, FaceToPrisms,
502  PrismToFaces, PrismDone);
503 
504  // loop over faces and number vertices of associated prisms.
505  for(faceIt = facelist.begin(); faceIt != facelist.end(); faceIt++)
506  {
507  int faceid = faceIt->second;
508 
509  for(i = 0; i < FaceToPrisms[faceid].size(); ++i)
510  {
511  int prismid = FaceToPrisms[faceid][i];
512 
513  if((FacesDone[PrismToFaces[prismid][0]] == true)&&
514  (FacesDone[PrismToFaces[prismid][1]] == true))
515  {
516  continue;
517  }
518 
519  Array<OneD, int> Nodes = SortFaceNodes(Vnodes,
520  ElementFaces[prismid],
521  FaceNodes);
522 
523  if((FacesDone[PrismToFaces[prismid][0]] == false)&&
524  (FacesDone[PrismToFaces[prismid][1]] == false))
525  {
526  // number all nodes consecutive since
527  // already correctly re-arranged.
528  for(i = 0; i < 3; ++i)
529  {
530  if(NodeReordering[Nodes[face1_map[i]]] == -1)
531  {
532  NodeReordering[Nodes[face1_map[i]]] = nodeid++;
533  }
534  }
535 
536  for(i = 0; i < 3; ++i)
537  {
538  if(NodeReordering[Nodes[face3_map[i]]] == -1)
539  {
540  NodeReordering[Nodes[face3_map[i]]] = nodeid++;
541  }
542  }
543  }
544  else if((FacesDone[PrismToFaces[prismid][0]] == false)&&
545  (FacesDone[PrismToFaces[prismid][1]] == true))
546  {
547  // find node of highest id
548  int max_id1,max_id2;
549 
550  max_id1 = (NodeReordering[Nodes[face3_map[0]]] <
551  NodeReordering[Nodes[face3_map[1]]] )? 1:0;
552  max_id2 = (NodeReordering[Nodes[face3_map[max_id1]]] <
553  NodeReordering[Nodes[face3_map[2]]] )? 2:max_id1;
554 
555  // add numbering according to order of
556  int id0 = (max_id1== 1)? 0:1;
557 
558  if(NodeReordering[Nodes[face1_map[id0]]] == -1)
559  {
560  NodeReordering[Nodes[face1_map[id0]]] =
561  nodeid++;
562  }
563 
564  if(NodeReordering[Nodes[face1_map[max_id1]]] == -1)
565  {
566  NodeReordering[Nodes[face1_map[max_id1]]] =
567  nodeid++;
568  }
569 
570  if(NodeReordering[Nodes[face1_map[max_id2]]] == -1)
571  {
572  NodeReordering[Nodes[face1_map[max_id2]]] =
573  nodeid++;
574  }
575  }
576  else if((FacesDone[PrismToFaces[prismid][0]] == true)&&
577  (FacesDone[PrismToFaces[prismid][1]] == false))
578  {
579  // find node of highest id
580  int max_id1,max_id2;
581 
582 
583  max_id1 = (NodeReordering[Nodes[face1_map[0]]] <
584  NodeReordering[Nodes[face1_map[1]]] )? 1:0;
585  max_id2 = (NodeReordering[Nodes[face1_map[max_id1]]] <
586  NodeReordering[Nodes[face1_map[2]]] )? 2:max_id1;
587 
588  // add numbering according to order of
589  int id0 = (max_id1== 1)? 0:1;
590 
591 
592  if(NodeReordering[Nodes[face3_map[id0]]] == -1)
593  {
594  NodeReordering[Nodes[face3_map[id0]]] =
595  nodeid++;
596  }
597 
598  if(NodeReordering[Nodes[face3_map[max_id1]]] == -1)
599  {
600  NodeReordering[Nodes[face3_map[max_id1]]] =
601  nodeid++;
602  }
603 
604  if(NodeReordering[Nodes[face3_map[max_id2]]] == -1)
605  {
606  NodeReordering[Nodes[face3_map[max_id2]]] =
607  nodeid++;
608  }
609 
610  }
611  }
612  }
613  }
614  }
615 
616  // fill in any unset nodes at from other shapes
617  for(i = 0; i < NodeReordering.num_elements(); ++i)
618  {
619  if(NodeReordering[i] == -1)
620  {
621  NodeReordering[i] = nodeid++;
622  }
623  }
624 
625  ASSERTL1(nodeid == NodeReordering.num_elements(),"Have not renumbered all nodes");
626 
627  // Renumbering successfull so resort nodes and faceNodes;
628  for(i = 0; i < FaceNodes.size(); ++i)
629  {
630  for(j = 0; j < FaceNodes[i].size(); ++j)
631  {
632  FaceNodes[i][j] = NodeReordering[FaceNodes[i][j]];
633  }
634  }
635 
636  vector<NodeSharedPtr> save(Vnodes);
637  for(i = 0; i < Vnodes.size(); ++i)
638  {
639  Vnodes[NodeReordering[i]] = save[i];
640  Vnodes[NodeReordering[i]]->SetID(NodeReordering[i]);
641  }
642 
643  }
Array< OneD, int > SortFaceNodes(vector< NodeSharedPtr > &Nodes, vector< int > &ElementFaces, vector< vector< int > > &FaceNodes)
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
static void PrismLineFaces(int prismid, map< int, int > &facelist, vector< vector< int > > &FacesToPrisms, vector< vector< int > > &PrismsToFaces, vector< bool > &PrismDone)
Definition: InputStar.cpp:423
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:191
Array< OneD, int > Nektar::Utilities::InputTec::SortEdgeNodes ( vector< NodeSharedPtr > &  Nodes,
vector< int > &  ElementFaces,
vector< vector< int > > &  FaceNodes 
)
protected

Definition at line 778 of file InputStarTec.cpp.

References ASSERTL1, Nektar::Utilities::Node::curl(), and Nektar::Utilities::Node::dot().

Referenced by GenElement2D().

781  {
782  int i,j;
783  Array<OneD, int> returnval;
784 
785  if(ElementFaces.size() == 3) // Triangle
786  {
787  returnval = Array<OneD, int>(3);
788 
789  returnval[0] = FaceNodes[ElementFaces[0]][0];
790  returnval[1] = FaceNodes[ElementFaces[0]][1];
791 
792  // Find third node index;
793  for(i = 0; i < 2; ++i)
794  {
795  if((FaceNodes[ElementFaces[1]][i] != returnval[0])&&(FaceNodes[ElementFaces[1]][i] != returnval[1]))
796  {
797  returnval[2]= FaceNodes[ElementFaces[1]][i];
798  break;
799  }
800  }
801  }
802  else if(ElementFaces.size() == 4) // quadrilateral
803  {
804  returnval = Array<OneD, int>(4);
805 
806  int indx0 = FaceNodes[ElementFaces[0]][0];
807  int indx1 = FaceNodes[ElementFaces[0]][1];
808  int indx2,indx3;
809 
810  indx2 = indx3 = -1;
811  // Find third, fourth node index;
812  for(j = 1; j < 4; ++j)
813  {
814  for(i = 0; i < 2; ++i)
815  {
816  if((FaceNodes[ElementFaces[j]][i] != indx0)&&(FaceNodes[ElementFaces[j]][i] != indx1))
817  {
818  if(indx2 == -1)
819  {
820  indx2 = FaceNodes[ElementFaces[j]][i];
821  }
822  else if(indx2 != -1)
823  {
824  if(FaceNodes[ElementFaces[j]][i] != indx2)
825  {
826  indx3 = FaceNodes[ElementFaces[j]][i];
827  }
828  }
829  }
830  }
831  }
832 
833  ASSERTL1((indx2 != -1)&&(indx3 != -1),"Failed to find vertex 3 or 4");
834 
835 
836  // calculate 0-1,
837  Node a = *(Vnodes[indx1]) - *(Vnodes[indx0]);
838  // calculate 0-2,
839  Node b = *(Vnodes[indx2]) - *(Vnodes[indx0]);
840  Node acurlb = a.curl(b);
841 
842 
843  // calculate 2-1,
844  Node c = *(Vnodes[indx1]) - *(Vnodes[indx2]);
845  // calculate 3-2,
846  Node d = *(Vnodes[indx3]) - *(Vnodes[indx2]);
847  Node acurld = a.curl(d);
848 
849  NekDouble acurlb_dot_acurld = acurlb.dot(acurld);
850  if(acurlb_dot_acurld > 0.0)
851  {
852  returnval[0] = indx0;
853  returnval[1] = indx1;
854  returnval[2] = indx2;
855  returnval[3] = indx3;
856  }
857  else
858  {
859  returnval[0] = indx0;
860  returnval[1] = indx1;
861  returnval[2] = indx3;
862  returnval[3] = indx2;
863  }
864  }
865 
866  return returnval;
867  }
double NekDouble
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:191
Array< OneD, int > Nektar::Utilities::InputTec::SortFaceNodes ( vector< NodeSharedPtr > &  Nodes,
vector< int > &  ElementFaces,
vector< vector< int > > &  FaceNodes 
)
protected

Definition at line 869 of file InputStarTec.cpp.

References ASSERTL0, ASSERTL1, Nektar::Utilities::Node::curl(), and Nektar::Utilities::Node::dot().

Referenced by GenElement3D(), and ResetNodes().

872  {
873 
874  int i,j;
875  Array<OneD, int> returnval;
876 
877 
878  if(ElementFaces.size() == 4) // Tetrahedron
879  {
880  ASSERTL1(FaceNodes[ElementFaces[0]].size() == 3,"Face is not triangular");
881 
882  returnval = Array<OneD, int>(4);
883 
884  int indx0 = FaceNodes[ElementFaces[0]][0];
885  int indx1 = FaceNodes[ElementFaces[0]][1];
886  int indx2 = FaceNodes[ElementFaces[0]][2];
887  int indx3 = -1;
888 
889 
890  // calculate 0-1,
891  Node a = *(Vnodes[indx1]) - *(Vnodes[indx0]);
892  // calculate 0-2,
893  Node b = *(Vnodes[indx2]) - *(Vnodes[indx0]);
894 
895  // Find fourth node index;
896  ASSERTL1(FaceNodes[ElementFaces[1]].size() == 3,"Face is not triangular");
897  for(i = 0; i < 3; ++i)
898  {
899 
900  if((FaceNodes[ElementFaces[1]][i] != indx0)&&(FaceNodes[ElementFaces[1]][i] != indx1)&&(FaceNodes[ElementFaces[1]][i] != indx2))
901  {
902  indx3 = FaceNodes[ElementFaces[1]][i];
903  break;
904  }
905  }
906 
907  // calculate 0-3,
908  Node c = *(Vnodes[indx3]) - *(Vnodes[indx0]);
909  Node acurlb = a.curl(b);
910 
911  NekDouble acurlb_dotc = acurlb.dot(c);
912  if(acurlb_dotc < 0.0)
913  {
914  returnval[0] = indx0;
915  returnval[1] = indx1;
916  returnval[2] = indx2;
917  returnval[3] = indx3;
918  }
919  else
920  {
921  returnval[0] = indx1;
922  returnval[1] = indx0;
923  returnval[2] = indx2;
924  returnval[3] = indx3;
925  }
926  }
927  else if(ElementFaces.size() == 5) //prism or pyramid
928  {
929  int triface0, triface1;
930  int quadface0, quadface1, quadface2;
931  bool isPrism = true;
932 
933 
934  //find ids of tri faces and first quad face
935  triface0 = triface1 = -1;
936  quadface0 = quadface1 = quadface2 = -1;
937  for(i = 0; i < 5; ++i)
938  {
939  if(FaceNodes[ElementFaces[i]].size() == 3)
940  {
941  if(triface0 == -1)
942  {
943  triface0 = i;
944  }
945  else if (triface1 == -1)
946  {
947  triface1 = i;
948  }
949  else
950  {
951  isPrism = false;
952  }
953 
954  }
955 
956  if(FaceNodes[ElementFaces[i]].size() == 4)
957  {
958  if(quadface0 == -1)
959  {
960  quadface0 = i;
961  }
962  else if (quadface1 == -1)
963  {
964  quadface1 = i;
965  }
966  else if (quadface2 == -1)
967  {
968  quadface2 = i;
969  }
970  }
971  }
972 
973  if(isPrism) //Prism
974  {
975  returnval = Array<OneD, int>(6);
976  }
977  else //Pyramid
978  {
979  returnval = Array<OneD, int>(5);
980  }
981 
982  // find matching nodes between triface0 and triquad0
983  int indx0,indx1,indx2,indx3,indx4;
984 
985  indx0 = indx1 = indx2 = indx3 = indx4 = -1;
986  // Loop over all quad nodes and if they match any
987  // triangular nodes If they do set these to indx0 and
988  // indx1 and if not set it to indx2, indx3
989 
990  for(i = 0; i < 4; ++i)
991  {
992  for(j = 0; j < 3; ++j)
993  {
994  if(FaceNodes[ElementFaces[triface0]][j] ==
995  FaceNodes[ElementFaces[quadface0]][i])
996  {
997  break; // same node break
998  }
999  }
1000 
1001  if(j == 3) // Vertex not in quad face
1002  {
1003  if(indx2 == -1)
1004  {
1005  indx2 = FaceNodes[ElementFaces[quadface0]][i];
1006 
1007  }
1008  else if(indx3 == -1)
1009  {
1010  indx3 = FaceNodes[ElementFaces[quadface0]][i];
1011  }
1012  else
1013  {
1014  ASSERTL0(false,"More than two vertices do not match triangular face");
1015  }
1016  }
1017  else // if found match then set indx0,indx1;
1018  {
1019  if(indx0 == -1)
1020  {
1021  indx0 = FaceNodes[ElementFaces[quadface0]][i];
1022  }
1023  else
1024  {
1025  indx1 = FaceNodes[ElementFaces[quadface0]][i];
1026  }
1027  }
1028  }
1029 
1030  // Finally check for top vertex
1031  for(int i = 0; i < 3; ++i)
1032  {
1033  if((FaceNodes[ElementFaces[triface0]][i] != indx0)&&
1034  (FaceNodes[ElementFaces[triface0]][i] != indx1)&&
1035  (FaceNodes[ElementFaces[triface0]][i] != indx2))
1036  {
1037  indx4 = FaceNodes[ElementFaces[triface0]][i];
1038  break;
1039  }
1040  }
1041 
1042  // calculate 0-1,
1043  Node a = *(Vnodes[indx1]) - *(Vnodes[indx0]);
1044  // calculate 0-4,
1045  Node b = *(Vnodes[indx4]) - *(Vnodes[indx0]);
1046  // calculate 0-2,
1047  Node c = *(Vnodes[indx2]) - *(Vnodes[indx0]);
1048  Node acurlb = a.curl(b);
1049 
1050  NekDouble acurlb_dotc = acurlb.dot(c);
1051  if(acurlb_dotc < 0.0)
1052  {
1053  returnval[0] = indx0;
1054  returnval[1] = indx1;
1055  returnval[4] = indx4;
1056  }
1057  else
1058  {
1059  returnval[0] = indx1;
1060  returnval[1] = indx0;
1061  returnval[4] = indx4;
1062  }
1063 
1064  // check to see if two vertices are shared between one of the other faces
1065  // to define which is indx2 and indx3
1066 
1067  int cnt = 0;
1068  for(int i = 0; i < 4; ++i)
1069  {
1070  if((FaceNodes[ElementFaces[quadface1]][i] == returnval[1])||
1071  (FaceNodes[ElementFaces[quadface1]][i] == indx2))
1072  {
1073  cnt++;
1074  }
1075  }
1076 
1077  if(cnt == 2) // have two matching vertices
1078  {
1079  returnval[2] = indx2;
1080  returnval[3] = indx3;
1081  }
1082  else
1083  {
1084  cnt = 0;
1085  for(int i = 0; i < 4; ++i)
1086  {
1087  if((FaceNodes[ElementFaces[quadface2]][i] == returnval[1])||
1088  (FaceNodes[ElementFaces[quadface2]][i] == indx2))
1089  {
1090  cnt++;
1091  }
1092  }
1093 
1094  if(cnt != 2) // neither of the other faces has two matching nodes so reverse
1095  {
1096  returnval[2] = indx3;
1097  returnval[3] = indx2;
1098  }
1099  else // have two matching vertices
1100  {
1101  returnval[2] = indx2;
1102  returnval[3] = indx3;
1103  }
1104  }
1105 
1106 
1107  if(isPrism == true)
1108  {
1109  // finally need to find last vertex from second triangular face.
1110  for(int i = 0; i < 3; ++i)
1111  {
1112  if((FaceNodes[ElementFaces[triface1]][i] != indx2)&&
1113  (FaceNodes[ElementFaces[triface1]][i] != indx3)&&
1114  (FaceNodes[ElementFaces[triface1]][i] != indx3))
1115  {
1116  returnval[5] = FaceNodes[ElementFaces[triface1]][i];
1117  break;
1118  }
1119  }
1120  }
1121 
1122  }
1123  else
1124  {
1125  ASSERTL0(false,"SortFaceNodes not set up for this number of faces");
1126  }
1127 
1128  return returnval;
1129  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
double NekDouble
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:191

Member Data Documentation

ModuleKey Nektar::Utilities::InputTec::className
static
Initial value:
=
"Reads Tecplot polyhedron ascii format converted from Star CCM (.dat).")

Definition at line 54 of file InputStarTec.h.