Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | List of all members
Nektar::SpatialDomains::MeshGraph2D Class Reference

#include <MeshGraph2D.h>

Inheritance diagram for Nektar::SpatialDomains::MeshGraph2D:
Inheritance graph
[legend]
Collaboration diagram for Nektar::SpatialDomains::MeshGraph2D:
Collaboration graph
[legend]

Public Member Functions

 MeshGraph2D ()
 MeshGraph2D (const LibUtilities::SessionReaderSharedPtr &pSession, const DomainRangeShPtr &rng=NullDomainRangeShPtr)
virtual ~MeshGraph2D ()
void ReadGeometry (const std::string &infilename)
 Read will read the meshgraph vertices given a filename.
void ReadGeometry (TiXmlDocument &doc)
 Read will read the meshgraph vertices given a TiXmlDocument.
SegGeomSharedPtr GetSegGeom (int eID)
int GetCoordim (void)
const TriGeomMapGetTrigeoms (void) const
const QuadGeomMapGetQuadgeoms (void) const
void GenXGeoFac ()
int GetNseggeoms () const
int GetVidFromElmt (LibUtilities::ShapeType shape, const int vert, const int elmt) const
int GetEidFromElmt (LibUtilities::ShapeType shape, const int edge, const int elmt) const
StdRegions::Orientation GetEorientFromElmt (LibUtilities::ShapeType shape, const int edge, const int elmt) const
StdRegions::Orientation GetCartesianEorientFromElmt (LibUtilities::ShapeType shape, const int edge, const int elmt) const
int GetNumComposites (void)
int GetNumCompositeItems (int whichComposite)
ElementEdgeVectorSharedPtr GetElementsFromEdge (SegGeomSharedPtr edge)
 Return the elements (shared ptrs) that have this edge.
ElementEdgeVectorSharedPtr GetElementsFromEdge (Geometry1DSharedPtr edge)
LibUtilities::BasisKey GetEdgeBasisKey (SegGeomSharedPtr edge, const std::string variable="DefaultVar")
 Return the BasisKey corresponding to an edge of an element If the expansion is a triangle the Modified_B direction is modified to be one-dimensional Modified_A,GaussLobattoLegendre.
- Public Member Functions inherited from Nektar::SpatialDomains::MeshGraph
 MeshGraph ()
 MeshGraph (unsigned int meshDimension, unsigned int spaceDimension)
 MeshGraph (const LibUtilities::SessionReaderSharedPtr &pSession, const DomainRangeShPtr &rng=NullDomainRangeShPtr)
virtual ~MeshGraph ()
void ReadGeometryInfo (const std::string &infilename)
 Read geometric information from a file.
void ReadGeometryInfo (TiXmlDocument &doc)
 Read geometric information from an XML document.
void ReadExpansions (const std::string &infilename)
 Read the expansions given the XML file path.
void ReadExpansions (TiXmlDocument &doc)
 Read the expansions given the XML document reference.
void ReadDomain (TiXmlDocument &doc)
void ReadCurves (TiXmlDocument &doc)
void ReadCurves (std::string &infilename)
int GetMeshDimension () const
 Dimension of the mesh (can be a 1D curve in 3D space).
int GetSpaceDimension () const
 Dimension of the space (can be a 1D curve in 3D space).
void SetDomainRange (NekDouble xmin, NekDouble xmax, NekDouble ymin=NekConstants::kNekUnsetDouble, NekDouble ymax=NekConstants::kNekUnsetDouble, NekDouble zmin=NekConstants::kNekUnsetDouble, NekDouble zmax=NekConstants::kNekUnsetDouble)
bool CheckRange (Geometry2D &geom)
 Check if goemetry is in range definition if activated.
bool CheckRange (Geometry3D &geom)
 Check if goemetry is in range definition if activated.
Composite GetComposite (int whichComposite) const
GeometrySharedPtr GetCompositeItem (int whichComposite, int whichItem)
void GetCompositeList (const std::string &compositeStr, CompositeMap &compositeVector) const
const CompositeMapGetComposites () const
const std::vector< CompositeMap > & GetDomain (void) const
const CompositeMapGetDomain (int domain) const
const ExpansionMapGetExpansions ()
const ExpansionMapGetExpansions (const std::string variable)
ExpansionShPtr GetExpansion (GeometrySharedPtr geom, const std::string variable="DefaultVar")
void SetExpansions (std::vector< LibUtilities::FieldDefinitionsSharedPtr > &fielddef)
 Sets expansions given field definitions.
void SetExpansions (std::vector< LibUtilities::FieldDefinitionsSharedPtr > &fielddef, std::vector< std::vector< LibUtilities::PointsType > > &pointstype)
 Sets expansions given field definition, quadrature points.
void SetExpansionsToEvenlySpacedPoints (int npoints=0)
 Sets expansions to have equispaced points.
void SetExpansions (const std::string variable, ExpansionMapShPtr &exp)
 This function sets the expansion #exp in map with entry #variable.
void SetBasisKey (LibUtilities::ShapeType shape, LibUtilities::BasisKeyVector &keys, std::string var="DefaultVar")
 Sets the basis key for all expansions of the given shape.
bool SameExpansions (const std::string var1, const std::string var2)
bool CheckForGeomInfo (std::string parameter)
const std::string GetGeomInfo (std::string parameter)
LibUtilities::BasisKeyVector DefineBasisKeyFromExpansionTypeHomo (GeometrySharedPtr in, ExpansionType type_x, ExpansionType type_y, ExpansionType type_z, const int nummodes_x, const int nummodes_y, const int nummodes_z)
int GetNvertices () const
PointGeomSharedPtr GetVertex (int id)
PointGeomSharedPtr AddVertex (NekDouble x, NekDouble y, NekDouble z)
 Adds a vertex to the with the next available ID.
