From 451aa81a39bb3aceb6bbeb8b3fc22dc42fd43c89 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Tue, 8 Mar 2016 12:03:39 +0000 Subject: [PATCH] Bugfix: rothalpy boundary condition handling. Ilaria De Dominicis --- .../fixedEnthalpyFvPatchScalarField.C | 38 +++++++++++++ .../gradientEnthalpyFvPatchScalarField.C | 56 +++++++++++++++++-- .../mixedEnthalpyFvPatchScalarField.C | 50 +++++++++++++++++ 3 files changed, 139 insertions(+), 5 deletions(-) diff --git a/src/thermophysicalModels/basic/derivedFvPatchFields/fixedEnthalpy/fixedEnthalpyFvPatchScalarField.C b/src/thermophysicalModels/basic/derivedFvPatchFields/fixedEnthalpy/fixedEnthalpyFvPatchScalarField.C index 603b94265..7d17ef4d9 100644 --- a/src/thermophysicalModels/basic/derivedFvPatchFields/fixedEnthalpy/fixedEnthalpyFvPatchScalarField.C +++ b/src/thermophysicalModels/basic/derivedFvPatchFields/fixedEnthalpy/fixedEnthalpyFvPatchScalarField.C @@ -115,6 +115,44 @@ void Foam::fixedEnthalpyFvPatchScalarField::updateCoeffs() dimensionedInternalField().name() == db().mangleFileName("i") ) { + // Get access to relative and rotational velocity + const word UrelName("Urel"); + const word UrotName("Urot"); + + if + ( + !this->db().objectRegistry::found(UrelName) + || !this->db().objectRegistry::found(UrotName) + ) + { + // Velocities not available, do not update + InfoIn + ( + "void gradientEnthalpyFvPatchScalarField::" + "updateCoeffs(const vectorField& Up)" + ) << "Velocity fields " << UrelName << " or " + << UrotName << " not found. " + << "Performing enthalpy value update for field " + << this->dimensionedInternalField().name() + << " and patch " << patchi + << endl; + + operator==(thermo.h(Tw, patchi)); + } + else + { + const fvPatchVectorField& Urelp = + lookupPatchField(UrelName); + + const fvPatchVectorField& Urotp = + lookupPatchField(UrotName); + + operator== + ( + thermo.h(Tw, patchi) + - 0.5*(magSqr(Urotp) - magSqr(Urelp)) + ); + } } else { diff --git a/src/thermophysicalModels/basic/derivedFvPatchFields/gradientEnthalpy/gradientEnthalpyFvPatchScalarField.C b/src/thermophysicalModels/basic/derivedFvPatchFields/gradientEnthalpy/gradientEnthalpyFvPatchScalarField.C index 2639a4fc6..42eb6be44 100644 --- a/src/thermophysicalModels/basic/derivedFvPatchFields/gradientEnthalpy/gradientEnthalpyFvPatchScalarField.C +++ b/src/thermophysicalModels/basic/derivedFvPatchFields/gradientEnthalpy/gradientEnthalpyFvPatchScalarField.C @@ -121,15 +121,61 @@ void Foam::gradientEnthalpyFvPatchScalarField::updateCoeffs() dimensionedInternalField().name() == db().mangleFileName("i") ) { + // Get access to relative and rotational velocity + const word UrelName("Urel"); + const word UrotName("Urot"); + + if + ( + !this->db().objectRegistry::found(UrelName) + || !this->db().objectRegistry::found(UrotName) + ) + { + // Velocities not available, do not update + InfoIn + ( + "void gradientEnthalpyFvPatchScalarField::" + "updateCoeffs(const vectorField& Up)" + ) << "Velocity fields " << UrelName << " or " + << UrotName << " not found. " + << "Performing enthalpy value update for field " + << this->dimensionedInternalField().name() + << " and patch " << patchi + << endl; + + gradient() = thermo.Cp(Tw, patchi)*Tw.snGrad() + + patch().deltaCoeffs()* + ( + thermo.h(Tw, patchi) + - thermo.h(Tw, patch().faceCells()) + ); + } + else + { + const fvPatchVectorField& Urelp = + lookupPatchField(UrelName); + + const fvPatchVectorField& Urotp = + lookupPatchField(UrotName); + + gradient() = thermo.Cp(Tw, patchi)*Tw.snGrad() + + patch().deltaCoeffs()* + ( + thermo.h(Tw, patchi) + - thermo.h(Tw, patch().faceCells()) + ) + - mag(Urotp)*mag(Urotp.snGrad()) + + mag(Urelp)*mag(Urelp.snGrad()); + } } else { gradient() = thermo.Cp(Tw, patchi)*Tw.snGrad() - + patch().deltaCoeffs()* - ( - thermo.hs(Tw, patchi) - - thermo.hs(Tw, patch().faceCells()) - ); + + patch().deltaCoeffs()* + ( + thermo.hs(Tw, patchi) + - thermo.hs(Tw, patch().faceCells()) + ); } fixedGradientFvPatchScalarField::updateCoeffs(); diff --git a/src/thermophysicalModels/basic/derivedFvPatchFields/mixedEnthalpy/mixedEnthalpyFvPatchScalarField.C b/src/thermophysicalModels/basic/derivedFvPatchFields/mixedEnthalpy/mixedEnthalpyFvPatchScalarField.C index 6670b3d1d..553f7d1bf 100644 --- a/src/thermophysicalModels/basic/derivedFvPatchFields/mixedEnthalpy/mixedEnthalpyFvPatchScalarField.C +++ b/src/thermophysicalModels/basic/derivedFvPatchFields/mixedEnthalpy/mixedEnthalpyFvPatchScalarField.C @@ -130,6 +130,56 @@ void Foam::mixedEnthalpyFvPatchScalarField::updateCoeffs() dimensionedInternalField().name() == db().mangleFileName("i") ) { + // Get access to relative and rotational velocity + const word UrelName("Urel"); + const word UrotName("Urot"); + + if + ( + !this->db().objectRegistry::found(UrelName) + || !this->db().objectRegistry::found(UrotName) + ) + { + // Velocities not available, do not update + InfoIn + ( + "void gradientEnthalpyFvPatchScalarField::" + "updateCoeffs(const vectorField& Up)" + ) << "Velocity fields " << UrelName << " or " + << UrotName << " not found. " + << "Performing enthalpy value update for field " + << this->dimensionedInternalField().name() + << " and patch " << patchi + << endl; + + refValue() = thermo.h(Tw.refValue(), patchi); + refGrad() = thermo.Cp(Tw, patchi)*Tw.refGrad() + + patch().deltaCoeffs()* + ( + thermo.h(Tw, patchi) + - thermo.h(Tw, patch().faceCells()) + ); + } + else + { + const fvPatchVectorField& Urelp = + lookupPatchField(UrelName); + + const fvPatchVectorField& Urotp = + lookupPatchField(UrotName); + + refValue() = thermo.h(Tw.refValue(), patchi) + - 0.5*(magSqr(Urotp) - magSqr(Urelp)); + + refGrad() = thermo.Cp(Tw, patchi)*Tw.refGrad() + + patch().deltaCoeffs()* + ( + thermo.h(Tw, patchi) + - thermo.h(Tw, patch().faceCells()) + ) + - mag(Urotp)*mag(Urotp.snGrad()) + + mag(Urelp)*mag(Urelp.snGrad()); + } } else {