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::MultiRegions::BottomUpSubStructuredGraph Class Reference

#include <SubStructuredGraph.h>

Collaboration diagram for Nektar::MultiRegions::BottomUpSubStructuredGraph:
Collaboration graph
[legend]

Public Member Functions

 BottomUpSubStructuredGraph (const Array< OneD, const int > septree, const int nPartition)
 BottomUpSubStructuredGraph (const MultiLevelBisectedGraphSharedPtr &graph)
 BottomUpSubStructuredGraph (const int nVerts)
 ~BottomUpSubStructuredGraph (void)
int GetTotDofs () const
void UpdateBottomUpReordering (Array< OneD, int > &perm, Array< OneD, int > &iperm) const
void ExpandGraphWithVertexWeights (const Array< OneD, const int > &wgts)
void MaskPatches (const int leveltomask, Array< OneD, NekDouble > &maskarray) const
int GetNpatchesWithInterior (const int whichlevel) const
void GetNintDofsPerPatch (const int whichlevel, Array< OneD, unsigned int > &outarray) const
int GetInteriorOffset (const int whichlevel, const int patch=0) const
std::vector< SubGraphSharedPtrGetInteriorBlocks (const int whichlevel) const
int GetNumGlobalDofs (const int whichlevel) const
int GetNlevels () const
void Dump () const

Protected Attributes

std::vector< SubGraphSharedPtrm_IntBlocks
BottomUpSubStructuredGraphSharedPtr m_daughterGraph

Private Member Functions

void SetBottomUpReordering (Array< OneD, int > &iperm) const
BottomUpSubStructuredGraphSharedPtr GetDaughterGraph () const
std::vector< SubGraphSharedPtrGetInteriorBlocks () const

Detailed Description

Definition at line 186 of file SubStructuredGraph.h.

Constructor & Destructor Documentation

Nektar::MultiRegions::BottomUpSubStructuredGraph::BottomUpSubStructuredGraph ( const Array< OneD, const int >  septree,
const int  nPartition 
)

Definition at line 412 of file SubStructuredGraph.cpp.

References m_daughterGraph, and m_IntBlocks.

:
{
// First, create a top-down graph structure based upon the separator
// tree. This is easier as separation tree is also structured
// following a top-down approach
MemoryManager<MultiLevelBisectedGraph>::AllocateSharedPtr(
septree);
if (nPartition > 0)
{
topDownGraph = MemoryManager<MultiLevelBisectedGraph>::
AllocateSharedPtr(topDownGraph, nPartition);
}
// set the global numbering of the top-down graph
topDownGraph->SetGlobalNumberingOffset();
topDownGraph->CutEmptyLeaves();
// Secondly, recursively construct the subgraphs of the bottom up
// point of view 1. Collect all the leaves of the topdown graph this
// will be the first level of the bottom up graph
topDownGraph->CollectLeaves(m_IntBlocks);
// 2. Reduce the topdown graph by cutting the leaves (this will
// allow a recursive approach)
int ncuts = topDownGraph->CutLeaves();
// 3. If there were leaves to cut, proceed recursively
if (ncuts)
{
m_daughterGraph = MemoryManager<BottomUpSubStructuredGraph>::
AllocateSharedPtr(topDownGraph);
}
}
Nektar::MultiRegions::BottomUpSubStructuredGraph::BottomUpSubStructuredGraph ( const MultiLevelBisectedGraphSharedPtr graph)

Definition at line 453 of file SubStructuredGraph.cpp.

References m_daughterGraph, and m_IntBlocks.

:
{
int ncuts;
graph->CutEmptyLeaves();
graph->CollectLeaves(m_IntBlocks);
ncuts = graph->CutLeaves();
if(ncuts)
{
m_daughterGraph = MemoryManager<BottomUpSubStructuredGraph>::
AllocateSharedPtr(graph);
}
}
Nektar::MultiRegions::BottomUpSubStructuredGraph::BottomUpSubStructuredGraph ( const int  nVerts)

Definition at line 397 of file SubStructuredGraph.cpp.

