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

This processing module calculates the Jacobian of elements using SpatialDomains::GeomFactors and the Element::GetGeom method. For now it simply prints a list of elements which have negative Jacobian. More...

#include <ProcessDetectSurf.h>

Inheritance diagram for Nektar::Utilities::ProcessDetectSurf:
Inheritance graph
[legend]
Collaboration diagram for Nektar::Utilities::ProcessDetectSurf:
Collaboration graph
[legend]

Public Member Functions

 ProcessDetectSurf (MeshSharedPtr m)
virtual ~ProcessDetectSurf ()
virtual void Process ()
 Write mesh to output file.
- Public Member Functions inherited from Nektar::Utilities::ProcessModule
 ProcessModule (FieldSharedPtr p_f)
 ProcessModule (MeshSharedPtr p_m)
- Public Member Functions inherited from Nektar::Utilities::Module
 Module (FieldSharedPtr p_f)
virtual void Process (po::variables_map &vm)=0
void RegisterConfig (string key, string value)
 Register a configuration option with a module.
void PrintConfig ()
 Print out all configuration options for a module.
void SetDefaults ()
 Sets default configuration options for those which have not been set.
bool GetRequireEquiSpaced (void)
void SetRequireEquiSpaced (bool pVal)
 Module (MeshSharedPtr p_m)
void RegisterConfig (string key, string value)
void PrintConfig ()
void SetDefaults ()
MeshSharedPtr GetMesh ()
virtual void ProcessVertices ()
 Extract element vertices.

Static Public Member Functions

static boost::shared_ptr< Modulecreate (MeshSharedPtr m)
 Creates an instance of this class.

Static Public Attributes

static ModuleKey className

Private Member Functions

void FindContiguousSurface (ElementSharedPtr start, set< int > &doneIds, vector< ElementSharedPtr > &block)

Additional Inherited Members

- Protected Member Functions inherited from Nektar::Utilities::Module
virtual void ProcessEdges (bool ReprocessEdges=true)
 Extract element edges.
virtual void ProcessFaces (bool ReprocessFaces=true)
 Extract element faces.
virtual void ProcessElements ()
 Generate element IDs.
virtual void ProcessComposites ()
 Generate composites.
void ReorderPrisms (PerMap &perFaces)
 Reorder node IDs so that prisms and tetrahedra are aligned correctly.
void PrismLines (int prism, PerMap &perFaces, set< int > &prismsDone, vector< ElementSharedPtr > &line)
- Protected Attributes inherited from Nektar::Utilities::Module
FieldSharedPtr m_f
 Field object.
map< string, ConfigOptionm_config
 List of configuration values.
bool m_requireEquiSpaced
MeshSharedPtr m_mesh
 Mesh object.

Detailed Description

This processing module calculates the Jacobian of elements using SpatialDomains::GeomFactors and the Element::GetGeom method. For now it simply prints a list of elements which have negative Jacobian.

Definition at line 51 of file ProcessDetectSurf.h.

Constructor & Destructor Documentation

Nektar::Utilities::ProcessDetectSurf::ProcessDetectSurf ( MeshSharedPtr  m)

Definition at line 54 of file ProcessDetectSurf.cpp.

References Nektar::Utilities::Module::m_config.

{
m_config["vol"] = ConfigOption(false, "-1",
"Tag identifying surface to process.");
}
Nektar::Utilities::ProcessDetectSurf::~ProcessDetectSurf ( )
virtual

Definition at line 60 of file ProcessDetectSurf.cpp.

{
}

Member Function Documentation

static boost::shared_ptr<Module> Nektar::Utilities::ProcessDetectSurf::create ( MeshSharedPtr  m)
inlinestatic

Creates an instance of this class.

Definition at line 55 of file ProcessDetectSurf.h.

{
return MemoryManager<ProcessDetectSurf>::AllocateSharedPtr(m);
}
void Nektar::Utilities::ProcessDetectSurf::FindContiguousSurface ( ElementSharedPtr  start,
set< int > &  doneIds,
vector< ElementSharedPtr > &  block 
)
private

Definition at line 212 of file ProcessDetectSurf.cpp.

Referenced by Process().

{
block.push_back(start);
doneIds.erase(start->GetId());
vector<EdgeSharedPtr> edges = start->GetEdgeList();
for (int i = 0; i < edges.size(); ++i)
{
for (int j = 0; j < edges[i]->m_elLink.size(); ++j)
{
ElementSharedPtr elmt = edges[i]->m_elLink[j].first;
if (elmt == start)
{
continue;
}
if (doneIds.count(elmt->GetId()) == 0)
{
continue;
}
FindContiguousSurface(elmt, doneIds, block);
}
}
}
void Nektar::Utilities::ProcessDetectSurf::Process ( )
virtual

