/*---------------------------------------------------------------------------*\ ========= | \ / F ield | OpenFOAM: The Open Source CFD Toolbox \ / O peration | \ / A nd | www.openfoam.com \/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2024 OpenCFD Ltd. ------------------------------------------------------------------------------- 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 "functionObjectValue.H" #include "addToRunTimeSelectionTable.H" #include "IFstream.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { namespace substitutionModels { defineTypeNameAndDebug(functionObjectValue, 0); addToRunTimeSelectionTable ( substitutionModel, functionObjectValue, dictionary ); } } // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // template bool Foam::substitutionModels::functionObjectValue::getValue ( OStringStream& oss, const word& lookup ) const { const auto& foProps = time_.functionObjects().propsDict(); Type result; if (foProps.getObjectResult(functionObject_, lookup, result)) { oss << result; return true; } return false; } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::substitutionModels::functionObjectValue::functionObjectValue ( const dictionary& dict, const Time& time ) : substitutionModel(dict, time), functionObject_(dict.get("functionObject")), entries_(), debugValues_(dict.getOrDefault("debugValues", false)) { // Populate entries const dictionary& entriesDict = dict.subDict("entries"); for (const auto& e : entriesDict) { entries_.insert(cleanKey(e.keyword()), word(e.stream())); } } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // bool Foam::substitutionModels::functionObjectValue::update() { if (debugValues_) { Info<< nl << "Function object results:" << nl; time_.functionObjects().propsDict().writeAllResultEntries(Info); } return true; } bool Foam::substitutionModels::functionObjectValue::valid ( const word& keyName ) const { return entries_.found(keyName); } bool Foam::substitutionModels::functionObjectValue::apply ( const word& key, string& buffer ) const { if (!valid(key)) return false; OStringStream oss; const word& lookup = entries_[key]; bool ok = getValue