SegGeomSharedPtr AddEdge (PointGeomSharedPtr v0, PointGeomSharedPtr v1, CurveSharedPtr curveDefinition=CurveSharedPtr())
 Adds an edge between two points. If curveDefinition is null, then the edge is straight, otherwise it is curved according to the curveDefinition.
SegGeomSharedPtr GetEdge (unsigned int id)
TriGeomSharedPtr AddTriangle (SegGeomSharedPtr edges[], StdRegions::Orientation orient[])
QuadGeomSharedPtr AddQuadrilateral (SegGeomSharedPtr edges[], StdRegions::Orientation orient[])
TetGeomSharedPtr AddTetrahedron (TriGeomSharedPtr tfaces[TetGeom::kNtfaces])
PyrGeomSharedPtr AddPyramid (TriGeomSharedPtr tfaces[PyrGeom::kNtfaces], QuadGeomSharedPtr qfaces[PyrGeom::kNqfaces])
PrismGeomSharedPtr AddPrism (TriGeomSharedPtr tfaces[PrismGeom::kNtfaces], QuadGeomSharedPtr qfaces[PrismGeom::kNqfaces])
HexGeomSharedPtr AddHexahedron (QuadGeomSharedPtr qfaces[HexGeom::kNqfaces])
const CurveVectorGetCurvedEdges () const
const CurveVectorGetCurvedFaces () const
const SegGeomMapGetAllSegGeoms () const
const TriGeomMapGetAllTriGeoms () const
const QuadGeomMapGetAllQuadGeoms () const
const TetGeomMapGetAllTetGeoms () const
const PyrGeomMapGetAllPyrGeoms () const
const PrismGeomMapGetAllPrismGeoms () const
const HexGeomMapGetAllHexGeoms () const
template<typename ElementType >
const std::map< int,
boost::shared_ptr< ElementType > > & 
GetAllElementsOfType () const
 Convenience method for ElVis.

Protected Member Functions

void ReadEdges (TiXmlDocument &doc)
void ReadElements (TiXmlDocument &doc)
void ReadComposites (TiXmlDocument &doc)
void ResolveGeomRef (const std::string &prevToken, const std::string &token, Composite &composite)
- Protected Member Functions inherited from Nektar::SpatialDomains::MeshGraph
ExpansionMapShPtr SetUpExpansionMap (void)

Additional Inherited Members

- Static Public Member Functions inherited from Nektar::SpatialDomains::MeshGraph
static boost::shared_ptr
< MeshGraph
Read (const LibUtilities::SessionReaderSharedPtr &pSession, DomainRangeShPtr &rng=NullDomainRangeShPtr)
static boost::shared_ptr
< MeshGraph
Read (const std::string &infilename, bool pReadExpansions=true)
static LibUtilities::BasisKeyVector DefineBasisKeyFromExpansionType (GeometrySharedPtr in, ExpansionType type, const int order)
- Protected Attributes inherited from Nektar::SpatialDomains::MeshGraph
LibUtilities::SessionReaderSharedPtr m_session
PointGeomMap m_vertSet
InterfaceCompList m_iComps
CurveVector m_curvedEdges
CurveVector m_curvedFaces
SegGeomMap m_segGeoms
TriGeomMap m_triGeoms
QuadGeomMap m_quadGeoms
TetGeomMap m_tetGeoms
PyrGeomMap m_pyrGeoms
PrismGeomMap m_prismGeoms
HexGeomMap m_hexGeoms
int m_meshDimension
int m_spaceDimension
int m_partition
bool m_meshPartitioned
CompositeMap m_meshComposites
std::vector< CompositeMapm_domain
DomainRangeShPtr m_domainRange
ExpansionMapShPtrMap m_expansionMapShPtrMap
GeomInfoMap m_geomInfo

Detailed Description

Definition at line 54 of file MeshGraph2D.h.

Constructor & Destructor Documentation

Nektar::SpatialDomains::MeshGraph2D::MeshGraph2D ( )

Definition at line 46 of file MeshGraph2D.cpp.

{
}
Nektar::SpatialDomains::MeshGraph2D::MeshGraph2D ( const LibUtilities::SessionReaderSharedPtr pSession,
const DomainRangeShPtr rng = NullDomainRangeShPtr 
)

Definition at line 54 of file MeshGraph2D.cpp.

References Nektar::SpatialDomains::MeshGraph::ReadExpansions(), and ReadGeometry().

: MeshGraph(pSession,rng)
{
ReadGeometry(pSession->GetDocument());
ReadExpansions(pSession->GetDocument());
}
Nektar::SpatialDomains::MeshGraph2D::~MeshGraph2D ( )
virtual

Definition at line 50 of file MeshGraph2D.cpp.

{
}

Member Function Documentation

void Nektar::SpatialDomains::MeshGraph2D::GenXGeoFac ( )
StdRegions::Orientation Nektar::SpatialDomains::MeshGraph2D::GetCartesianEorientFromElmt ( LibUtilities::ShapeType  shape,
const int  edge,
const int  elmt 
) const
inline

Definition at line 154 of file MeshGraph2D.h.

References ASSERTL2, Nektar::StdRegions::eBackwards, Nektar::StdRegions::eForwards, Nektar::LibUtilities::eTriangle, Nektar::SpatialDomains::MeshGraph::m_quadGeoms, and Nektar::SpatialDomains::MeshGraph::m_triGeoms.

