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 Nektar::MemoryManager< DataType >::AllocateSharedPtr(), m_daughterGraph, and m_IntBlocks.

414  :
415  m_IntBlocks(),
417  {
418  // First, create a top-down graph structure based upon the separator
419  // tree. This is easier as separation tree is also structured
420  // following a top-down approach
421  MultiLevelBisectedGraphSharedPtr topDownGraph =
423  septree);
424 
425  if (nPartition > 0)
426  {
428  AllocateSharedPtr(topDownGraph, nPartition);
429  }
430 
431  // set the global numbering of the top-down graph
432  topDownGraph->SetGlobalNumberingOffset();
433 
434  topDownGraph->CutEmptyLeaves();
435 
436  // Secondly, recursively construct the subgraphs of the bottom up
437  // point of view 1. Collect all the leaves of the topdown graph this
438  // will be the first level of the bottom up graph
439  topDownGraph->CollectLeaves(m_IntBlocks);
440 
441  // 2. Reduce the topdown graph by cutting the leaves (this will
442  // allow a recursive approach)
443  int ncuts = topDownGraph->CutLeaves();
444 
445  // 3. If there were leaves to cut, proceed recursively
446  if (ncuts)
447  {
449  AllocateSharedPtr(topDownGraph);
450  }
451  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
boost::shared_ptr< MultiLevelBisectedGraph > MultiLevelBisectedGraphSharedPtr
BottomUpSubStructuredGraphSharedPtr m_daughterGraph
Nektar::MultiRegions::BottomUpSubStructuredGraph::BottomUpSubStructuredGraph ( const MultiLevelBisectedGraphSharedPtr graph)

Definition at line 453 of file SubStructuredGraph.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), m_daughterGraph, and m_IntBlocks.

454  :
455  m_IntBlocks (),
457  {
458  int ncuts;
459  graph->CutEmptyLeaves();
460  graph->CollectLeaves(m_IntBlocks);
461  ncuts = graph->CutLeaves();
462 
463  if(ncuts)
464  {
466  AllocateSharedPtr(graph);
467  }
468  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
BottomUpSubStructuredGraphSharedPtr m_daughterGraph
Nektar::MultiRegions::BottomUpSubStructuredGraph::BottomUpSubStructuredGraph ( const int  nVerts)

Definition at line 397 of file SubStructuredGraph.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), and m_IntBlocks.

