/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2018-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 "age.H" #include "fvmDiv.H" #include "fvmLaplacian.H" #include "fvModels.H" #include "fvConstraints.H" #include "momentumTransportModel.H" #include "zeroInletOutletFvPatchField.H" #include "wallFvPatch.H" #include "zeroGradientFvPatchField.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { namespace functionObjects { defineTypeNameAndDebug(age, 0); addToRunTimeSelectionTable(functionObject, age, dictionary); } } // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // Foam::wordList Foam::functionObjects::age::patchTypes() const { wordList result ( mesh_.boundary().size(), zeroInletOutletFvPatchField::typeName ); forAll(mesh_.boundary(), patchi) { if (isA(mesh_.boundary()[patchi])) { result[patchi] = zeroGradientFvPatchField::typeName; } } return result; } bool Foam::functionObjects::age::converged ( const int nCorr, const scalar initialResidual ) const { if (initialResidual < tolerance_) { Info<< "Field " << typeName << " converged in " << nCorr << " correctors\n" << endl; return true; } else { return false; } } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::age::age ( const word& name, const Time& runTime, const dictionary& dict ) : fvMeshFunctionObject(name, runTime, dict) { read(dict); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::functionObjects::age::~age() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // bool Foam::functionObjects::age::read(const dictionary& dict) { phiName_ = dict.lookupOrDefault("phi", "phi"); rhoName_ = dict.lookupOrDefault("rho", "rho"); schemesField_ = dict.lookupOrDefault("schemesField", typeName); solverField_ = dict.lookupOrDefault("solverField", typeName); diffusion_ = dict.lookupOrDefault("diffusion", false); tolerance_ = dict.lookupOrDefault("tolerance", 1e-5); return true; } Foam::wordList Foam::functionObjects::age::fields() const { return wordList{phiName_, rhoName_}; } bool Foam::functionObjects::age::execute() { tmp tage ( new volScalarField ( IOobject ( typeName, time_.name(), mesh_, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE, false ), mesh_, dimensionedScalar(dimensions::time, 0), patchTypes() ) ); volScalarField& age = tage.ref(); const word divScheme("div(phi,", schemesField_, ')'); const int nCorr = mesh_.solution().solverDict(solverField_) .lookupOrDefaultBackwardsCompatible