{
{
ASSERTL2(m_triGeoms.find(elmt) != m_triGeoms.end(),
"eid is out of range");
returnval = m_triGeoms.find(elmt)->second->GetEorient(edge);
}
else
{
ASSERTL2(m_quadGeoms.find(elmt) != m_quadGeoms.end(),
"eid is out of range");
returnval = m_quadGeoms.find(elmt)->second->GetEorient(edge);
}
// swap orientation if on edge 2 & 3 (if quad)
if(edge >= 2)
{
if(returnval == StdRegions::eForwards)
{
}
else
{
returnval = StdRegions::eForwards;
}
}
return returnval;
}
int Nektar::SpatialDomains::MeshGraph2D::GetCoordim ( void  )
inline

Definition at line 69 of file MeshGraph2D.h.

References Nektar::SpatialDomains::MeshGraph::GetSpaceDimension().

{
}
LibUtilities::BasisKey Nektar::SpatialDomains::MeshGraph2D::GetEdgeBasisKey ( SegGeomSharedPtr  edge,
const std::string  variable = "DefaultVar" 
)

Return the BasisKey corresponding to an edge of an element If the expansion is a triangle the Modified_B direction is modified to be one-dimensional Modified_A,GaussLobattoLegendre.

Definition at line 660 of file MeshGraph2D.cpp.

References ASSERTL0, Nektar::LibUtilities::eGaussLobattoLegendre, Nektar::LibUtilities::eGaussRadauMAlpha1Beta0, Nektar::LibUtilities::eGLL_Lagrange, Nektar::LibUtilities::eModified_A, Nektar::LibUtilities::eModified_B, Nektar::LibUtilities::eOrtho_B, Nektar::LibUtilities::eTriangle, GetElementsFromEdge(), Nektar::SpatialDomains::MeshGraph::GetExpansion(), and Nektar::LibUtilities::NullBasisKey().

{
// Perhaps, a check should be done here to ensure that
// in case elements->size!=1, all elements to which
// the edge belongs have the same type and order of
// expansion such that no confusion can arise.
ExpansionShPtr expansion = GetExpansion((*elements)[0]->m_Element, variable);
int edge_id = (*elements)[0]->m_EdgeIndx;
if((*elements)[0]->m_Element->GetShapeType() == LibUtilities::eTriangle)
{
edge_id = (edge_id)? 1:0;
}
else
{
edge_id = edge_id%2;
}
int nummodes = expansion->m_basisKeyVector[edge_id].GetNumModes();
int numpoints = expansion->m_basisKeyVector[edge_id].GetNumPoints();
if((*elements)[0]->m_Element->GetShapeType() == LibUtilities::eTriangle)
{
// Use edge 0 to define basis of order relevant to edge
switch(expansion->m_basisKeyVector[edge_id].GetBasisType())
{
{
switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
{
{
const LibUtilities::PointsKey pkey(numpoints,LibUtilities::eGaussLobattoLegendre);
return LibUtilities::BasisKey(expansion->m_basisKeyVector[0].GetBasisType(),nummodes,pkey);
}
break;
default:
ASSERTL0(false,"Unexpected points distribution");
// It doesn't matter what we return
// here since the ASSERT will stop
// execution. Just return something
// to prevent warnings messages.
const LibUtilities::PointsKey pkey(numpoints,LibUtilities::eGaussLobattoLegendre);
return LibUtilities::BasisKey(expansion->m_basisKeyVector[0].GetBasisType(),nummodes,pkey);
break;
}
}
break;
case LibUtilities::eOrtho_B: // Assume this is called from nodal triangular basis
{
switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
{
{
const LibUtilities::PointsKey pkey(numpoints+1,LibUtilities::eGaussLobattoLegendre);
return LibUtilities::BasisKey(LibUtilities::eGLL_Lagrange,nummodes,pkey);
}
break;
default:
ASSERTL0(false,"Unexpected points distribution");
// It doesn't matter what we return
// here since the ASSERT will stop
// execution. Just return something
// to prevent warnings messages.
const LibUtilities::PointsKey pkey(numpoints+1,LibUtilities::eGaussLobattoLegendre);
return LibUtilities::BasisKey(expansion->m_basisKeyVector[0].GetBasisType(),nummodes,pkey);
break;
}
}
break;
{
switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
{
{
const LibUtilities::PointsKey pkey(numpoints+1,LibUtilities::eGaussLobattoLegendre);
return LibUtilities::BasisKey(expansion->m_basisKeyVector[0].GetBasisType(),nummodes,pkey);
}
break;
{
const LibUtilities::PointsKey pkey(numpoints,LibUtilities::eGaussLobattoLegendre);
return LibUtilities::BasisKey(expansion->m_basisKeyVector[0].GetBasisType(),nummodes,pkey);
}
break;
default:
ASSERTL0(false,"Unexpected points distribution");
// It doesn't matter what we return
// here since the ASSERT will stop
// execution. Just return something
// to prevent warnings messages.
const LibUtilities::PointsKey pkey(numpoints+1,LibUtilities::eGaussLobattoLegendre);
return LibUtilities::BasisKey(expansion->m_basisKeyVector[0].GetBasisType(),nummodes,pkey);
break;
}
}
break;
{
switch(expansion->m_basisKeyVector[edge_id].GetPointsType())
{
{
const LibUtilities::PointsKey pkey(numpoints,LibUtilities::eGaussLobattoLegendre);
return LibUtilities::BasisKey(expansion->m_basisKeyVector[0].GetBasisType(),nummodes,pkey);
}
break;
default:
ASSERTL0(false,"Unexpected points distribution");
// It doesn't matter what we return here
// since the ASSERT will stop execution.
// Just return something to prevent
// warnings messages.
const LibUtilities::PointsKey pkey(numpoints,LibUtilities::eGaussLobattoLegendre);
return LibUtilities::BasisKey(expansion->m_basisKeyVector[0].GetBasisType(),nummodes,pkey);
break;
}
}
break;
default:
ASSERTL0(false,"Unexpected basis distribution");
// It doesn't matter what we return here since the
// ASSERT will stop execution. Just return
// something to prevent warnings messages.
const LibUtilities::PointsKey pkey(numpoints+1,LibUtilities::eGaussLobattoLegendre);
return LibUtilities::BasisKey(expansion->m_basisKeyVector[0].GetBasisType(),nummodes,pkey);
}
}
else
{
// Quadrilateral
const LibUtilities::PointsKey pkey(numpoints,expansion->m_basisKeyVector[edge_id].GetPointsType());
return LibUtilities::BasisKey(expansion->m_basisKeyVector[edge_id].GetBasisType(),nummodes,pkey);
}
ASSERTL0(false, "Unable to determine edge points type.");
}
int Nektar::SpatialDomains::MeshGraph2D::GetEidFromElmt ( LibUtilities::ShapeType  shape,
const int  edge,
const int  elmt 
) const
inline

