/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2016-2026 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . \*---------------------------------------------------------------------------*/ #include "binaryTree.H" #include "SortableList.H" // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // bool Foam::binaryTree::inSubTree ( const scalarField& phiq, binaryNode* y, chemPointISAT* x ) { if ((n2ndSearch_ < max2ndSearch_) && (y!=nullptr)) { scalar vPhi = 0; const scalarField& v = y->v(); const scalar a = y->a(); // compute v*phi for (label i=0; inodeLeft() == nullptr)// left is a chemPoint { n2ndSearch_++; if (y->leafLeft()->inEOA(phiq)) { x = y->leafLeft(); return true; } } else // the left side is a node { if (inSubTree(phiq, y->nodeLeft(),x)) { return true; } } // not on the left side, try the right side if ((n2ndSearch_ < max2ndSearch_) && y->nodeRight() == nullptr) { n2ndSearch_++; // we reach the end of the subTree we can return the result if (y->leafRight()->inEOA(phiq)) { x = y->leafRight(); return true; } else { x = nullptr; return false; } } else // test for n2ndSearch is done in the call of inSubTree { return inSubTree(phiq, y->nodeRight(),x); } } else // on right side (symmetric of above) { if (y->nodeRight() == nullptr) { n2ndSearch_++; if (y->leafRight()->inEOA(phiq)) { return true; } } else // the right side is a node { if (inSubTree(phiq, y->nodeRight(),x)) { x = y->leafRight(); return true; } } // if we reach this point, the retrieve has // failed on the right side, explore the left side if ((n2ndSearch_ < max2ndSearch_) && y->nodeLeft() == nullptr) { n2ndSearch_++; if (y->leafLeft()->inEOA(phiq)) { x = y->leafLeft(); return true; } else { x = nullptr; return false; } } else { return inSubTree(phiq, y->nodeLeft(),x); } } } else { return false; } } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::binaryTree::binaryTree ( chemistryTabulationMethods::ISAT& table, const dictionary& coeffDict ) : table_(table), root_(nullptr), maxNLeafs_(coeffDict.lookup