Nektar++
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
Nektar::MultiRegions::BottomUpSubStructuredGraph Class Reference

#include <SubStructuredGraph.h>

Public Member Functions

 BottomUpSubStructuredGraph (MultiLevelBisectedGraphSharedPtr graph, int nPartition=0, bool globaloffset=false)
 
 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 188 of file SubStructuredGraph.h.

Constructor & Destructor Documentation

◆ BottomUpSubStructuredGraph() [1/2]

Nektar::MultiRegions::BottomUpSubStructuredGraph::BottomUpSubStructuredGraph ( MultiLevelBisectedGraphSharedPtr  graph,
int  nPartition = 0,
bool  globaloffset = false 
)

Definition at line 305 of file SubStructuredGraph.cpp.

308{
309 int ncuts;
310
311 if (nPartition > 0)
312 {
314 graph, nPartition);
315 }
316
317 if (globaloffset)
318 {
319 graph->SetGlobalNumberingOffset();
320 }
321
322 graph->CutEmptyLeaves();
323 graph->CollectLeaves(m_IntBlocks);
324 ncuts = graph->CutLeaves();
325
326 if (ncuts)
327 {
330 }
331}
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
BottomUpSubStructuredGraphSharedPtr m_daughterGraph

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

◆ BottomUpSubStructuredGraph() [2/2]

Nektar::MultiRegions::BottomUpSubStructuredGraph::BottomUpSubStructuredGraph ( const int  nVerts)

Definition at line 290 of file SubStructuredGraph.cpp.

292{
293 // This constructor should only be used in the very special case
294 // when there is a graph consisting of nVerts vertices but without
295 // any connectivity whatsowever (i.e. no edges)
296
297 SubGraphSharedPtr subgraph;
298 for (int i = 0; i < nVerts; i++)
299 {
301 m_IntBlocks.push_back(subgraph);
302 }
303}
std::shared_ptr< SubGraph > SubGraphSharedPtr

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

◆ ~BottomUpSubStructuredGraph()

Nektar::MultiRegions::BottomUpSubStructuredGraph::~BottomUpSubStructuredGraph ( void  )

Definition at line 333 of file SubStructuredGraph.cpp.

334{
335}

Member Function Documentation

◆ Dump()

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

Definition at line 366 of file SubStructuredGraph.cpp.

367{
368 static int level = 0;
369 level++;
370
371 cout << "LEVEL " << level << endl;
372 cout << "interior blocks" << endl;
373 for (int i = 0; i < m_IntBlocks.size(); i++)
374 {
375 cout << " " << i << "/" << m_IntBlocks.size() - 1 << ": "
376 << m_IntBlocks[i]->GetNverts() << ", "
377 << m_IntBlocks[i]->GetIdOffset() << endl;
378 }
379 cout << endl;
380
381 if (m_daughterGraph.get())
382 {
383 m_daughterGraph->Dump();
384 }
385
386 level--;
387}

References CellMLToNektar.pycml::level, m_daughterGraph, and m_IntBlocks.

◆ ExpandGraphWithVertexWeights()

void Nektar::MultiRegions::BottomUpSubStructuredGraph::ExpandGraphWithVertexWeights ( const Array< OneD, const int > &  wgts)

Definition at line 442 of file SubStructuredGraph.cpp.

444{
445 static int offset = 0;
446 static int level = 0;
447 level++;
448
449 if (m_daughterGraph.get())
450 {
451 m_daughterGraph->ExpandGraphWithVertexWeights(wgts);
452 }
453
454 for (int i = 0; i < m_IntBlocks.size(); i++)
455 {
456 int OrigGlobIdOffset = m_IntBlocks[i]->GetIdOffset();
457 int newNverts = 0;
458
459 m_IntBlocks[i]->SetIdOffset(offset);
460
461 for (int j = 0; j < m_IntBlocks[i]->GetNverts(); j++)
462 {
463 newNverts += wgts[OrigGlobIdOffset + j];
464 offset += wgts[OrigGlobIdOffset + j];
465 }
466
467 m_IntBlocks[i]->SetNverts(newNverts);
468 }
469
470 // erase the blocks that do not have any vertices
471 m_IntBlocks.erase(
472 remove_if(m_IntBlocks.begin(), m_IntBlocks.end(), SubGraphWithoutVerts),
473 m_IntBlocks.end());
474
475 // remove the current level if there are no interior blocks
476 if (m_IntBlocks.size() == 0 && m_daughterGraph.get())
477 {
478 m_IntBlocks = m_daughterGraph->GetInteriorBlocks();
479 m_daughterGraph = m_daughterGraph->GetDaughterGraph();
480 }
481
482 level--;
483 if (level == 0)
484 {
485 offset = 0;
486 }
487}
bool SubGraphWithoutVerts(const SubGraphSharedPtr g)

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

◆ GetDaughterGraph()

BottomUpSubStructuredGraphSharedPtr Nektar::MultiRegions::BottomUpSubStructuredGraph::GetDaughterGraph ( ) const
inlineprivate

Definition at line 233 of file SubStructuredGraph.h.

234 {
235 return m_daughterGraph;
236 }