Definition at line 116 of file MeshGraph2D.h.

References ASSERTL2, Nektar::LibUtilities::eTriangle, Nektar::SpatialDomains::MeshGraph::m_quadGeoms, and Nektar::SpatialDomains::MeshGraph::m_triGeoms.

{
{
ASSERTL2(m_triGeoms.find(elmt) != m_triGeoms.end(),
"eid is out of range");
return m_triGeoms.find(elmt)->second->GetEid(edge);
}
else
{
ASSERTL2(m_quadGeoms.find(elmt) != m_quadGeoms.end(),
"eid is out of range");
return m_quadGeoms.find(elmt)->second->GetEid(edge);
}
}
ElementEdgeVectorSharedPtr Nektar::SpatialDomains::MeshGraph2D::GetElementsFromEdge ( SegGeomSharedPtr  edge)

Return the elements (shared ptrs) that have this edge.

Definition at line 604 of file MeshGraph2D.cpp.

References Nektar::SpatialDomains::MeshGraph::m_domain.

Referenced by GetEdgeBasisKey(), and GetElementsFromEdge().

{
// Search tris and quads
// Need to iterate through vectors because there may be multiple
// occurrences.
ElementEdgeSharedPtr elementEdge;
//TriGeomVectorIter triIter;
ElementEdgeVectorSharedPtr returnval = MemoryManager<ElementEdgeVector>::AllocateSharedPtr();
CompositeMapIter compIter;
TriGeomSharedPtr triGeomShPtr;
QuadGeomSharedPtr quadGeomShPtr;
for(int d = 0; d < m_domain.size(); ++d)
{
for (compIter = m_domain[d].begin(); compIter != m_domain[d].end(); ++compIter)
{
for (geomIter = (compIter->second)->begin(); geomIter != (compIter->second)->end(); ++geomIter)
{
triGeomShPtr = boost::dynamic_pointer_cast<TriGeom>(*geomIter);
quadGeomShPtr = boost::dynamic_pointer_cast<QuadGeom>(*geomIter);
if (triGeomShPtr || quadGeomShPtr)
{
int edgeNum;
if (triGeomShPtr)
{
if ((edgeNum = triGeomShPtr->WhichEdge(edge)) > -1)
{
elementEdge = MemoryManager<ElementEdge>::AllocateSharedPtr();
elementEdge->m_Element = triGeomShPtr;
elementEdge->m_EdgeIndx = edgeNum;
returnval->push_back(elementEdge);
}
}
else if (quadGeomShPtr)
{
if ((edgeNum = quadGeomShPtr->WhichEdge(edge)) > -1)
{
elementEdge = MemoryManager<ElementEdge>::AllocateSharedPtr();
elementEdge->m_Element = quadGeomShPtr;
elementEdge->m_EdgeIndx = edgeNum;
returnval->push_back(elementEdge);
}
}
}
}
}
}
return returnval;
}
ElementEdgeVectorSharedPtr Nektar::SpatialDomains::MeshGraph2D::GetElementsFromEdge ( Geometry1DSharedPtr  edge)

Definition at line 592 of file MeshGraph2D.cpp.

References ASSERTL0, and GetElementsFromEdge().

{
if(!(Sedge = boost::dynamic_pointer_cast<SegGeom>(edge)))
{
ASSERTL0(false,"Dynamics cast failed");
}
return GetElementsFromEdge(Sedge);
}
StdRegions::Orientation Nektar::SpatialDomains::MeshGraph2D::GetEorientFromElmt ( LibUtilities::ShapeType  shape,
const int  edge,
const int  elmt 
) const
inline

Definition at line 135 of file MeshGraph2D.h.

References ASSERTL2, Nektar::LibUtilities::eTriangle, Nektar::SpatialDomains::MeshGraph::m_quadGeoms, and Nektar::SpatialDomains::MeshGraph::m_triGeoms.

