fluidThermo: Moved psi_ and mu_ from rhoThermo and psiThermo into fluidThermo

to avoid unnecessary code duplication
This commit is contained in:
Henry Weller
2022-11-01 14:14:37 +00:00
parent 63feb9ad33
commit e6c59650de
6 changed files with 71 additions and 168 deletions

View File

@ -42,7 +42,35 @@ Foam::fluidThermo::implementation::implementation
const word& phaseName
)
:
p_(lookupOrConstruct(mesh, "p"))
p_(lookupOrConstruct(mesh, "p")),
psi_
(
IOobject
(
phasePropertyName("psi", phaseName),
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionSet(0, -2, 2, 0, 0)
),
mu_
(
IOobject
(
phasePropertyName("mu", phaseName),
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionSet(1, -1, -1, 0, 0)
)
{}
@ -95,4 +123,25 @@ const Foam::volScalarField& Foam::fluidThermo::implementation::p() const
}
const Foam::volScalarField& Foam::fluidThermo::implementation::psi() const
{
return psi_;
}
Foam::tmp<Foam::volScalarField> Foam::fluidThermo::implementation::mu() const
{
return mu_;
}
Foam::tmp<Foam::scalarField> Foam::fluidThermo::implementation::mu
(
const label patchi
) const
{
return mu_.boundaryField()[patchi];
}
// ************************************************************************* //

View File

@ -169,6 +169,12 @@ protected:
//- Pressure [Pa]
volScalarField& p_;
//- Compressibility [s^2/m^2]
volScalarField psi_;
//- Dynamic viscosity [kg/m/s]
volScalarField mu_;
public:
@ -196,6 +202,18 @@ public:
//- Pressure [Pa]
virtual const volScalarField& p() const;
//- Compressibility [s^2/m^2]
virtual const volScalarField& psi() const;
// Access to transport state variables
//- Dynamic viscosity of mixture [kg/m/s]
virtual tmp<volScalarField> mu() const;
//- Dynamic viscosity of mixture for patch [kg/m/s]
virtual tmp<scalarField> mu(const label patchi) const;
// Member Operators

View File

@ -41,34 +41,6 @@ Foam::psiThermo::implementation::implementation
const fvMesh& mesh,
const word& phaseName
)
:
psi_
(
IOobject
(
phasePropertyName("psi", phaseName),
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionSet(0, -2, 2, 0, 0)
),
mu_
(
IOobject
(
phasePropertyName("mu", phaseName),
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionSet(1, -1, -1, 0, 0)
)
{}
@ -102,7 +74,7 @@ void Foam::psiThermo::correctRho(const Foam::volScalarField& deltaRho)
Foam::tmp<Foam::volScalarField> Foam::psiThermo::implementation::rho() const
{
return p()*psi_;
return p()*psi();
}
@ -111,7 +83,7 @@ Foam::tmp<Foam::scalarField> Foam::psiThermo::implementation::rho
const label patchi
) const
{
return p().boundaryField()[patchi]*psi_.boundaryField()[patchi];
return p().boundaryField()[patchi]*psi().boundaryField()[patchi];
}
@ -123,28 +95,7 @@ Foam::tmp<Foam::volScalarField> Foam::psiThermo::implementation::renameRho()
Foam::tmp<Foam::volScalarField> Foam::psiThermo::implementation::rho0() const
{
return p().oldTime()*psi_.oldTime();
}
const Foam::volScalarField& Foam::psiThermo::implementation::psi() const
{
return psi_;
}
Foam::tmp<Foam::volScalarField> Foam::psiThermo::implementation::mu() const
{
return mu_;
}
Foam::tmp<Foam::scalarField> Foam::psiThermo::implementation::mu
(
const label patchi
) const
{
return mu_.boundaryField()[patchi];
return p().oldTime()*psi().oldTime();
}

View File

@ -114,18 +114,6 @@ public:
//- Old-time density [kg/m^3]
virtual tmp<volScalarField> rho0() const = 0;
//- Compressibility [s^2/m^2]
virtual const volScalarField& psi() const = 0;
// Access to transport state variables
//- Dynamic viscosity of mixture [kg/m/s]
virtual tmp<volScalarField> mu() const = 0;
//- Dynamic viscosity of mixture for patch [kg/m/s]
virtual tmp<scalarField> mu(const label patchi) const = 0;
};
@ -137,18 +125,6 @@ class psiThermo::implementation
:
virtual public psiThermo
{
protected:
// Protected data
// Fields
//- Compressibility [s^2/m^2]
volScalarField psi_;
//- Dynamic viscosity [kg/m/s]
volScalarField mu_;
public:
@ -182,18 +158,6 @@ public:
//- Old-time density [kg/m^3]
virtual tmp<volScalarField> rho0() const;
//- Compressibility [s^2/m^2]
virtual const volScalarField& psi() const;
// Access to transport state variables
//- Dynamic viscosity of mixture [kg/m/s]
virtual tmp<volScalarField> mu() const;
//- Dynamic viscosity of mixture for patch [kg/m/s]
virtual tmp<scalarField> mu(const label patchi) const;
// Member Operators

View File

@ -54,34 +54,6 @@ Foam::rhoThermo::implementation::implementation
),
mesh,
dimDensity
),
psi_
(
IOobject
(
phasePropertyName("psi", phaseName),
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionSet(0, -2, 2, 0, 0)
),
mu_
(
IOobject
(
phasePropertyName("mu", phaseName),
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionSet(1, -1, -1, 0, 0)
)
{}
@ -150,25 +122,4 @@ void Foam::rhoThermo::implementation::correctRho(const volScalarField& deltaRho)
}
const Foam::volScalarField& Foam::rhoThermo::implementation::psi() const
{
return psi_;
}
Foam::tmp<Foam::volScalarField> Foam::rhoThermo::implementation::mu() const
{
return mu_;
}
Foam::tmp<Foam::scalarField> Foam::rhoThermo::implementation::mu
(
const label patchi
) const
{
return mu_.boundaryField()[patchi];
}
// ************************************************************************* //

View File

@ -117,18 +117,6 @@ public:
//- Add the given density correction to the density field.
// Used to update the density field following pressure solution
virtual void correctRho(const volScalarField& deltaRho) = 0;
//- Compressibility [s^2/m^2]
virtual const volScalarField& psi() const = 0;
// Access to transport state variables
//- Dynamic viscosity of mixture [kg/m/s]
virtual tmp<volScalarField> mu() const = 0;
//- Dynamic viscosity of mixture for patch [kg/m/s]
virtual tmp<scalarField> mu(const label patchi) const = 0;
};
@ -148,12 +136,6 @@ protected:
// Named 'rho' to avoid (potential) conflict with solver density
volScalarField rho_;
//- Compressibility [s^2/m^2]
volScalarField psi_;
//- Dynamic viscosity [kg/m/s]
volScalarField mu_;
public:
@ -194,18 +176,6 @@ public:
// Used to update the density field following pressure solution
virtual void correctRho(const volScalarField& deltaRho);
//- Compressibility [s^2/m^2]
virtual const volScalarField& psi() const;
// Access to transport state variables
//- Dynamic viscosity of mixture [kg/m/s]
virtual tmp<volScalarField> mu() const;
//- Dynamic viscosity of mixture for patch [kg/m/s]
virtual tmp<scalarField> mu(const label patchi) const;
// Member Operators