From 268f1f612efcf1ddbcc9696c823b5da89f0a15ea Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Thu, 14 Jun 2018 10:49:15 +0100 Subject: [PATCH] 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 --- .../chtMultiRegionFoam/fluid/createFluidFields.H | 8 +------- src/finiteVolume/cfdTools/general/include/gh.H | 7 +------ .../derived/PrghPressure/PrghPressureFvPatchScalarField.C | 7 +------ .../uniformDensityHydrostaticPressureFvPatchScalarField.C | 7 +------ .../tabulatedAccelerationSourceTemplates.C | 7 +------ 5 files changed, 5 insertions(+), 31 deletions(-) diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H index c8484f8f7..a38cffc63 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H @@ -121,13 +121,7 @@ forAll(fluidRegions, i) ) ); - dimensionedScalar ghRef - ( - mag(gFluid[i].value()) > small - ? gFluid[i] - & (cmptMag(gFluid[i].value())/mag(gFluid[i].value()))*hRefFluid[i] - : dimensionedScalar("ghRef", gFluid[i].dimensions()*dimLength, 0) - ); + dimensionedScalar ghRef(- mag(gFluid[i])*hRefFluid[i]); Info<< " Adding to ghFluid\n" << endl; ghFluid.set diff --git a/src/finiteVolume/cfdTools/general/include/gh.H b/src/finiteVolume/cfdTools/general/include/gh.H index 24774c74e..12ca32f0c 100644 --- a/src/finiteVolume/cfdTools/general/include/gh.H +++ b/src/finiteVolume/cfdTools/general/include/gh.H @@ -1,9 +1,4 @@ Info<< "Calculating field g.h\n" << endl; - dimensionedScalar ghRef - ( - mag(g.value()) > small - ? g & (cmptMag(g.value())/mag(g.value()))*hRef - : dimensionedScalar("ghRef", g.dimensions()*dimLength, 0) - ); + dimensionedScalar ghRef(- mag(g)*hRef); volScalarField gh("gh", (g & mesh.C()) - ghRef); surfaceScalarField ghf("ghf", (g & mesh.Cf()) - ghRef); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/PrghPressure/PrghPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/PrghPressure/PrghPressureFvPatchScalarField.C index b17a8f973..3428350b3 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/PrghPressure/PrghPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/PrghPressure/PrghPressureFvPatchScalarField.C @@ -118,12 +118,7 @@ updateCoeffs() const uniformDimensionedScalarField& hRef = this->db().template lookupObject("hRef"); - dimensionedScalar ghRef - ( - mag(g.value()) > small - ? g & (cmptMag(g.value())/mag(g.value()))*hRef - : dimensionedScalar("ghRef", g.dimensions()*dimLength, 0) - ); + const dimensionedScalar ghRef(- mag(g)*hRef); this->operator== ( diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.C index 1760a340a..4449d1f65 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.C @@ -140,12 +140,7 @@ void Foam::uniformDensityHydrostaticPressureFvPatchScalarField::updateCoeffs() const uniformDimensionedScalarField& hRef = db().lookupObject("hRef"); - ghRef = - ( - mag(g.value()) > small - ? (g & (cmptMag(g.value())/mag(g.value()))*hRef).value() - : 0 - ); + ghRef = - mag(g.value())*hRef.value(); } operator== diff --git a/src/fvOptions/sources/derived/tabulatedAccelerationSource/tabulatedAccelerationSourceTemplates.C b/src/fvOptions/sources/derived/tabulatedAccelerationSource/tabulatedAccelerationSourceTemplates.C index df0cd5706..ce89e6161 100644 --- a/src/fvOptions/sources/derived/tabulatedAccelerationSource/tabulatedAccelerationSourceTemplates.C +++ b/src/fvOptions/sources/derived/tabulatedAccelerationSource/tabulatedAccelerationSourceTemplates.C @@ -51,12 +51,7 @@ void Foam::fv::tabulatedAccelerationSource::addSup g = g0_ - dimensionedVector("a", dimAcceleration, acceleration.x()); - dimensionedScalar ghRef - ( - mag(g.value()) > small - ? g & (cmptMag(g.value())/mag(g.value()))*hRef - : dimensionedScalar("ghRef", g.dimensions()*dimLength, 0) - ); + dimensionedScalar ghRef(- mag(g)*hRef); mesh_.lookupObjectRef("gh") = (g & mesh_.C()) - ghRef;