{
{
ASSERTL2(m_triGeoms.find(elmt) != m_triGeoms.end(),
"eid is out of range");
return m_triGeoms.find(elmt)->second->GetEorient(edge);
}
else
{
ASSERTL2(m_quadGeoms.find(elmt) != m_quadGeoms.end(),
"eid is out of range");
return m_quadGeoms.find(elmt)->second->GetEorient(edge);
}
}
int Nektar::SpatialDomains::MeshGraph2D::GetNseggeoms ( ) const
inline

Definition at line 92 of file MeshGraph2D.h.

References Nektar::SpatialDomains::MeshGraph::m_segGeoms.

{
return int(m_segGeoms.size());
}
int Nektar::SpatialDomains::MeshGraph2D::GetNumCompositeItems ( int  whichComposite)
inline

Definition at line 193 of file MeshGraph2D.h.

References ErrorUtil::efatal, Nektar::SpatialDomains::MeshGraph::m_meshComposites, and NEKERROR.

{
int returnval = -1;
try
{
returnval = int(m_meshComposites[whichComposite]->size());
}
catch(...)
{
std::ostringstream errStream;
errStream << "Unable to access composite item [" << whichComposite << "].";
NEKERROR(ErrorUtil::efatal, errStream.str());
}
return returnval;
}
int Nektar::SpatialDomains::MeshGraph2D::GetNumComposites ( void  )
inline

Definition at line 188 of file MeshGraph2D.h.

References Nektar::SpatialDomains::MeshGraph::m_meshComposites.

{
return int(m_meshComposites.size());
}
const QuadGeomMap& Nektar::SpatialDomains::MeshGraph2D::GetQuadgeoms ( void  ) const
inline

Definition at line 78 of file MeshGraph2D.h.

References Nektar::SpatialDomains::MeshGraph::m_quadGeoms.

{
return m_quadGeoms;
}
SegGeomSharedPtr Nektar::SpatialDomains::MeshGraph2D::GetSegGeom ( int  eID)

Definition at line 450 of file MeshGraph2D.cpp.

References ASSERTL0, Nektar::iterator, and Nektar::SpatialDomains::MeshGraph::m_segGeoms.

Referenced by ReadElements().

{
SegGeomSharedPtr returnval;
ASSERTL0(x != m_segGeoms.end(), "Segment not found.");
return x->second;
};
const TriGeomMap& Nektar::SpatialDomains::MeshGraph2D::GetTrigeoms ( void  ) const
inline

Definition at line 73 of file MeshGraph2D.h.

References Nektar::SpatialDomains::MeshGraph::m_triGeoms.

{
return m_triGeoms;
}
int Nektar::SpatialDomains::MeshGraph2D::GetVidFromElmt ( LibUtilities::ShapeType  shape,
const int  vert,
const int  elmt 
) const
inline

Definition at line 97 of file MeshGraph2D.h.

References ASSERTL2, Nektar::LibUtilities::eTriangle, Nektar::SpatialDomains::MeshGraph::m_quadGeoms, and Nektar::SpatialDomains::MeshGraph::m_triGeoms.

{
{
ASSERTL2(m_triGeoms.find(elmt) != m_triGeoms.end(),
"eid is out of range");
return m_triGeoms.find(elmt)->second->GetVid(vert);
}
else
{
ASSERTL2(m_quadGeoms.find(elmt) != m_quadGeoms.end(),
"eid is out of range");
return m_quadGeoms.find(elmt)->second->GetVid(vert);
}
}
void Nektar::SpatialDomains::MeshGraph2D::ReadComposites ( TiXmlDocument &  doc)
protected

We know we have it since we made it this far.

Look for elements in ELEMENT block.

All elements are of the form: "<C ID = "N"> ... </C>". Read the ID field first.

Parse out the element components corresponding to type of element.

Keep looking

Definition at line 363 of file MeshGraph2D.cpp.

References ASSERTL0, ErrorUtil::efatal, Nektar::SpatialDomains::MeshGraph::m_meshComposites, NEKERROR, and ResolveGeomRef().

Referenced by ReadGeometry().

{
TiXmlHandle docHandle(&doc);
/// We know we have it since we made it this far.
TiXmlElement* mesh = docHandle.FirstChildElement("NEKTAR").FirstChildElement("GEOMETRY").Element();
TiXmlElement* field = NULL;
ASSERTL0(mesh, "Unable to find GEOMETRY tag in file.");
/// Look for elements in ELEMENT block.
field = mesh->FirstChildElement("COMPOSITE");
ASSERTL0(field, "Unable to find COMPOSITE tag in file.");
int nextCompositeNumber = -1;
/// All elements are of the form: "<C ID = "N"> ... </C>".
/// Read the ID field first.
TiXmlElement *composite = field->FirstChildElement("C");
while (composite)
{
nextCompositeNumber++;
int indx;
int err = composite->QueryIntAttribute("ID", &indx);
ASSERTL0(err == TIXML_SUCCESS, "Unable to read attribute ID.");
// ASSERTL0(indx == nextCompositeNumber, "Composite IDs must begin with zero and be sequential.");
TiXmlNode* compositeChild = composite->FirstChild();
// This is primarily to skip comments that may be present.
// Comments appear as nodes just like elements.
// We are specifically looking for text in the body
// of the definition.
while(compositeChild && compositeChild->Type() != TiXmlNode::TINYXML_TEXT)
{
compositeChild = compositeChild->NextSibling();
}
ASSERTL0(compositeChild, "Unable to read composite definition body.");
std::string compositeStr = compositeChild->ToText()->ValueStr();
/// Parse out the element components corresponding to type of element.
std::istringstream compositeDataStrm(compositeStr.c_str());
try
{
bool first = true;
std::string prevCompositeElementStr;
while (!compositeDataStrm.fail())
{
std::string compositeElementStr;
compositeDataStrm >> compositeElementStr;
if (!compositeDataStrm.fail())
{
if (first)
{
first = false;
Composite curVector(MemoryManager<GeometryVector>::AllocateSharedPtr());
m_meshComposites[indx] = curVector;
}
if (compositeElementStr.length() > 0)
{
ResolveGeomRef(prevCompositeElementStr, compositeElementStr, m_meshComposites[indx]);
}
prevCompositeElementStr = compositeElementStr;
}
}
}
catch(...)
{
(std::string("Unable to read COMPOSITE data for composite: ") + compositeStr).c_str());
}
/// Keep looking
composite = composite->NextSiblingElement("C");
}
}
void Nektar::SpatialDomains::MeshGraph2D::ReadEdges ( TiXmlDocument &  doc)
protected

We know we have it since we made it this far.

Look for elements in ELEMENT block.

All elements are of the form: "<E ID="#"> ... </E>", with ? being the element type. Read the ID field first.

Since all edge data is one big text block, we need to accumulate all TINYXML_TEXT data and then parse it. This approach effectively skips all comments or other node types since we only care about the edge list. We cannot handle missing edge numbers as we could with missing element numbers due to the text block format.

Now parse out the edges, three fields at a time.

Definition at line 97 of file MeshGraph2D.cpp.

References ASSERTL0, ErrorUtil::efatal, Nektar::SpatialDomains::MeshGraph::GetVertex(), Nektar::SpatialDomains::MeshGraph::m_curvedEdges, Nektar::SpatialDomains::MeshGraph::m_segGeoms, Nektar::SpatialDomains::MeshGraph::m_spaceDimension, and NEKERROR.

Referenced by ReadGeometry().

{
/// We know we have it since we made it this far.
TiXmlHandle docHandle(&doc);
TiXmlElement* mesh = docHandle.FirstChildElement("NEKTAR").FirstChildElement("GEOMETRY").Element();
TiXmlElement* field = NULL;
/// Look for elements in ELEMENT block.
field = mesh->FirstChildElement("EDGE");
ASSERTL0(field, "Unable to find EDGE tag in file.");
/// All elements are of the form: "<E ID="#"> ... </E>", with
/// ? being the element type.
/// Read the ID field first.
TiXmlElement *edge = field->FirstChildElement("E");
/// Since all edge data is one big text block, we need to
/// accumulate all TINYXML_TEXT data and then parse it. This
/// approach effectively skips all comments or other node
/// types since we only care about the edge list. We
/// cannot handle missing edge numbers as we could with
/// missing element numbers due to the text block format.
std::string edgeStr;
int i,indx;
int nextEdgeNumber = -1;
// Curved Edges
map<int, int> edge_curved;
for(i = 0; i < m_curvedEdges.size(); ++i)
{
edge_curved[m_curvedEdges[i]->m_curveID] = i;
}
while(edge)
{
nextEdgeNumber++;
int err = edge->QueryIntAttribute("ID",&indx);
ASSERTL0(err == TIXML_SUCCESS, "Unable to read edge attribute ID.");
// ASSERTL0(indx == nextEdgeNumber, "Edge IDs must begin with zero and be sequential.");
TiXmlNode *child = edge->FirstChild();
edgeStr.clear();
if (child->Type() == TiXmlNode::TINYXML_TEXT)
{
edgeStr += child->ToText()->ValueStr();
}
/// Now parse out the edges, three fields at a time.
int vertex1, vertex2;
std::istringstream edgeDataStrm(edgeStr.c_str());
try
{
while (!edgeDataStrm.fail())
{
edgeDataStrm >> vertex1 >> vertex2;
// Must check after the read because we may be
// at the end and not know it. If we are at
// the end we will add a duplicate of the last
// entry if we don't check here.
if (!edgeDataStrm.fail())
{
PointGeomSharedPtr vertices[2] = {GetVertex(vertex1), GetVertex(vertex2)};
if(edge_curved.count(indx) == 0)
{
edge = MemoryManager<SegGeom>::AllocateSharedPtr(indx, m_spaceDimension, vertices);
edge->SetGlobalID(indx); // Set global mesh id
}
else
{
edge = MemoryManager<SegGeom>::AllocateSharedPtr(indx, m_spaceDimension, vertices, m_curvedEdges[edge_curved.find(indx)->second]);
edge->SetGlobalID(indx); //Set global mesh id
}
m_segGeoms[indx] = edge;
}
}
}
catch(...)
{
NEKERROR(ErrorUtil::efatal, (std::string("Unable to read edge data: ") + edgeStr).c_str());
}
edge = edge->NextSiblingElement("E");
}
}
void Nektar::SpatialDomains::MeshGraph2D::ReadElements ( TiXmlDocument &  doc)
protected

We know we have it since we made it this far.

Look for elements in ELEMENT block.

All elements are of the form: "<? ID="#"> ... </?>", with ? being the element type.

These should be ordered.

Read id attribute.

Read text element description.

Parse out the element components corresponding to type of element.

Create a TriGeom to hold the new definition.

Create a QuadGeom to hold the new definition.

Keep looking

Definition at line 191 of file MeshGraph2D.cpp.

References ASSERTL0, ErrorUtil::efatal, Nektar::SpatialDomains::SegGeom::GetEdgeOrientation(), GetSegGeom(), Nektar::iterator, Nektar::SpatialDomains::TriGeom::kNedges, Nektar::SpatialDomains::QuadGeom::kNedges, Nektar::SpatialDomains::MeshGraph::m_curvedFaces, Nektar::SpatialDomains::MeshGraph::m_quadGeoms, Nektar::SpatialDomains::MeshGraph::m_triGeoms, and NEKERROR.

