Commit d89eef6b authored by Dave Moxey's avatar Dave Moxey
Browse files

Simplify read/write functions substantially, a few more things required

parent cccb9b7a
......@@ -99,6 +99,7 @@ MeshGraphSharedPtr MeshGraph::Read(
if (isRoot)
{
std::cout <<"lol init" << std::endl;
// Parse the XML document.
session->InitSession();
......@@ -2496,6 +2497,46 @@ ExpansionMapShPtr MeshGraph::SetUpExpansionMap(void)
return returnval;
}
/**
* @brief Returns a string representation of a composite.
*/
std::string MeshGraph::GetCompositeString(CompositeSharedPtr comp)
{
if (comp->m_geomVec.size() == 0)
{
return "";
}
// Create a map that gets around the issue of mapping faces -> F and edges
// -> E inside the tag.
map<LibUtilities::ShapeType, pair<string, string>> compMap;
compMap[LibUtilities::ePoint] = make_pair("V", "V");
compMap[LibUtilities::eSegment] = make_pair("S", "E");
compMap[LibUtilities::eQuadrilateral] = make_pair("Q", "F");
compMap[LibUtilities::eTriangle] = make_pair("T", "F");
compMap[LibUtilities::eTetrahedron] = make_pair("A", "A");
compMap[LibUtilities::ePyramid] = make_pair("P", "P");
compMap[LibUtilities::ePrism] = make_pair("R", "R");
compMap[LibUtilities::eHexahedron] = make_pair("H", "H");
stringstream s;
GeometrySharedPtr firstGeom = comp->m_geomVec[0];
int shapeDim = firstGeom->GetShapeDim();
string tag = (shapeDim < m_meshDimension)
? compMap[firstGeom->GetShapeType()].second
: compMap[firstGeom->GetShapeType()].first;
std::vector<unsigned int> idxList;
std::transform(
comp->m_geomVec.begin(), comp->m_geomVec.end(),
std::back_inserter(idxList),
[] (GeometrySharedPtr geom) { return geom->GetGlobalID(); });
s << " " << tag << "[" << ParseUtils::GenerateSeqString(idxList) << "] ";
return s.str();
}
void MeshGraph::ReadExpansions()
{
// Find the Expansions tag
......
......@@ -424,6 +424,7 @@ protected:
void PopulateFaceToElMap(Geometry3DSharedPtr element, int kNfaces);
ExpansionMapShPtr SetUpExpansionMap();
std::string GetCompositeString(CompositeSharedPtr comp);
LibUtilities::SessionReaderSharedPtr m_session;
PointGeomMap m_vertSet;
......
This diff is collapsed.
......@@ -84,11 +84,9 @@ protected:
private:
void ReadVertices();
void ReadCurves();
void ReadDomain();
void ReadEdges();
void ReadFaces();
void ReadElements();
......@@ -98,6 +96,16 @@ private:
void WriteGeometryMap(std::map<int, std::shared_ptr<T>> &geomMap,
std::string datasetName);
template<class T>
void ReadGeometryMap(
std::map<int, std::shared_ptr<T>> &geomMap,
std::string dataSet,
const CurveMap &curveMap = CurveMap(),
const std::unordered_set<unsigned int> &readIds = std::unordered_set<unsigned int>());
template<class T, typename DataType> void ConstructGeomObject(
std::map<int, std::shared_ptr<T>> &geomMap, int id,
DataType *data, CurveSharedPtr curve);
void WriteCurves(CurveMap &edges, CurveMap &faces);
void WriteComposites(CompositeMap &comps);
void WriteDomain(vector<CompositeMap> &domain);
......
......@@ -2647,48 +2647,16 @@ void MeshGraphXml::WriteComposites(TiXmlElement *geomTag, CompositeMap &comps)
{
TiXmlElement *compTag = new TiXmlElement("COMPOSITE");
// Create a map that gets around the issue of mapping faces -> F and
// edges -> E inside the tag.
map<LibUtilities::ShapeType, pair<string, string>> compMap;
compMap[LibUtilities::ePoint] = make_pair("V", "V");
compMap[LibUtilities::eSegment] = make_pair("S", "E");
compMap[LibUtilities::eQuadrilateral] = make_pair("Q", "F");
compMap[LibUtilities::eTriangle] = make_pair("T", "F");
compMap[LibUtilities::eTetrahedron] = make_pair("A", "A");
compMap[LibUtilities::ePyramid] = make_pair("P", "P");
compMap[LibUtilities::ePrism] = make_pair("R", "R");
compMap[LibUtilities::eHexahedron] = make_pair("H", "H");
std::vector<unsigned int> idxList;
for (auto &cIt : comps)
{
stringstream s;
TiXmlElement *c = new TiXmlElement("C");
if (cIt.second->m_geomVec.size() == 0)
{
continue;
}
GeometrySharedPtr firstGeom = cIt.second->m_geomVec[0];
int shapeDim = firstGeom->GetShapeDim();
string tag = (shapeDim < m_meshDimension)
? compMap[firstGeom->GetShapeType()].second
: compMap[firstGeom->GetShapeType()].first;
idxList.clear();
s << " " << tag << "[";
for (int i = 0; i < cIt.second->m_geomVec.size(); ++i)
{
idxList.push_back(cIt.second->m_geomVec[i]->GetGlobalID());
}
s << ParseUtils::GenerateSeqString(idxList) << "] ";
TiXmlElement *c = new TiXmlElement("C");
c->SetAttribute("ID", cIt.first);
c->LinkEndChild(new TiXmlText(s.str()));
c->LinkEndChild(new TiXmlText(GetCompositeString(cIt.second)));
compTag->LinkEndChild(c);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment