31 bool Foam::binaryTree::inSubTree
38 if ((n2ndSearch_ < max2ndSearch_) && (
y!=
nullptr))
42 const scalar a =
y->a();
44 for (
label i=0; i<phiq.size(); i++)
50 if (
y->nodeLeft() ==
nullptr)
53 if (
y->leafLeft()->inEOA(phiq))
61 if (inSubTree(phiq,
y->nodeLeft(),
x))
68 if ((n2ndSearch_ < max2ndSearch_) &&
y->nodeRight() ==
nullptr)
72 if (
y->leafRight()->inEOA(phiq))
85 return inSubTree(phiq,
y->nodeRight(),
x);
90 if (
y->nodeRight() ==
nullptr)
93 if (
y->leafRight()->inEOA(phiq))
100 if (inSubTree(phiq,
y->nodeRight(),
x))
108 if ((n2ndSearch_ < max2ndSearch_) &&
y->nodeLeft() ==
nullptr)
111 if (
y->leafLeft()->inEOA(phiq))
124 return inSubTree(phiq,
y->nodeLeft(),
x);
145 maxNLeafs_(coeffsDict.lookup<
label>(
"maxNLeafs")),
148 max2ndSearch_(coeffsDict.lookupOrDefault(
"max2ndSearch",0)),
149 coeffsDict_(coeffsDict)
160 const scalar& epsTol,
186 root_->leafLeft() = newChemPoint;
193 binaryTreeSearch(phiq, root_,
phi0);
222 insertNode(
phi0, newNode);
232 phi0->node() = newNode;
233 newChemPoint->
node()=newNode;
247 if ((n2ndSearch_ < max2ndSearch_) && (size_ > 1))
259 else if (inSubTree(phiq, nodeSibling(
x),
x))
266 while((
y->parent()!=
nullptr) && (n2ndSearch_ < max2ndSearch_))
268 xS = chemPSibling(
y);
278 else if (inSubTree(phiq, nodeSibling(
y),
x))
309 if (siblingPhi0 !=
nullptr)
312 if (z->
parent() ==
nullptr)
315 root_->leafLeft()=siblingPhi0;
316 siblingPhi0->
node()=root_;
333 <<
"wrong addressing of the initial leaf"
339 x = nodeSibling(
phi0);
347 <<
"inconsistent structure of the tree, no leaf and no node"
364 label chemPointISATi=0;
367 chemPoints[chemPointISATi++] =
x;
368 x = treeSuccessor(
x);
387 variance[vi] +=
sqr(phij[vi]-mean[vi]);
392 scalar maxVariance(-1.0);
396 if (maxVariance < variance[vi])
398 maxVariance = variance[vi];
411 phiMaxDir[j] = chemPoints[j]->phi()[maxDir];
422 chemPoints[phiMaxDir.
indices()[0]],
423 chemPoints[phiMaxDir.
indices()[phiMaxDir.
size()-1]],
428 chemPoints[phiMaxDir.
indices()[0]]->node() = newNode;
429 chemPoints[phiMaxDir.
indices()[phiMaxDir.
size()-1]]->node() = newNode;
431 for (
label cpi=1; cpi<chemPoints.
size()-1; cpi++)
436 chemPoints[phiMaxDir.
indices()[cpi]]->phi(),
444 chemPoints[phiMaxDir.
indices()[cpi]],
449 insertNode(
phi0, nodeToAdd);
450 phi0->node() = nodeToAdd;
451 chemPoints[phiMaxDir.
indices()[cpi]]->node() = nodeToAdd;
460 if (
x ==
x->node()->leafLeft())
462 if (
x->node()->nodeRight() ==
nullptr)
464 return x->node()->leafRight();
468 return treeMin(
x->node()->nodeRight());
471 else if (
x ==
x->node()->leafRight())
474 while((
y->parent() !=
nullptr))
476 if (
y ==
y->parent()->nodeLeft())
478 if (
y->parent()->nodeRight() ==
nullptr)
480 return y->parent()->leafRight();
484 return treeMin(
y->parent()->nodeRight());
497 <<
"inconsistent structure of the tree, no leaf and no node"
static const Foam::dimensionedScalar A("A", Foam::dimPressure, 611.21)
#define forAll(list, i)
Loop across all elements in list.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void size(const label)
Override size to be inconsistent with allocated storage.
A list that is sorted upon construction or when explicitly requested with the sort() method.
const labelList & indices() const
Return the list of sorted indices. Updated every sort.
void sort()
(stable) sort the list (if changed after construction time)
chemPointISAT *& leafLeft()
Access.
binaryNode *& nodeRight()
chemPointISAT *& leafRight()
void deleteLeaf(chemPointISAT *&phi0)
Delete a leaf from the binary tree and reshape the binary tree for.
bool secondaryBTSearch(const scalarField &phiq, chemPointISAT *&x)
chemPointISAT * treeSuccessor(chemPointISAT *x)
void insertNewLeaf(const scalarField &phiq, const scalarField &Rphiq, const scalarSquareMatrix &A, const scalarField &scaleFactor, const scalar &epsTol, const label nCols, const label nActive, chemPointISAT *&phi0)
binaryTree(chemistryTabulationMethods::ISAT &table, dictionary coeffsDict)
Constructors.
void balance()
Cheap balance function.
Leaf of the binary tree. The chemPoint stores the composition 'phi', the mapping of this composition ...
bool inEOA(const scalarField &phiq)
To RETRIEVE the mapping from the stored chemPoint phi, the query.
Implementation of the ISAT (In-situ adaptive tabulation), for chemistry calculation.
A list of keyword definitions, which are a keyword followed by any number of values (e....
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
volScalarField scalarField(fieldObject, mesh)
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.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
void deleteDemandDrivenData(DataType *&dataPtr)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.