MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
BinaryPropertyMPITree Class Reference

#include <binarytree.h>

Inheritance diagram for BinaryPropertyMPITree:
[legend]
Collaboration diagram for BinaryPropertyMPITree:
[legend]

Public Member Functions

 BinaryPropertyMPITree (MInt num_procs)
 
 ~BinaryPropertyMPITree ()
 
void printTree ()
 
BinaryTreeIntNodegetMyMPILocation ()
 
BinaryTreeIntNodegetMyMPIReceiver ()
 
BinaryTreeIntNodegetMyLeftMPISender ()
 
BinaryTreeIntNodegetMyRightMPISender ()
 

Protected Member Functions

void insertBalancedNode (BinaryTreeIntNode *node)
 

Static Protected Member Functions

static void printTreeRoot (BinaryTreeIntNode *node, MInt level)
 

Protected Attributes

BinaryTreeIntNodem_myMPILocation
 
std::queue< BinaryTreeIntNode * > * m_queue
 

Additional Inherited Members

- Private Member Functions inherited from BinaryTree< T >
 BinaryTree ()
 
 BinaryTree (BinaryTreeNode< T > *root)
 
BinaryTreeNode< T > * getRoot ()
 
MInt getMaxDepth ()
 
MInt getNodeDepth (BinaryTreeNode< T > *node)
 
- Private Attributes inherited from BinaryTree< T >
BinaryTreeNode< T > * m_root
 

Detailed Description

Definition at line 102 of file binarytree.h.

Constructor & Destructor Documentation

◆ BinaryPropertyMPITree()

BinaryPropertyMPITree::BinaryPropertyMPITree ( MInt  num_procs)
inlineexplicit

Definition at line 104 of file binarytree.h.

104 : m_myMPILocation(nullptr) {
105 MInt rank = globalDomainId();
106 m_queue = new std::queue<BinaryTreeIntNode*>;
107 for(MInt i = 0; i < num_procs; i++) {
108 auto* ins_int = new MInt();
109 *ins_int = i;
110 auto* ins = new BinaryTreeIntNode(ins_int);
111 if(i == 0) {
112 m_root = ins;
113 m_queue->push(m_root);
114 } else {
116 }
117
118 if(i == rank) {
119 m_myMPILocation = ins;
120 }
121 }
122 }
BinaryTreeNode< MInt > BinaryTreeIntNode
Definition: binarytree.h:57
std::queue< BinaryTreeIntNode * > * m_queue
Definition: binarytree.h:163
void insertBalancedNode(BinaryTreeIntNode *node)
Definition: binarytree.h:175
BinaryTreeIntNode * m_myMPILocation
Definition: binarytree.h:162
BinaryTreeNode< T > * m_root
Definition: binarytree.h:82
MInt globalDomainId()
Return global domain id.
int32_t MInt
Definition: maiatypes.h:62

◆ ~BinaryPropertyMPITree()

BinaryPropertyMPITree::~BinaryPropertyMPITree ( )
inline

Definition at line 123 of file binarytree.h.

123 {
124 for(MUlong i = 0; i < m_queue->size(); i++) {
125 delete m_queue->front();
126 m_queue->pop();
127 }
128 delete m_queue;
129 m_queue = nullptr;
130 }
uint64_t MUlong
Definition: maiatypes.h:65

Member Function Documentation

◆ getMyLeftMPISender()

BinaryTreeIntNode * BinaryPropertyMPITree::getMyLeftMPISender ( )
inline

Definition at line 148 of file binarytree.h.

148 {
149 if(m_myMPILocation != nullptr && m_myMPILocation->getLeftChild() != nullptr) {
151 }
152 return nullptr;
153 }
BinaryTreeNode< T > * getLeftChild()
Definition: binarytree.h:42

◆ getMyMPILocation()

BinaryTreeIntNode * BinaryPropertyMPITree::getMyMPILocation ( )
inline

Definition at line 134 of file binarytree.h.

134 {
135 if(m_myMPILocation == nullptr) {
136 return nullptr;
137 }
138 return m_myMPILocation;
139 }

◆ getMyMPIReceiver()

BinaryTreeIntNode * BinaryPropertyMPITree::getMyMPIReceiver ( )
inline

Definition at line 141 of file binarytree.h.

141 {
142 if(m_myMPILocation != nullptr && m_myMPILocation->getFather() != nullptr) {
143 return m_myMPILocation->getFather();
144 }
145 return nullptr;
146 }
BinaryTreeNode< T > * getFather()
Definition: binarytree.h:41

◆ getMyRightMPISender()

BinaryTreeIntNode * BinaryPropertyMPITree::getMyRightMPISender ( )
inline

Definition at line 154 of file binarytree.h.

154 {
155 if(m_myMPILocation != nullptr && m_myMPILocation->getRightChild() != nullptr) {
157 }
158 return nullptr;
159 }
BinaryTreeNode< T > * getRightChild()
Definition: binarytree.h:43

◆ insertBalancedNode()

void BinaryPropertyMPITree::insertBalancedNode ( BinaryTreeIntNode node)
inlineprotected

Definition at line 175 of file binarytree.h.

175 {
176 while(!m_queue->empty()) {
177 // full, descend
178 if(m_queue->front()->getLeftChild() != nullptr && m_queue->front()->getRightChild() != nullptr) {
179 m_queue->push(m_queue->front()->getLeftChild());
180 m_queue->push(m_queue->front()->getRightChild());
181 m_queue->pop();
182 }
183 // not full, fill up
184 else {
185 node->setFather(m_queue->front());
186 if(m_queue->front()->getLeftChild() == nullptr) {
187 m_queue->front()->setLeftChild(node);
188 } else {
189 m_queue->front()->setRightChild(node);
190 }
191
192 break;
193 }
194 }
195 }
void setFather(BinaryTreeNode< T > *node)
Definition: binarytree.h:46

◆ printTree()

void BinaryPropertyMPITree::printTree ( )
inline

Definition at line 132 of file binarytree.h.

132{ printTreeRoot(m_root, 0); }
static void printTreeRoot(BinaryTreeIntNode *node, MInt level)
Definition: binarytree.h:165

◆ printTreeRoot()

static void BinaryPropertyMPITree::printTreeRoot ( BinaryTreeIntNode node,
MInt  level 
)
inlinestaticprotected

Definition at line 165 of file binarytree.h.

165 {
166 m_log << "L " << level << ":" << *(node->getObject()) << std::endl;
167 if(node->getLeftChild() != nullptr) {
168 printTreeRoot(node->getLeftChild(), level + 1);
169 }
170 if(node->getRightChild() != nullptr) {
171 printTreeRoot(node->getRightChild(), level + 1);
172 }
173 }
T * getObject()
Definition: binarytree.h:40
InfoOutFile m_log

Member Data Documentation

◆ m_myMPILocation

BinaryTreeIntNode* BinaryPropertyMPITree::m_myMPILocation
protected

Definition at line 162 of file binarytree.h.

◆ m_queue

std::queue<BinaryTreeIntNode*>* BinaryPropertyMPITree::m_queue
protected

Definition at line 163 of file binarytree.h.


The documentation for this class was generated from the following file: