STYLE: simpler mass-flow/volume-flow dimension check

* (dimMass/dimTime)    instead of  (dimDensity*dimVelocity*dimArea)
* (dimVolume/dimTime)  instead of  (dimVelocity*dimArea)
This commit is contained in:
Mark Olesen 2023-01-02 09:33:00 +01:00
parent 2db3e2b64f
commit 35dae3fc3b
28 changed files with 48 additions and 52 deletions

View File

@ -37,7 +37,7 @@ surfaceScalarField phi
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar(dimArea*dimVelocity, Zero)
dimensionedScalar(dimVelocity*dimArea, Zero)
);
multiphaseSystem fluid(U, phi);

View File

@ -53,7 +53,7 @@
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar(dimArea*dimVelocity, Zero)
dimensionedScalar(dimVelocity*dimArea, Zero)
);
volScalarField rho("rho", fluid.rho());

View File

@ -180,7 +180,7 @@ while (pimple.correct())
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("phiHbyA", dimArea*dimVelocity, 0)
dimensionedScalar(dimVelocity*dimArea, Zero)
);
forAll(phases, phasei)

View File

@ -165,7 +165,7 @@ while (pimple.correct())
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("phiHbyA", dimArea*dimVelocity, 0)
dimensionedScalar(dimVelocity*dimArea, Zero)
);
forAll(phases, phasei)

View File

@ -166,7 +166,7 @@ Foam::advectiveFvPatchField<Type>::advectionSpeed() const
phiName_
);
if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
if (phi.dimensions() == dimMass/dimTime)
{
const fvPatchScalarField& rhop =
this->patch().template lookupPatchField<volScalarField, scalar>

View File

@ -77,7 +77,7 @@ void Foam::fanFvPatchField<Foam::scalar>::calcFanJump()
}
}
if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
if (phi.dimensions() == dimMass/dimTime)
{
Un /= patch().lookupPatchField<volScalarField, scalar>(rhoName_);
}

View File

@ -162,11 +162,11 @@ void Foam::fanPressureFvPatchScalarField::updateCoeffs()
// Average volumetric flow rate
scalar volFlowRate = 0;
if (phi.dimensions() == dimVelocity*dimArea)
if (phi.dimensions() == dimVolume/dimTime)
{
volFlowRate = dir*gSum(phip);
}
else if (phi.dimensions() == dimVelocity*dimArea*dimDensity)
else if (phi.dimensions() == dimMass/dimTime)
{
const scalarField& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName());

View File

@ -115,11 +115,11 @@ void Foam::fluxCorrectedVelocityFvPatchVectorField::evaluate
const vectorField n(patch().nf());
const Field<scalar>& magS = patch().magSf();
if (phi.dimensions() == dimVelocity*dimArea)
if (phi.dimensions() == dimVolume/dimTime)
{
operator==(*this - n*(n & *this) + n*phip/magS);
}
else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
else if (phi.dimensions() == dimMass/dimTime)
{
const fvPatchField<scalar>& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);

View File

@ -140,12 +140,12 @@ void Foam::mappedFlowRateFvPatchVectorField::updateCoeffs()
vectorField n(patch().nf());
if (phiName.dimensions() == dimVelocity*dimArea)
if (phiName.dimensions() == dimVolume/dimTime)
{
// volumetric flow-rate
operator==(n*U);
}
else if (phiName.dimensions() == dimDensity*dimVelocity*dimArea)
else if (phiName.dimensions() == dimMass/dimTime)
{
const fvPatchField<scalar>& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);

View File

