mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Adding lumpedMassWallTemperature BC and adding usage tutorial in buoyantPimpleFoam/hotRoom
This commit is contained in:
@ -12,6 +12,7 @@ $(BCs)/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchSca
|
||||
$(BCs)/wallHeatTransfer/wallHeatTransferFvPatchScalarField.C
|
||||
$(BCs)/convectiveHeatTransfer/convectiveHeatTransferFvPatchScalarField.C
|
||||
$(BCs)/fixedIncidentRadiation/fixedIncidentRadiationFvPatchScalarField.C
|
||||
$(BCs)/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C
|
||||
|
||||
turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C
|
||||
turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.C
|
||||
|
||||
@ -0,0 +1,210 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ 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 "lumpedMassWallTemperatureFvPatchScalarField.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "fvPatchFieldMapper.H"
|
||||
#include "volFields.H"
|
||||
#include "mappedPatchBase.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::lumpedMassWallTemperatureFvPatchScalarField::
|
||||
lumpedMassWallTemperatureFvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
mixedFvPatchScalarField(p, iF),
|
||||
temperatureCoupledBase(patch(), "undefined", "undefined", "undefined-K"),
|
||||
Cp_(0.0),
|
||||
mass_(0.0),
|
||||
curTimeIndex_(-1)
|
||||
{
|
||||
refValue() = 0.0;
|
||||
refGrad() = 0.0;
|
||||
valueFraction() = 1.0;
|
||||
}
|
||||
|
||||
|
||||
Foam::lumpedMassWallTemperatureFvPatchScalarField::
|
||||
lumpedMassWallTemperatureFvPatchScalarField
|
||||
(
|
||||
const lumpedMassWallTemperatureFvPatchScalarField& ptf,
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF,
|
||||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
mixedFvPatchScalarField(ptf, p, iF, mapper),
|
||||
temperatureCoupledBase(patch(), ptf),
|
||||
Cp_(ptf.Cp_),
|
||||
mass_(ptf.mass_),
|
||||
curTimeIndex_(-1)
|
||||
{}
|
||||
|
||||
|
||||
Foam::lumpedMassWallTemperatureFvPatchScalarField::
|
||||
lumpedMassWallTemperatureFvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
mixedFvPatchScalarField(p, iF),
|
||||
temperatureCoupledBase(patch(), dict),
|
||||
Cp_(readScalar(dict.lookup("Cp"))),
|
||||
mass_(readScalar(dict.lookup("mass"))),
|
||||
curTimeIndex_(-1)
|
||||
{
|
||||
refGrad() = 0.0;
|
||||
valueFraction() = 1.0;
|
||||
refValue() = scalarField("value", dict, p.size());
|
||||
|
||||
fvPatchScalarField::operator=(scalarField("value", dict, p.size()));
|
||||
}
|
||||
|
||||
|
||||
Foam::lumpedMassWallTemperatureFvPatchScalarField::
|
||||
lumpedMassWallTemperatureFvPatchScalarField
|
||||
(
|
||||
const lumpedMassWallTemperatureFvPatchScalarField& tppsf
|
||||
)
|
||||
:
|
||||
mixedFvPatchScalarField(tppsf),
|
||||
temperatureCoupledBase(tppsf),
|
||||
Cp_(tppsf.Cp_),
|
||||
mass_(tppsf.mass_),
|
||||
curTimeIndex_(-1)
|
||||
{}
|
||||
|
||||
|
||||
Foam::lumpedMassWallTemperatureFvPatchScalarField::
|
||||
lumpedMassWallTemperatureFvPatchScalarField
|
||||
(
|
||||
const lumpedMassWallTemperatureFvPatchScalarField& tppsf,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
mixedFvPatchScalarField(tppsf, iF),
|
||||
temperatureCoupledBase(patch(), tppsf),
|
||||
Cp_(tppsf.Cp_),
|
||||
mass_(tppsf.mass_),
|
||||
curTimeIndex_(-1)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::lumpedMassWallTemperatureFvPatchScalarField::updateCoeffs()
|
||||
{
|
||||
if (updated() || (curTimeIndex_ == this->db().time().timeIndex()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate heat flux in or out the wall
|
||||
scalarField& Tp(*this);
|
||||
const scalarField& magSf = patch().magSf();
|
||||
|
||||
const scalar deltaT(db().time().deltaTValue());
|
||||
|
||||
tmp<scalarField> tkappa(kappa(Tp));
|
||||
|
||||
const scalarField q(tkappa.ref()*snGrad());
|
||||
|
||||
// Total heat in or out of the wall
|
||||
const scalar Q = gSum(q*magSf);
|
||||
|
||||
Tp += -(Q/mass_/Cp_)*deltaT;
|
||||
|
||||
refGrad() = 0.0;
|
||||
refValue() = Tp;
|
||||
valueFraction() = 1.0;
|
||||
|
||||
mixedFvPatchScalarField::updateCoeffs();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
scalar qin(0);
|
||||
scalar qout(0);
|
||||
|
||||
forAll(q, facei)
|
||||
{
|
||||
if (q[facei] > 0.0) //out the wall
|
||||
{
|
||||
qout += q[facei]*magSf[facei];
|
||||
}
|
||||
else if (q[facei] < 0.0) //into the wall
|
||||
{
|
||||
qin += q[facei]*magSf[facei];
|
||||
}
|
||||
}
|
||||
|
||||
Info<< patch().boundaryMesh().mesh().name() << ':'
|
||||
<< patch().name() << ':'
|
||||
<< this->internalField().name() << " :"
|
||||
<< " heat transfer rate:" << Q
|
||||
<< " wall temperature "
|
||||
<< " min:" << gMin(*this)
|
||||
<< " max:" << gMax(*this)
|
||||
<< " avg:" << gAverage(*this)
|
||||
<< " Qin [W]:" << qin
|
||||
<< " Qout [W]:" << qout
|
||||
<< endl;
|
||||
}
|
||||
|
||||
curTimeIndex_ = this->db().time().timeIndex();
|
||||
}
|
||||
|
||||
|
||||
void Foam::lumpedMassWallTemperatureFvPatchScalarField::write
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
mixedFvPatchScalarField::write(os);
|
||||
temperatureCoupledBase::write(os);
|
||||
|
||||
os.writeKeyword("Cp")<< Cp_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("mass")<< mass_
|
||||
<< token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makePatchTypeField
|
||||
(
|
||||
fvPatchScalarField,
|
||||
lumpedMassWallTemperatureFvPatchScalarField
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,188 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ 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::lumpedMassWallTemperatureFvPatchScalarField
|
||||
|
||||
Group
|
||||
grpThermoBoundaryConditions grpWallBoundaryConditions
|
||||
|
||||
Description
|
||||
Employs a lumped mass model for temperature.
|
||||
|
||||
It considers a single temperature value for the whole patch and evaluates
|
||||
the temperature evolution using the net heat flux into the patch.
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
kappa | thermal conductivity option | yes |
|
||||
Cp | Heat capacity [J/Kg K]] | yes |
|
||||
mass | Total mass [Kg] | yes |
|
||||
\endtable
|
||||
|
||||
Example of the boundary condition specification:
|
||||
\verbatim
|
||||
myPatch
|
||||
{
|
||||
type lumpedMassWallTemperature;
|
||||
kappaMethod fluidThermo;
|
||||
kappaName none;
|
||||
mass 1000;
|
||||
Cp 4100;
|
||||
value uniform 300.0;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
lumpedMassWallTemperatureFvPatchScalarField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef lumpedMassWallTemperatureFvPatchScalarField_H
|
||||
#define lumpedMassWallTemperatureFvPatchScalarField_H
|
||||
|
||||
#include "mixedFvPatchFields.H"
|
||||
#include "temperatureCoupledBase.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class lumpedMassWallTemperatureFvPatchScalarField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class lumpedMassWallTemperatureFvPatchScalarField
|
||||
:
|
||||
public mixedFvPatchScalarField,
|
||||
public temperatureCoupledBase
|
||||
{
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Specifc heat capacity [J/kg/K]
|
||||
scalar Cp_;
|
||||
|
||||
//- Mass / [kg]
|
||||
scalar mass_;
|
||||
|
||||
//- Current time index (used for updating)
|
||||
label curTimeIndex_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("lumpedMassWallTemperature");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch and internal field
|
||||
lumpedMassWallTemperatureFvPatchScalarField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct from patch, internal field and dictionary
|
||||
lumpedMassWallTemperatureFvPatchScalarField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
//- Construct by mapping given
|
||||
// lumpedMassWallTemperatureFvPatchScalarField
|
||||
// onto a new patch
|
||||
lumpedMassWallTemperatureFvPatchScalarField
|
||||
(
|
||||
const lumpedMassWallTemperatureFvPatchScalarField&,
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
const fvPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Construct as copy
|
||||
lumpedMassWallTemperatureFvPatchScalarField
|
||||
(
|
||||
const lumpedMassWallTemperatureFvPatchScalarField&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<fvPatchScalarField> clone() const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
(
|
||||
new lumpedMassWallTemperatureFvPatchScalarField(*this)
|
||||
);
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
lumpedMassWallTemperatureFvPatchScalarField
|
||||
(
|
||||
const lumpedMassWallTemperatureFvPatchScalarField&,
|
||||
const DimensionedField<scalar, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone setting internal field reference
|
||||
virtual tmp<fvPatchScalarField> clone
|
||||
(
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
) const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
(
|
||||
new lumpedMassWallTemperatureFvPatchScalarField(*this, iF)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
// Evaluation functions
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
|
||||
|
||||
// I-O
|
||||
|
||||
//- Write
|
||||
void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -28,8 +28,12 @@ boundaryField
|
||||
|
||||
ceiling
|
||||
{
|
||||
type fixedValue;
|
||||
value uniform 300;
|
||||
type lumpedMassWallTemperature;
|
||||
kappaMethod fluidThermo;
|
||||
kappaName none;
|
||||
mass 1000;
|
||||
Cp 4100;
|
||||
value uniform 300.0;
|
||||
}
|
||||
|
||||
fixedWalls
|
||||
|
||||
@ -28,8 +28,12 @@ boundaryField
|
||||
|
||||
ceiling
|
||||
{
|
||||
type fixedValue;
|
||||
value uniform 300;
|
||||
type lumpedMassWallTemperature;
|
||||
kappaMethod fluidThermo;
|
||||
kappaName none;
|
||||
mass 1000;
|
||||
Cp 4100;
|
||||
value uniform 300.0;
|
||||
}
|
||||
|
||||
fixedWalls
|
||||
|
||||
Reference in New Issue
Block a user