From 4fb68fa0db0b91cb6d6830ddaaa1566b1eed3dfb Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Tue, 19 Jul 2022 08:48:45 +0100 Subject: [PATCH] functionObjects::scalarTransport: Updated handling of the schemesField option The schemesField option: - To employ the same numerical schemes as another field set the \c schemesField entry, works to set discretisation schemes and a standard linear solver and settings but not MULES for which an entry in fvSolution under the actual field name is required. --- src/OpenFOAM/matrices/solution/solution.C | 6 ++ src/OpenFOAM/matrices/solution/solution.H | 3 + .../solvers/scalarTransport/scalarTransport.C | 83 ++++++++++--------- 3 files changed, 52 insertions(+), 40 deletions(-) diff --git a/src/OpenFOAM/matrices/solution/solution.C b/src/OpenFOAM/matrices/solution/solution.C index 6e60001ee0..2542bd6f51 100644 --- a/src/OpenFOAM/matrices/solution/solution.C +++ b/src/OpenFOAM/matrices/solution/solution.C @@ -326,6 +326,12 @@ const Foam::dictionary& Foam::solution::dict() const } +const Foam::dictionary& Foam::solution::solversDict() const +{ + return solvers_; +} + + const Foam::dictionary& Foam::solution::solverDict(const word& name) const { if (debug) diff --git a/src/OpenFOAM/matrices/solution/solution.H b/src/OpenFOAM/matrices/solution/solution.H index 9db7c438bf..1239e059fd 100644 --- a/src/OpenFOAM/matrices/solution/solution.H +++ b/src/OpenFOAM/matrices/solution/solution.H @@ -136,6 +136,9 @@ public: // keyword is given, otherwise return the complete dictionary const dictionary& dict() const; + //- Return the solver controls dictionary + const dictionary& solversDict() const; + //- Return the solver controls dictionary for the given field const dictionary& solverDict(const word& name) const; diff --git a/src/functionObjects/solvers/scalarTransport/scalarTransport.C b/src/functionObjects/solvers/scalarTransport/scalarTransport.C index 97d1b5ebd4..f70a6bde42 100644 --- a/src/functionObjects/solvers/scalarTransport/scalarTransport.C +++ b/src/functionObjects/solvers/scalarTransport/scalarTransport.C @@ -87,7 +87,7 @@ const Foam::NamedEnum Foam::tmp Foam::functionObjects::scalarTransport::D() const { - const word Dname("D" + s_.name()); + const word Dname("D" + fieldName_); if (diffusion_ == diffusionType::constant) { @@ -147,41 +147,44 @@ Foam::functionObjects::scalarTransport::scalarTransport { read(dict); - const dictionary& controls = mesh_.solution().solverDict(s_.name()); - - if (controls.found("nSubCycles")) + if (mesh_.solution().solversDict().found(fieldName_)) { - MULES_ = true; + const dictionary& controls = mesh_.solution().solverDict(fieldName_); - typeIOobject sPhiHeader - ( - IOobject::groupName("sPhi", s_.group()), - runTime.timeName(), - mesh_, - IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE - ); - - sRestart_ = sPhiHeader.headerOk(); - - if (sRestart_) + if (controls.found("nSubCycles")) { - Info << "Restarting s" << endl; - } + MULES_ = true; - const surfaceScalarField& phi = + typeIOobject sPhiHeader + ( + IOobject::groupName("sPhi", s_.group()), + runTime.timeName(), + mesh_, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ); + + sRestart_ = sPhiHeader.headerOk(); + + if (sRestart_) + { + Info << "Restarting s" << endl; + } + + const surfaceScalarField& phi = mesh_.lookupObject(phiName_); - // Scalar volumetric flux - tsPhi_ = new surfaceScalarField - ( - sPhiHeader, - phi*fvc::interpolate(s_) - ); + // Scalar volumetric flux + tsPhi_ = new surfaceScalarField + ( + sPhiHeader, + phi*fvc::interpolate(s_) + ); - if (controls.lookupOrDefault("MULESCorr", false)) - { - mesh_.schemes().setFluxRequired(s_.name()); + if (controls.lookupOrDefault("MULESCorr", false)) + { + mesh_.schemes().setFluxRequired(fieldName_); + } } } } @@ -334,7 +337,7 @@ bool Foam::functionObjects::scalarTransport::execute() void Foam::functionObjects::scalarTransport::subCycleMULES() { - const dictionary& controls = mesh_.solution().solverDict(s_.name()); + const dictionary& controls = mesh_.solution().solverDict(fieldName_); const label nSubCycles(controls.lookup