@ -196,7 +196,7 @@ void Foam::plenumPressureFvPatchScalarField::updateCoeffs()
// Calculate the current mass flow rate
scalar massFlowRate(1.0);
if (phi.internalField().dimensions() == dimVelocity*dimArea)
if (phi.internalField().dimensions() == dimVolume/dimTime)
{
if (hasRho_)
{
@ -209,11 +209,7 @@ void Foam::plenumPressureFvPatchScalarField::updateCoeffs()
<< exit(FatalError);
}
}
else if
(
phi.internalField().dimensions()
== dimDensity*dimVelocity*dimArea
)
else if (phi.internalField().dimensions() == dimMass/dimTime)
{
if (hasRho_)
{

View File

@ -160,11 +160,11 @@ void Foam::pressureDirectedInletOutletVelocityFvPatchVectorField::updateCoeffs()
tmp<vectorField> n = patch().nf();
tmp<scalarField> ndmagS = (n & inletDir_)*patch().magSf();
if (phi.dimensions() == dimVelocity*dimArea)
if (phi.dimensions() == dimVolume/dimTime)
{
refValue() = inletDir_*phip/ndmagS;
}
else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
else if (phi.dimensions() == dimMass/dimTime)
{
const fvPatchField<scalar>& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);

View File

@ -150,11 +150,11 @@ void Foam::pressureDirectedInletVelocityFvPatchVectorField::updateCoeffs()
tmp<vectorField> n = patch().nf();
tmp<scalarField> ndmagS = (n & inletDir_)*patch().magSf();
if (phi.dimensions() == dimVelocity*dimArea)
if (phi.dimensions() == dimVolume/dimTime)
{
operator==(inletDir_*phip/ndmagS);
}
else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
else if (phi.dimensions() == dimMass/dimTime)
{
const fvPatchField<scalar>& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);

View File

@ -134,11 +134,11 @@ void Foam::pressureInletOutletParSlipVelocityFvPatchVectorField::updateCoeffs()
vectorField Ut(patchInternalField());
Ut -= n()*(Ut & n());
if (phi.dimensions() == dimVelocity*dimArea)
if (phi.dimensions() == dimVolume/dimTime)
{
refValue() = Ut + n*phip/magSf;
}
else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
else if (phi.dimensions() == dimMass/dimTime)
{
const fvPatchField<scalar>& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);

View File

@ -118,11 +118,11 @@ void Foam::pressureInletVelocityFvPatchVectorField::updateCoeffs()
tmp<vectorField> n = patch().nf();
const Field<scalar>& magS = patch().magSf();
if (phi.dimensions() == dimVelocity*dimArea)
if (phi.dimensions() == dimVolume/dimTime)
{
operator==(n*phip/magS);
}
else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
else if (phi.dimensions() == dimMass/dimTime)
{
const fvPatchField<scalar>& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);

View File

@ -130,11 +130,11 @@ void Foam::pressureNormalInletOutletVelocityFvPatchVectorField::updateCoeffs()
tmp<vectorField> n = patch().nf();
const Field<scalar>& magS = patch().magSf();
if (phi.dimensions() == dimVelocity*dimArea)
if (phi.dimensions() == dimVolume/dimTime)
{
refValue() = n*phip/magS;
}
else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
else if (phi.dimensions() == dimMass/dimTime)
{
const fvPatchField<scalar>& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);

View File

@ -238,11 +238,11 @@ void Foam::pressurePIDControlInletVelocityFvPatchVectorField::updateCoeffs()
// Get the density
scalar rho = 1;
if (phi.dimensions() == dimVelocity*dimArea)
if (phi.dimensions() == dimVolume/dimTime)
{
// do nothing ...
}
else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
else if (phi.dimensions() == dimMass/dimTime)
{
const fvPatchField<scalar>& rhoField =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
@ -254,9 +254,9 @@ void Foam::pressurePIDControlInletVelocityFvPatchVectorField::updateCoeffs()
FatalErrorInFunction
<< "The dimensions of the field " << phiName_
<< "are not recognised. The dimensions are " << phi.dimensions()
<< ". The dimensions should be either " << dimVelocity*dimArea
<< ". The dimensions should be either " << dimVolume/dimTime
<< " for an incompressible case, or "
<< dimDensity*dimVelocity*dimArea << " for a compressible case."
<< dimMass/dimTime << " for a compressible case."
<< exit(FatalError);
}

View File

@ -138,11 +138,11 @@ updateCoeffs()
const vectorField n(patch().nf());
if (phi.dimensions() == dimVelocity*dimArea)
if (phi.dimensions() == dimVolume/dimTime)
{
refValue() = (phip/patch().magSf())*n;
}
else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
else if (phi.dimensions() == dimMass/dimTime)
{
const fvPatchField<scalar>& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);

View File

@ -171,12 +171,12 @@ void Foam::swirlFlowRateInletVelocityFvPatchVectorField::updateCoeffs()
const surfaceScalarField& phi =
db().lookupObject<surfaceScalarField>(phiName_);
if (phi.dimensions() == dimVelocity*dimArea)
if (phi.dimensions() == dimVolume/dimTime)
{
// volumetric flow-rate
operator==(tangentialVelocity + n*avgU);
}
else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
else if (phi.dimensions() == dimMass/dimTime)
{
const fvPatchField<scalar>& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);

View File

@ -206,11 +206,11 @@ void Foam::syringePressureFvPatchScalarField::updateCoeffs()
const fvsPatchField<scalar>& phip =
patch().patchField<surfaceScalarField, scalar>(phi);
if (phi.dimensions() == dimVelocity*dimArea)
if (phi.dimensions() == dimVolume/dimTime)
{
ams_ = ams0_ + deltaT*sum((*this*psi_)*phip);
}
else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
else if (phi.dimensions() == dimMass/dimTime)
{
ams_ = ams0_ + deltaT*sum(phip);
}

View File

@ -164,7 +164,7 @@ void Foam::waveSurfacePressureFvPatchScalarField::updateCoeffs()
// Change in zeta due to flux
vectorField dZetap(dt*nf()*phi.boundaryField()[patchi]/patch().magSf());
if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
if (phi.dimensions() == dimMass/dimTime)
{
const scalarField& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);

View File

@ -121,7 +121,7 @@ Foam::waveTransmissiveFvPatchField<Type>::advectionSpeed() const
this->patch().template
lookupPatchField<surfaceScalarField, scalar>(this->phiName_);
if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
if (phi.dimensions() == dimMass/dimTime)
{
const fvPatchScalarField& rhop =
this->patch().template

View File

@ -68,7 +68,7 @@ Foam::PhiScheme<Type, PhiLimiter>::limiter
tmp<surfaceScalarField> tUflux = this->faceFlux_;
if (this->faceFlux_.dimensions() == dimDensity*dimVelocity*dimArea)
if (this->faceFlux_.dimensions() == dimMass/dimTime)
{
const volScalarField& rho =
phi.db().objectRegistry::template lookupObject<volScalarField>
@ -76,7 +76,7 @@ Foam::PhiScheme<Type, PhiLimiter>::limiter
tUflux = this->faceFlux_/fvc::interpolate(rho);
}
else if (this->faceFlux_.dimensions() != dimVelocity*dimArea)
else if (this->faceFlux_.dimensions() != dimVolume/dimTime)
{
FatalErrorInFunction
<< "dimensions of faceFlux are not correct"

View File

@ -199,7 +199,7 @@ public:
const fvMesh& mesh = this->mesh();
tmp<surfaceScalarField> tUflux = faceFlux_;
if (faceFlux_.dimensions() == dimDensity*dimVelocity*dimArea)
if (faceFlux_.dimensions() == dimMass/dimTime)
{
// Currently assume that the density field
// corresponding to the mass-flux is named "rho"
@ -209,7 +209,7 @@ public:
tUflux = faceFlux_/fvc::interpolate(rho);
}
else if (faceFlux_.dimensions() != dimVelocity*dimArea)
else if (faceFlux_.dimensions() != dimVolume/dimTime)
{
FatalErrorInFunction
<< "dimensions of faceFlux are not correct"

View File

@ -208,7 +208,7 @@ public:
const fvMesh& mesh = this->mesh();
tmp<surfaceScalarField> tUflux = faceFlux_;
if (faceFlux_.dimensions() == dimDensity*dimVelocity*dimArea)
if (faceFlux_.dimensions() == dimMass/dimTime)
{
// Currently assume that the density field
// corresponding to the mass-flux is named "rho"
@ -218,7 +218,7 @@ public:
tUflux = faceFlux_/fvc::interpolate(rho);
}
else if (faceFlux_.dimensions() != dimVelocity*dimArea)
else if (faceFlux_.dimensions() != dimVolume/dimTime)
{
FatalErrorInFunction
<< "dimensions of faceFlux are not correct"

View File

@ -268,7 +268,7 @@ void Foam::fv::directionalPressureGradientExplicitSource::correct
{
case pDarcyForchheimer:
{
if (phi.dimensions() == dimVelocity*dimArea)
if (phi.dimensions() == dimVolume/dimTime)
{
const auto& turbModel =
mesh().lookupObject<incompressible::turbulenceModel>
@ -323,7 +323,7 @@ void Foam::fv::directionalPressureGradientExplicitSource::correct
}
reduce(totalphi, sumOp<scalar>());
if (phi.dimensions() == dimVelocity*dimArea)
if (phi.dimensions() == dimVolume/dimTime)
{
volFlowRate = mag(totalphi);
}

View File

@ -133,7 +133,7 @@ Foam::scalar Foam::PatchFlowRateInjection<CloudType>::flowRate() const
const scalarField& phip = phi.boundaryField()[patchId_];
scalar flowRateIn = 0.0;
if (phi.dimensions() == dimVelocity*dimArea)
if (phi.dimensions() == dimVolume/dimTime)
{
flowRateIn = max(0.0, -sum(phip));
}

View File

@ -176,9 +176,9 @@ void Foam::filmPyrolysisVelocityCoupledFvPatchVectorField::updateCoeffs()
const surfaceScalarField& phi =
db().lookupObject<surfaceScalarField>(phiName_);
if (phi.dimensions() == dimVelocity*dimArea)
if (phi.dimensions() == dimVolume/dimTime)
{}
else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
else if (phi.dimensions() == dimMass/dimTime)
{
const fvPatchField<scalar>& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);

View File

@ -160,7 +160,7 @@ void Foam::outletMachNumberPressureFvPatchScalarField::updateCoeffs()
patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
// Calculate the current mass flow rate
if (phi.internalField().dimensions() != dimDensity*dimVelocity*dimArea)
if (phi.internalField().dimensions() != dimMass/dimTime)
{
FatalErrorInFunction
<<"phi is not a mass flux." << exit(FatalError);