References m_IntBlocks.

{
// This constructor should only be used in the very special case
// when there is a graph consisting of nVerts vertices but without
// any connectivity whatsowever (i.e. no edges)
for (int i = 0 ; i < nVerts; i++)
{
subgraph = MemoryManager<SubGraph>::AllocateSharedPtr(1,i);
m_IntBlocks.push_back(subgraph);
}
}
Nektar::MultiRegions::BottomUpSubStructuredGraph::~BottomUpSubStructuredGraph ( void  )

Definition at line 470 of file SubStructuredGraph.cpp.

{
}

Member Function Documentation

void Nektar::MultiRegions::BottomUpSubStructuredGraph::Dump ( ) const

Definition at line 503 of file SubStructuredGraph.cpp.

References m_daughterGraph, and m_IntBlocks.

{
static int level = 0;
level++;
cout << "LEVEL " << level << endl;
cout << "interior blocks" << endl;
for (int i = 0; i < m_IntBlocks.size(); i++)
{
cout << " " << i
<< "/" << m_IntBlocks.size()-1
<< ": " << m_IntBlocks[i]->GetNverts()
<< ", " << m_IntBlocks[i]->GetIdOffset() << endl;
}
cout << endl;
if (m_daughterGraph.get())
{
m_daughterGraph->Dump();
}
level--;
}
void Nektar::MultiRegions::BottomUpSubStructuredGraph::ExpandGraphWithVertexWeights ( const Array< OneD, const int > &  wgts)

Definition at line 581 of file SubStructuredGraph.cpp.

References m_daughterGraph, m_IntBlocks, and Nektar::MultiRegions::SubGraphWithoutVerts().

{
static int offset = 0;
static int level = 0;
level++;
if( m_daughterGraph.get())
{
m_daughterGraph->ExpandGraphWithVertexWeights(wgts);
}
for(int i = 0; i < m_IntBlocks.size(); i++)
{
int OrigGlobIdOffset = m_IntBlocks[i]->GetIdOffset();
int newNverts = 0;
m_IntBlocks[i]->SetIdOffset(offset);
for(int j = 0; j < m_IntBlocks[i]->GetNverts(); j++)
{
newNverts += wgts[OrigGlobIdOffset+j];
offset += wgts[OrigGlobIdOffset+j];
}
m_IntBlocks[i]->SetNverts(newNverts);
}
// erase the blocks that do not have any vertices
m_IntBlocks.erase(
remove_if(m_IntBlocks.begin(),
m_IntBlocks.end(),
m_IntBlocks.end());
// remove the current level if there are no interior blocks
if(m_IntBlocks.size() == 0 && m_daughterGraph.get())
{
m_IntBlocks = m_daughterGraph->GetInteriorBlocks();
m_daughterGraph = m_daughterGraph->GetDaughterGraph();
}
level--;
if(level == 0)
{
offset = 0;
}
}
BottomUpSubStructuredGraphSharedPtr Nektar::MultiRegions::BottomUpSubStructuredGraph::GetDaughterGraph ( ) const
inlineprivate

Definition at line 239 of file SubStructuredGraph.h.

References m_daughterGraph.

{
}
std::vector< SubGraphSharedPtr > Nektar::MultiRegions::BottomUpSubStructuredGraph::GetInteriorBlocks ( const int  whichlevel) const

Definition at line 748 of file SubStructuredGraph.cpp.

References ErrorUtil::efatal, m_daughterGraph, m_IntBlocks, and NEKERROR.

{
std::vector<SubGraphSharedPtr> returnval;
static int level = 0;
level++;
if(level < whichlevel)
{
returnval = m_daughterGraph->GetInteriorBlocks(whichlevel);
}
else if(level == whichlevel)
{
returnval = m_IntBlocks;
}
else
{
"If statement should not arrive here");
}
level--;
return returnval;
}
std::vector<SubGraphSharedPtr> Nektar::MultiRegions::BottomUpSubStructuredGraph::GetInteriorBlocks ( ) const
inlineprivate

Definition at line 243 of file SubStructuredGraph.h.

