44 namespace SpatialDomains
64 TiXmlDocument doc(infilename);
65 bool loadOkay = doc.LoadFile();
67 std::stringstream errstr;
68 errstr <<
"Unable to load file: " << infilename <<
"\n";
69 errstr << doc.ErrorDesc() <<
" (Line " << doc.ErrorRow()
70 <<
", Column " << doc.ErrorCol() <<
")";
81 TiXmlHandle docHandle(&doc);
83 TiXmlElement* mesh = NULL;
86 mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
88 ASSERTL0(mesh,
"Unable to find GEOMETRY tag in file.");
100 TiXmlHandle docHandle(&doc);
101 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
102 TiXmlElement* field = NULL;
105 field = mesh->FirstChildElement(
"EDGE");
107 ASSERTL0(field,
"Unable to find EDGE tag in file.");
112 TiXmlElement *edge = field->FirstChildElement(
"E");
122 int nextEdgeNumber = -1;
125 map<int, int> edge_curved;
135 int err = edge->QueryIntAttribute(
"ID",&indx);
136 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read edge attribute ID.");
139 TiXmlNode *child = edge->FirstChild();
141 if (child->Type() == TiXmlNode::TEXT)
143 edgeStr += child->ToText()->ValueStr();
147 int vertex1, vertex2;
148 std::istringstream edgeDataStrm(edgeStr.c_str());
152 while (!edgeDataStrm.fail())
154 edgeDataStrm >> vertex1 >> vertex2;
160 if (!edgeDataStrm.fail())
166 if(edge_curved.count(indx) == 0)
169 edge->SetGlobalID(indx);
174 edge->SetGlobalID(indx);
186 edge = edge->NextSiblingElement(
"E");
194 TiXmlHandle docHandle(&doc);
195 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
196 TiXmlElement* field = NULL;
199 field = mesh->FirstChildElement(
"ELEMENT");
201 ASSERTL0(field,
"Unable to find ELEMENT tag in file.");
204 map<int, int> faceCurves;
211 int nextElementNumber = -1;
216 TiXmlElement *element = field->FirstChildElement();
220 std::string elementType(element->ValueStr());
222 ASSERTL0(elementType ==
"Q" || elementType ==
"T",
223 (std::string(
"Unknown 2D element type: ") + elementType).c_str());
230 int err = element->QueryIntAttribute(
"ID", &indx);
231 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read element attribute ID.");
235 TiXmlNode* elementChild = element->FirstChild();
236 std::string elementStr;
239 if (elementChild->Type() == TiXmlNode::TEXT)
241 elementStr += elementChild->ToText()->ValueStr();
243 elementChild = elementChild->NextSibling();
246 ASSERTL0(!elementStr.empty(),
"Unable to read element description body.");
249 if (elementType ==
"T")
252 int edge1, edge2, edge3;
253 std::istringstream elementDataStrm(elementStr.c_str());
257 elementDataStrm >> edge1;
258 elementDataStrm >> edge2;
259 elementDataStrm >> edge3;
261 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read element data for TRIANGLE: ") + elementStr).c_str());
279 if ((x = faceCurves.find(indx)) == faceCurves.end())
294 trigeom->SetGlobalID(indx);
303 else if (elementType ==
"Q")
306 int edge1, edge2, edge3, edge4;
307 std::istringstream elementDataStrm(elementStr.c_str());
311 elementDataStrm >> edge1;
312 elementDataStrm >> edge2;
313 elementDataStrm >> edge3;
314 elementDataStrm >> edge4;
316 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read element data for QUAD: ") + elementStr).c_str());
332 if ((x = faceCurves.find(indx)) == faceCurves.end())
347 quadgeom->SetGlobalID(indx);
359 element = element->NextSiblingElement();
365 TiXmlHandle docHandle(&doc);
368 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
369 TiXmlElement* field = NULL;
371 ASSERTL0(mesh,
"Unable to find GEOMETRY tag in file.");
374 field = mesh->FirstChildElement(
"COMPOSITE");
376 ASSERTL0(field,
"Unable to find COMPOSITE tag in file.");
378 int nextCompositeNumber = -1;
382 TiXmlElement *composite = field->FirstChildElement(
"C");
386 nextCompositeNumber++;
389 int err = composite->QueryIntAttribute(
"ID", &indx);
390 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read attribute ID.");
393 TiXmlNode* compositeChild = composite->FirstChild();
398 while(compositeChild && compositeChild->Type() != TiXmlNode::TEXT)
400 compositeChild = compositeChild->NextSibling();
403 ASSERTL0(compositeChild,
"Unable to read composite definition body.");
404 std::string compositeStr = compositeChild->ToText()->ValueStr();
408 std::istringstream compositeDataStrm(compositeStr.c_str());
413 std::string prevCompositeElementStr;
415 while (!compositeDataStrm.fail())
417 std::string compositeElementStr;
418 compositeDataStrm >> compositeElementStr;
420 if (!compositeDataStrm.fail())
430 if (compositeElementStr.length() > 0)
434 prevCompositeElementStr = compositeElementStr;
441 (std::string(
"Unable to read COMPOSITE data for composite: ") + compositeStr).c_str());
445 composite = composite->NextSiblingElement(
"C");
470 std::istringstream tokenStream(token);
471 std::istringstream prevTokenStream(prevToken);
478 std::string::size_type indxBeg = token.find_first_of(
'[') + 1;
479 std::string::size_type indxEnd = token.find_last_of(
']') - 1;
481 ASSERTL0(indxBeg <= indxEnd, (std::string(
"Error reading index definition:") + token).c_str());
483 std::string indxStr = token.substr(indxBeg, indxEnd - indxBeg + 1);
484 std::vector<unsigned int> seqVector;
489 ASSERTL0(err, (std::string(
"Error reading composite elements: ") + indxStr).c_str());
491 prevTokenStream >> prevType;
494 bool validSequence = (prevToken.empty() ||
495 (type ==
'V' && prevType ==
'V') ||
496 (type ==
'E' && prevType ==
'E') ||
497 ((type ==
'T' || type ==
'Q') &&
498 (prevType ==
'T' || prevType ==
'Q')));
500 ASSERTL0(validSequence, (std::string(
"Invalid combination of composite items: ")
501 + type +
" and " + prevType +
".").c_str());
507 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
511 char errStr[16] =
"";
512 ::sprintf(errStr,
"%d", *seqIter);
524 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
528 char errStr[16] =
"";
529 ::sprintf(errStr,
"%d", *seqIter);
545 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
549 char errStr[16] =
"";
550 ::sprintf(errStr,
"%d", *seqIter);
565 for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
569 char errStr[16] =
"";
570 ::sprintf(errStr,
"%d", *seqIter);
575 composite->push_back(
m_vertSet[*seqIter]);
596 if(!(Sedge = boost::dynamic_pointer_cast<SegGeom>(edge)))
598 ASSERTL0(
false,
"Dynamics cast failed");
620 for(
int d = 0; d <
m_domain.size(); ++d)
622 for (compIter =
m_domain[d].begin(); compIter !=
m_domain[d].end(); ++compIter)
624 for (geomIter = (compIter->second)->begin(); geomIter != (compIter->second)->end(); ++geomIter)
626 triGeomShPtr = boost::dynamic_pointer_cast<
TriGeom>(*geomIter);
627 quadGeomShPtr = boost::dynamic_pointer_cast<
QuadGeom>(*geomIter);
629 if (triGeomShPtr || quadGeomShPtr)
634 if ((edgeNum = triGeomShPtr->WhichEdge(edge)) > -1)
637 elementEdge->m_Element = triGeomShPtr;
638 elementEdge->m_EdgeIndx = edgeNum;
639 returnval->push_back(elementEdge);
642 else if (quadGeomShPtr)
644 if ((edgeNum = quadGeomShPtr->WhichEdge(edge)) > -1)
647 elementEdge->m_Element = quadGeomShPtr;
648 elementEdge->m_EdgeIndx = edgeNum;
649 returnval->push_back(elementEdge);
669 int edge_id = (*elements)[0]->m_EdgeIndx;
673 edge_id = (edge_id)? 1:0;
680 int nummodes = expansion->m_basisKeyVector[edge_id].GetNumModes();
681 int numpoints = expansion->m_basisKeyVector[edge_id].GetNumPoints();
686 switch(expansion->m_basisKeyVector[edge_id].GetBasisType())
690 switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
700 ASSERTL0(
false,
"Unexpected points distribution");
714 switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
724 ASSERTL0(
false,
"Unexpected points distribution");
738 switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
748 ASSERTL0(
false,
"Unexpected points distribution");
762 switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
771 ASSERTL0(
false,
"Unexpected points distribution");
784 ASSERTL0(
false,
"Unexpected basis distribution");
799 ASSERTL0(
false,
"Unable to determine edge points type.");