59 #include <boost/algorithm/string.hpp>
60 #include <boost/graph/adjacency_list.hpp>
61 #include <boost/graph/adjacency_iterator.hpp>
62 #include <boost/graph/detail/edge.hpp>
63 #include <boost/format.hpp>
67 namespace LibUtilities
74 Loki::SingleThreaded> Type;
75 return Type::Instance();
79 m_isCompressed(false),
82 m_comm(pSession->GetComm()),
83 m_weightingRequired(false)
99 "Too few elements for this many processes.");
113 TiXmlDeclaration * decl =
new TiXmlDeclaration(
"1.0",
"utf-8",
"");
114 vNew.LinkEndChild(decl);
116 TiXmlElement* vElmtNektar;
117 vElmtNektar =
new TiXmlElement(
"NEKTAR");
119 int rank =
m_comm->GetRowComm()->GetRank();
122 vNew.LinkEndChild(vElmtNektar);
124 std::string dirname = pSession->GetSessionName() +
"_xml";
125 fs::path pdirname(dirname);
127 boost::format pad(
"P%1$07d.xml");
129 fs::path pFilename(pad.str());
131 if(!fs::is_directory(dirname))
133 fs::create_directory(dirname);
136 fs::path fullpath = pdirname / pFilename;
145 TiXmlDeclaration * decl =
new TiXmlDeclaration(
"1.0",
"utf-8",
"");
146 vNew.LinkEndChild(decl);
148 TiXmlElement* vElmtNektar;
149 vElmtNektar =
new TiXmlElement(
"NEKTAR");
153 vNew.LinkEndChild(vElmtNektar);
155 std::string dirname = pSession->GetSessionName() +
"_xml";
156 fs::path pdirname(dirname);
158 boost::format pad(
"P%1$07d.xml");
160 fs::path pFilename(pad.str());
162 fs::path fullpath = pdirname / pFilename;
164 if(!fs::is_directory(dirname))
166 fs::create_directory(dirname);
179 composites[it->first] = it->second.list;
192 TiXmlElement *expansionTypes = pSession->GetElement(
"Nektar/Expansions");
195 TiXmlElement *expansion = expansionTypes->FirstChildElement();
196 std::string expType = expansion->Value();
201 ASSERTL0(
false,
"Expansion type not defined or not supported at the moment");
213 std::vector<unsigned int> composite;
214 std::vector<unsigned int> nummodes;
215 std::vector<std::string> fieldName;
217 const char *nModesStr = expansion->Attribute(
"NUMMODES");
218 ASSERTL0(nModesStr,
"NUMMODES was not defined in EXPANSION section of input");
219 std::string numModesStr = nModesStr;
221 ASSERTL0(valid,
"Unable to correctly parse the number of modes.");
223 if (nummodes.size() == 1)
225 for (
int i = 1; i <
m_dim; i++)
227 nummodes.push_back( nummodes[0] );
230 ASSERTL0(nummodes.size() ==
m_dim,
"Number of modes should match mesh dimension");
233 const char *fStr = expansion->Attribute(
"FIELDS");
236 std::string fieldStr = fStr;
238 ASSERTL0(valid,
"Unable to correctly parse the field string in ExpansionTypes.");
240 for (
int i = 0; i < fieldName.size(); ++i)
252 fieldName.push_back(
"DefaultVar");
258 "Omitting field variables and explicitly listing " \
259 "them in different ExpansionTypes is wrong practise");
266 std::string compositeStr = expansion->Attribute(
"COMPOSITE");
267 ASSERTL0(compositeStr.length() > 3,
"COMPOSITE must be specified in expansion definition");
268 int beg = compositeStr.find_first_of(
"[");
269 int end = compositeStr.find_first_of(
"]");
270 std::string compositeListStr = compositeStr.substr(beg+1,end-beg-1);
272 ASSERTL0(parseGood && !composite.empty(),
273 (std::string(
"Unable to read composite index range: ") + compositeListStr).c_str());
277 for (
int i = 0; i < composite.size(); ++i)
279 for (
int j = 0; j < fieldName.size(); j++)
285 expansion = expansion->NextSiblingElement(
"E");
295 TiXmlElement *vGeometry, *vSubElement;
297 vGeometry = pSession->GetElement(
"Nektar/Geometry");
298 m_dim = atoi(vGeometry->Attribute(
"DIM"));
301 vSubElement = pSession->GetElement(
"Nektar/Geometry/Vertex");
304 std::string attr[] = {
"XSCALE",
"YSCALE",
"ZSCALE",
305 "XMOVE",
"YMOVE",
"ZMOVE" };
306 for (
int i = 0; i < 6; ++i)
308 const char *val = vSubElement->Attribute(attr[i].c_str());
316 std::string IsCompressed;
317 vSubElement->QueryStringAttribute(
"COMPRESSED",&IsCompressed);
319 if(IsCompressed.size())
321 ASSERTL0(boost::iequals(IsCompressed,
323 "Compressed formats do not match. Expected :"
325 +
"but got "+ std::string(IsCompressed));
330 TiXmlNode* vertexChild = vSubElement->FirstChild();
331 ASSERTL0(vertexChild,
"Unable to extract the data "
332 "from the compressed vertex tag.");
334 std::string vertexStr;
335 if (vertexChild->Type() == TiXmlNode::TINYXML_TEXT)
337 vertexStr += vertexChild->ToText()->ValueStr();
340 std::vector<MeshVertex> vertData;
343 for(
int i = 0; i < vertData.size(); ++i)
350 x = vSubElement->FirstChildElement();
354 TiXmlAttribute* y = x->FirstAttribute();
355 ASSERTL0(y,
"Failed to get attribute.");
357 v.
id = y->IntValue();
358 std::vector<std::string> vCoords;
359 std::string vCoordStr = x->FirstChild()->ToText()->Value();
360 boost::split(vCoords, vCoordStr, boost::is_any_of(
"\t "));
361 v.
x = atof(vCoords[0].c_str());
362 v.
y = atof(vCoords[1].c_str());
363 v.
z = atof(vCoords[2].c_str());
365 x = x->NextSiblingElement();
372 vSubElement = pSession->GetElement(
"Nektar/Geometry/Edge");
373 ASSERTL0(vSubElement,
"Cannot read edges");
376 std::string IsCompressed;
377 vSubElement->QueryStringAttribute(
"COMPRESSED",&IsCompressed);
379 if(IsCompressed.size())
381 ASSERTL0(boost::iequals(IsCompressed,
383 "Compressed formats do not match. Expected :"
386 + boost::lexical_cast<std::string>(IsCompressed));
391 TiXmlNode* edgeChild = vSubElement->FirstChild();
393 "Unable to extract the data from the compressed "
398 if (edgeChild->Type() == TiXmlNode::TINYXML_TEXT)
400 edgeStr += edgeChild->ToText()->ValueStr();
403 std::vector<MeshEdge> edgeData;
406 for(
int i = 0; i < edgeData.size(); ++i)
409 e.
id = edgeData[i].id;
410 e.
list.push_back(edgeData[i].v0);
411 e.
list.push_back(edgeData[i].v1);
417 x = vSubElement->FirstChildElement();
421 TiXmlAttribute* y = x->FirstAttribute();
422 ASSERTL0(y,
"Failed to get attribute.");
424 e.
id = y->IntValue();
426 std::vector<std::string> vVertices;
427 std::string vVerticesString = x->FirstChild()->ToText()->Value();
428 boost::split(vVertices, vVerticesString, boost::is_any_of(
"\t "));
429 e.
list.push_back(atoi(vVertices[0].c_str()));
430 e.
list.push_back(atoi(vVertices[1].c_str()));
432 x = x->NextSiblingElement();
440 vSubElement = pSession->GetElement(
"Nektar/Geometry/Face");
441 ASSERTL0(vSubElement,
"Cannot read faces.");
442 x = vSubElement->FirstChildElement();
447 std::string IsCompressed;
448 x->QueryStringAttribute(
"COMPRESSED",&IsCompressed);
450 if(IsCompressed.size())
452 ASSERTL0(boost::iequals(IsCompressed,
454 "Compressed formats do not match. Expected :"
457 + boost::lexical_cast<std::string>(
462 TiXmlNode* faceChild = x->FirstChild();
463 ASSERTL0(faceChild,
"Unable to extract the data from "
464 "the compressed edge tag.");
467 if (faceChild->Type() == TiXmlNode::TINYXML_TEXT)
469 faceStr += faceChild->ToText()->ValueStr();
473 const std::string val= x->Value();
475 if(boost::iequals(val,
"T"))
477 std::vector<MeshTri> faceData;
481 for(
int i= 0; i < faceData.size(); ++i)
485 f.
id = faceData[i].id;
487 for (
int j = 0; j < 3; ++j)
489 f.
list.push_back(faceData[i].e[j]);
494 else if (boost::iequals(val,
"Q"))
496 std::vector<MeshQuad> faceData;
500 for(
int i= 0; i < faceData.size(); ++i)
504 f.
id = faceData[i].id;
506 for (
int j = 0; j < 4; ++j)
508 f.
list.push_back(faceData[i].e[j]);
515 ASSERTL0(
false,
"Unrecognised face tag");
520 TiXmlAttribute* y = x->FirstAttribute();
521 ASSERTL0(y,
"Failed to get attribute.");
523 f.
id = y->IntValue();
524 f.
type = x->Value()[0];
525 std::vector<std::string> vEdges;
526 std::string vEdgeStr = x->FirstChild()->ToText()->Value();
527 boost::split(vEdges, vEdgeStr, boost::is_any_of(
"\t "));
528 for (
int i = 0; i < vEdges.size(); ++i)
530 f.
list.push_back(atoi(vEdges[i].c_str()));
534 x = x->NextSiblingElement();
539 vSubElement = pSession->GetElement(
"Nektar/Geometry/Element");
540 ASSERTL0(vSubElement,
"Cannot read elements.");
541 x = vSubElement->FirstChildElement();
545 std::string IsCompressed;
546 x->QueryStringAttribute(
"COMPRESSED",&IsCompressed);
548 if(IsCompressed.size())
550 ASSERTL0(boost::iequals(IsCompressed,
552 "Compressed formats do not match. Expected :"
555 + boost::lexical_cast<std::string>(IsCompressed));
559 TiXmlNode* child = x->FirstChild();
560 ASSERTL0(child,
"Unable to extract the data from the "
561 "compressed element tag.");
564 if (child->Type() == TiXmlNode::TINYXML_TEXT)
566 elmtStr += child->ToText()->ValueStr();
570 const std::string val= x->Value();
576 std::vector<MeshEdge> data;
579 for(
int i= 0; i < data.size(); ++i)
584 e.
list.push_back(data[i].v0);
585 e.
list.push_back(data[i].v1);
592 std::vector<MeshTri> data;
595 for(
int i= 0; i < data.size(); ++i)
600 for (
int j = 0; j < 3; ++j)
602 f.
list.push_back(data[i].e[j]);
610 std::vector<MeshQuad> data;
613 for(
int i= 0; i < data.size(); ++i)
618 for (
int j = 0; j < 4; ++j)
620 f.
list.push_back(data[i].e[j]);
628 std::vector<MeshTet> data;
631 for(
int i= 0; i < data.size(); ++i)
636 for (
int j = 0; j < 4; ++j)
638 f.
list.push_back(data[i].f[j]);
646 std::vector<MeshPyr> data;
649 for(
int i= 0; i < data.size(); ++i)
654 for (
int j = 0; j < 5; ++j)
656 f.
list.push_back(data[i].f[j]);
664 std::vector<MeshPrism> data;
667 for(
int i= 0; i < data.size(); ++i)
672 for (
int j = 0; j < 5; ++j)
674 f.
list.push_back(data[i].f[j]);
682 std::vector<MeshHex> data;
685 for(
int i= 0; i < data.size(); ++i)
690 for (
int j = 0; j < 6; ++j)
692 f.
list.push_back(data[i].f[j]);
699 ASSERTL0(
false,
"Unrecognised element tag");
704 TiXmlAttribute* y = x->FirstAttribute();
705 ASSERTL0(y,
"Failed to get attribute.");
707 e.
id = y->IntValue();
708 std::vector<std::string> vItems;
709 std::string vItemStr = x->FirstChild()->ToText()->Value();
710 boost::split(vItems, vItemStr, boost::is_any_of(
"\t "));
711 for (
int i = 0; i < vItems.size(); ++i)
713 e.
list.push_back(atoi(vItems[i].c_str()));
715 e.
type = x->Value()[0];
718 x = x->NextSiblingElement();
722 if (pSession->DefinesElement(
"Nektar/Geometry/Curved"))
724 vSubElement = pSession->GetElement(
"Nektar/Geometry/Curved");
727 std::string IsCompressed;
728 vSubElement->QueryStringAttribute(
"COMPRESSED",&IsCompressed);
730 x = vSubElement->FirstChildElement();
733 if(IsCompressed.size())
735 ASSERTL0(boost::iequals(IsCompressed,
737 "Compressed formats do not match. Expected :"
740 + boost::lexical_cast<std::string>(
745 const char *entitytype = x->Value();
763 if(boost::iequals(entitytype,
"E")||
764 boost::iequals(entitytype,
"F"))
768 TiXmlNode* child = x->FirstChild();
770 if (child->Type() == TiXmlNode::TINYXML_TEXT)
772 elmtStr = child->ToText()->ValueStr();
775 std::vector<MeshCurvedInfo> cinfo;
780 for(
int i = 0; i < cinfo.size(); ++i)
788 c.
ptid = cinfo[i].ptid;
794 else if(boost::iequals(entitytype,
"DATAPOINTS"))
800 "Failed to get ID from PTS section");
806 TiXmlElement* DataIdx =
807 x->FirstChildElement(
"INDEX");
809 "Cannot read data index tag in compressed "
812 TiXmlNode* child = DataIdx->FirstChild();
813 if (child->Type() == TiXmlNode::TINYXML_TEXT)
815 elmtStr = child->ToText()->ValueStr();
821 TiXmlElement* DataPts
822 = x->FirstChildElement(
"POINTS");
824 "Cannot read data pts tag in compressed "
827 child = DataPts->FirstChild();
828 if (child->Type() == TiXmlNode::TINYXML_TEXT)
830 elmtStr = child->ToText()->ValueStr();
840 ASSERTL0(
false,
"Unknown tag in curved section");
843 x = x->NextSiblingElement();
849 "Failed to get attribute ID");
850 c.
type = std::string(x->Attribute(
"TYPE"));
852 "Failed to get attribute TYPE");
854 "Failed to get attribute NUMPOINTS");
855 c.
data = x->FirstChild()->ToText()->Value();
861 "Failed to get attribute EDGEID");
866 "Failed to get attribute FACEID");
870 ASSERTL0(
false,
"Unknown curve type.");
874 x = x->NextSiblingElement();
880 vSubElement = pSession->GetElement(
"Nektar/Geometry/Composite");
881 ASSERTL0(vSubElement,
"Cannot read composites.");
882 x = vSubElement->FirstChildElement();
885 TiXmlAttribute* y = x->FirstAttribute();
886 ASSERTL0(y,
"Failed to get attribute.");
888 c.
id = y->IntValue();
889 std::string vSeqStr = x->FirstChild()->ToText()->Value();
891 std::string::size_type indxBeg = vSeqStr.find_first_of(
'[') + 1;
892 std::string::size_type indxEnd = vSeqStr.find_last_of(
']') - 1;
893 vSeqStr = vSeqStr.substr(indxBeg, indxEnd - indxBeg + 1);
895 std::vector<unsigned int> vSeq;
898 for (
int i = 0; i < vSeq.size(); ++i)
900 c.
list.push_back(vSeq[i]);
903 x = x->NextSiblingElement();
907 vSubElement = pSession->GetElement(
"Nektar/Geometry/Domain");
908 ASSERTL0(vSubElement,
"Cannot read domain");
909 std::string vSeqStr = vSubElement->FirstChild()->ToText()->Value();
910 std::string::size_type indxBeg = vSeqStr.find_first_of(
'[') + 1;
911 std::string::size_type indxEnd = vSeqStr.find_last_of(
']') - 1;
912 vSeqStr = vSeqStr.substr(indxBeg, indxEnd - indxBeg + 1);
918 int nElmt = boost::num_vertices(
m_mesh);
921 out <<
"# Partition information:" << std::endl;
922 out <<
"# No. elements : " << nElmt << std::endl;
923 out <<
"# No. partitions: " << nPart << std::endl;
924 out <<
"# ID nElmt nLocDof nBndDof" << std::endl;
927 std::vector<int> partElmtCount(nPart, 0);
928 std::vector<int> partLocCount (nPart, 0);
929 std::vector<int> partBndCount (nPart, 0);
931 std::map<int, int> elmtSizes;
932 std::map<int, int> elmtBndSizes;
934 for (
unsigned int i = 0; i <
m_domain.size(); ++i)
942 " Number of directional" \
943 " modes in expansion spec for composite id = " +
944 boost::lexical_cast<std::string>(cId) +
946 boost::lexical_cast<std::string>(it->first) +
947 " does not correspond to mesh dimension");
949 int na = it->second[0];
950 int nb = it->second[1];
965 elmtSizes[elid] = weight;
966 elmtBndSizes[elid] = bndWeight;
971 for (boost::tie(vertit, vertit_end) = boost::vertices(
m_mesh);
972 vertit != vertit_end; ++vertit)
974 int partId =
m_mesh[*vertit].partition;
975 partElmtCount[partId]++;
976 partLocCount [partId] += elmtSizes[
m_mesh[*vertit].id];
977 partBndCount [partId] += elmtBndSizes[m_mesh[*vertit].id];
980 for (
int i = 0; i < nPart; ++i)
982 out << i <<
" " << partElmtCount[i] <<
" " << partLocCount[i] <<
" " << partBndCount[i] << std::endl;
988 if (!pSession->DefinesElement(
"Nektar/Conditions/SolverInfo"))
995 TiXmlElement* solverInfoElement =
996 pSession->GetElement(
"Nektar/Conditions/SolverInfo");
998 TiXmlElement* solverInfo =
999 solverInfoElement->FirstChildElement(
"I");
1000 ASSERTL0(solverInfo,
"Cannot read SolverInfo tags");
1005 ASSERTL0(solverInfo->Attribute(
"PROPERTY"),
1006 "Missing PROPERTY attribute in solver info "
1008 std::string solverProperty =
1009 solverInfo->Attribute(
"PROPERTY");
1011 "Solver info properties must have a non-empty "
1014 std::string solverPropertyUpper =
1015 boost::to_upper_copy(solverProperty);
1019 ASSERTL0(solverInfo->Attribute(
"VALUE"),
1020 "Missing VALUE attribute in solver info section. ");
1021 std::string solverValue = solverInfo->Attribute(
"VALUE");
1023 "Solver info properties must have a non-empty value");
1025 std::string propertyValueUpper =
1026 boost::to_upper_copy(solverValue);
1028 if (solverPropertyUpper ==
"WEIGHTPARTITIONS")
1030 if (propertyValueUpper !=
"UNIFORM")
1036 solverInfo = solverInfo->NextSiblingElement(
"I");
1064 for (
unsigned int i = 0; i <
m_domain.size(); ++i)
1072 " Number of directional" \
1073 " modes in expansion spec for composite id = " +
1074 boost::lexical_cast<std::string>(cId) +
1076 boost::lexical_cast<std::string>(it->first) +
1077 " does not correspond to mesh dimension");
1079 int na = it->second[0];
1107 std::map<int, int> vGraphEdges;
1115 pGraph[v].id = eIt->first;
1116 pGraph[v].partition = 0;
1124 for (
unsigned j = 0; j < eIt->second.list.size(); ++j)
1126 int eId = eIt->second.list[j];
1130 if (vGraphEdges.find(eId) != vGraphEdges.end())
1132 BoostEdge e = boost::add_edge(vcnt, vGraphEdges[eId], pGraph).first;
1133 pGraph[e].id = vcnt;
1137 vGraphEdges[eId] = vcnt;
1162 std::vector<BoostSubGraph>& pLocalPartition,
1166 int nGraphVerts = boost::num_vertices(pGraph);
1167 int nGraphEdges = boost::num_edges(pGraph);
1174 if (
m_comm->GetRowComm()->TreatAsRankZero())
1178 int nWeight = nGraphVerts;
1184 for ( boost::tie(vertit, vertit_end) = boost::vertices(pGraph);
1185 vertit != vertit_end;
1188 for ( boost::tie(adjvertit, adjvertit_end) = boost::adjacent_vertices(*vertit,pGraph);
1189 adjvertit != adjvertit_end;
1192 adjncy[acnt++] = *adjvertit;
1195 xadj[++vcnt] = acnt;
1199 vwgt[vcnt-1] = pGraph[*vertit].weight[0];
1215 if(
m_comm->GetColumnComm()->GetRank() == 0)
1226 for (i = 1; i <
m_comm->GetColumnComm()->GetSize(); ++i)
1228 m_comm->GetColumnComm()->Send(i, part);
1234 m_comm->GetColumnComm()->Recv(0, part);
1238 m_comm->GetColumnComm()->Block();
1242 for (i = 1; i <
m_comm->GetRowComm()->GetSize(); ++i)
1244 m_comm->GetRowComm()->Send(i, part);
1251 "Error in calling metis to partition graph.");
1256 m_comm->GetRowComm()->Recv(0, part);
1261 pLocalPartition.resize(nCols);
1262 for (i = 0; i < nCols; ++i)
1264 pLocalPartition[i] = pGraph.create_subgraph();
1269 for ( boost::tie(vertit, vertit_end) = boost::vertices(pGraph);
1270 vertit != vertit_end;
1273 pGraph[*vertit].partition = part[i];
1274 boost::add_vertex(i, pLocalPartition[part[i]]);
1281 for ( boost::tie(vertit, vertit_end) = boost::vertices(pGraph);
1282 vertit != vertit_end;
1285 for (boost::tie(adjvertit, adjvertit_end) = boost::adjacent_vertices(*vertit,pGraph);
1286 adjvertit != adjvertit_end; ++adjvertit)
1288 if(part[*adjvertit] != part[*vertit])
1290 boost::add_vertex(*adjvertit, pLocalPartition[part[*vertit]]);
1301 unsigned int cnt = 0;
1305 for (i = 0; i < nParts; ++i)
1307 cnt = std::count(pPart.begin(), pPart.end(), i);
1321 for (i = 0; i < pPart.num_elements(); ++i)
1323 pPart[i] = i % nParts;
1332 TiXmlElement* pNektar)
1335 std::string vDim = pSession->GetElement(
"Nektar/Geometry")->Attribute(
"DIM");
1336 std::string vSpace = pSession->GetElement(
"Nektar/Geometry")->Attribute(
"SPACE");
1337 std::string vPart = boost::lexical_cast<std::string>(pGraph[*boost::vertices(pGraph).first].partition);
1338 TiXmlElement* vElmtGeometry =
new TiXmlElement(
"GEOMETRY");
1339 vElmtGeometry->SetAttribute(
"DIM", vDim);
1340 vElmtGeometry->SetAttribute(
"SPACE", vSpace);
1341 vElmtGeometry->SetAttribute(
"PARTITION", vPart);
1343 TiXmlElement *vVertex =
new TiXmlElement(
"VERTEX");
1344 TiXmlElement *vEdge =
new TiXmlElement(
"EDGE");
1345 TiXmlElement *vFace =
new TiXmlElement(
"FACE");
1346 TiXmlElement *vElement =
new TiXmlElement(
"ELEMENT");
1347 TiXmlElement *vCurved =
new TiXmlElement(
"CURVED");
1348 TiXmlElement *vComposite =
new TiXmlElement(
"COMPOSITE");
1349 TiXmlElement *vDomain =
new TiXmlElement(
"DOMAIN");
1357 std::map<int, MeshEntity> vComposites;
1358 std::map<int, MeshEntity> vElements;
1359 std::map<int, MeshEntity> vEdges;
1360 std::map<int, MeshEntity> vFaces;
1361 std::map<int, MeshVertex> vVertices;
1366 std::vector<unsigned int> idxList;
1369 for (boost::tie(vertit, vertit_end) = boost::vertices(pGraph);
1370 vertit != vertit_end;
1373 id = pGraph[*vertit].id;
1377 std::map<int, MeshEntity> * vNext = &vElements;
1383 for (vIt = vNext->begin(); vIt != vNext->end(); vIt++)
1385 for (
unsigned int j = 0; j < vIt->second.list.size(); ++j)
1387 id = vIt->second.list[j];
1396 for (vIt = vNext->begin(); vIt != vNext->end(); vIt++)
1398 for (
unsigned int j = 0; j < vIt->second.list.size(); ++j)
1400 id = vIt->second.list[j];
1409 for (vIt = vNext->begin(); vIt != vNext->end(); vIt++)
1411 for (
unsigned int j = 0; j < vIt->second.list.size(); ++j)
1413 id = vIt->second.list[j];
1423 std::vector<MeshVertex> vertInfo;
1424 for (vVertIt = vVertices.begin();
1425 vVertIt != vVertices.end(); vVertIt++)
1428 v.
id = vVertIt->first;
1429 v.
x = vVertIt->second.x;
1430 v.
y = vVertIt->second.y;
1431 v.
z = vVertIt->second.z;
1432 vertInfo.push_back(v);
1434 std::string vertStr;
1436 vVertex->SetAttribute(
"COMPRESSED",
1438 vVertex->SetAttribute(
"BITSIZE",
1440 vVertex->LinkEndChild(
new TiXmlText(vertStr));
1444 for (vVertIt = vVertices.begin(); vVertIt != vVertices.end(); vVertIt++)
1446 x =
new TiXmlElement(
"V");
1447 x->SetAttribute(
"ID", vVertIt->first);
1448 std::stringstream vCoords;
1449 vCoords.precision(12);
1450 vCoords << std::setw(15) << vVertIt->second.x <<
" "
1451 << std::setw(15) << vVertIt->second.y <<
" "
1452 << std::setw(15) << vVertIt->second.z <<
" ";
1453 y =
new TiXmlText(vCoords.str());
1455 vVertex->LinkEndChild(x);
1464 vVertex->SetAttribute(vAttrIt->first, vAttrIt->second);
1471 std::vector<MeshEdge> edgeInfo;
1472 for (vIt = vEdges.begin(); vIt != vEdges.end(); vIt++)
1476 e.
v0 = vIt->second.list[0];
1477 e.
v1 = vIt->second.list[1];
1478 edgeInfo.push_back(e);
1480 std::string edgeStr;
1482 vEdge->SetAttribute(
"COMPRESSED",
1484 vEdge->SetAttribute(
"BITSIZE",
1486 vEdge->LinkEndChild(
new TiXmlText(edgeStr));
1490 for (vIt = vEdges.begin(); vIt != vEdges.end(); vIt++)
1492 x =
new TiXmlElement(
"E");
1493 x->SetAttribute(
"ID", vIt->first);
1494 std::stringstream vVertices;
1495 vVertices << std::setw(10) << vIt->second.list[0]
1496 << std::setw(10) << vIt->second.list[1]
1498 y =
new TiXmlText(vVertices.str());
1500 vEdge->LinkEndChild(x);
1510 std::vector<MeshTri> TriFaceInfo;
1511 std::vector<MeshQuad> QuadFaceInfo;
1513 for (vIt = vFaces.begin(); vIt != vFaces.end(); vIt++)
1515 switch(vIt->second.list.size())
1521 for(
int i = 0; i < 3; ++i)
1523 f.
e[i] = vIt->second.list[i];
1525 TriFaceInfo.push_back(f);
1532 for(
int i = 0; i < 4; ++i)
1534 f.
e[i] = vIt->second.list[i];
1536 QuadFaceInfo.push_back(f);
1540 ASSERTL0(
false,
"Unknown face type.");
1544 if(TriFaceInfo.size())
1546 std::string vType(
"T");
1547 x =
new TiXmlElement(vType);
1549 std::string faceStr;
1552 x->SetAttribute(
"COMPRESSED",
1554 x->SetAttribute(
"BITSIZE",
1556 x->LinkEndChild(
new TiXmlText(faceStr));
1557 vFace->LinkEndChild(x);
1560 if(QuadFaceInfo.size())
1562 std::string vType(
"Q");
1563 x =
new TiXmlElement(vType);
1564 std::string faceStr;
1567 x->SetAttribute(
"COMPRESSED",
1569 x->SetAttribute(
"BITSIZE",
1571 x->LinkEndChild(
new TiXmlText(faceStr));
1572 vFace->LinkEndChild(x);
1577 for (vIt = vFaces.begin(); vIt != vFaces.end(); vIt++)
1579 std::string vType(
"F");
1580 vType[0] = vIt->second.type;
1581 x =
new TiXmlElement(vType);
1582 x->SetAttribute(
"ID", vIt->first);
1583 std::stringstream vListStr;
1584 for (
unsigned int i = 0; i < vIt->second.list.size(); ++i)
1586 vListStr << std::setw(10) << vIt->second.list[i];
1589 y =
new TiXmlText(vListStr.str());
1591 vFace->LinkEndChild(x);
1599 std::vector<MeshEdge> SegInfo;
1600 std::vector<MeshTri> TriInfo;
1601 std::vector<MeshQuad> QuadInfo;
1602 std::vector<MeshTet> TetInfo;
1603 std::vector<MeshPyr> PyrInfo;
1604 std::vector<MeshPrism> PrismInfo;
1605 std::vector<MeshHex> HexInfo;
1608 for (vIt = vElements.begin(); vIt != vElements.end(); vIt++)
1610 switch(vIt->second.type)
1616 e.
v0 = vIt->second.list[0];
1617 e.
v1 = vIt->second.list[1];
1618 SegInfo.push_back(e);
1625 for(
int i = 0; i < 3; ++i)
1627 f.
e[i] = vIt->second.list[i];
1629 TriInfo.push_back(f);
1636 for(
int i = 0; i < 4; ++i)
1638 f.
e[i] = vIt->second.list[i];
1640 QuadInfo.push_back(f);
1646 vol.
id = vIt->first;
1647 for(
int i = 0; i < 4; ++i)
1649 vol.
f[i] = vIt->second.list[i];
1651 TetInfo.push_back(vol);
1657 vol.
id = vIt->first;
1658 for(
int i = 0; i < 5; ++i)
1660 vol.
f[i] = vIt->second.list[i];
1662 PyrInfo.push_back(vol);
1668 vol.
id = vIt->first;
1669 for(
int i = 0; i < 5; ++i)
1671 vol.
f[i] = vIt->second.list[i];
1673 PrismInfo.push_back(vol);
1679 vol.
id = vIt->first;
1680 for(
int i = 0; i < 6; ++i)
1682 vol.
f[i] = vIt->second.list[i];
1684 HexInfo.push_back(vol);
1688 ASSERTL0(
false,
"Unknown element type");
1694 std::string vType(
"S");
1695 x =
new TiXmlElement(vType);
1699 x->SetAttribute(
"COMPRESSED",
1701 x->SetAttribute(
"BITSIZE",
1703 x->LinkEndChild(
new TiXmlText(segStr));
1704 vElement->LinkEndChild(x);
1709 std::string vType(
"T");
1710 x =
new TiXmlElement(vType);
1712 std::string faceStr;
1714 x->SetAttribute(
"COMPRESSED",
1716 x->SetAttribute(
"BITSIZE",
1718 x->LinkEndChild(
new TiXmlText(faceStr));
1719 vElement->LinkEndChild(x);
1724 std::string vType(
"Q");
1725 x =
new TiXmlElement(vType);
1726 std::string faceStr;
1728 x->SetAttribute(
"COMPRESSED",
1730 x->SetAttribute(
"BITSIZE",
1732 x->LinkEndChild(
new TiXmlText(faceStr));
1733 vElement->LinkEndChild(x);
1738 std::string vType(
"A");
1739 x =
new TiXmlElement(vType);
1742 x->SetAttribute(
"COMPRESSED",
1744 x->SetAttribute(
"BITSIZE",
1746 x->LinkEndChild(
new TiXmlText(volStr));
1747 vElement->LinkEndChild(x);
1752 std::string vType(
"P");
1753 x =
new TiXmlElement(vType);
1756 x->SetAttribute(
"COMPRESSED",
1758 x->SetAttribute(
"BITSIZE",
1760 x->LinkEndChild(
new TiXmlText(volStr));
1761 vElement->LinkEndChild(x);
1764 if(PrismInfo.size())
1766 std::string vType(
"R");
1767 x =
new TiXmlElement(vType);
1770 x->SetAttribute(
"COMPRESSED",
1772 x->SetAttribute(
"BITSIZE",
1774 x->LinkEndChild(
new TiXmlText(volStr));
1775 vElement->LinkEndChild(x);
1780 std::string vType(
"H");
1781 x =
new TiXmlElement(vType);
1784 x->SetAttribute(
"COMPRESSED",
1786 x->SetAttribute(
"BITSIZE",
1788 x->LinkEndChild(
new TiXmlText(volStr));
1789 vElement->LinkEndChild(x);
1795 for (vIt = vElements.begin(); vIt != vElements.end(); vIt++)
1797 std::string vType(
"T");
1798 vType[0] = vIt->second.type;
1799 x =
new TiXmlElement(vType.c_str());
1800 x->SetAttribute(
"ID", vIt->first);
1801 std::stringstream vEdges;
1802 for (
unsigned i = 0; i < vIt->second.list.size(); ++i)
1804 vEdges << std::setw(10) << vIt->second.list[i];
1807 y =
new TiXmlText(vEdges.str());
1809 vElement->LinkEndChild(x);
1815 std::map<MeshCurvedKey, MeshCurved>::const_iterator vItCurve;
1819 std::vector<MeshCurvedInfo> edgeinfo;
1820 std::vector<MeshCurvedInfo> faceinfo;
1825 std::map<int,int> idxmap;
1833 bool IsEdge = boost::iequals(c.
entitytype,
"E");
1834 bool IsFace = boost::iequals(c.
entitytype,
"F");
1836 if((IsEdge&&vEdges.find(c.
entityid) != vEdges.end())||
1837 (IsFace&&vFaces.find(c.
entityid) != vFaces.end()))
1858 edgeinfo.push_back(cinfo);
1862 faceinfo.push_back(cinfo);
1866 for(
int i =0; i < c.
npoints; ++i)
1874 if(idxmap.count(idx) == 0)
1876 idxmap[idx] = newidx;
1877 curvedpts.
index.push_back(newidx);
1878 curvedpts.
pts.push_back(
1884 curvedpts.
index.push_back(idxmap[idx]);
1893 vCurved->SetAttribute(
"COMPRESSED",
1895 vCurved->SetAttribute(
"BITSIZE",
1898 x =
new TiXmlElement(
"E");
1899 std::string dataStr;
1901 x->LinkEndChild(
new TiXmlText(dataStr));
1902 vCurved->LinkEndChild(x);
1907 vCurved->SetAttribute(
"COMPRESSED",
1909 vCurved->SetAttribute(
"BITSIZE",
1912 x =
new TiXmlElement(
"F");
1913 std::string dataStr;
1915 x->LinkEndChild(
new TiXmlText(dataStr));
1916 vCurved->LinkEndChild(x);
1919 if(edgeinfo.size()||faceinfo.size())
1921 x =
new TiXmlElement(
"DATAPOINTS");
1922 x->SetAttribute(
"ID", curvedpts.
id);
1924 TiXmlElement *subx =
new TiXmlElement(
"INDEX");
1925 std::string dataStr;
1928 subx->LinkEndChild(
new TiXmlText(dataStr));
1929 x->LinkEndChild(subx);
1931 subx =
new TiXmlElement(
"POINTS");
1934 subx->LinkEndChild(
new TiXmlText(dataStr));
1935 x->LinkEndChild(subx);
1937 vCurved->LinkEndChild(x);
1948 bool IsEdge = boost::iequals(c.
entitytype,
"E");
1949 bool IsFace = boost::iequals(c.
entitytype,
"F");
1951 if((IsEdge&&vEdges.find(c.
entityid) != vEdges.end())||
1952 (IsFace&&vFaces.find(c.
entityid) != vFaces.end()))
1955 x->SetAttribute(
"ID", c.
id);
1958 x->SetAttribute(
"EDGEID", c.
entityid);
1962 x->SetAttribute(
"FACEID", c.
entityid);
1964 x->SetAttribute(
"TYPE", c.
type);
1965 x->SetAttribute(
"NUMPOINTS", c.
npoints);
1966 y =
new TiXmlText(c.
data);
1968 vCurved->LinkEndChild(x);
1980 for (
unsigned int j = 0; j < vIt->second.list.size(); ++j)
1983 switch (vIt->second.type)
1986 if (vVertices.find(vIt->second.list[j]) == vVertices.end())
1992 if (vEdges.find(vIt->second.list[j]) == vEdges.end())
1998 if (vFaces.find(vIt->second.list[j]) == vFaces.end())
2004 if (vElements.find(vIt->second.list[j]) == vElements.end())
2011 idxList.push_back(vIt->second.list[j]);
2016 if (vCompositeStr.length() > 0)
2018 vComposites[vIt->first] = vIt->second;
2019 x =
new TiXmlElement(
"C");
2020 x->SetAttribute(
"ID", vIt->first);
2021 vCompositeStr =
"X[" + vCompositeStr +
"]";
2022 vCompositeStr[0] = vIt->second.type;
2023 y =
new TiXmlText(vCompositeStr.c_str());
2025 vComposite->LinkEndChild(x);
2030 std::string vDomainListStr;
2031 for (
unsigned int i = 0; i <
m_domain.size(); ++i)
2033 if (vComposites.find(
m_domain[i]) != vComposites.end())
2039 TiXmlText* vDomainList =
new TiXmlText(vDomainListStr);
2040 vDomain->LinkEndChild(vDomainList);
2042 vElmtGeometry->LinkEndChild(vVertex);
2045 vElmtGeometry->LinkEndChild(vEdge);
2049 vElmtGeometry->LinkEndChild(vFace);
2051 vElmtGeometry->LinkEndChild(vElement);
2054 vElmtGeometry->LinkEndChild(vCurved);
2056 vElmtGeometry->LinkEndChild(vComposite);
2057 vElmtGeometry->LinkEndChild(vDomain);
2059 pNektar->LinkEndChild(vElmtGeometry);
2061 if (pSession->DefinesElement(
"Nektar/Conditions"))
2063 std::set<int> vBndRegionIdList;
2064 TiXmlElement* vConditions =
new TiXmlElement(*pSession->GetElement(
"Nektar/Conditions"));
2065 TiXmlElement* vBndRegions = vConditions->FirstChildElement(
"BOUNDARYREGIONS");
2066 TiXmlElement* vBndConditions = vConditions->FirstChildElement(
"BOUNDARYCONDITIONS");
2067 TiXmlElement* vItem;
2071 TiXmlElement* vNewBndRegions =
new TiXmlElement(
"BOUNDARYREGIONS");
2072 vItem = vBndRegions->FirstChildElement();
2075 std::string vSeqStr = vItem->FirstChild()->ToText()->Value();
2076 std::string::size_type indxBeg = vSeqStr.find_first_of(
'[') + 1;
2077 std::string::size_type indxEnd = vSeqStr.find_last_of(
']') - 1;
2078 vSeqStr = vSeqStr.substr(indxBeg, indxEnd - indxBeg + 1);
2079 std::vector<unsigned int> vSeq;
2084 for (
unsigned int i = 0; i < vSeq.size(); ++i)
2086 if (vComposites.find(vSeq[i]) != vComposites.end())
2088 idxList.push_back(vSeq[i]);
2091 int p = atoi(vItem->Attribute(
"ID"));
2095 if (vListStr.length() == 0)
2097 TiXmlElement* tmp = vItem;
2098 vItem = vItem->NextSiblingElement();
2099 vBndRegions->RemoveChild(tmp);
2103 vListStr =
"C[" + vListStr +
"]";
2104 TiXmlText* vList =
new TiXmlText(vListStr);
2105 TiXmlElement* vNewElement =
new TiXmlElement(
"B");
2106 vNewElement->SetAttribute(
"ID", p);
2107 vNewElement->LinkEndChild(vList);
2108 vNewBndRegions->LinkEndChild(vNewElement);
2109 vBndRegionIdList.insert(p);
2110 vItem = vItem->NextSiblingElement();
2117 vConditions->ReplaceChild(vBndRegions, *vNewBndRegions);
2122 vItem = vBndConditions->FirstChildElement();
2126 if ((x = vBndRegionIdList.find(atoi(vItem->Attribute(
"REF")))) != vBndRegionIdList.end())
2128 vItem->SetAttribute(
"REF", *x);
2129 vItem = vItem->NextSiblingElement();
2133 TiXmlElement* tmp = vItem;
2134 vItem = vItem->NextSiblingElement();
2135 vBndConditions->RemoveChild(tmp);
2139 pNektar->LinkEndChild(vConditions);
2143 TiXmlElement* vSrc = pSession->GetElement(
"Nektar")
2144 ->FirstChildElement();
2147 std::string vName = boost::to_upper_copy(vSrc->ValueStr());
2148 if (vName !=
"GEOMETRY" && vName !=
"CONDITIONS")
2150 pNektar->LinkEndChild(
new TiXmlElement(*vSrc));
2152 vSrc = vSrc->NextSiblingElement();
2163 for ( boost::tie(vertit, vertit_end) = boost::vertices(
m_localPartition[procid]);
2164 vertit != vertit_end;
2183 weight = bndWeight ?
2188 weight = bndWeight ?
2193 weight = bndWeight ?
2198 weight = bndWeight ?
2203 weight = bndWeight ?
2208 weight = bndWeight ?
2213 weight = bndWeight ?
void GetCompositeOrdering(CompositeOrdering &composites)
int CalculateElementWeight(char elmtType, bool bndWeight, int na, int nb, int nc)
#define ASSERTL0(condition, msg)
static bool GenerateOrderedStringVector(const char *const str, std::vector< std::string > &vec)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
std::map< std::string, std::string > m_vertexAttributes
int getNumberOfBndCoefficients(int Na, int Nb)
int getNumberOfCoefficients(int Na, int Nb, int Nc)
static bool GenerateOrderedVector(const char *const str, std::vector< unsigned int > &vec)
NekInt64 ptoffset
the id of point data map (currently always 0 since we are using just one set).
std::map< int, MeshEntity > m_meshComposites
void WriteLocalPartition(SessionReaderSharedPtr &pSession)
const std::string kPointsTypeStr[]
int getNumberOfBndCoefficients(int Na, int Nb, int Nc)
std::map< int, MeshVertex > m_meshVertices
std::vector< NekInt64 > index
id of this Point set
void CheckPartitions(int nParts, Array< OneD, int > &pPart)
void ReadConditions(const SessionReaderSharedPtr &pSession)
static std::string GenerateSeqString(const std::vector< unsigned int > &elmtids)
int getNumberOfBndCoefficients(int Na, int Nb, int Nc)
std::map< MeshCurvedKey, MeshCurved > m_meshCurved
std::map< int, std::vector< unsigned int > > BndRegionOrdering
virtual void PartitionGraphImpl(int &nVerts, int &nVertConds, Nektar::Array< Nektar::OneD, int > &xadj, Nektar::Array< Nektar::OneD, int > &adjcy, Nektar::Array< Nektar::OneD, int > &vertWgt, Nektar::Array< Nektar::OneD, int > &vertSize, int &nparts, int &volume, Nektar::Array< Nektar::OneD, int > &part)=0
boost::graph_traits< BoostGraph >::vertex_descriptor BoostVertex
std::map< int, MultiWeight > m_vertWeights
std::map< int, std::vector< unsigned int > > CompositeOrdering
int getNumberOfCoefficients(int Na, int Nb, int Nc)
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
static bool GenerateSeqVector(const char *const str, std::vector< unsigned int > &vec)
NekInt64 entityid
Id of this curved information.
std::map< std::string, NumModes > NummodesPerField
std::map< std::string, int > m_fieldNameToId
void ReadExpansions(const SessionReaderSharedPtr &pSession)
std::string GetCompressString(void)
std::map< int, NummodesPerField > m_expansions
std::vector< unsigned int > list
std::map< int, MeshEntity > m_meshElements
NekInt64 npoints
The entity id corresponding to the global edge/curve.
int getNumberOfCoefficients(int Na)
LibUtilities::NekFactory< std::string, MeshPartition, const SessionReaderSharedPtr & > MeshPartitionFactory
Datatype of the NekFactory used to instantiate classes derived from the EquationSystem class...
void CreateGraph(BoostSubGraph &pGraph)
void GetBndRegionOrdering(BndRegionOrdering &composites)
int getNumberOfCoefficients(int Na, int Nb)
void GetElementIDs(const int procid, std::vector< unsigned int > &tmp)
std::vector< unsigned int > m_domain
std::vector< BoostSubGraph > m_localPartition
std::string PortablePath(const boost::filesystem::path &path)
create portable path on different platforms for boost::filesystem path
void ReadGeometry(const SessionReaderSharedPtr &pSession)
int getNumberOfBndCoefficients(int Na)
int ZlibEncodeToBase64Str(std::vector< T > &in, std::string &out64)
int getNumberOfBndCoefficients(int Na, int Nb)
NekInt64 ptype
point offset of data entry for this curve
BndRegionOrdering m_bndRegOrder
int getNumberOfCoefficients(int Na, int Nb, int Nc)
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
std::string GetBitSizeStr(void)
boost::graph_traits< BoostGraph >::adjacency_iterator BoostAdjacencyIterator
std::map< int, MeshEntity > m_meshEdges
int getNumberOfBndCoefficients(int Na, int Nb, int Nc)
NekInt64 ptid
The number of points in this curved entity.
int getNumberOfCoefficients(int Na, int Nb)
void PartitionMesh(int nParts, bool shared=false, bool overlapping=false)
boost::graph_traits< BoostGraph >::edge_descriptor BoostEdge
void PrintPartInfo(std::ostream &out)
std::map< int, MeshEntity > m_meshFaces
void WriteAllPartitions(SessionReaderSharedPtr &pSession)
boost::graph_traits< BoostGraph >::vertex_iterator BoostVertexIterator
std::vector< MeshVertex > pts
mapping to access pts value.
void OutputPartition(SessionReaderSharedPtr &pSession, BoostSubGraph &pGraph, TiXmlElement *pGeometry)
void PartitionGraph(BoostSubGraph &pGraph, int nParts, std::vector< BoostSubGraph > &pLocalPartition, bool overlapping=false)
Partition the graph.
int getNumberOfCoefficients(int Na, int Nb, int Nc)
MeshPartition(const SessionReaderSharedPtr &pSession)
std::map< int, MeshCurvedPts > m_meshCurvedPts
MeshPartitionFactory & GetMeshPartitionFactory()
int getNumberOfBndCoefficients(int Na, int Nb, int Nc)
int ZlibDecodeFromBase64Str(std::string &in64, std::vector< T > &out)
Provides a generic Factory class.
boost::subgraph< BoostGraph > BoostSubGraph