From 0c08c2888c0c561886332770d3dcc72763fc1b46 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Fri, 7 Apr 2023 19:55:21 +0100 Subject: [PATCH] solvers: Provided public constant access to state fields --- .../solvers/modules/XiFluid/XiFluid.C | 25 +++++---- .../solvers/modules/XiFluid/XiFluid.H | 19 +++++-- .../modules/XiFluid/thermophysicalPredictor.C | 13 +++-- .../modules/fluid/thermophysicalPredictor.C | 6 +- .../incompressibleFluid/correctPressure.C | 4 ++ .../incompressibleFluid/incompressibleFluid.C | 22 +++++--- .../incompressibleFluid/incompressibleFluid.H | 18 +++++- .../incompressibleFluid/momentumPredictor.C | 2 + .../modules/incompressibleFluid/moveMesh.C | 8 +-- .../isothermalFluid/correctBuoyantPressure.C | 7 ++- .../modules/isothermalFluid/correctDensity.C | 2 + .../modules/isothermalFluid/correctPressure.C | 7 ++- .../modules/isothermalFluid/isothermalFluid.C | 56 ++++++++++--------- .../modules/isothermalFluid/isothermalFluid.H | 30 ++++++++-- .../isothermalFluid/momentumPredictor.C | 2 + .../modules/isothermalFluid/moveMesh.C | 8 +-- .../multicomponentFluid/multicomponentFluid.C | 17 +++--- .../multicomponentFluid/multicomponentFluid.H | 15 ++++- .../modules/multicomponentFluid/setRDeltaT.C | 2 +- .../thermophysicalPredictor.C | 8 +-- .../modules/shockFluid/correctDensity.C | 2 + .../modules/shockFluid/fluxPredictor.C | 2 +- .../modules/shockFluid/momentumPredictor.C | 2 + .../modules/shockFluid/pressureCorrector.C | 6 +- .../solvers/modules/shockFluid/shockFluid.C | 38 +++++++------ .../solvers/modules/shockFluid/shockFluid.H | 30 ++++++++-- .../shockFluid/thermophysicalPredictor.C | 4 +- 27 files changed, 235 insertions(+), 120 deletions(-) diff --git a/applications/solvers/modules/XiFluid/XiFluid.C b/applications/solvers/modules/XiFluid/XiFluid.C index 7e0de95229..b49984bbb4 100644 --- a/applications/solvers/modules/XiFluid/XiFluid.C +++ b/applications/solvers/modules/XiFluid/XiFluid.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -49,16 +49,13 @@ Foam::solvers::XiFluid::XiFluid(fvMesh& mesh) autoPtr(psiuMulticomponentThermo::New(mesh).ptr()) ), - thermo(refCast(isothermalFluid::thermo)), + thermo_(refCast(isothermalFluid::thermo_)), - composition(thermo.composition()), + composition(thermo_.composition()), - b(composition.Y("b")), + b_(composition.Y("b")), - unstrainedLaminarFlameSpeed - ( - laminarFlameSpeed::New(thermo) - ), + unstrainedLaminarFlameSpeed(laminarFlameSpeed::New(thermo_)), Su ( @@ -76,7 +73,7 @@ Foam::solvers::XiFluid::XiFluid(fvMesh& mesh) SuMin(0.01*Su.average()), SuMax(4*Su.average()), - Xi + Xi_ ( IOobject ( @@ -99,7 +96,7 @@ Foam::solvers::XiFluid::XiFluid(fvMesh& mesh) IOobject::NO_READ, IOobject::AUTO_WRITE ), - Xi*Su + Xi_*Su ), combustionProperties @@ -149,9 +146,13 @@ Foam::solvers::XiFluid::XiFluid(fvMesh& mesh) thermophysicalTransport ( momentumTransport(), - thermo, + thermo_, true - ) + ), + + thermo(thermo_), + b(b_), + Xi(Xi_) { thermo.validate(type(), "ha", "ea"); diff --git a/applications/solvers/modules/XiFluid/XiFluid.H b/applications/solvers/modules/XiFluid/XiFluid.H index cfd5b96105..6ce362202b 100644 --- a/applications/solvers/modules/XiFluid/XiFluid.H +++ b/applications/solvers/modules/XiFluid/XiFluid.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -101,7 +101,7 @@ protected: // Thermophysical properties - psiuMulticomponentThermo& thermo; + psiuMulticomponentThermo& thermo_; // Composition @@ -111,7 +111,7 @@ protected: //- Reference to the combustion regress variable // obtained from the combustion mixture - volScalarField& b; + volScalarField& b_; //- Set of fields used for the multivariate convection scheme multivariateSurfaceInterpolationScheme::fieldTable fields; @@ -132,7 +132,7 @@ protected: dimensionedScalar SuMax; //- Flame wrinkling coefficient field - volScalarField Xi; + volScalarField Xi_; //- Turbulent flame-speed field volScalarField St; @@ -214,6 +214,17 @@ protected: public: + //- Reference to the fluid thermophysical properties + const psiuMulticomponentThermo& thermo; + + //- Reference to the combustion regress variable + // obtained from the combustion mixture + const volScalarField& b; + + //- Flame wrinkling coefficient field + const volScalarField& Xi; + + //- Runtime type information TypeName("XiFluid"); diff --git a/applications/solvers/modules/XiFluid/thermophysicalPredictor.C b/applications/solvers/modules/XiFluid/thermophysicalPredictor.C index 5e036ed6e3..3de2274c3b 100644 --- a/applications/solvers/modules/XiFluid/thermophysicalPredictor.C +++ b/applications/solvers/modules/XiFluid/thermophysicalPredictor.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -161,6 +161,9 @@ void Foam::solvers::XiFluid::bSolve const fv::convectionScheme& mvConvection ) { + volScalarField& b(b_); + volScalarField& Xi(Xi_); + // progress variable // ~~~~~~~~~~~~~~~~~ const volScalarField c("c", scalar(1) - b); @@ -480,7 +483,7 @@ void Foam::solvers::XiFluid::EauSolve const fv::convectionScheme& mvConvection ) { - volScalarField& heau = thermo.heu(); + volScalarField& heau = thermo_.heu(); const volScalarField::Internal rhoByRhou(rho()/thermo.rhou()()); @@ -522,7 +525,7 @@ void Foam::solvers::XiFluid::EaSolve const fv::convectionScheme& mvConvection ) { - volScalarField& hea = thermo.he(); + volScalarField& hea = thermo_.he(); fvScalarMatrix EaEqn ( @@ -581,10 +584,10 @@ void Foam::solvers::XiFluid::thermophysicalPredictor() if (!ign.ignited()) { - thermo.heu() == thermo.he(); + thermo_.heu() == thermo.he(); } - thermo.correct(); + thermo_.correct(); } diff --git a/applications/solvers/modules/fluid/thermophysicalPredictor.C b/applications/solvers/modules/fluid/thermophysicalPredictor.C index aa3b6b873e..c71e3e9500 100644 --- a/applications/solvers/modules/fluid/thermophysicalPredictor.C +++ b/applications/solvers/modules/fluid/thermophysicalPredictor.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -31,7 +31,7 @@ License void Foam::solvers::fluid::thermophysicalPredictor() { - volScalarField& he = thermo.he(); + volScalarField& he = thermo_.he(); fvScalarMatrix EEqn ( @@ -60,7 +60,7 @@ void Foam::solvers::fluid::thermophysicalPredictor() fvConstraints().constrain(he); - thermo.correct(); + thermo_.correct(); } diff --git a/applications/solvers/modules/incompressibleFluid/correctPressure.C b/applications/solvers/modules/incompressibleFluid/correctPressure.C index d667c31572..7c6a01e305 100644 --- a/applications/solvers/modules/incompressibleFluid/correctPressure.C +++ b/applications/solvers/modules/incompressibleFluid/correctPressure.C @@ -38,6 +38,10 @@ License void Foam::solvers::incompressibleFluid::correctPressure() { + volScalarField& p(p_); + volVectorField& U(U_); + surfaceScalarField& phi(phi_); + fvVectorMatrix& UEqn = tUEqn.ref(); volScalarField rAU(1.0/UEqn.A()); diff --git a/applications/solvers/modules/incompressibleFluid/incompressibleFluid.C b/applications/solvers/modules/incompressibleFluid/incompressibleFluid.C index 38673f4851..1ce0b2f92f 100644 --- a/applications/solvers/modules/incompressibleFluid/incompressibleFluid.C +++ b/applications/solvers/modules/incompressibleFluid/incompressibleFluid.C @@ -60,7 +60,7 @@ Foam::solvers::incompressibleFluid::incompressibleFluid(fvMesh& mesh) : fluidSolver(mesh), - p + p_ ( IOobject ( @@ -73,9 +73,9 @@ Foam::solvers::incompressibleFluid::incompressibleFluid(fvMesh& mesh) mesh ), - pressureReference(p, pimple.dict()), + pressureReference(p_, pimple.dict()), - U + U_ ( IOobject ( @@ -88,7 +88,7 @@ Foam::solvers::incompressibleFluid::incompressibleFluid(fvMesh& mesh) mesh ), - phi + phi_ ( IOobject ( @@ -98,7 +98,7 @@ Foam::solvers::incompressibleFluid::incompressibleFluid(fvMesh& mesh) IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), - linearInterpolate(U) & mesh.Sf() + linearInterpolate(U_) & mesh.Sf() ), viscosity(viscosityModel::New(mesh)), @@ -107,13 +107,17 @@ Foam::solvers::incompressibleFluid::incompressibleFluid(fvMesh& mesh) ( incompressible::momentumTransportModel::New ( - U, - phi, + U_, + phi_, viscosity ) ), - MRF(mesh) + MRF(mesh), + + p(p_), + U(U_), + phi(phi_) { mesh.schemes().setFluxRequired(p.name()); @@ -124,7 +128,7 @@ Foam::solvers::incompressibleFluid::incompressibleFluid(fvMesh& mesh) Info<< "Constructing face momentum Uf" << endl; // Ensure the U BCs are up-to-date before constructing Uf - U.correctBoundaryConditions(); + U_.correctBoundaryConditions(); Uf = new surfaceVectorField ( diff --git a/applications/solvers/modules/incompressibleFluid/incompressibleFluid.H b/applications/solvers/modules/incompressibleFluid/incompressibleFluid.H index 367bcded21..18636719a6 100644 --- a/applications/solvers/modules/incompressibleFluid/incompressibleFluid.H +++ b/applications/solvers/modules/incompressibleFluid/incompressibleFluid.H @@ -81,7 +81,7 @@ protected: // Pressure //- Pressure field - volScalarField p; + volScalarField p_; //- Pressure reference Foam::pressureReference pressureReference; @@ -90,10 +90,10 @@ protected: // Kinematic properties //- Velocity field - volVectorField U; + volVectorField U_; //- Mass-flux field - surfaceScalarField phi; + surfaceScalarField phi_; // Momentum transport @@ -143,6 +143,18 @@ protected: public: + // Public Data + + //- Reference to the pressure field + const volScalarField& p; + + //- Reference to the velocity field + const volVectorField& U; + + //- Reference to the mass-flux field + const surfaceScalarField& phi; + + //- Runtime type information TypeName("incompressibleFluid"); diff --git a/applications/solvers/modules/incompressibleFluid/momentumPredictor.C b/applications/solvers/modules/incompressibleFluid/momentumPredictor.C index 7554039cc9..7f919eed28 100644 --- a/applications/solvers/modules/incompressibleFluid/momentumPredictor.C +++ b/applications/solvers/modules/incompressibleFluid/momentumPredictor.C @@ -31,6 +31,8 @@ License void Foam::solvers::incompressibleFluid::momentumPredictor() { + volVectorField& U(U_); + tUEqn = ( fvm::ddt(U) + fvm::div(phi, U) diff --git a/applications/solvers/modules/incompressibleFluid/moveMesh.C b/applications/solvers/modules/incompressibleFluid/moveMesh.C index 54232f5d5a..4145174e69 100644 --- a/applications/solvers/modules/incompressibleFluid/moveMesh.C +++ b/applications/solvers/modules/incompressibleFluid/moveMesh.C @@ -45,13 +45,13 @@ void Foam::solvers::incompressibleFluid::moveMesh() { // Calculate absolute flux // from the mapped surface velocity - phi = mesh.Sf() & Uf(); + phi_ = mesh.Sf() & Uf(); - correctUphiBCs(U, phi, true); + correctUphiBCs(U_, phi_, true); fv::correctPhi ( - phi, + phi_, U, p, autoPtr(), @@ -61,7 +61,7 @@ void Foam::solvers::incompressibleFluid::moveMesh() ); // Make the flux relative to the mesh motion - fvc::makeRelative(phi, U); + fvc::makeRelative(phi_, U); } meshCourantNo(); diff --git a/applications/solvers/modules/isothermalFluid/correctBuoyantPressure.C b/applications/solvers/modules/isothermalFluid/correctBuoyantPressure.C index 03b9c1dc7a..3fcbc54234 100644 --- a/applications/solvers/modules/isothermalFluid/correctBuoyantPressure.C +++ b/applications/solvers/modules/isothermalFluid/correctBuoyantPressure.C @@ -40,6 +40,11 @@ License void Foam::solvers::isothermalFluid::correctBuoyantPressure() { + volScalarField& rho(rho_); + volScalarField& p(p_); + volVectorField& U(U_); + surfaceScalarField& phi(phi_); + // Local references to the buoyancy parameters const volScalarField& gh = buoyancy->gh; const surfaceScalarField& ghf = buoyancy->ghf; @@ -220,7 +225,7 @@ void Foam::solvers::isothermalFluid::correctBuoyantPressure() const bool constrained = fvConstraints().constrain(p); // Thermodynamic density update - thermo.correctRho(psi*p - psip0); + thermo_.correctRho(psi*p - psip0); if (constrained) { diff --git a/applications/solvers/modules/isothermalFluid/correctDensity.C b/applications/solvers/modules/isothermalFluid/correctDensity.C index 016b1538a2..14ea7bf310 100644 --- a/applications/solvers/modules/isothermalFluid/correctDensity.C +++ b/applications/solvers/modules/isothermalFluid/correctDensity.C @@ -30,6 +30,8 @@ License void Foam::solvers::isothermalFluid::correctDensity() { + volScalarField& rho(rho_); + fvScalarMatrix rhoEqn ( fvm::ddt(rho) + fvc::div(phi) diff --git a/applications/solvers/modules/isothermalFluid/correctPressure.C b/applications/solvers/modules/isothermalFluid/correctPressure.C index 4e648eb16b..3d7ba71d1d 100644 --- a/applications/solvers/modules/isothermalFluid/correctPressure.C +++ b/applications/solvers/modules/isothermalFluid/correctPressure.C @@ -41,6 +41,11 @@ License void Foam::solvers::isothermalFluid::correctPressure() { + volScalarField& rho(rho_); + volScalarField& p(p_); + volVectorField& U(U_); + surfaceScalarField& phi(phi_); + const volScalarField& psi = thermo.psi(); rho = thermo.rho(); rho.relax(); @@ -199,7 +204,7 @@ void Foam::solvers::isothermalFluid::correctPressure() const bool constrained = fvConstraints().constrain(p); // Thermodynamic density update - thermo.correctRho(psi*p - psip0); + thermo_.correctRho(psi*p - psip0); if (constrained) { diff --git a/applications/solvers/modules/isothermalFluid/isothermalFluid.C b/applications/solvers/modules/isothermalFluid/isothermalFluid.C index 89a9d0415f..119a6840d5 100644 --- a/applications/solvers/modules/isothermalFluid/isothermalFluid.C +++ b/applications/solvers/modules/isothermalFluid/isothermalFluid.C @@ -95,12 +95,12 @@ Foam::solvers::isothermalFluid::isothermalFluid : fluidSolver(mesh), - thermo_(thermoPtr), - thermo(thermo_()), + thermoPtr_(thermoPtr), + thermo_(thermoPtr_()), - p(thermo.p()), + p_(thermo_.p()), - rho + rho_ ( IOobject ( @@ -110,7 +110,7 @@ Foam::solvers::isothermalFluid::isothermalFluid IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), - thermo.renameRho() + thermo_.renameRho() ), dpdt @@ -122,22 +122,22 @@ Foam::solvers::isothermalFluid::isothermalFluid mesh ), mesh, - dimensionedScalar(p.dimensions()/dimTime, 0) + dimensionedScalar(p_.dimensions()/dimTime, 0) ), buoyancy(buoyancy::New(mesh)), - p_rgh(buoyancy.valid() ? buoyancy->p_rgh : p), + p_rgh(buoyancy.valid() ? buoyancy->p_rgh : p_), pressureReference ( - p, + p_, p_rgh, pimple.dict(), - thermo.incompressible() + thermo_.incompressible() ), - U + U_ ( IOobject ( @@ -150,7 +150,7 @@ Foam::solvers::isothermalFluid::isothermalFluid mesh ), - phi + phi_ ( IOobject ( @@ -160,25 +160,31 @@ Foam::solvers::isothermalFluid::isothermalFluid IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), - linearInterpolate(rho*U) & mesh.Sf() + linearInterpolate(rho_*U_) & mesh.Sf() ), - K("K", 0.5*magSqr(U)), + K("K", 0.5*magSqr(U_)), momentumTransport ( compressible::momentumTransportModel::New ( - rho, - U, - phi, - thermo + rho_, + U_, + phi_, + thermo_ ) ), - initialMass(fvc::domainIntegrate(rho)), + initialMass(fvc::domainIntegrate(rho_)), - MRF(mesh) + MRF(mesh), + + thermo(thermo_), + p(p_), + rho(rho_), + U(U_), + phi(phi_) { // Read the controls readControls(); @@ -191,13 +197,13 @@ Foam::solvers::isothermalFluid::isothermalFluid hydrostaticInitialisation ( p_rgh, - p, - rho, + p_, + rho_, U, buoyancy->gh, buoyancy->ghf, buoyancy->pRef, - thermo, + thermo_, pimple.dict() ); @@ -222,7 +228,7 @@ Foam::solvers::isothermalFluid::isothermalFluid Info<< "Constructing face momentum rhoUf" << endl; // Ensure the U BCs are up-to-date before constructing Uf - U.correctBoundaryConditions(); + U_.correctBoundaryConditions(); rhoUf = new surfaceVectorField ( @@ -327,7 +333,7 @@ void Foam::solvers::isothermalFluid::preSolve() void Foam::solvers::isothermalFluid::thermophysicalPredictor() { - thermo.correct(); + thermo_.correct(); } @@ -364,7 +370,7 @@ void Foam::solvers::isothermalFluid::postSolve() if (!mesh.schemes().steady()) { - rho = thermo.rho(); + rho_ = thermo.rho(); // Correct rhoUf with the updated density if the mesh is moving fvc::correctRhoUf(rhoUf, rho, U, phi, MRF); diff --git a/applications/solvers/modules/isothermalFluid/isothermalFluid.H b/applications/solvers/modules/isothermalFluid/isothermalFluid.H index a444802191..1800c38172 100644 --- a/applications/solvers/modules/isothermalFluid/isothermalFluid.H +++ b/applications/solvers/modules/isothermalFluid/isothermalFluid.H @@ -82,16 +82,16 @@ protected: // Thermophysical properties //- Pointer to the fluid thermophysical properties - autoPtr thermo_; + autoPtr thermoPtr_; //- Reference to the fluid thermophysical properties - fluidThermo& thermo; + fluidThermo& thermo_; //- Reference to the pressure field - volScalarField& p; + volScalarField& p_; //- The continuity density field - volScalarField rho; + volScalarField rho_; //- Rate of change of the pressure // Used in the enthalpy equation @@ -118,10 +118,10 @@ protected: // Kinematic properties //- Velocity field - volVectorField U; + volVectorField U_; //- Mass-flux field - surfaceScalarField phi; + surfaceScalarField phi_; //- Kinetic energy field // Used in the energy equation @@ -213,6 +213,24 @@ protected: public: + // Public Data + + //- Reference to the fluid thermophysical properties + const fluidThermo& thermo; + + //- Reference to the pressure field + const volScalarField& p; + + //- Reference to the continuity density field + const volScalarField& rho; + + //- Velocity field + const volVectorField& U; + + //- Mass-flux field + const surfaceScalarField& phi; + + //- Runtime type information TypeName("isothermalFluid"); diff --git a/applications/solvers/modules/isothermalFluid/momentumPredictor.C b/applications/solvers/modules/isothermalFluid/momentumPredictor.C index f68201f8c0..714737aa40 100644 --- a/applications/solvers/modules/isothermalFluid/momentumPredictor.C +++ b/applications/solvers/modules/isothermalFluid/momentumPredictor.C @@ -31,6 +31,8 @@ License void Foam::solvers::isothermalFluid::momentumPredictor() { + volVectorField& U(U_); + tUEqn = ( fvm::ddt(rho, U) + fvm::div(phi, U) diff --git a/applications/solvers/modules/isothermalFluid/moveMesh.C b/applications/solvers/modules/isothermalFluid/moveMesh.C index 09af637daa..e6879bf983 100644 --- a/applications/solvers/modules/isothermalFluid/moveMesh.C +++ b/applications/solvers/modules/isothermalFluid/moveMesh.C @@ -54,13 +54,13 @@ void Foam::solvers::isothermalFluid::moveMesh() { // Calculate absolute flux // from the mapped surface velocity - phi = mesh.Sf() & rhoUf(); + phi_ = mesh.Sf() & rhoUf(); - correctUphiBCs(rho, U, phi, true); + correctUphiBCs(rho, U_, phi_, true); fv::correctPhi ( - phi, + phi_, buoyancy.valid() ? p_rgh : p, thermo.psi(), autoPtr(), @@ -69,7 +69,7 @@ void Foam::solvers::isothermalFluid::moveMesh() ); // Make the fluxes relative to the mesh-motion - fvc::makeRelative(phi, rho, U); + fvc::makeRelative(phi_, rho, U); } meshCourantNo(); diff --git a/applications/solvers/modules/multicomponentFluid/multicomponentFluid.C b/applications/solvers/modules/multicomponentFluid/multicomponentFluid.C index 92f8723a52..1008190ed2 100644 --- a/applications/solvers/modules/multicomponentFluid/multicomponentFluid.C +++ b/applications/solvers/modules/multicomponentFluid/multicomponentFluid.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -49,22 +49,25 @@ Foam::solvers::multicomponentFluid::multicomponentFluid(fvMesh& mesh) autoPtr(fluidMulticomponentThermo::New(mesh).ptr()) ), - thermo(refCast(isothermalFluid::thermo)), + thermo_(refCast(isothermalFluid::thermo_)), - composition(thermo.composition()), + composition(thermo_.composition()), - Y(composition.Y()), + Y_(composition.Y()), - reaction(combustionModel::New(thermo, momentumTransport())), + reaction(combustionModel::New(thermo_, momentumTransport())), thermophysicalTransport ( fluidMulticomponentThermophysicalTransportModel::New ( momentumTransport(), - thermo + thermo_ ) - ) + ), + + thermo(thermo_), + Y(Y_) { thermo.validate(type(), "h", "e"); diff --git a/applications/solvers/modules/multicomponentFluid/multicomponentFluid.H b/applications/solvers/modules/multicomponentFluid/multicomponentFluid.H index f8482bcdc1..85260f72ff 100644 --- a/applications/solvers/modules/multicomponentFluid/multicomponentFluid.H +++ b/applications/solvers/modules/multicomponentFluid/multicomponentFluid.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -81,13 +81,13 @@ protected: // Thermophysical properties - fluidMulticomponentThermo& thermo; + fluidMulticomponentThermo& thermo_; // Composition basicSpecieMixture& composition; - PtrList& Y; + PtrList& Y_; // Reactions @@ -112,6 +112,15 @@ private: public: + // Public Data + + //- Reference to the fluid thermophysical properties + const fluidMulticomponentThermo& thermo; + + //- Reference to the composition + const PtrList& Y; + + //- Runtime type information TypeName("multicomponentFluid"); diff --git a/applications/solvers/modules/multicomponentFluid/setRDeltaT.C b/applications/solvers/modules/multicomponentFluid/setRDeltaT.C index ef1c640738..e63f990048 100644 --- a/applications/solvers/modules/multicomponentFluid/setRDeltaT.C +++ b/applications/solvers/modules/multicomponentFluid/setRDeltaT.C @@ -108,7 +108,7 @@ void Foam::solvers::multicomponentFluid::setRDeltaT() { if (composition.solve(i)) { - volScalarField& Yi = Y[i]; + volScalarField& Yi = Y_[i]; if (Yref.found(Yi.name())) { diff --git a/applications/solvers/modules/multicomponentFluid/thermophysicalPredictor.C b/applications/solvers/modules/multicomponentFluid/thermophysicalPredictor.C index d7c37806f2..7504e565fb 100644 --- a/applications/solvers/modules/multicomponentFluid/thermophysicalPredictor.C +++ b/applications/solvers/modules/multicomponentFluid/thermophysicalPredictor.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -47,7 +47,7 @@ void Foam::solvers::multicomponentFluid::thermophysicalPredictor() { if (composition.solve(i)) { - volScalarField& Yi = Y[i]; + volScalarField& Yi = Y_[i]; fvScalarMatrix YiEqn ( @@ -72,7 +72,7 @@ void Foam::solvers::multicomponentFluid::thermophysicalPredictor() composition.normalise(); - volScalarField& he = thermo.he(); + volScalarField& he = thermo_.he(); fvScalarMatrix EEqn ( @@ -102,7 +102,7 @@ void Foam::solvers::multicomponentFluid::thermophysicalPredictor() fvConstraints().constrain(he); - thermo.correct(); + thermo_.correct(); } diff --git a/applications/solvers/modules/shockFluid/correctDensity.C b/applications/solvers/modules/shockFluid/correctDensity.C index e1c220484b..4b792e0149 100644 --- a/applications/solvers/modules/shockFluid/correctDensity.C +++ b/applications/solvers/modules/shockFluid/correctDensity.C @@ -31,6 +31,8 @@ License void Foam::solvers::shockFluid::correctDensity() { + volScalarField& rho(rho_); + fvScalarMatrix rhoEqn ( fvm::ddt(rho) + fvc::div(phi) diff --git a/applications/solvers/modules/shockFluid/fluxPredictor.C b/applications/solvers/modules/shockFluid/fluxPredictor.C index 2940a044ce..fd68acefc6 100644 --- a/applications/solvers/modules/shockFluid/fluxPredictor.C +++ b/applications/solvers/modules/shockFluid/fluxPredictor.C @@ -124,7 +124,7 @@ void Foam::solvers::shockFluid::fluxPredictor() aphiv_pos = surfaceScalarField::New("aphiv_pos", phiv_pos - aSf()); aphiv_neg = surfaceScalarField::New("aphiv_neg", phiv_neg + aSf()); - phi = aphiv_pos()*rho_pos() + aphiv_neg()*rho_neg(); + phi_ = aphiv_pos()*rho_pos() + aphiv_neg()*rho_neg(); } diff --git a/applications/solvers/modules/shockFluid/momentumPredictor.C b/applications/solvers/modules/shockFluid/momentumPredictor.C index 4b8d092950..de00d7c3b6 100644 --- a/applications/solvers/modules/shockFluid/momentumPredictor.C +++ b/applications/solvers/modules/shockFluid/momentumPredictor.C @@ -31,6 +31,8 @@ License void Foam::solvers::shockFluid::momentumPredictor() { + volVectorField& U(U_); + const surfaceVectorField phiUp ( (aphiv_pos()*rhoU_pos() + aphiv_neg()*rhoU_neg()) diff --git a/applications/solvers/modules/shockFluid/pressureCorrector.C b/applications/solvers/modules/shockFluid/pressureCorrector.C index 397e8805f5..7d93660f3b 100644 --- a/applications/solvers/modules/shockFluid/pressureCorrector.C +++ b/applications/solvers/modules/shockFluid/pressureCorrector.C @@ -30,9 +30,9 @@ License void Foam::solvers::shockFluid::pressureCorrector() { const volScalarField& psi = thermo.psi(); - p.ref() = rho()/psi(); - p.correctBoundaryConditions(); - rho.boundaryFieldRef() == psi.boundaryField()*p.boundaryField(); + p_.ref() = rho()/psi(); + p_.correctBoundaryConditions(); + rho_.boundaryFieldRef() == psi.boundaryField()*p.boundaryField(); } diff --git a/applications/solvers/modules/shockFluid/shockFluid.C b/applications/solvers/modules/shockFluid/shockFluid.C index 25a43093ec..5f749a513a 100644 --- a/applications/solvers/modules/shockFluid/shockFluid.C +++ b/applications/solvers/modules/shockFluid/shockFluid.C @@ -94,13 +94,13 @@ Foam::solvers::shockFluid::shockFluid(fvMesh& mesh) : fluidSolver(mesh), - thermo_(psiThermo::New(mesh)), + thermoPtr_(psiThermo::New(mesh)), - thermo(thermo_()), + thermo_(thermoPtr_()), - p(thermo.p()), + p_(thermo_.p()), - rho + rho_ ( IOobject ( @@ -110,10 +110,10 @@ Foam::solvers::shockFluid::shockFluid(fvMesh& mesh) IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), - thermo.renameRho() + thermo_.renameRho() ), - U + U_ ( IOobject ( @@ -126,7 +126,7 @@ Foam::solvers::shockFluid::shockFluid(fvMesh& mesh) mesh ), - phi + phi_ ( IOobject ( @@ -136,14 +136,14 @@ Foam::solvers::shockFluid::shockFluid(fvMesh& mesh) IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), - linearInterpolate(rho*U) & mesh.Sf() + linearInterpolate(rho_*U_) & mesh.Sf() ), - K("K", 0.5*magSqr(U)), + K("K", 0.5*magSqr(U_)), inviscid ( - max(thermo.mu()().primitiveField()) > 0 + max(thermo_.mu()().primitiveField()) > 0 ? false : true ), @@ -154,10 +154,10 @@ Foam::solvers::shockFluid::shockFluid(fvMesh& mesh) ? autoPtr(nullptr) : compressible::momentumTransportModel::New ( - rho, - U, - phi, - thermo + rho_, + U_, + phi_, + thermo_ ) ), @@ -168,14 +168,20 @@ Foam::solvers::shockFluid::shockFluid(fvMesh& mesh) : fluidThermoThermophysicalTransportModel::New ( momentumTransport(), - thermo + thermo_ ) ), fluxScheme ( mesh.schemes().dict().lookupOrDefault("fluxScheme", "Kurganov") - ) + ), + + thermo(thermo_), + p(p_), + rho(rho_), + U(U_), + phi(phi_) { // Read the controls readControls(); diff --git a/applications/solvers/modules/shockFluid/shockFluid.H b/applications/solvers/modules/shockFluid/shockFluid.H index f370e3beb3..2636351c9f 100644 --- a/applications/solvers/modules/shockFluid/shockFluid.H +++ b/applications/solvers/modules/shockFluid/shockFluid.H @@ -78,25 +78,25 @@ protected: // Thermophysical properties //- Pointer to the fluid thermophysical properties - autoPtr thermo_; + autoPtr thermoPtr_; //- Reference to the fluid thermophysical properties - psiThermo& thermo; + psiThermo& thermo_; //- Reference to the pressure field - volScalarField& p; + volScalarField& p_; //- The continuity density field - volScalarField rho; + volScalarField rho_; // Kinematic properties //- Velocity field - volVectorField U; + volVectorField U_; //- Mass-flux field - surfaceScalarField phi; + surfaceScalarField phi_; //- Kinetic energy field // Used in the energy equation @@ -201,6 +201,24 @@ private: public: + // Public Data + + //- Reference to the fluid thermophysical properties + const psiThermo& thermo; + + //- Reference to the pressure field + const volScalarField& p; + + //- Reference to the continuity density field + const volScalarField& rho; + + //- Reference to the velocity field + const volVectorField& U; + + //- Reference to the mass-flux field + const surfaceScalarField& phi; + + //- Runtime type information TypeName("shockFluid"); diff --git a/applications/solvers/modules/shockFluid/thermophysicalPredictor.C b/applications/solvers/modules/shockFluid/thermophysicalPredictor.C index ff0fd0c305..4d2a278237 100644 --- a/applications/solvers/modules/shockFluid/thermophysicalPredictor.C +++ b/applications/solvers/modules/shockFluid/thermophysicalPredictor.C @@ -32,7 +32,7 @@ License void Foam::solvers::shockFluid::thermophysicalPredictor() { - volScalarField& e = thermo.he(); + volScalarField& e = thermo_.he(); const surfaceScalarField e_pos(interpolate(e, pos, thermo.T().name())); const surfaceScalarField e_neg(interpolate(e, neg, thermo.T().name())); @@ -78,7 +78,7 @@ void Foam::solvers::shockFluid::thermophysicalPredictor() fvConstraints().constrain(e); - thermo.correct(); + thermo_.correct(); }