References m_IntBlocks.

{
return m_IntBlocks;
}
int Nektar::MultiRegions::BottomUpSubStructuredGraph::GetInteriorOffset ( const int  whichlevel,
const int  patch = 0 
) const

Definition at line 721 of file SubStructuredGraph.cpp.

References ErrorUtil::efatal, m_daughterGraph, m_IntBlocks, and NEKERROR.

{
int retval = -1;
static int level = 0;
level++;
if(level < whichlevel)
{
retval = m_daughterGraph->GetInteriorOffset(whichlevel,patch);
}
else if(level == whichlevel)
{
retval = m_IntBlocks[patch]->GetIdOffset();
}
else
{
"If statement should not arrive here");
}
level--;
return retval;
}
void Nektar::MultiRegions::BottomUpSubStructuredGraph::GetNintDofsPerPatch ( const int  whichlevel,
Array< OneD, unsigned int > &  outarray 
) const

Definition at line 691 of file SubStructuredGraph.cpp.

References ASSERTL1, ErrorUtil::efatal, m_daughterGraph, m_IntBlocks, and NEKERROR.

{
static int level = 0;
level++;
if(level < whichlevel)
{
m_daughterGraph->GetNintDofsPerPatch(whichlevel,outarray);
}
else if(level == whichlevel)
{
ASSERTL1(outarray.num_elements() >= m_IntBlocks.size(),
"Array dimension not sufficient");
for(int i = 0; i < m_IntBlocks.size(); i++)
{
outarray[i] = (unsigned int) m_IntBlocks[i]->GetNverts();
}
}
else
{
"If statement should not arrive here");
}
level--;
}
int Nektar::MultiRegions::BottomUpSubStructuredGraph::GetNlevels ( ) const

Definition at line 799 of file SubStructuredGraph.cpp.

References m_daughterGraph.

{
int returnval = 0;
static int level = 0;
level++;
if( m_daughterGraph.get())
{
returnval = m_daughterGraph->GetNlevels();
}
returnval = max(returnval,level);
level--;
return returnval;
}
int Nektar::MultiRegions::BottomUpSubStructuredGraph::GetNpatchesWithInterior ( const int  whichlevel) const

Definition at line 664 of file SubStructuredGraph.cpp.

References ErrorUtil::efatal, m_daughterGraph, m_IntBlocks, and NEKERROR.

{
int returnval = -1;
static int level = 0;
level++;
if(level < whichlevel)
{
returnval = m_daughterGraph->GetNpatchesWithInterior(
whichlevel);
}
else if(level == whichlevel)
{
returnval = m_IntBlocks.size();
}
else
{
"If statement should not arrive here");
}
level--;
return returnval;
}
int Nektar::MultiRegions::BottomUpSubStructuredGraph::GetNumGlobalDofs ( const int  whichlevel) const

Definition at line 772 of file SubStructuredGraph.cpp.

References ErrorUtil::efatal, m_daughterGraph, m_IntBlocks, and NEKERROR.

{
int returnval = -1;
static int level = 0;
level++;
if(level < whichlevel)
{
returnval = m_daughterGraph->GetNumGlobalDofs(whichlevel);
}
else if(level == whichlevel)
{
returnval = m_IntBlocks[m_IntBlocks.size()-1]->GetIdOffset()+
m_IntBlocks[m_IntBlocks.size()-1]->GetNverts();
}
else
{
"If statement should not arrive here");
}
level--;
return returnval;
}
int Nektar::MultiRegions::BottomUpSubStructuredGraph::GetTotDofs ( ) const

Definition at line 474 of file SubStructuredGraph.cpp.

References m_daughterGraph, and m_IntBlocks.

Referenced by UpdateBottomUpReordering().

{
static int nIntDofs = 0;
static int level = 0;
level++;
int returnval;
if( m_daughterGraph.get())
{
m_daughterGraph->GetTotDofs();
}
for(int i = 0; i < m_IntBlocks.size(); i++)
{
nIntDofs += m_IntBlocks[i]->GetNverts();
}
returnval = nIntDofs;
level--;
if(level == 0)
{
nIntDofs = 0;
}
return returnval;
}
void Nektar::MultiRegions::BottomUpSubStructuredGraph::MaskPatches ( const int  leveltomask,
Array< OneD, NekDouble > &  maskarray 
) const

