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

#include <Domain.h>

Collaboration diagram for Nektar::SpatialDomains::Domain:
Collaboration graph
[legend]

Public Member Functions

 Domain (MeshGraph *meshGraph)
virtual ~Domain ()
void Read (std::string &infilename)
void Read (TiXmlDocument &doc)
void Write (std::string &outfilename)
CompositeVector GetDomain (void) const
BoundaryVector GetBoundaries (void) const
void SetFileName (const std::string &inString)

Protected Attributes

MeshGraphm_meshGraph
CompositeVector m_domain
BoundaryVector m_boundaries

Private Member Functions

 Domain ()

Detailed Description

Definition at line 82 of file Domain.h.

Constructor & Destructor Documentation

Nektar::SpatialDomains::Domain::Domain ( MeshGraph meshGraph)

Definition at line 51 of file Domain.cpp.

:
m_meshGraph(meshGraph)
{
}
Nektar::SpatialDomains::Domain::~Domain ( )
virtual

Definition at line 56 of file Domain.cpp.

{
}
Nektar::SpatialDomains::Domain::Domain ( )
inlineprivate

Definition at line 110 of file Domain.h.

References ErrorUtil::efatal, and NEKERROR.

{ NEKERROR(ErrorUtil::efatal, "Must provide a meshgraph to create a Domain."); }; // Don't call this.

Member Function Documentation

BoundaryVector Nektar::SpatialDomains::Domain::GetBoundaries ( void  ) const
inline

Definition at line 95 of file Domain.h.

{ return m_Boundaries; };
CompositeVector Nektar::SpatialDomains::Domain::GetDomain ( void  ) const
inline

Definition at line 94 of file Domain.h.

{ return m_Domain; };
void Nektar::SpatialDomains::Domain::Read ( std::string &  infilename)

Definition at line 60 of file Domain.cpp.

References ASSERTL0, and SetFileName().

{
SetFileName(infilename);
TiXmlDocument doc(infilename);
bool loadOkay = doc.LoadFile();
ASSERTL0(loadOkay, (std::string("Unable to load file: ") + infilename).c_str());
Read(doc);
}
void Nektar::SpatialDomains::Domain::Read ( TiXmlDocument &  doc)

Definition at line 72 of file Domain.cpp.

References ASSERTL0, Nektar::SpatialDomains::BoundaryTypeNameMap, Nektar::SpatialDomains::eBoundaryTypeLastElement, Nektar::StdRegions::find(), Nektar::SpatialDomains::MeshGraph::GetComposite(), m_boundaries, m_domain, and m_meshGraph.

{
TiXmlElement* master = NULL; // Master tag within which all data is contained.
TiXmlElement* domain = NULL;
TiXmlElement* boundary = NULL;
master = doc.FirstChildElement("NEKTAR");
ASSERTL0(master, "Unable to find NEKTAR tag in file");
domain = master->FirstChildElement("DOMAIN");
ASSERTL0(domain, "Unable to find DOMAIN tag in file.");
TiXmlNode *node = domain->FirstChild();
std::string components(node->ValueStr());
std::istringstream domainStrm(components);
std::string entry;
// May have multiple composites defined.
if(domainStrm)
{
domainStrm >> entry;
if (entry.length())
{
ASSERTL0(entry[0] == 'C', "Only composites are allowed in a definition of a domain.");
// Determine the index associated with the C. Allow range syntax.
std::string::size_type indxBeg = entry.find_first_of('[') + 1;
std::string::size_type indxEnd = entry.find_last_of(']') - 1;
ASSERTL0(indxBeg <= indxEnd, (std::string("Error reading DOMAIN definition:") + entry).c_str());
std::string indxStr = entry.substr(indxBeg, indxEnd - indxBeg + 1);
std::istringstream indexStrm(indxStr);
int indx1=-1, indx2=-1;
if (indexStrm)
{
// Should read either [a] where a is a nonnegative integer, or
// [a-b] where a and b are nonnegative integers, b>a.
// Easiest way to know is if a '-' is present we have the latter
// case.
indexStrm >> indx1;
ASSERTL0(indx1 >= 0, (std::string("Error reading collection range: ") + indxStr).c_str());
indx2 = indx1;
std::string::size_type dashLoc=indxStr.find('-');
if (dashLoc != std::string::npos)
{
// Skip up to and including the '-' character, then read
// the other index. We are safe in doing this because we
// already know it is there...somewhere.
indexStrm.seekg(dashLoc+1);
indexStrm >> indx2;
ASSERTL0(indx1 < indx2 && indx2 >= 0,
(std::string("Error reading collection range: ") + indxStr).c_str());
}
for (int i=indx1; i<=indx2; ++i)
{
m_domain.push_back(composite);
}
}
}
}
boundary = master->FirstChildElement("BOUNDARY");
ASSERTL0(boundary, "Unable to find BOUNDARY tag in file.");
TiXmlElement *bc = boundary->FirstChildElement();
// Boundary will have type and composite list.
while(bc)
{
std::string bcType(bc->ValueStr());
TiXmlNode *node = bc->FirstChild();
std::string components(node->ValueStr());
std::istringstream boundaryStrm(components);
std::string entry;
// Index of the tag letter into the type enum.
const char *beginName = BoundaryTypeNameMap;
// std::find needs the end to be one past the last element.
const char *endName = BoundaryTypeNameMap+eBoundaryTypeLastElement + 1;
const char* indx = std::find(beginName, endName, bcType[0]);
// Not found if the index (ptr) is past the last element.
ASSERTL0(indx != endName, (std::string("Unable to read boundary type tag: ") + bcType).c_str());
BoundarySharedPtr boundary(new BoundaryEntry);
boundary->m_BoundaryType = BoundaryType(indx - BoundaryTypeNameMap);
m_boundaries.push_back(boundary);
// May have multiple composites defined.
if(boundaryStrm)
{
domainStrm >> entry;
if (entry.length())
{
ASSERTL0(entry[0] == 'C', "Only composites are allowed in a definition of a boundary condition.");
// Determine the index associated with the C. Allow range syntax.
std::string::size_type indxBeg = entry.find_first_of('[') + 1;
std::string::size_type indxEnd = entry.find_last_of(']') - 1;
ASSERTL0(indxBeg <= indxEnd, (std::string("Error reading BOUNDARY definition:") + entry).c_str());
// Read between the brackets.
std::string indxStr = entry.substr(indxBeg, indxEnd - indxBeg + 1);
std::istringstream indexStrm(indxStr);
int indx1=-1, indx2=-1;
if(indexStrm)
{
// Should read either [a] where a is a nonnegative integer, or
// [a-b] where a and b are nonnegative integers, b>a.
// Easiest way to know is if a '-' is present we have the latter
// case.
indexStrm >> indx1;
ASSERTL0(indx1 >= 0, (std::string("Error reading collection range: ") + indxStr).c_str());
std::string::size_type dashLoc=indxStr.find('-');
if (dashLoc != std::string::npos)
{
// Skip up to and including the '-' character, then read
// the other index. We are safe in doing this because we
// already know it is there...somewhere.
while(indexStrm.get() != '-');
indexStrm >> indx2;
ASSERTL0(indx1 < indx2 && indx2 >= 0,
(std::string("Error reading collection range: ") + indxStr).c_str());
}
for (int i=indx1; i<=indx2; ++i)
{
boundary->m_BoundaryComposites.push_back(composite);
}
}
}
}
bc = bc->NextSiblingElement();
}
}
void Nektar::SpatialDomains::Domain::SetFileName ( const std::string &  inString)
inline

Definition at line 97 of file Domain.h.

Referenced by Read().

{
m_FileName = inString;
};
void Nektar::SpatialDomains::Domain::Write ( std::string &  outfilename)

Definition at line 228 of file Domain.cpp.

{
}

Member Data Documentation

BoundaryVector Nektar::SpatialDomains::Domain::m_boundaries
protected

Definition at line 107 of file Domain.h.

Referenced by Read().

CompositeVector Nektar::SpatialDomains::Domain::m_domain
protected

Definition at line 106 of file Domain.h.

Referenced by Read().

MeshGraph* Nektar::SpatialDomains::Domain::m_meshGraph
protected

Definition at line 100 of file Domain.h.

Referenced by Read().