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

A composite is a collection of elements. More...

#include <MeshElements.h>

Collaboration diagram for Nektar::Utilities::Composite:
Collaboration graph
[legend]

Public Member Functions

 Composite ()
std::string GetXmlString (bool doSort=true)
 Generate the list of IDs of elements within this composite.

Public Attributes

unsigned int m_id
 ID of composite.
std::string m_tag
 Element type tag.
bool m_reorder
 Determines whether items can be reordered.
std::vector< ElementSharedPtrm_items
 List of elements in this composite.

Detailed Description

A composite is a collection of elements.

All elements should be of the same type, i.e. have the same tag.

Definition at line 1107 of file MeshElements.h.

Constructor & Destructor Documentation

Nektar::Utilities::Composite::Composite ( )
inline

Definition at line 1109 of file MeshElements.h.

: m_reorder(true) {}

Member Function Documentation

string Nektar::Utilities::Composite::GetXmlString ( bool  doSort = true)

Generate the list of IDs of elements within this composite.

Generate a Nektar++ string describing the composite.

The list of composites may include individual element IDs or ranges of element IDs.

Definition at line 330 of file MeshElements.cpp.

References Nektar::iterator, m_items, and m_tag.

{
#if 0 // turn this option off since causes problem with InputNekpp.cpp
if (doSort)
{
element_id_less_than sortOperator;
sort(m_items.begin(), m_items.end(), sortOperator);
}
#endif
stringstream st;
bool range = false;
int vId = m_items[0]->GetId();
int prevId = vId;
st << " " << m_tag << "[" << vId;
for (it = m_items.begin()+1; it != m_items.end(); ++it){
// store previous element ID and get current one
prevId = vId;
vId = (*it)->GetId();
// continue an already started range
if (prevId > -1 && vId == prevId + 1)
{
range = true;
// if this is the last element, it's the end of a range, so write
if (*it == m_items.back())
{
st << "-" << vId;
}
continue;
}
// terminate a range, if present
if (range)
{
st << "-" << prevId;
range = false;
}
// write what will be either a single entry or start of new range
st << "," << vId;
}
// terminate
st << "] ";
return st.str();
}

Member Data Documentation

unsigned int Nektar::Utilities::Composite::m_id

ID of composite.

Definition at line 1115 of file MeshElements.h.

std::vector<ElementSharedPtr> Nektar::Utilities::Composite::m_items

List of elements in this composite.

Definition at line 1121 of file MeshElements.h.

Referenced by GetXmlString().

bool Nektar::Utilities::Composite::m_reorder

Determines whether items can be reordered.

Definition at line 1119 of file MeshElements.h.

std::string Nektar::Utilities::Composite::m_tag

Element type tag.

Definition at line 1117 of file MeshElements.h.

Referenced by GetXmlString().