References m_daughterGraph.

◆ GetInteriorBlocks() [1/2]

std::vector< SubGraphSharedPtr > Nektar::MultiRegions::BottomUpSubStructuredGraph::GetInteriorBlocks ( ) const
inlineprivate

Definition at line 237 of file SubStructuredGraph.h.

238 {
239 return m_IntBlocks;
240 }

References m_IntBlocks.

◆ GetInteriorBlocks() [2/2]

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

Definition at line 599 of file SubStructuredGraph.cpp.

601{
602 std::vector<SubGraphSharedPtr> returnval;
603 static int level = 0;
604 level++;
605
606 if (level < whichlevel)
607 {
608 returnval = m_daughterGraph->GetInteriorBlocks(whichlevel);
609 }
610 else if (level == whichlevel)
611 {
612 returnval = m_IntBlocks;
613 }
614 else
615 {
616 NEKERROR(ErrorUtil::efatal, "If statement should not arrive here");
617 }
618
619 level--;
620 return returnval;
621}
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:202

References Nektar::ErrorUtil::efatal, CellMLToNektar.pycml::level, m_daughterGraph, m_IntBlocks, and NEKERROR.

◆ GetInteriorOffset()

int Nektar::MultiRegions::BottomUpSubStructuredGraph::GetInteriorOffset ( const int  whichlevel,
const int  patch = 0 
) const

Definition at line 574 of file SubStructuredGraph.cpp.

576{
577 int retval = -1;
578 static int level = 0;
579 level++;
580
581 if (level < whichlevel)
582 {
583 retval = m_daughterGraph->GetInteriorOffset(whichlevel, patch);
584 }
585 else if (level == whichlevel)
586 {
587 retval = m_IntBlocks[patch]->GetIdOffset();
588 }
589 else
590 {
591 NEKERROR(ErrorUtil::efatal, "If statement should not arrive here");
592 }
593
594 level--;
595
596 return retval;
597}

References Nektar::ErrorUtil::efatal, CellMLToNektar.pycml::level, m_daughterGraph, m_IntBlocks, and NEKERROR.

◆ GetNintDofsPerPatch()

void Nektar::MultiRegions::BottomUpSubStructuredGraph::GetNintDofsPerPatch ( const int  whichlevel,
Array< OneD, unsigned int > &  outarray 
) const

Definition at line 546 of file SubStructuredGraph.cpp.

548{
549 static int level = 0;
550 level++;
551
552 if (level < whichlevel)
553 {
554 m_daughterGraph->GetNintDofsPerPatch(whichlevel, outarray);
555 }
556 else if (level == whichlevel)
557 {
558 ASSERTL1(outarray.size() >= m_IntBlocks.size(),
559 "Array dimension not sufficient");
560
561 for (int i = 0; i < m_IntBlocks.size(); i++)
562 {
563 outarray[i] = (unsigned int)m_IntBlocks[i]->GetNverts();
564 }
565 }
566 else
567 {
568 NEKERROR(ErrorUtil::efatal, "If statement should not arrive here");
569 }
570
571 level--;
572}
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:242

References ASSERTL1, Nektar::ErrorUtil::efatal, CellMLToNektar.pycml::level, m_daughterGraph, m_IntBlocks, and NEKERROR.

◆ GetNlevels()

int Nektar::MultiRegions::BottomUpSubStructuredGraph::GetNlevels ( ) const

Definition at line 648 of file SubStructuredGraph.cpp.

649{
650 int returnval = 0;
651 static int level = 0;
652 level++;
653
654 if (m_daughterGraph.get())
655 {
656 returnval = m_daughterGraph->GetNlevels();
657 }
658 returnval = max(returnval, level);
659
660 level--;
661
662 return returnval;
663}

References CellMLToNektar.pycml::level, and m_daughterGraph.

◆ GetNpatchesWithInterior()

int Nektar::MultiRegions::BottomUpSubStructuredGraph::GetNpatchesWithInterior ( const int  whichlevel) const

Definition at line 521 of file SubStructuredGraph.cpp.

523{
524 int returnval = -1;
525 static int level = 0;
526 level++;
527
528 if (level < whichlevel)
529 {
530 returnval = m_daughterGraph->GetNpatchesWithInterior(whichlevel);
531 }
532 else if (level == whichlevel)
533 {
534 returnval = m_IntBlocks.size();
535 }
536 else
537 {
538 NEKERROR(ErrorUtil::efatal, "If statement should not arrive here");
539 }
540
541 level--;
542
543 return returnval;
544}

References Nektar::ErrorUtil::efatal, CellMLToNektar.pycml::level, m_daughterGraph, m_IntBlocks, and NEKERROR.

◆ GetNumGlobalDofs()

int Nektar::MultiRegions::BottomUpSubStructuredGraph::GetNumGlobalDofs ( const int  whichlevel) const

Definition at line 623 of file SubStructuredGraph.cpp.