Referenced by ReadGeometry().

{
/// We know we have it since we made it this far.
TiXmlHandle docHandle(&doc);
TiXmlElement* mesh = docHandle.FirstChildElement("NEKTAR").FirstChildElement("GEOMETRY").Element();
TiXmlElement* field = NULL;
/// Look for elements in ELEMENT block.
field = mesh->FirstChildElement("ELEMENT");
ASSERTL0(field, "Unable to find ELEMENT tag in file.");
// Set up curve map for curved elements on an embedded manifold.
map<int, int> faceCurves;
for (int i = 0; i < m_curvedFaces.size(); ++i)
{
faceCurves[m_curvedFaces[i]->m_curveID] = i;
}
int nextElementNumber = -1;
/// All elements are of the form: "<? ID="#"> ... </?>", with
/// ? being the element type.
TiXmlElement *element = field->FirstChildElement();
while (element)
{
std::string elementType(element->ValueStr());
ASSERTL0(elementType == "Q" || elementType == "T",
(std::string("Unknown 2D element type: ") + elementType).c_str());
/// These should be ordered.
nextElementNumber++;
/// Read id attribute.
int indx;
int err = element->QueryIntAttribute("ID", &indx);
ASSERTL0(err == TIXML_SUCCESS, "Unable to read element attribute ID.");
// ASSERTL0(indx == nextElementNumber, "Element IDs must begin with zero and be sequential.");
/// Read text element description.
TiXmlNode* elementChild = element->FirstChild();
std::string elementStr;
while(elementChild)
{
if (elementChild->Type() == TiXmlNode::TINYXML_TEXT)
{
elementStr += elementChild->ToText()->ValueStr();
}
elementChild = elementChild->NextSibling();
}
ASSERTL0(!elementStr.empty(), "Unable to read element description body.");
/// Parse out the element components corresponding to type of element.
if (elementType == "T")
{
// Read three edge numbers
int edge1, edge2, edge3;
std::istringstream elementDataStrm(elementStr.c_str());
try
{
elementDataStrm >> edge1;
elementDataStrm >> edge2;
elementDataStrm >> edge3;
ASSERTL0(!elementDataStrm.fail(), (std::string("Unable to read element data for TRIANGLE: ") + elementStr).c_str());
/// Create a TriGeom to hold the new definition.
{
GetSegGeom(edge1),
GetSegGeom(edge2),
GetSegGeom(edge3)
};
{
SegGeom::GetEdgeOrientation(*edges[0], *edges[1]),
SegGeom::GetEdgeOrientation(*edges[1], *edges[2]),
SegGeom::GetEdgeOrientation(*edges[2], *edges[0])
};
if ((x = faceCurves.find(indx)) == faceCurves.end())
{
trigeom = MemoryManager<TriGeom>
::AllocateSharedPtr(indx,
edges,
edgeorient);
}
else
{
trigeom = MemoryManager<TriGeom>
::AllocateSharedPtr(indx,
edges,
edgeorient,
m_curvedFaces[x->second]);
}
trigeom->SetGlobalID(indx);
m_triGeoms[indx] = trigeom;
}
catch(...)
{
NEKERROR(ErrorUtil::efatal, (std::string("Unable to read element data for TRIANGLE: ") + elementStr).c_str());
}
}
else if (elementType == "Q")
{
// Read four edge numbers
int edge1, edge2, edge3, edge4;
std::istringstream elementDataStrm(elementStr.c_str());
try
{
elementDataStrm >> edge1;
elementDataStrm >> edge2;
elementDataStrm >> edge3;
elementDataStrm >> edge4;
ASSERTL0(!elementDataStrm.fail(), (std::string("Unable to read element data for QUAD: ") + elementStr).c_str());
/// Create a QuadGeom to hold the new definition.
{GetSegGeom(edge1),GetSegGeom(edge2),
GetSegGeom(edge3),GetSegGeom(edge4)};
{
SegGeom::GetEdgeOrientation(*edges[0], *edges[1]),
SegGeom::GetEdgeOrientation(*edges[1], *edges[2]),
SegGeom::GetEdgeOrientation(*edges[2], *edges[3]),
SegGeom::GetEdgeOrientation(*edges[3], *edges[0])
};
if ((x = faceCurves.find(indx)) == faceCurves.end())
{
quadgeom = MemoryManager<QuadGeom>
::AllocateSharedPtr(indx,
edges,
edgeorient);
}
else
{
quadgeom = MemoryManager<QuadGeom>
::AllocateSharedPtr(indx,
edges,
edgeorient,
m_curvedFaces[x->second]);
}
quadgeom->SetGlobalID(indx);
m_quadGeoms[indx] = quadgeom;
}
catch(...)
{
NEKERROR(ErrorUtil::efatal,(std::string("Unable to read element data for QUAD: ") + elementStr).c_str());
}
}
/// Keep looking
element = element->NextSiblingElement();
}
}
void Nektar::SpatialDomains::MeshGraph2D::ReadGeometry ( const std::string &  infilename)
virtual

Read will read the meshgraph vertices given a filename.

Reimplemented from Nektar::SpatialDomains::MeshGraph.

Definition at line 62 of file MeshGraph2D.cpp.

References ASSERTL0.

Referenced by MeshGraph2D(), and ReadGeometry().