399  {
400  // This constructor should only be used in the very special case
401  // when there is a graph consisting of nVerts vertices but without
402  // any connectivity whatsowever (i.e. no edges)
403 
404  SubGraphSharedPtr subgraph;
405  for (int i = 0 ; i < nVerts; i++)
406  {
408  m_IntBlocks.push_back(subgraph);
409  }
410  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
boost::shared_ptr< SubGraph > SubGraphSharedPtr
BottomUpSubStructuredGraphSharedPtr m_daughterGraph
Nektar::MultiRegions::BottomUpSubStructuredGraph::~BottomUpSubStructuredGraph ( void  )

Definition at line 470 of file SubStructuredGraph.cpp.

471  {
472  }

Member Function Documentation

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

Definition at line 503 of file SubStructuredGraph.cpp.

References m_daughterGraph, and m_IntBlocks.

504  {
505  static int level = 0;
506  level++;
507 
508  cout << "LEVEL " << level << endl;
509  cout << "interior blocks" << endl;
510  for (int i = 0; i < m_IntBlocks.size(); i++)
511  {
512  cout << " " << i
513  << "/" << m_IntBlocks.size()-1
514  << ": " << m_IntBlocks[i]->GetNverts()
515  << ", " << m_IntBlocks[i]->GetIdOffset() << endl;
516  }
517  cout << endl;
518 
519  if (m_daughterGraph.get())
520  {
521  m_daughterGraph->Dump();
522  }
523 
524  level--;
525  }
BottomUpSubStructuredGraphSharedPtr m_daughterGraph
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().

583  {
584  static int offset = 0;
585  static int level = 0;
586  level++;
587 
588  if( m_daughterGraph.get())
589  {
590  m_daughterGraph->ExpandGraphWithVertexWeights(wgts);
591  }
592 
593  for(int i = 0; i < m_IntBlocks.size(); i++)
594  {
595  int OrigGlobIdOffset = m_IntBlocks[i]->GetIdOffset();
596  int newNverts = 0;
597 
598  m_IntBlocks[i]->SetIdOffset(offset);
599 
600  for(int j = 0; j < m_IntBlocks[i]->GetNverts(); j++)
601  {
602  newNverts += wgts[OrigGlobIdOffset+j];
603  offset += wgts[OrigGlobIdOffset+j];
604  }
605 
606  m_IntBlocks[i]->SetNverts(newNverts);
607  }
608 
609  // erase the blocks that do not have any vertices
610  m_IntBlocks.erase(
611  remove_if(m_IntBlocks.begin(),
612  m_IntBlocks.end(),
614  m_IntBlocks.end());
615 
616  // remove the current level if there are no interior blocks
617  if(m_IntBlocks.size() == 0 && m_daughterGraph.get())
618  {
619  m_IntBlocks = m_daughterGraph->GetInteriorBlocks();
620  m_daughterGraph = m_daughterGraph->GetDaughterGraph();
621  }
622 
623  level--;
624  if(level == 0)
625  {
626  offset = 0;
627  }
628  }
BottomUpSubStructuredGraphSharedPtr m_daughterGraph
bool SubGraphWithoutVerts(const SubGraphSharedPtr g)
BottomUpSubStructuredGraphSharedPtr Nektar::MultiRegions::BottomUpSubStructuredGraph::GetDaughterGraph ( ) const
inlineprivate

Definition at line 239 of file SubStructuredGraph.h.

References m_daughterGraph.

240  {
241  return m_daughterGraph;
242  }
BottomUpSubStructuredGraphSharedPtr 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.

749  {
750  std::vector<SubGraphSharedPtr> returnval;
751  static int level = 0;
752  level++;
753 
754  if(level < whichlevel)
755  {
756  returnval = m_daughterGraph->GetInteriorBlocks(whichlevel);
757  }
758  else if(level == whichlevel)
759  {
760  returnval = m_IntBlocks;
761  }
762  else
763  {
765  "If statement should not arrive here");
766  }
767 
768  level--;
769  return returnval;
770  }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:158
BottomUpSubStructuredGraphSharedPtr m_daughterGraph
std::vector<SubGraphSharedPtr> Nektar::MultiRegions::BottomUpSubStructuredGraph::GetInteriorBlocks ( ) const
inlineprivate

Definition at line 243 of file SubStructuredGraph.h.

References m_IntBlocks.

244  {
245  return m_IntBlocks;
246  }
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.

723  {
724  int retval = -1;
725  static int level = 0;
726  level++;
727 
728  if(level < whichlevel)
729  {
730  retval = m_daughterGraph->GetInteriorOffset(whichlevel,patch);
731  }
732  else if(level == whichlevel)
733  {
734  retval = m_IntBlocks[patch]->GetIdOffset();
735  }
736  else
737  {
739  "If statement should not arrive here");
740  }
741 
742  level--;
743 
744  return retval;
745  }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:158
BottomUpSubStructuredGraphSharedPtr m_daughterGraph
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.

694  {
695  static int level = 0;
696  level++;
697 
698  if(level < whichlevel)
699  {
700  m_daughterGraph->GetNintDofsPerPatch(whichlevel,outarray);
701  }
702  else if(level == whichlevel)
703  {
704  ASSERTL1(outarray.num_elements() >= m_IntBlocks.size(),
705  "Array dimension not sufficient");
706 
707  for(int i = 0; i < m_IntBlocks.size(); i++)
708  {
709  outarray[i] = (unsigned int) m_IntBlocks[i]->GetNverts();
710  }
711  }
712  else
713  {
715  "If statement should not arrive here");
716  }
717 
718  level--;
719  }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:158
BottomUpSubStructuredGraphSharedPtr m_daughterGraph
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:191
int Nektar::MultiRegions::BottomUpSubStructuredGraph::GetNlevels ( ) const

Definition at line 799 of file SubStructuredGraph.cpp.

References m_daughterGraph.

800  {
801  int returnval = 0;
802  static int level = 0;
803  level++;
804 
805  if( m_daughterGraph.get())
806  {
807  returnval = m_daughterGraph->GetNlevels();
808  }
809  returnval = max(returnval,level);
810 
811  level--;
812 
813  return returnval;
814 
815  }
BottomUpSubStructuredGraphSharedPtr m_daughterGraph
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.