624{
625 int returnval = -1;
626 static int level = 0;
627 level++;
628
629 if (level < whichlevel)
630 {
631 returnval = m_daughterGraph->GetNumGlobalDofs(whichlevel);
632 }
633 else if (level == whichlevel)
634 {
635 returnval = m_IntBlocks[m_IntBlocks.size() - 1]->GetIdOffset() +
636 m_IntBlocks[m_IntBlocks.size() - 1]->GetNverts();
637 }
638 else
639 {
640 NEKERROR(ErrorUtil::efatal, "If statement should not arrive here");
641 }
642
643 level--;
644
645 return returnval;
646}

References Nektar::ErrorUtil::efatal, CellMLToNektar.pycml::level, m_daughterGraph, m_IntBlocks, and NEKERROR.

◆ GetTotDofs()

int Nektar::MultiRegions::BottomUpSubStructuredGraph::GetTotDofs ( ) const

Definition at line 337 of file SubStructuredGraph.cpp.

338{
339 static int nIntDofs = 0;
340 static int level = 0;
341 level++;
342
343 int returnval;
344
345 if (m_daughterGraph.get())
346 {
347 m_daughterGraph->GetTotDofs();
348 }
349
350 for (int i = 0; i < m_IntBlocks.size(); i++)
351 {
352 nIntDofs += m_IntBlocks[i]->GetNverts();
353 }
354
355 returnval = nIntDofs;
356
357 level--;
358 if (level == 0)
359 {
360 nIntDofs = 0;
361 }
362
363 return returnval;
364}

References CellMLToNektar.pycml::level, m_daughterGraph, and m_IntBlocks.

Referenced by UpdateBottomUpReordering().

◆ MaskPatches()

void Nektar::MultiRegions::BottomUpSubStructuredGraph::MaskPatches ( const int  leveltomask,
Array< OneD, NekDouble > &  maskarray 
) const

Definition at line 489 of file SubStructuredGraph.cpp.

491{
492 static int level = 0;
493 level++;
494
495 if (level < leveltomask)
496 {
497 m_daughterGraph->MaskPatches(leveltomask, maskarray);
498 }
499 else if (level == leveltomask)
500 {
501 int GlobIdOffset;
502 int nVerts;
503 for (int i = 0; i < m_IntBlocks.size(); i++)
504 {
505 GlobIdOffset = m_IntBlocks[i]->GetIdOffset();
506 nVerts = m_IntBlocks[i]->GetNverts();
507 for (int j = 0; j < nVerts; j++)
508 {
509 maskarray[GlobIdOffset + j] = (NekDouble)i;
510 }
511 }
512 }
513 else
514 {
515 NEKERROR(ErrorUtil::efatal, "If statement should not arrive here");
516 }
517
518 level--;
519}
double NekDouble

References Nektar::ErrorUtil::efatal, CellMLToNektar.pycml::level, m_daughterGraph, m_IntBlocks, and NEKERROR.

◆ SetBottomUpReordering()

void Nektar::MultiRegions::BottomUpSubStructuredGraph::SetBottomUpReordering ( Array< OneD, int > &  iperm) const
private

Definition at line 412 of file SubStructuredGraph.cpp.

414{
415 static int offset = 0;
416 static int level = 0;
417 level++;
418
419 if (m_daughterGraph.get())
420 {
421 m_daughterGraph->SetBottomUpReordering(iperm);
422 }
423
424 for (int i = 0; i < m_IntBlocks.size(); i++)
425 {
426 int GlobIdOffset = m_IntBlocks[i]->GetIdOffset();
427 m_IntBlocks[i]->SetIdOffset(offset);
428 for (int j = 0; j < m_IntBlocks[i]->GetNverts(); j++)
429 {
430 iperm[GlobIdOffset + j] = offset;
431 offset++;
432 }
433 }
434
435 level--;
436 if (level == 0)
437 {
438 offset = 0;
439 }
440}

References CellMLToNektar.pycml::level, m_daughterGraph, and m_IntBlocks.

Referenced by UpdateBottomUpReordering().

◆ UpdateBottomUpReordering()

void Nektar::MultiRegions::BottomUpSubStructuredGraph::UpdateBottomUpReordering ( Array< OneD, int > &  perm,
Array< OneD, int > &  iperm 
) const

Definition at line 389 of file SubStructuredGraph.cpp.

391{
392 int nDofs = GetTotDofs();
393
394 // Step 1: make a permutation array that goes from the current
395 // reordering in the bottom-up graph to an ordering where the
396 // interior dofs of the first (=bottom) level are ordered last,
397 // followed interior dofs of the second level, ...
398 Array<OneD, int> iperm1(nDofs);
399 SetBottomUpReordering(iperm1);
400
401 // Now, based upon the input permutation array, update the
402 // permutation arrays between the original ordering of the dofs
403 // (defined somewhere outside) and the final reordering as given by
404 // iperm1
405 for (int i = 0; i < nDofs; i++)
406 {
407 iperm[i] = iperm1[iperm[i]];
408 perm[iperm[i]] = i;
409 }
410}
void SetBottomUpReordering(Array< OneD, int > &iperm) const

References GetTotDofs(), and SetBottomUpReordering().

Member Data Documentation

◆ m_daughterGraph

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

◆ m_IntBlocks

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