{
TiXmlDocument doc(infilename);
bool loadOkay = doc.LoadFile();
std::stringstream errstr;
errstr << "Unable to load file: " << infilename << "\n";
errstr << doc.ErrorDesc() << " (Line " << doc.ErrorRow()
<< ", Column " << doc.ErrorCol() << ")";
ASSERTL0(loadOkay, errstr.str());
}
void Nektar::SpatialDomains::MeshGraph2D::ReadGeometry ( TiXmlDocument &  doc)
virtual

Read will read the meshgraph vertices given a TiXmlDocument.

Look for all geometry related data in GEOMETRY block.

Error value returned by TinyXML.

Reimplemented from Nektar::SpatialDomains::MeshGraph.

Definition at line 77 of file MeshGraph2D.cpp.

References ASSERTL0, ReadComposites(), Nektar::SpatialDomains::MeshGraph::ReadCurves(), Nektar::SpatialDomains::MeshGraph::ReadDomain(), ReadEdges(), ReadElements(), and ReadGeometry().

{
// Read mesh first
TiXmlHandle docHandle(&doc);
TiXmlElement* mesh = NULL;
/// Look for all geometry related data in GEOMETRY block.
mesh = docHandle.FirstChildElement("NEKTAR").FirstChildElement("GEOMETRY").Element();
ASSERTL0(mesh, "Unable to find GEOMETRY tag in file.");
ReadCurves(doc);
ReadEdges(doc);
ReadDomain(doc);
}
void Nektar::SpatialDomains::MeshGraph2D::ResolveGeomRef ( const std::string &  prevToken,
const std::string &  token,
Composite composite 
)
protected

Definition at line 465 of file MeshGraph2D.cpp.

References ASSERTL0, Nektar::SpatialDomains::MeshGraph::CheckRange(), ErrorUtil::efatal, ErrorUtil::ewarning, Nektar::ParseUtils::GenerateSeqVector(), Nektar::iterator, Nektar::SpatialDomains::MeshGraph::m_quadGeoms, Nektar::SpatialDomains::MeshGraph::m_segGeoms, Nektar::SpatialDomains::MeshGraph::m_triGeoms, Nektar::SpatialDomains::MeshGraph::m_vertSet, and NEKERROR.

Referenced by ReadComposites().

{
try
{
std::istringstream tokenStream(token);
std::istringstream prevTokenStream(prevToken);
char type;
char prevType;
tokenStream >> type;
std::string::size_type indxBeg = token.find_first_of('[') + 1;
std::string::size_type indxEnd = token.find_last_of(']') - 1;
ASSERTL0(indxBeg <= indxEnd, (std::string("Error reading index definition:") + token).c_str());
std::string indxStr = token.substr(indxBeg, indxEnd - indxBeg + 1);
std::vector<unsigned int> seqVector;
bool err = ParseUtils::GenerateSeqVector(indxStr.c_str(), seqVector);
ASSERTL0(err, (std::string("Error reading composite elements: ") + indxStr).c_str());
prevTokenStream >> prevType;
// All composites must be of the same dimension.
bool validSequence = (prevToken.empty() || // No previous, then current is just fine.
(type == 'V' && prevType == 'V') ||
(type == 'E' && prevType == 'E') ||
((type == 'T' || type == 'Q') &&
(prevType == 'T' || prevType == 'Q')));
ASSERTL0(validSequence, (std::string("Invalid combination of composite items: ")
+ type + " and " + prevType + ".").c_str());
switch(type)
{
case 'E': // Edge
for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
{
if (m_segGeoms.find(*seqIter) == m_segGeoms.end())
{
char errStr[16] = "";
::sprintf(errStr, "%d", *seqIter);
NEKERROR(ErrorUtil::ewarning, (std::string("Unknown edge index: ") + errStr).c_str());
}
else
{
composite->push_back(m_segGeoms[*seqIter]);
}
}
break;
case 'T': // Triangle
{
for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
{
if (m_triGeoms.count(*seqIter) == 0 )
{
char errStr[16] = "";
::sprintf(errStr, "%d", *seqIter);
NEKERROR(ErrorUtil::ewarning, (std::string("Unknown triangle index: ") + errStr).c_str());
}
else
{
if(CheckRange(*m_triGeoms[*seqIter]))
{
composite->push_back(m_triGeoms[*seqIter]);
}
}
}
}
break;
case 'Q': // Quad
{
for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
{
if (m_quadGeoms.count(*seqIter) == 0)
{
char errStr[16] = "";
::sprintf(errStr, "%d", *seqIter);
NEKERROR(ErrorUtil::ewarning, (std::string("Unknown quad index: ") + errStr +std::string(" in Composite section")).c_str());
}
else
{
if(CheckRange(*m_quadGeoms[*seqIter]))
{
composite->push_back(m_quadGeoms[*seqIter]);
}
}
}
}
break;
case 'V': // Vertex
for (seqIter = seqVector.begin(); seqIter != seqVector.end(); ++seqIter)
{
if (*seqIter >= m_vertSet.size())
{
char errStr[16] = "";
::sprintf(errStr, "%d", *seqIter);
NEKERROR(ErrorUtil::ewarning, (std::string("Unknown vertex index: ") + errStr).c_str());
}
else
{
composite->push_back(m_vertSet[*seqIter]);
}
}
break;
default:
NEKERROR(ErrorUtil::efatal, (std::string("Unrecognized composite token: ") + token).c_str());
}
}
catch(...)
{
NEKERROR(ErrorUtil::efatal, (std::string("Problem processing composite token: ") + token).c_str());
}
return;
}