Write mesh to output file.

Implements Nektar::Utilities::Module.

Definition at line 71 of file ProcessDetectSurf.cpp.

References ASSERTL0, Nektar::LibUtilities::eSegment, FindContiguousSurface(), Nektar::ParseUtils::GenerateSeqVector(), Nektar::Utilities::GetElementFactory(), Nektar::iterator, Nektar::Utilities::Module::m_config, and Nektar::Utilities::Module::m_mesh.

{
if (m_mesh->m_expDim > 2)
{
cerr << "Surface detection only implemented for 2D meshes" << endl;
return;
}
int i, j;
string surf = m_config["vol"].as<string>();
// Obtain vector of surface IDs from string.
vector<unsigned int> surfs;
if (surf != "-1")
{
ParseUtils::GenerateSeqVector(surf.c_str(), surfs);
sort(surfs.begin(), surfs.end());
}
// If we're running in verbose mode print out a list of surfaces.
if (m_mesh->m_verbose)
{
cout << "ProcessDetectSurf: detecting surfaces";
if (surfs.size() > 0)
{
cout << " for surface" << (surfs.size() == 1 ? "" : "s")
<< " " << surf << endl;
}
}
vector<ElementSharedPtr> &el = m_mesh->m_element[m_mesh->m_expDim];
map<int, EdgeInfo> edgeCount;
set<int> doneIds;
map<int, int> idMap;
// Iterate over list of surface elements.
for (i = 0; i < el.size(); ++i)
{
// Work out whether this lies on our surface of interest.
if (surfs.size() > 0)
{
vector<int> inter, tags = el[i]->GetTagList();
sort(tags.begin(), tags.end());
set_intersection(surfs.begin(), surfs.end(),
tags .begin(), tags .end(),
back_inserter(inter));
// It doesn't continue to next element.
if (inter.size() != 1)
{
continue;
}
}
// List all edges.
ElementSharedPtr elmt = el[i];
for (j = 0; j < elmt->GetEdgeCount(); ++j)
{
EdgeSharedPtr e = elmt->GetEdge(j);
int eId = e->m_id;
edgeCount[eId].count++;
edgeCount[eId].edge = e;
}
doneIds.insert(elmt->GetId());
ASSERTL0(idMap.count(elmt->GetId()) == 0, "Shouldn't happen");
idMap[elmt->GetId()] = i;
}
unsigned int maxId = 0;
for (cIt = m_mesh->m_composite.begin(); cIt != m_mesh->m_composite.end(); ++cIt)
{
maxId = std::max(cIt->first, maxId);
}
++maxId;
while (doneIds.size() > 0)
{
= m_mesh->m_element[m_mesh->m_expDim][idMap[*(doneIds.begin())]];
vector<ElementSharedPtr> block;
FindContiguousSurface(start, doneIds, block);
ASSERTL0(block.size() > 0, "Contiguous block not found");
// Loop over all edges in block.
for (i = 0; i < block.size(); ++i)
{
// Find edge info.
ElementSharedPtr elmt = block[i];
for (j = 0; j < elmt->GetEdgeCount(); ++j)
{
eIt = edgeCount.find(elmt->GetEdge(j)->m_id);
ASSERTL0(eIt != edgeCount.end(), "Couldn't find edge");
eIt->second.group = maxId;
}
}
++maxId;
}
for (eIt = edgeCount.begin(); eIt != edgeCount.end(); ++eIt)
{
if (eIt->second.count > 1)
{
continue;
}
unsigned int compId = eIt->second.group;
CompositeMap::iterator cIt = m_mesh->m_composite.find(compId);
if (cIt == m_mesh->m_composite.end())
{
comp->m_id = compId;
comp->m_tag = "E";
cIt = m_mesh->m_composite.insert(std::make_pair(compId, comp)).first;
}
vector<int> tags(1);
tags[0] = compId;
vector<NodeSharedPtr> nodeList(2);
nodeList[0] = eIt->second.edge->m_n1;
nodeList[1] = eIt->second.edge->m_n2;
ElmtConfig conf(LibUtilities::eSegment, 1, false, false);
CreateInstance(LibUtilities::eSegment,conf,nodeList,tags);
elmt->SetEdgeLink(eIt->second.edge);
cIt->second->m_items.push_back(elmt);
}
}

Member Data Documentation

ModuleKey Nektar::Utilities::ProcessDetectSurf::className
static
Initial value:
"Process elements to detect a surface.")

Definition at line 58 of file ProcessDetectSurf.h.