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

#include <MeshGraph1D.h>

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

Public Member Functions

 MeshGraph1D ()
 MeshGraph1D (const LibUtilities::SessionReaderSharedPtr &pSession, const DomainRangeShPtr &rng=NullDomainRangeShPtr)
virtual ~MeshGraph1D ()
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.
void ReadElements (TiXmlDocument &doc)
void ReadComposites (TiXmlDocument &doc)
void ResolveGeomRef (const std::string &prevToken, const std::string &token, Composite &composite)
int GetCoordim (void)
const SegGeomMapGetSeggeoms (void) const
int GetVidFromElmt (const int vert, const int elmt) const
- 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.

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 Member Functions inherited from Nektar::SpatialDomains::MeshGraph
ExpansionMapShPtr SetUpExpansionMap (void)
- 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 47 of file MeshGraph1D.h.

Constructor & Destructor Documentation

Nektar::SpatialDomains::MeshGraph1D::MeshGraph1D ( )

Definition at line 46 of file MeshGraph1D.cpp.

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

Definition at line 50 of file MeshGraph1D.cpp.

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

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

Definition at line 58 of file MeshGraph1D.cpp.

{
}

Member Function Documentation

int Nektar::SpatialDomains::MeshGraph1D::GetCoordim ( void  )
inline

Definition at line 62 of file MeshGraph1D.h.

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

{
}
const SegGeomMap& Nektar::SpatialDomains::MeshGraph1D::GetSeggeoms ( void  ) const
inline

Definition at line 67 of file MeshGraph1D.h.

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

{
return m_segGeoms;
}
int Nektar::SpatialDomains::MeshGraph1D::GetVidFromElmt ( const int  vert,
const int  elmt 
) const
inline

Definition at line 72 of file MeshGraph1D.h.

References ASSERTL2, and Nektar::SpatialDomains::MeshGraph::m_segGeoms.

{
ASSERTL2((elmt >=0)&&(elmt < m_segGeoms.size()),
"eid is out of range");
//return m_segGeoms[elmt]->GetVid(vert);
return m_segGeoms.find(elmt)->second->GetVid(vert);
}
void Nektar::SpatialDomains::MeshGraph1D::ReadComposites ( TiXmlDocument &  doc)

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.

Parse out the element components corresponding to type of element.

Keep looking for additional composite definitions.

Definition at line 164 of file MeshGraph1D.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.");
TiXmlElement *node = field->FirstChildElement("C");
// Sequential counter for the composite numbers.
int nextCompositeNumber = -1;
while (node)
{
/// All elements are of the form: "<? ID="#"> ... </?>", with
/// ? being the element type.
nextCompositeNumber++;
int indx;
int err = node->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 = node->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<std::vector<GeometrySharedPtr> >::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 for additional composite definitions.
node = node->NextSiblingElement("C");
}
ASSERTL0(nextCompositeNumber >= 0, "At least one composite must be specified.");
}
void Nektar::SpatialDomains::MeshGraph1D::ReadElements ( TiXmlDocument &  doc)

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

Look for elements in ELEMENT block.

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

Parse out the element components corresponding to type of element. Read two vertex numbers

Keep looking for additional segments

Definition at line 96 of file MeshGraph1D.cpp.

References ASSERTL0, ErrorUtil::efatal, Nektar::SpatialDomains::MeshGraph::GetVertex(), Nektar::SpatialDomains::MeshGraph::m_segGeoms, 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.");
int nextElementNumber = -1;
/// All elements are of the form: "<S ID = n> ... </S>", with
/// ? being the element type.
TiXmlElement *segment = field->FirstChildElement("S");
while (segment)
{
nextElementNumber++;
int indx;
int err = segment->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.");
TiXmlNode* elementChild = segment->FirstChild();
while(elementChild && elementChild->Type() != TiXmlNode::TINYXML_TEXT)
{
elementChild = elementChild->NextSibling();
}
ASSERTL0(elementChild, "Unable to read element description body.");
std::string elementStr = elementChild->ToText()->ValueStr();
/// Parse out the element components corresponding to type of element.
/// Read two vertex numbers
int vertex1, vertex2;
std::istringstream elementDataStrm(elementStr.c_str());
try
{
elementDataStrm >> vertex1;
elementDataStrm >> vertex2;
ASSERTL0(!elementDataStrm.fail(), (std::string("Unable to read element data for SEGMENT: ") + elementStr).c_str());
SegGeomSharedPtr seg = MemoryManager<SegGeom>::AllocateSharedPtr(indx, v1,v2);
seg->SetGlobalID(indx);
m_segGeoms[indx] = seg;
}
catch(...)
{
(std::string("Unable to read element data for segment: ") + elementStr).c_str());
}
/// Keep looking for additional segments
segment = segment->NextSiblingElement("S");
}
ASSERTL0(nextElementNumber >= 0, "At least one element must be specified.");
}
void Nektar::SpatialDomains::MeshGraph1D::ReadGeometry ( const std::string &  infilename)
virtual

Read will read the meshgraph vertices given a filename.

Reimplemented from Nektar::SpatialDomains::MeshGraph.

Definition at line 63 of file MeshGraph1D.cpp.

References ASSERTL0.

Referenced by MeshGraph1D(), 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::MeshGraph1D::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 78 of file MeshGraph1D.cpp.

References ASSERTL0, ReadComposites(), Nektar::SpatialDomains::MeshGraph::ReadDomain(), 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.");
ReadDomain(doc);
}
void Nektar::SpatialDomains::MeshGraph1D::ResolveGeomRef ( const std::string &  prevToken,
const std::string &  token,
Composite composite 
)

Definition at line 259 of file MeshGraph1D.cpp.

References ASSERTL0, ErrorUtil::efatal, ErrorUtil::ewarning, Nektar::ParseUtils::GenerateSeqVector(), Nektar::iterator, Nektar::SpatialDomains::MeshGraph::m_segGeoms, 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);
typedef vector<unsigned int> SeqVectorType;
SeqVectorType seqVector;
if (!ParseUtils::GenerateSeqVector(indxStr.c_str(), seqVector))
{
NEKERROR(ErrorUtil::efatal, (std::string("Ill-formed sequence definition: ") + 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 == 'S' && prevType == 'S'));
ASSERTL0(validSequence, (std::string("Invalid combination of composite items: ")
+ type + " and " + prevType + ".").c_str());
switch(type)
{
case 'V': // Vertex
for (SeqVectorType::iterator iter=seqVector.begin(); iter!=seqVector.end(); ++iter)
{
if (m_vertSet.find(*iter) == m_vertSet.end())
{
char errStr[16] = "";
::sprintf(errStr, "%d", *iter);
NEKERROR(ErrorUtil::ewarning, (std::string("Unknown vertex index: ") + errStr).c_str());
}
else
{
composite->push_back(m_vertSet[*iter]);
}
}
break;
case 'S': // Segment
for (SeqVectorType::iterator iter=seqVector.begin(); iter!=seqVector.end(); ++iter)
{
if (m_segGeoms.find(*iter) == m_segGeoms.end())
{
char errStr[16] = "";
::sprintf(errStr, "%d", *iter);
NEKERROR(ErrorUtil::ewarning, (std::string("Unknown segment index: ") + errStr).c_str());
}
else
{
composite->push_back(m_segGeoms[*iter]);
}
}
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;
}