fvModels: Added heatSource model
This model applies a heat source. It requires either the power, Q, or
the power per unit volume, q, to be specified.
Example usage:
heatSource
{
type heatSource;
selectionMode cellSet;
cellSet heater;
Q 1e6;
}
This commit is contained in:
@ -49,6 +49,32 @@ void Foam::Function1s::Scale<Type>::read(const dictionary& dict)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
Foam::Function1s::Scale<Type>::Scale
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Function1<scalar>& scale,
|
||||||
|
const Function1<scalar>& xScale,
|
||||||
|
const Function1<Type>& value
|
||||||
|
)
|
||||||
|
:
|
||||||
|
FieldFunction1<Type, Scale<Type>>(name),
|
||||||
|
scale_(scale.clone().ptr()),
|
||||||
|
xScale_(xScale.clone().ptr()),
|
||||||
|
value_(value.clone().ptr()),
|
||||||
|
integrableScale_
|
||||||
|
(
|
||||||
|
isA<Constant<scalar>>(xScale_())
|
||||||
|
&& isA<Constant<scalar>>(scale_())
|
||||||
|
),
|
||||||
|
integrableValue_
|
||||||
|
(
|
||||||
|
isA<Constant<scalar>>(xScale_())
|
||||||
|
&& isA<Constant<Type>>(value_())
|
||||||
|
)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::Function1s::Scale<Type>::Scale
|
Foam::Function1s::Scale<Type>::Scale
|
||||||
(
|
(
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2017-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2017-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -169,6 +169,15 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from name and functions
|
||||||
|
Scale
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Function1<scalar>& scale,
|
||||||
|
const Function1<scalar>& xScale,
|
||||||
|
const Function1<Type>& value
|
||||||
|
);
|
||||||
|
|
||||||
//- Construct from name and dictionary
|
//- Construct from name and dictionary
|
||||||
Scale
|
Scale
|
||||||
(
|
(
|
||||||
|
|||||||
@ -27,6 +27,7 @@ derived/accelerationSource/accelerationSource.C
|
|||||||
derived/volumeFractionSource/volumeFractionSource.C
|
derived/volumeFractionSource/volumeFractionSource.C
|
||||||
derived/solidEquilibriumEnergySource/solidEquilibriumEnergySource.C
|
derived/solidEquilibriumEnergySource/solidEquilibriumEnergySource.C
|
||||||
derived/massSource/massSource.C
|
derived/massSource/massSource.C
|
||||||
|
derived/heatSource/heatSource.C
|
||||||
derived/heatTransfer/heatTransfer.C
|
derived/heatTransfer/heatTransfer.C
|
||||||
|
|
||||||
interRegion/interRegionModel/interRegionModel.C
|
interRegion/interRegionModel/interRegionModel.C
|
||||||
|
|||||||
167
src/fvModels/derived/heatSource/heatSource.C
Normal file
167
src/fvModels/derived/heatSource/heatSource.C
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration | Website: https://openfoam.org
|
||||||
|
\\ / A nd | Copyright (C) 2021 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 "heatSource.H"
|
||||||
|
#include "basicThermo.H"
|
||||||
|
#include "fvModels.H"
|
||||||
|
#include "fvMatrix.H"
|
||||||
|
#include "Scale.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace fv
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(heatSource, 0);
|
||||||
|
addToRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
fvModel,
|
||||||
|
heatSource,
|
||||||
|
dictionary
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fv::heatSource::readCoeffs()
|
||||||
|
{
|
||||||
|
if (!coeffs().found("q") && !coeffs().found("Q"))
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(coeffs())
|
||||||
|
<< "Neither heat source per unit volume, q, or total heat source, "
|
||||||
|
<< "Q, has been specified. One is required." << exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (coeffs().found("q") && coeffs().found("Q"))
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(coeffs())
|
||||||
|
<< "Both heat source per unit volume, q, and total heat source, "
|
||||||
|
<< "Q, have been specified. One is required."
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (coeffs().found("q"))
|
||||||
|
{
|
||||||
|
q_.reset(Function1<scalar>::New("q", coeffs()).ptr());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
q_.reset
|
||||||
|
(
|
||||||
|
new Function1s::Scale<scalar>
|
||||||
|
(
|
||||||
|
"q",
|
||||||
|
Function1s::Constant<scalar>("1/V", 1/set_.V()),
|
||||||
|
Function1s::Constant<scalar>("1", 1),
|
||||||
|
Function1<scalar>::New("Q", coeffs())()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::fv::heatSource::heatSource
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const word& modelType,
|
||||||
|
const dictionary& dict,
|
||||||
|
const fvMesh& mesh
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fvModel(name, modelType, dict, mesh),
|
||||||
|
set_(coeffs(), mesh),
|
||||||
|
q_(nullptr)
|
||||||
|
{
|
||||||
|
readCoeffs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::fv::heatSource::~heatSource()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::wordList Foam::fv::heatSource::addSupFields() const
|
||||||
|
{
|
||||||
|
const basicThermo& thermo =
|
||||||
|
mesh().lookupObject<basicThermo>(basicThermo::dictName);
|
||||||
|
|
||||||
|
return wordList(1, thermo.he().name());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fv::heatSource::addSup
|
||||||
|
(
|
||||||
|
fvMatrix<scalar>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const labelList& cells = set_.cells();
|
||||||
|
|
||||||
|
const scalar t = mesh().time().value();
|
||||||
|
const scalar q = q_->value(t);
|
||||||
|
|
||||||
|
forAll(cells, i)
|
||||||
|
{
|
||||||
|
eqn.source()[cells[i]] -= mesh().V()[cells[i]]*q;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fv::heatSource::addSup
|
||||||
|
(
|
||||||
|
const volScalarField& rho,
|
||||||
|
fvMatrix<scalar>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
addSup(eqn, fieldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::fv::heatSource::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
if (fvModel::read(dict))
|
||||||
|
{
|
||||||
|
readCoeffs();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
149
src/fvModels/derived/heatSource/heatSource.H
Normal file
149
src/fvModels/derived/heatSource/heatSource.H
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration | Website: https://openfoam.org
|
||||||
|
\\ / A nd | Copyright (C) 2021 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::fv::heatSource
|
||||||
|
|
||||||
|
Description
|
||||||
|
Model for applying a heat source. Requires either the power, Q, or the
|
||||||
|
power per unit volume, q, to be specified.
|
||||||
|
|
||||||
|
Usage
|
||||||
|
Example usage:
|
||||||
|
\verbatim
|
||||||
|
heatSource
|
||||||
|
{
|
||||||
|
type heatSource;
|
||||||
|
|
||||||
|
selectionMode cellSet;
|
||||||
|
cellSet heater;
|
||||||
|
|
||||||
|
Q 1e6;
|
||||||
|
}
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef heatSource_H
|
||||||
|
#define heatSource_H
|
||||||
|
|
||||||
|
#include "fvModel.H"
|
||||||
|
#include "fvCellSet.H"
|
||||||
|
#include "Function1.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace fv
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class heatSource Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class heatSource
|
||||||
|
:
|
||||||
|
public fvModel
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- The set of cells the model applies to
|
||||||
|
fvCellSet set_;
|
||||||
|
|
||||||
|
//- The heat source
|
||||||
|
autoPtr<Function1<scalar>> q_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private member functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("heatSource");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
heatSource
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const word& modelType,
|
||||||
|
const dictionary& dict,
|
||||||
|
const fvMesh& mesh
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~heatSource();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Checks
|
||||||
|
|
||||||
|
//- Return the list of fields for which the fvModel adds source term
|
||||||
|
// to the transport equation
|
||||||
|
virtual wordList addSupFields() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Sources
|
||||||
|
|
||||||
|
//- Source term to energy equation
|
||||||
|
virtual void addSup
|
||||||
|
(
|
||||||
|
fvMatrix<scalar>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Source term to compressible energy equation
|
||||||
|
virtual void addSup
|
||||||
|
(
|
||||||
|
const volScalarField& rho,
|
||||||
|
fvMatrix<scalar>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
// IO
|
||||||
|
|
||||||
|
//- Read dictionary
|
||||||
|
virtual bool read(const dictionary& dict);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace fv
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -17,20 +17,11 @@ FoamFile
|
|||||||
|
|
||||||
energySource
|
energySource
|
||||||
{
|
{
|
||||||
type semiImplicitSource;
|
type heatSource;
|
||||||
|
|
||||||
selectionMode all;
|
selectionMode all;
|
||||||
|
|
||||||
volumeMode specific;
|
q 1e7;
|
||||||
|
|
||||||
sources
|
|
||||||
{
|
|
||||||
e
|
|
||||||
{
|
|
||||||
explicit 1e7; // W/m^3 == kg/m/s^3
|
|
||||||
implicit 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
Reference in New Issue
Block a user