From 64690f39cc2edc61830dd724d9a7d78c9e40dff9 Mon Sep 17 00:00:00 2001 From: Henry Weller <http://cfd.direct> Date: Mon, 23 Nov 2015 14:50:05 +0000 Subject: [PATCH] fixedMultiPhaseHeatFlux: Calculates a wall temperature that produces the specified overall wall heat flux across all the phases in an Eulerian multi-phase simulation. Intended to be used with copiedFixedValue to ensure that phase wall temperature are consistent: - Set 'fixedMultiPhaseHeatFlux' boundary for one of the phases - Use 'copiedFixedValue' for all the other phases. Based on code provided by Juho Peltola --- .../Make/files | 2 + .../copiedFixedValueFvPatchScalarField.C | 130 ++++++++++++ .../copiedFixedValueFvPatchScalarField.H | 136 ++++++++++++ ...ixedMultiPhaseHeatFluxFvPatchScalarField.C | 195 ++++++++++++++++++ ...ixedMultiPhaseHeatFluxFvPatchScalarField.H | 142 +++++++++++++ 5 files changed, 605 insertions(+) create mode 100644 applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/copiedFixedValue/copiedFixedValueFvPatchScalarField.C create mode 100644 applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/copiedFixedValue/copiedFixedValueFvPatchScalarField.H create mode 100644 applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.C create mode 100644 applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.H diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/Make/files b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/Make/files index 10a0e8679ad..facf0f0f05c 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/Make/files +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/Make/files @@ -36,5 +36,7 @@ kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJack kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.C derivedFvPatchFields/alphatFixedDmdtWallBoilingWallFunction/alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField.C +derivedFvPatchFields/copiedFixedValue/copiedFixedValueFvPatchScalarField.C +derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.C LIB = $(FOAM_LIBBIN)/libtwoPhaseReactingTurbulenceModels diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/copiedFixedValue/copiedFixedValueFvPatchScalarField.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/copiedFixedValue/copiedFixedValueFvPatchScalarField.C new file mode 100644 index 00000000000..2f7abc70151 --- /dev/null +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/copiedFixedValue/copiedFixedValueFvPatchScalarField.C @@ -0,0 +1,130 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "copiedFixedValueFvPatchScalarField.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::copiedFixedValueFvPatchScalarField::copiedFixedValueFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF +) +: + fixedValueFvPatchScalarField(p, iF), + sourceFieldName_("default") +{} + + +Foam::copiedFixedValueFvPatchScalarField::copiedFixedValueFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict), + sourceFieldName_(dict.lookup("sourceFieldName")) +{} + + +Foam::copiedFixedValueFvPatchScalarField::copiedFixedValueFvPatchScalarField +( + const copiedFixedValueFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper), + sourceFieldName_(ptf.sourceFieldName_) +{} + + +Foam::copiedFixedValueFvPatchScalarField::copiedFixedValueFvPatchScalarField +( + const copiedFixedValueFvPatchScalarField& awfpsf +) +: + fixedValueFvPatchScalarField(awfpsf), + sourceFieldName_(awfpsf.sourceFieldName_) +{} + + +Foam::copiedFixedValueFvPatchScalarField::copiedFixedValueFvPatchScalarField +( + const copiedFixedValueFvPatchScalarField& awfpsf, + const DimensionedField<scalar, volMesh>& iF +) +: + fixedValueFvPatchScalarField(awfpsf, iF), + sourceFieldName_(awfpsf.sourceFieldName_) +{} + + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::copiedFixedValueFvPatchScalarField::updateCoeffs() +{ + if (this->updated()) + { + return; + } + + operator== + ( + patch().lookupPatchField<volScalarField, scalar>(sourceFieldName_) + ); + + fixedValueFvPatchScalarField::updateCoeffs(); +} + + +void Foam::copiedFixedValueFvPatchScalarField::write(Ostream& os) const +{ + fvPatchField<scalar>::write(os); + os.writeKeyword("sourceFieldName") + << sourceFieldName_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + copiedFixedValueFvPatchScalarField + ); +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/copiedFixedValue/copiedFixedValueFvPatchScalarField.H b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/copiedFixedValue/copiedFixedValueFvPatchScalarField.H new file mode 100644 index 00000000000..2db6a151ce9 --- /dev/null +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/copiedFixedValue/copiedFixedValueFvPatchScalarField.H @@ -0,0 +1,136 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::copiedFixedValueFvPatchScalarField + +Group + grpCmpWallFunctions + +Description + Copies the boundary values from a user specified field. + +SeeAlso + Foam::fixedValueFvPatchField + +SourceFiles + copiedFixedValueFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef copiedFixedValueFvPatchScalarField_H +#define copiedFixedValueFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class copiedFixedValueFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class copiedFixedValueFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ +protected: + + // Protected data + + word sourceFieldName_; + +public: + + //- Runtime type information + TypeName("copiedFixedValue"); + + + // Constructors + + //- Construct from patch and internal field + copiedFixedValueFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + copiedFixedValueFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given + // copiedFixedValueFvPatchScalarField + // onto a new patch + copiedFixedValueFvPatchScalarField + ( + const copiedFixedValueFvPatchScalarField&, + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + copiedFixedValueFvPatchScalarField + ( + const copiedFixedValueFvPatchScalarField& + ); + + //- Construct as copy setting internal field reference + copiedFixedValueFvPatchScalarField + ( + const copiedFixedValueFvPatchScalarField&, + const DimensionedField<scalar, volMesh>& + ); + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // I-O + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.C new file mode 100644 index 00000000000..ec4e1a24847 --- /dev/null +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.C @@ -0,0 +1,195 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "fixedMultiPhaseHeatFluxFvPatchScalarField.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "twoPhaseSystem.H" +#include "ThermalPhaseChangePhaseSystem.H" +#include "MomentumTransferPhaseSystem.H" +#include "compressibleTurbulenceModel.H" +#include "ThermalDiffusivity.H" +#include "PhaseCompressibleTurbulenceModel.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fixedMultiPhaseHeatFluxFvPatchScalarField:: +fixedMultiPhaseHeatFluxFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF +) +: + fixedValueFvPatchScalarField(p, iF), + q_(p.size(), 0.0) +{} + + +Foam::fixedMultiPhaseHeatFluxFvPatchScalarField:: +fixedMultiPhaseHeatFluxFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict), + q_("q", dict, p.size()) +{} + + +Foam::fixedMultiPhaseHeatFluxFvPatchScalarField:: +fixedMultiPhaseHeatFluxFvPatchScalarField +( + const fixedMultiPhaseHeatFluxFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper), + q_(ptf.q_, mapper) +{} + + +Foam::fixedMultiPhaseHeatFluxFvPatchScalarField:: +fixedMultiPhaseHeatFluxFvPatchScalarField +( + const fixedMultiPhaseHeatFluxFvPatchScalarField& awfpsf +) +: + fixedValueFvPatchScalarField(awfpsf), + q_(awfpsf.q_) +{} + + +Foam::fixedMultiPhaseHeatFluxFvPatchScalarField:: +fixedMultiPhaseHeatFluxFvPatchScalarField +( + const fixedMultiPhaseHeatFluxFvPatchScalarField& awfpsf, + const DimensionedField<scalar, volMesh>& iF +) +: + fixedValueFvPatchScalarField(awfpsf, iF), + q_(awfpsf.q_) +{} + + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::fixedMultiPhaseHeatFluxFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + // Lookup the fluid model + const ThermalPhaseChangePhaseSystem + < + MomentumTransferPhaseSystem<twoPhaseSystem> + >& fluid = + refCast + < + const ThermalPhaseChangePhaseSystem + < + MomentumTransferPhaseSystem<twoPhaseSystem> + > + > + ( + db().lookupObject<phaseSystem>("phaseProperties") + ); + + const scalarField& Tp = *this; + + scalarField A(Tp.size(), scalar(0)); + scalarField B(Tp.size(), scalar(0)); + scalarField Q(Tp.size(), scalar(0)); + + forAll(fluid.phases(), phasei) + { + const phaseModel& phase = fluid.phases()[phasei]; + const fluidThermo& thermo = phase.thermo(); + + const fvPatchScalarField& alpha = + phase.boundaryField()[patch().index()]; + + const fvPatchScalarField& T = + thermo.T().boundaryField()[patch().index()]; + + const scalarField kappaEff + ( + thermo.kappaEff(phase.turbulence().alphat(), patch().index()) + ); + + if (debug) + { + scalarField q0(T.snGrad()*alpha*kappaEff); + Q += q0; + + Info<< patch().name() << " " << phase.name() + << ": Heat flux " << gMin(q0) << " - " << gMax(q0) << endl; + } + + A += T.patchInternalField()*alpha*kappaEff*patch().deltaCoeffs(); + B += alpha*kappaEff*patch().deltaCoeffs(); + } + + if (debug) + { + Info<< patch().name() << " " << ": overall heat flux " + << gMin(Q) << " - " << gMax(Q) << endl; + } + + scalar relax(1); + operator==((1 - relax)*Tp + relax*(q_ + A)/(B)); + + fixedValueFvPatchScalarField::updateCoeffs(); +} + + +void Foam::fixedMultiPhaseHeatFluxFvPatchScalarField::write(Ostream& os) const +{ + fvPatchField<scalar>::write(os); + q_.writeEntry("q", os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + fixedMultiPhaseHeatFluxFvPatchScalarField + ); +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.H b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.H new file mode 100644 index 00000000000..0024fd08e79 --- /dev/null +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.H @@ -0,0 +1,142 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::fixedMultiPhaseHeatFluxFvPatchScalarField + +Group + grpCmpWallFunctions + +Description + Calculates a wall temperature that produces the specified overall wall heat + flux across all the phases in an Eulerian multi-phase simulation. + + Intended to be used with copiedFixedValue to ensure that phase wall + temperature are consistent: + - Set 'fixedMultiPhaseHeatFlux' boundary for one of the phases + - Use 'copiedFixedValue' for all the other phases. + +SeeAlso + Foam::fixedValueFvPatchField + +SourceFiles + fixedMultiPhaseHeatFluxFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef fixedMultiPhaseHeatFluxFvPatchScalarField_H +#define fixedMultiPhaseHeatFluxFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class fixedMultiPhaseHeatFluxFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class fixedMultiPhaseHeatFluxFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + // Private data + + //- Heat power [W] or flux [W/m2] + scalarField q_; + + +public: + + //- Runtime type information + TypeName("fixedMultiPhaseHeatFlux"); + + + // Constructors + + //- Construct from patch and internal field + fixedMultiPhaseHeatFluxFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + fixedMultiPhaseHeatFluxFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given + // fixedMultiPhaseHeatFluxFvPatchScalarField + // onto a new patch + fixedMultiPhaseHeatFluxFvPatchScalarField + ( + const fixedMultiPhaseHeatFluxFvPatchScalarField&, + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + fixedMultiPhaseHeatFluxFvPatchScalarField + ( + const fixedMultiPhaseHeatFluxFvPatchScalarField& + ); + + //- Construct as copy setting internal field reference + fixedMultiPhaseHeatFluxFvPatchScalarField + ( + const fixedMultiPhaseHeatFluxFvPatchScalarField&, + const DimensionedField<scalar, volMesh>& + ); + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // I-O + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // -- GitLab