Definition at line 630 of file SubStructuredGraph.cpp.

References ErrorUtil::efatal, m_daughterGraph, m_IntBlocks, and NEKERROR.

{
static int level = 0;
level++;
if(level < leveltomask)
{
m_daughterGraph->MaskPatches(leveltomask,maskarray);
}
else if(level == leveltomask)
{
int GlobIdOffset;
int nVerts;
for(int i = 0; i < m_IntBlocks.size(); i++)
{
GlobIdOffset = m_IntBlocks[i]->GetIdOffset();
nVerts = m_IntBlocks[i]->GetNverts();
for(int j = 0; j < nVerts; j++)
{
maskarray[GlobIdOffset+j] = (NekDouble) i;
}
}
}
else
{
"If statement should not arrive here");
}
level--;
}
void Nektar::MultiRegions::BottomUpSubStructuredGraph::SetBottomUpReordering ( Array< OneD, int > &  iperm) const
private

Definition at line 551 of file SubStructuredGraph.cpp.

References m_daughterGraph, and m_IntBlocks.

Referenced by UpdateBottomUpReordering().

{
static int offset = 0;
static int level = 0;
level++;
if( m_daughterGraph.get() )
{
m_daughterGraph->SetBottomUpReordering(iperm);
}
for(int i = 0; i < m_IntBlocks.size(); i++)
{
int GlobIdOffset = m_IntBlocks[i]->GetIdOffset();
m_IntBlocks[i]->SetIdOffset(offset);
for(int j = 0; j < m_IntBlocks[i]->GetNverts(); j++)
{
iperm[GlobIdOffset+j] = offset;
offset++;
}
}
level--;
if(level == 0)
{
offset = 0;
}
}
void Nektar::MultiRegions::BottomUpSubStructuredGraph::UpdateBottomUpReordering ( Array< OneD, int > &  perm,
Array< OneD, int > &  iperm 
) const

Definition at line 527 of file SubStructuredGraph.cpp.

References GetTotDofs(), and SetBottomUpReordering().

{
int nDofs = GetTotDofs();
// Step 1: make a permutation array that goes from the current
// reordering in the bottom-up graph to an ordering where the
// interior dofs of the first (=bottom) level are ordered last,
// followed interior dofs of the second level, ...
Array<OneD, int> iperm1(nDofs);
// Now, based upon the input permutation array, update the
// permutation arrays between the original ordering of the dofs
// (defined somewhere outside) and the final reordering as given by
// iperm1
for (int i=0; i < nDofs; i++)
{
iperm[i] = iperm1[iperm[i]];
perm[iperm[i]] = i;
}
}

Member Data Documentation

BottomUpSubStructuredGraphSharedPtr Nektar::MultiRegions::BottomUpSubStructuredGraph::m_daughterGraph
protected

Definition at line 234 of file SubStructuredGraph.h.

Referenced by BottomUpSubStructuredGraph(), Dump(), ExpandGraphWithVertexWeights(), GetDaughterGraph(), GetInteriorBlocks(), GetInteriorOffset(), GetNintDofsPerPatch(), GetNlevels(), GetNpatchesWithInterior(), GetNumGlobalDofs(), GetTotDofs(), MaskPatches(), and SetBottomUpReordering().

std::vector<SubGraphSharedPtr> Nektar::MultiRegions::BottomUpSubStructuredGraph::m_IntBlocks
protected

Definition at line 233 of file SubStructuredGraph.h.

Referenced by BottomUpSubStructuredGraph(), Dump(), ExpandGraphWithVertexWeights(), GetInteriorBlocks(), GetInteriorOffset(), GetNintDofsPerPatch(), GetNpatchesWithInterior(), GetNumGlobalDofs(), GetTotDofs(), MaskPatches(), and SetBottomUpReordering().