30 inline void Foam::binaryTree::insertNode
36 if (
phi0 ==
phi0->node()->leafRight())
38 phi0->node()->leafRight() =
nullptr;
39 phi0->node()->nodeRight() = newNode;
42 else if (
phi0 ==
phi0->node()->leafLeft())
44 phi0->node()->leafLeft() =
nullptr;
45 phi0->node()->nodeLeft() = newNode;
52 <<
"trying to insert a node with a wrong pointer to a chemPoint"
57 inline void Foam::binaryTree::deleteSubTree(binaryNode* subTreeRoot)
59 if (subTreeRoot !=
nullptr)
63 deleteSubTree(subTreeRoot->nodeLeft());
64 deleteSubTree(subTreeRoot->nodeRight());
70 inline void Foam::binaryTree::deleteSubTree()
76 inline void Foam::binaryTree::transplant(binaryNode* u, binaryNode* v)
81 if (u->parent() ==
nullptr)
86 else if (u == u->parent()->nodeLeft())
88 u->parent()->nodeLeft() = v;
91 else if (u == u->parent()->nodeRight())
93 u->parent()->nodeRight() = v;
98 <<
"wrong addressing of the initial node"
101 v->parent() = u->parent();
106 <<
"trying to transplant a nullptr node"
114 if (
y->parent() !=
nullptr)
116 if (
y ==
y->parent()->nodeLeft())
119 return y->parent()->leafRight();
121 else if (
y ==
y->parent()->nodeRight())
123 return y->parent()->leafLeft();
128 <<
"wrong addressing of the initial node"
143 if (
x ==
x->node()->leafLeft())
147 return x->node()->leafRight();
149 else if (
x ==
x->node()->leafRight())
152 return x->node()->leafLeft();
157 <<
"wrong addressing of the initial leaf"
170 if (
y->parent()!=
nullptr)
172 if (
y ==
y->parent()->nodeLeft())
175 return y->parent()->nodeRight();
177 else if (
y ==
y->parent()->nodeRight())
179 return y->parent()->nodeLeft();
184 <<
"wrong addressing of the initial node"
197 if (
x ==
x->node()->leafLeft())
200 return x->node()->nodeRight();
202 else if (
x ==
x->node()->leafRight())
205 return x->node()->nodeLeft();
210 <<
"wrong addressing of the initial leaf"
221 if (subTreeRoot !=
nullptr)
223 deleteAllNode(subTreeRoot->nodeLeft());
224 deleteAllNode(subTreeRoot->nodeRight());
241 if (subTreeRoot ==
nullptr)
287 const scalar& a = node->
a();
289 for (
label i=0; i<phiq.
size(); i++) vPhi += phiq[i]*v[i];
296 binaryTreeSearch(phiq, node->
nodeRight(), nearest);
308 binaryTreeSearch(phiq, node->
nodeLeft(), nearest);
320 nearest = root_->leafLeft();
331 if (subTreeRoot!=
nullptr)
333 while(subTreeRoot->
nodeLeft() !=
nullptr)
335 subTreeRoot = subTreeRoot->
nodeLeft();
361 return size_ >= maxNLeafs_;
376 while (nextChP !=
nullptr)
379 nextChP = treeSuccessor(nextChP);
void size(const label)
Override size to be inconsistent with allocated storage.
chemPointISAT *& leafLeft()
Access.
const scalarField & v() const
Topology.
binaryNode *& nodeRight()
chemPointISAT *& leafRight()
chemPointISAT * treeMin()
label size() const
Member functions.
void binaryTreeSearch(const scalarField &phiq, binaryNode *node, chemPointISAT *&nearest)
void clear()
Removes every entries of the tree and delete the associated objects.
Leaf of the binary tree. The chemPoint stores the composition 'phi', the mapping of this composition ...
void resetNumRetrieve()
Resets the number of retrieves at each time step.
Template functions to aid in the implementation of demand driven data.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const dimensionedScalar phi0
Magnetic flux quantum: default SI units: [Wb].
errorManipArg< error, int > exit(error &err, const int errNo=1)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void deleteDemandDrivenData(DataType *&dataPtr)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)