53 Loki::SingleThreaded> Type;
54 return Type::Instance();
80 string fname =
m_config[
"infile"].as<
string>();
84 cerr <<
"Error opening file: " << fname << endl;
94 string fname =
m_config[
"outfile"].as<
string>();
98 cerr <<
"Error opening file: " << fname << endl;
113 vector<ElementSharedPtr> &elmt =
m_mesh->m_element[
m_mesh->m_expDim];
115 m_mesh->m_vertexSet.clear();
117 for (
int i = 0, vid = 0; i < elmt.size(); ++i)
119 for (
int j = 0; j < elmt[i]->GetVertexCount(); ++j)
121 pair<NodeSet::iterator,bool> testIns =
122 m_mesh->m_vertexSet.insert(elmt[i]->GetVertex(j));
126 (*(testIns.first))->m_id = vid++;
130 elmt[i]->SetVertex(j,*testIns.first);
153 if (
m_mesh->m_expDim < 2)
return;
157 vector<ElementSharedPtr> &elmt =
m_mesh->m_element[
m_mesh->m_expDim];
159 m_mesh->m_edgeSet.clear();
162 for (
int i = 0, eid = 0; i < elmt.size(); ++i)
164 for (
int j = 0; j < elmt[i]->GetEdgeCount(); ++j)
166 pair<EdgeSet::iterator,bool> testIns;
168 testIns =
m_mesh->m_edgeSet.insert(ed);
172 (*(testIns.first))->m_id = eid++;
177 elmt[i]->SetEdge(j, e2);
178 if (e2->m_edgeNodes.size() == 0 &&
179 ed->m_edgeNodes.size() > 0)
181 e2->m_curveType = ed->m_curveType;
182 e2->m_edgeNodes = ed->m_edgeNodes;
185 if (e2->m_n1->m_id != ed->m_n1->m_id)
187 reverse(e2->m_edgeNodes.begin(),
188 e2->m_edgeNodes.end());
193 (*(testIns.first))->m_elLink.push_back(
194 pair<ElementSharedPtr,int>(elmt[i],j));
201 for (
int i = 0; i <
m_mesh->m_element[1].size(); ++i)
205 vector<NodeSharedPtr> edgeNodes;
207 new Edge(v0, v1, edgeNodes,
208 m_mesh->m_element[1][i]->GetConf().m_edgeCurveType));
210 if (it ==
m_mesh->m_edgeSet.end())
212 cerr <<
"Cannot find corresponding element edge for "
213 <<
"1D element " << i << endl;
216 m_mesh->m_element[1][i]->SetEdgeLink(*it);
219 pair<ElementSharedPtr, int> eMap = (*it)->m_elLink.at(0);
220 eMap.first->SetBoundaryLink(eMap.second, i);
223 if ((*it)->m_edgeNodes.size() > 0)
226 if (edge->GetVertex(0) == (*it)->m_n1)
228 edge->SetVolumeNodes((*it)->m_edgeNodes);
252 if (
m_mesh->m_expDim < 3)
return;
256 vector<ElementSharedPtr> &elmt =
m_mesh->m_element[
m_mesh->m_expDim];
258 m_mesh->m_faceSet.clear();
261 for (
int i = 0, fid = 0; i < elmt.size(); ++i)
263 for (
int j = 0; j < elmt[i]->GetFaceCount(); ++j)
265 pair<FaceSet::iterator,bool> testIns;
266 testIns =
m_mesh->m_faceSet.insert(elmt[i]->GetFace(j));
270 (*(testIns.first))->m_id = fid++;
274 elmt[i]->SetFace(j,*testIns.first);
276 (*(testIns.first))->m_elLink.push_back(
277 pair<ElementSharedPtr,int>(elmt[i],j));
284 for (
int i = 0; i <
m_mesh->m_element[2].size(); ++i)
286 vector<NodeSharedPtr> vertices =
m_mesh->m_element[2][i]->GetVertexList();
287 vector<NodeSharedPtr> faceNodes;
288 vector<EdgeSharedPtr> edgeList =
m_mesh->m_element[2][i]->GetEdgeList();
290 new Face(vertices, faceNodes, edgeList,
291 m_mesh->m_element[2][i]->GetConf().m_faceCurveType));
293 if (it ==
m_mesh->m_faceSet.end())
295 cout <<
"Cannot find corresponding element face for 2D "
296 <<
"element " << i << endl;
299 m_mesh->m_element[2][i]->SetFaceLink(*it);
302 pair<ElementSharedPtr, int> eMap = (*it)->m_elLink.at(0);
303 eMap.first->SetBoundaryLink(eMap.second, i);
318 for (
int i = 0; i <
m_mesh->m_element[
m_mesh->m_expDim].size(); ++i)
335 m_mesh->m_composite.clear();
340 for (
int d = 0; d <=
m_mesh->m_expDim; ++d)
342 vector<ElementSharedPtr> &elmt =
m_mesh->m_element[d];
344 for (
int i = 0; i < elmt.size(); ++i)
347 unsigned int tagid = elmt[i]->GetTagList()[0];
349 it =
m_mesh->m_composite.find(tagid);
351 if (it ==
m_mesh->m_composite.end())
355 pair<CompositeMap::iterator, bool> testIns;
357 tmp->m_tag = elmt[i]->GetTag();
358 if(
m_mesh->m_faceLabels.count(tmp->m_id) != 0)
360 tmp->m_label =
m_mesh->m_faceLabels[tmp->m_id];
363 testIns =
m_mesh->m_composite.insert(
364 pair<unsigned int, CompositeSharedPtr>(tagid,tmp));
368 if (elmt[i]->GetTag() != it->second->m_tag)
370 cout <<
"Different types of elements in same composite!" << endl;
371 cout <<
" -> Composite uses " << it->second->m_tag << endl;
372 cout <<
" -> Element uses " << elmt[i]->GetTag() << endl;
373 cout <<
"Have you specified physical volumes and surfaces?" << endl;
375 it->second->m_items.push_back(elmt[i]);
417 set<int> prismsDone, tetsDone;
421 for (i = 0; i <
m_mesh->m_element[3].size(); ++i)
427 prismsDone.insert(i);
437 for (it =
m_mesh->m_vertexSet.begin(); it !=
m_mesh->m_vertexSet.end(); ++it)
444 int prismTris[2][3] = {{0,1,4}, {3,2,5}};
447 bool warnCurvature =
false;
451 boost::unordered_set<int> facesDone;
455 while (prismsDone.size() > 0)
457 vector<ElementSharedPtr> line;
461 PrismLines(*prismsDone.begin(), perFaces, prismsDone, line);
465 for (i = 0; i < line.size(); ++i)
468 vector<int> tags = line[i]->GetTagList();
469 vector<NodeSharedPtr> nodes = line[i]->GetVertexList();
474 line[i]->GetFace(1), line[i]->GetFace(3)
477 fIt[0] = facesDone.find(f[0]->m_id);
478 fIt[1] = facesDone.find(f[1]->m_id);
482 for (j = 0; j < 2; ++j)
484 pIt = perFaces.find(f[j]->m_id);
486 if (pIt == perFaces.end())
491 fIt2 = facesDone.find(pIt->second.first->m_id);
493 if (fIt[j] == facesDone.end() &&
494 fIt2 != facesDone.end())
500 if (fIt[0] != facesDone.end() &&
501 fIt[1] != facesDone.end())
505 ASSERTL0(
false,
"Renumbering error!");
507 else if (fIt[0] == facesDone.end() &&
508 fIt[1] == facesDone.end())
511 for (j = 0; j < 2; ++j)
513 for (k = 0; k < 3; ++k)
523 facesDone.insert(f[0]->m_id);
524 facesDone.insert(f[1]->m_id);
530 int t = fIt[0] == facesDone.end() ? 0 : 1;
532 ASSERTL1(fIt[o] != facesDone.end(),
"Renumbering error");
538 nodes[prismTris[o][0]]->m_id,
539 nodes[prismTris[o][1]]->m_id,
540 nodes[prismTris[o][2]]->m_id
542 int tmp2[3] = {0,1,2};
544 if (tmp1[0] > tmp1[1])
546 swap(tmp1[0], tmp1[1]);
547 swap(tmp2[0], tmp2[1]);
550 if (tmp1[1] > tmp1[2])
552 swap(tmp1[1], tmp1[2]);
553 swap(tmp2[1], tmp2[2]);
556 if (tmp1[0] > tmp1[2])
558 swap(tmp1[0], tmp1[2]);
559 swap(tmp2[0], tmp2[2]);
563 for (j = 0; j < 3; ++j)
572 facesDone.insert(f[t]->m_id);
575 for (j = 0; j < 6; ++j)
577 ASSERTL1(nodes[j]->m_id != -1,
"Renumbering error");
587 for (j = 0; j < 9; ++j)
590 for (k = 0; k < 9; ++k)
593 if (e1->m_n1 == e2->m_n1 && e1->m_n2 == e2->m_n2)
595 e2->m_edgeNodes = e1->m_edgeNodes;
597 else if (e1->m_n1 == e2->m_n1 && e1->m_n2 == e2->m_n2)
599 e2->m_edgeNodes = e1->m_edgeNodes;
600 std::reverse(e2->m_edgeNodes.begin(),
601 e2->m_edgeNodes.end());
609 for (j = 0; j < 5; ++j)
611 if (line[i]->GetFace(j)->m_faceNodes.size() > 0)
613 warnCurvature =
true;
620 m_mesh->m_element[3][line[i]->GetId()] = el;
626 cerr <<
"[ReorderPrisms] WARNING: Face curvature detected in "
627 <<
"some prisms; this will be ignored in further module "
633 for (pIt = perFaces.begin(); pIt != perFaces.end(); ++pIt)
637 vector<int> perVerts = pIt->second.second;
638 int nVerts = perVerts.size();
641 for (j = 0; j < nVerts; ++j)
646 if (n1->m_id == -1 && n2->m_id == -1)
651 else if (n1->m_id != -1 && n2->m_id != -1)
657 ASSERTL0(
false,
"Periodic face renumbering error");
664 for (it2 = tetsDone.begin(); it2 != tetsDone.end(); ++it2)
667 vector<NodeSharedPtr> nodes = el->GetVertexList();
668 vector<int> tags = el->GetTagList();
670 for (i = 0; i < 4; ++i)
672 if (nodes[i]->m_id == -1)
674 nodes[i]->m_id = nodeId++;
685 for (it =
m_mesh->m_vertexSet.begin(); it !=
m_mesh->m_vertexSet.end(); ++it)
687 if ((*it)->m_id == -1)
689 (*it)->m_id = nodeId++;
700 set<int> &prismsDone,
701 vector<ElementSharedPtr> &line)
707 if (it == prismsDone.end())
713 prismsDone.erase(it);
714 line.push_back(
m_mesh->m_element[3][prism]);
717 for (i = 1; i <= 3; i += 2)
723 it2 = perFaces.find(f->m_id);
725 if (it2 != perFaces.end())
727 int id2 = it2->second.first->m_id;
728 nextId = it2->second.first->m_elLink[0].first->GetId();
731 PrismLines(nextId, perFaces, prismsDone, line);
735 if (f->m_elLink.size() == 1)
740 nextId = f->m_elLink[0].first->GetId();
741 if (nextId ==
m_mesh->m_element[3][prism]->GetId())
743 nextId = f->m_elLink[1].first->GetId();
746 PrismLines(nextId, perFaces, prismsDone, line);
758 cerr <<
"WARNING: Unrecognised config option " << key
759 <<
", proceeding anyway." << endl;
762 it->second.beenSet =
true;
764 if (it->second.isBool)
766 it->second.value =
"1";
770 it->second.value = val;
783 cerr <<
"No configuration options for this module." << endl;
789 cerr << setw(10) << it->first <<
": " << it->second.desc
804 if (!it->second.beenSet)
806 it->second.value = it->second.defValue;
818 cerr <<
"Expansion dimension is " <<
m_mesh->m_expDim << endl;
819 cerr <<
"Space dimension is " <<
m_mesh->m_spaceDim << endl;
820 cerr <<
"Read " <<
m_mesh->m_node.size() <<
" nodes" << endl;
821 cerr <<
"Read " <<
m_mesh->GetNumElements() <<
" "
822 <<
m_mesh->m_expDim <<
"-D elements" << endl;
823 cerr <<
"Read " <<
m_mesh->GetNumBndryElements()
824 <<
" boundary elements" << endl;
LibUtilities::NekFactory< ModuleKey, Module, FieldSharedPtr > ModuleFactory
#define ASSERTL0(condition, msg)
pair< ModuleType, string > ModuleKey
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.
Represents an edge which joins two points.
boost::shared_ptr< Edge > EdgeSharedPtr
Shared pointer to an edge.
map< string, ConfigOption > m_config
List of configuration values.
MeshSharedPtr m_mesh
Mesh object.
boost::shared_ptr< Face > FaceSharedPtr
Shared pointer to a face.
void RegisterConfig(string key, string value)
Register a configuration option with a module.
boost::shared_ptr< Node > NodeSharedPtr
Shared pointer to a Node.
boost::shared_ptr< Composite > CompositeSharedPtr
Shared pointer to a composite.
virtual void ProcessEdges(bool ReprocessEdges=true)
Extract element edges.
boost::shared_ptr< Element > ElementSharedPtr
Shared pointer to an element.
std::ostream & operator<<(std::ostream &os, const BasisKey &rhs)
virtual void ProcessVertices()
Extract element vertices.
virtual void ProcessElements()
Generate element IDs.
OutputModule(FieldSharedPtr p_f)
map< int, pair< FaceSharedPtr, vector< int > > > PerMap
boost::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
void PrismLines(int prism, PerMap &perFaces, set< int > &prismsDone, vector< ElementSharedPtr > &line)
Basic information about an element.
virtual void ProcessComposites()
Generate composites.
boost::shared_ptr< GeometryVector > Composite
void PrintConfig()
Print out all configuration options for a module.
Represents a command-line configuration option.
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
virtual void ProcessFaces(bool ReprocessFaces=true)
Extract element faces.
void ReorderPrisms(PerMap &perFaces)
Reorder node IDs so that prisms and tetrahedra are aligned correctly.
std::ofstream m_mshFile
Output stream.
Represents a face comprised of three or more edges.
void OpenStream()
Open a file for output.
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
void SetDefaults()
Sets default configuration options for those which have not been set.
ElementFactory & GetElementFactory()
ModuleFactory & GetModuleFactory()
const char *const ModuleTypeMap[]