.. _program_listing_file_rootFinding_NewtonRootFinder_NewtonRootFinder.C: Program Listing for File NewtonRootFinder.C =========================================== |exhale_lsh| :ref:`Return to documentation for file ` (``rootFinding/NewtonRootFinder/NewtonRootFinder.C``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp /*---------------------------------------------------------------------------* \ License This file is part of libWallModelledLES. libWallModelledLES 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. libWallModelledLES 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 libWallModelledLES. If not, see . \*---------------------------------------------------------------------------*/ #include "NewtonRootFinder.H" #include "addToRunTimeSelectionTable.H" using namespace boost::math::policies; // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // #if !defined(DOXYGEN_SHOULD_SKIP_THIS) namespace Foam { defineTypeNameAndDebug(NewtonRootFinder, 0); addToRunTimeSelectionTable(RootFinder, NewtonRootFinder, Word); addToRunTimeSelectionTable(RootFinder, NewtonRootFinder, Dictionary); addToRunTimeSelectionTable(RootFinder, NewtonRootFinder, DictionaryOnly); } #endif typedef policy< domain_error, overflow_error > myPolicy; // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // std::pair Foam::NewtonRootFinder::root( scalar guess, scalar lowerBound, scalar upperBound ) const { label iterations = 0; auto funcTuple = [this, &iterations](scalar uTau) { iterations++; return std::make_pair(this->f_(uTau), this->d_(uTau)); }; auto maxIter = static_cast(maxIter_); scalar result = boost::math::tools::newton_raphson_iterate( funcTuple, guess, lowerBound, upperBound, getDigits_, maxIter ); return std::make_pair(result, iterations); } // ************************************************************************* //