666  {
667  int returnval = -1;
668  static int level = 0;
669  level++;
670 
671  if(level < whichlevel)
672  {
673  returnval = m_daughterGraph->GetNpatchesWithInterior(
674  whichlevel);
675  }
676  else if(level == whichlevel)
677  {
678  returnval = m_IntBlocks.size();
679  }
680  else
681  {
683  "If statement should not arrive here");
684  }
685 
686  level--;
687 
688  return returnval;
689  }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:158
BottomUpSubStructuredGraphSharedPtr m_daughterGraph
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.

774  {
775  int returnval = -1;
776  static int level = 0;
777  level++;
778 
779  if(level < whichlevel)
780  {
781  returnval = m_daughterGraph->GetNumGlobalDofs(whichlevel);
782  }
783  else if(level == whichlevel)
784  {
785  returnval = m_IntBlocks[m_IntBlocks.size()-1]->GetIdOffset()+
786  m_IntBlocks[m_IntBlocks.size()-1]->GetNverts();
787  }
788  else
789  {
791  "If statement should not arrive here");
792  }
793 
794  level--;
795 
796  return returnval;
797  }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:158
BottomUpSubStructuredGraphSharedPtr m_daughterGraph
int Nektar::MultiRegions::BottomUpSubStructuredGraph::GetTotDofs ( ) const

Definition at line 474 of file SubStructuredGraph.cpp.

References m_daughterGraph, and m_IntBlocks.

Referenced by UpdateBottomUpReordering().

475  {
476  static int nIntDofs = 0;
477  static int level = 0;
478  level++;
479 
480  int returnval;
481 
482  if( m_daughterGraph.get())
483  {
484  m_daughterGraph->GetTotDofs();
485  }
486 
487  for(int i = 0; i < m_IntBlocks.size(); i++)
488  {
489  nIntDofs += m_IntBlocks[i]->GetNverts();
490  }
491 
492  returnval = nIntDofs;
493 
494  level--;
495  if(level == 0)
496  {
497  nIntDofs = 0;
498  }
499 
500  return returnval;
501  }
BottomUpSubStructuredGraphSharedPtr m_daughterGraph
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.

633  {
634  static int level = 0;
635  level++;
636 
637  if(level < leveltomask)
638  {
639  m_daughterGraph->MaskPatches(leveltomask,maskarray);
640  }
641  else if(level == leveltomask)
642  {
643  int GlobIdOffset;
644  int nVerts;
645  for(int i = 0; i < m_IntBlocks.size(); i++)
646  {
647  GlobIdOffset = m_IntBlocks[i]->GetIdOffset();
648  nVerts = m_IntBlocks[i]->GetNverts();
649  for(int j = 0; j < nVerts; j++)
650  {
651  maskarray[GlobIdOffset+j] = (NekDouble) i;
652  }
653  }
654  }
655  else
656  {
658  "If statement should not arrive here");
659  }
660 
661  level--;
662  }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:158
double NekDouble
BottomUpSubStructuredGraphSharedPtr m_daughterGraph
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().

553  {
554  static int offset = 0;
555  static int level = 0;
556  level++;
557 
558  if( m_daughterGraph.get() )
559  {
560  m_daughterGraph->SetBottomUpReordering(iperm);
561  }
562 
563  for(int i = 0; i < m_IntBlocks.size(); i++)
564  {
565  int GlobIdOffset = m_IntBlocks[i]->GetIdOffset();
566  m_IntBlocks[i]->SetIdOffset(offset);
567  for(int j = 0; j < m_IntBlocks[i]->GetNverts(); j++)
568  {
569  iperm[GlobIdOffset+j] = offset;
570  offset++;
571  }
572  }
573 
574  level--;
575  if(level == 0)
576  {
577  offset = 0;
578  }
579  }
BottomUpSubStructuredGraphSharedPtr m_daughterGraph
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().

530  {
531  int nDofs = GetTotDofs();
532 
533  // Step 1: make a permutation array that goes from the current
534  // reordering in the bottom-up graph to an ordering where the
535  // interior dofs of the first (=bottom) level are ordered last,
536  // followed interior dofs of the second level, ...
537  Array<OneD, int> iperm1(nDofs);
538  SetBottomUpReordering(iperm1);
539 
540  // Now, based upon the input permutation array, update the
541  // permutation arrays between the original ordering of the dofs
542  // (defined somewhere outside) and the final reordering as given by
543  // iperm1
544  for (int i=0; i < nDofs; i++)
545  {
546  iperm[i] = iperm1[iperm[i]];
547  perm[iperm[i]] = i;
548  }
549  }
void SetBottomUpReordering(Array< OneD, int > &iperm) const

Member Data Documentation

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