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_(coeffDict.lookup<
label>(
"maxNLeafs")),
148 max2ndSearch_(coeffDict.lookupOrDefault(
"max2ndSearch",0)),
149 maxNumNewDim_(coeffDict.lookupOrDefault(
"maxNumNewDim",0)),
150 printProportion_(coeffDict.lookupOrDefault(
"printProportion",false))
161 const scalar& epsTol,
188 root_->leafLeft() = newChemPoint;
195 binaryTreeSearch(phiq, root_,
phi0);
225 insertNode(
phi0, newNode);
235 phi0->node() = newNode;
236 newChemPoint->
node()=newNode;
250 if ((n2ndSearch_ < max2ndSearch_) && (size_ > 1))
262 else if (inSubTree(phiq, nodeSibling(
x),
x))
269 while((
y->parent()!=
nullptr) && (n2ndSearch_ < max2ndSearch_))
271 xS = chemPSibling(
y);
281 else if (inSubTree(phiq, nodeSibling(
y),
x))
312 if (siblingPhi0 !=
nullptr)
315 if (z->
parent() ==
nullptr)
318 root_->leafLeft()=siblingPhi0;
319 siblingPhi0->
node()=root_;
336 <<
"wrong addressing of the initial leaf"
342 x = nodeSibling(
phi0);
350 <<
"inconsistent structure of the tree, no leaf and no node"
367 label chemPointISATi=0;
370 chemPoints[chemPointISATi++] =
x;
371 x = treeSuccessor(
x);
390 variance[vi] +=
sqr(phij[vi]-mean[vi]);
395 scalar maxVariance(-1.0);
399 if (maxVariance < variance[vi])
401 maxVariance = variance[vi];
414 phiMaxDir[j] = chemPoints[j]->phi()[maxDir];
425 chemPoints[phiMaxDir.
indices()[0]],
426 chemPoints[phiMaxDir.
indices()[phiMaxDir.
size()-1]],
431 chemPoints[phiMaxDir.
indices()[0]]->node() = newNode;
432 chemPoints[phiMaxDir.
indices()[phiMaxDir.
size()-1]]->node() = newNode;
434 for (
label cpi=1; cpi<chemPoints.
size()-1; cpi++)
439 chemPoints[phiMaxDir.
indices()[cpi]]->phi(),
447 chemPoints[phiMaxDir.
indices()[cpi]],
452 insertNode(
phi0, nodeToAdd);
453 phi0->node() = nodeToAdd;
454 chemPoints[phiMaxDir.
indices()[cpi]]->node() = nodeToAdd;
463 if (
x ==
x->node()->leafLeft())
465 if (
x->node()->nodeRight() ==
nullptr)
467 return x->node()->leafRight();
471 return treeMin(
x->node()->nodeRight());
474 else if (
x ==
x->node()->leafRight())
477 while((
y->parent() !=
nullptr))
479 if (
y ==
y->parent()->nodeLeft())
481 if (
y->parent()->nodeRight() ==
nullptr)
483 return y->parent()->leafRight();
487 return treeMin(
y->parent()->nodeRight());
500 <<
"inconsistent structure of the tree, no leaf and no node"
#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)
void balance()
Cheap balance function.
binaryTree(chemistryTabulationMethods::ISAT &table, const dictionary &coeffDict)
Constructors.
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 keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
volScalarField scalarField(fieldObject, mesh)
const dimensionedScalar phi0
Magnetic flux quantum: default SI units: [Wb].
static const coefficient A("A", dimPressure, 611.21)
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)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void sqr(LagrangianPatchField< typename outerProduct< Type, Type >::type > &f, const LagrangianPatchField< Type > &f1)