hRef: Define height in opposite direction to gravity

The reference height is now defined in the direction of -g, whether as
previously it was defined in the direction cmptMag(g). This change makes
the behaviour consistent when the case is transformed. For a "typical"
case with g along one of the negative axes, this should make no
difference. None of the tutorials are affected.

Resolves bug report https://bugs.openfoam.org/view.php?id=2980
This commit is contained in:
Will Bainbridge
2018-06-14 10:49:15 +01:00
parent ff2c53086c
commit 268f1f612e
5 changed files with 5 additions and 31 deletions

View File

@ -121,13 +121,7 @@ forAll(fluidRegions, i)
) )
); );
dimensionedScalar ghRef dimensionedScalar ghRef(- mag(gFluid[i])*hRefFluid[i]);
(
mag(gFluid[i].value()) > small
? gFluid[i]
& (cmptMag(gFluid[i].value())/mag(gFluid[i].value()))*hRefFluid[i]
: dimensionedScalar("ghRef", gFluid[i].dimensions()*dimLength, 0)
);
Info<< " Adding to ghFluid\n" << endl; Info<< " Adding to ghFluid\n" << endl;
ghFluid.set ghFluid.set

View File

@ -1,9 +1,4 @@
Info<< "Calculating field g.h\n" << endl; Info<< "Calculating field g.h\n" << endl;
dimensionedScalar ghRef dimensionedScalar ghRef(- mag(g)*hRef);
(
mag(g.value()) > small
? g & (cmptMag(g.value())/mag(g.value()))*hRef
: dimensionedScalar("ghRef", g.dimensions()*dimLength, 0)
);
volScalarField gh("gh", (g & mesh.C()) - ghRef); volScalarField gh("gh", (g & mesh.C()) - ghRef);
surfaceScalarField ghf("ghf", (g & mesh.Cf()) - ghRef); surfaceScalarField ghf("ghf", (g & mesh.Cf()) - ghRef);

View File

@ -118,12 +118,7 @@ updateCoeffs()
const uniformDimensionedScalarField& hRef = const uniformDimensionedScalarField& hRef =
this->db().template lookupObject<uniformDimensionedScalarField>("hRef"); this->db().template lookupObject<uniformDimensionedScalarField>("hRef");
dimensionedScalar ghRef const dimensionedScalar ghRef(- mag(g)*hRef);
(
mag(g.value()) > small
? g & (cmptMag(g.value())/mag(g.value()))*hRef
: dimensionedScalar("ghRef", g.dimensions()*dimLength, 0)
);
this->operator== this->operator==
( (

View File

@ -140,12 +140,7 @@ void Foam::uniformDensityHydrostaticPressureFvPatchScalarField::updateCoeffs()
const uniformDimensionedScalarField& hRef = const uniformDimensionedScalarField& hRef =
db().lookupObject<uniformDimensionedScalarField>("hRef"); db().lookupObject<uniformDimensionedScalarField>("hRef");
ghRef = ghRef = - mag(g.value())*hRef.value();
(
mag(g.value()) > small
? (g & (cmptMag(g.value())/mag(g.value()))*hRef).value()
: 0
);
} }
operator== operator==

View File

@ -51,12 +51,7 @@ void Foam::fv::tabulatedAccelerationSource::addSup
g = g0_ - dimensionedVector("a", dimAcceleration, acceleration.x()); g = g0_ - dimensionedVector("a", dimAcceleration, acceleration.x());
dimensionedScalar ghRef dimensionedScalar ghRef(- mag(g)*hRef);
(
mag(g.value()) > small
? g & (cmptMag(g.value())/mag(g.value()))*hRef
: dimensionedScalar("ghRef", g.dimensions()*dimLength, 0)
);
mesh_.lookupObjectRef<volScalarField>("gh") = (g & mesh_.C()) - ghRef; mesh_.lookupObjectRef<volScalarField>("gh") = (g & mesh_.C()) - ghRef;