mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
In most boundary conditions, fvOptions etc. required and optional fields
to be looked-up from the objectRegistry are selected by setting the
keyword corresponding to the standard field name in the BC etc. to the
appropriate name in the objectRegistry. Usually a default is provided
with sets the field name to the keyword name, e.g. in the
totalPressureFvPatchScalarField the velocity is selected by setting the
keyword 'U' to the appropriate name which defaults to 'U':
Property | Description | Required | Default value
U | velocity field name | no | U
phi | flux field name | no | phi
.
.
.
However, in some BCs and functionObjects and many fvOptions another
convention is used in which the field name keyword is appended by 'Name'
e.g.
Property | Description | Required | Default value
pName | pressure field name | no | p
UName | velocity field name | no | U
This difference in convention is unnecessary and confusing, hinders code
and dictionary reuse and complicates code maintenance. In this commit
the appended 'Name' is removed from the field selection keywords
standardizing OpenFOAM on the first convention above.
172 lines
4.4 KiB
C
172 lines
4.4 KiB
C
/*---------------------------------------------------------------------------*\
|
|
========= |
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
\\ / O peration |
|
|
\\ / A nd | Copyright (C) 2012-2016 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 "fixedTemperatureConstraint.H"
|
|
#include "fvMesh.H"
|
|
#include "fvMatrices.H"
|
|
#include "basicThermo.H"
|
|
#include "addToRunTimeSelectionTable.H"
|
|
|
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
|
|
|
namespace Foam
|
|
{
|
|
namespace fv
|
|
{
|
|
defineTypeNameAndDebug(fixedTemperatureConstraint, 0);
|
|
addToRunTimeSelectionTable
|
|
(
|
|
option,
|
|
fixedTemperatureConstraint,
|
|
dictionary
|
|
);
|
|
}
|
|
|
|
template<>
|
|
const char* NamedEnum<fv::fixedTemperatureConstraint::temperatureMode, 2>::
|
|
names[] =
|
|
{
|
|
"uniform",
|
|
"lookup"
|
|
};
|
|
}
|
|
|
|
const Foam::NamedEnum<Foam::fv::fixedTemperatureConstraint::temperatureMode, 2>
|
|
Foam::fv::fixedTemperatureConstraint::temperatureModeNames_;
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
|
|
Foam::fv::fixedTemperatureConstraint::fixedTemperatureConstraint
|
|
(
|
|
const word& name,
|
|
const word& modelType,
|
|
const dictionary& dict,
|
|
const fvMesh& mesh
|
|
)
|
|
:
|
|
cellSetOption(name, modelType, dict, mesh),
|
|
mode_(temperatureModeNames_.read(coeffs_.lookup("mode"))),
|
|
Tuniform_(NULL),
|
|
TName_("T")
|
|
{
|
|
switch (mode_)
|
|
{
|
|
case tmUniform:
|
|
{
|
|
Tuniform_.reset
|
|
(
|
|
Function1<scalar>::New("temperature", coeffs_).ptr()
|
|
);
|
|
break;
|
|
}
|
|
case tmLookup:
|
|
{
|
|
TName_ = coeffs_.lookupOrDefault<word>("T", "T");
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
// error handling done by NamedEnum
|
|
}
|
|
}
|
|
|
|
|
|
// Set the field name to that of the energy field from which the temperature
|
|
// is obtained
|
|
|
|
const basicThermo& thermo =
|
|
mesh_.lookupObject<basicThermo>(basicThermo::dictName);
|
|
|
|
fieldNames_.setSize(1, thermo.he().name());
|
|
|
|
applied_.setSize(1, false);
|
|
}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
|
|
void Foam::fv::fixedTemperatureConstraint::constrain
|
|
(
|
|
fvMatrix<scalar>& eqn,
|
|
const label
|
|
)
|
|
{
|
|
const basicThermo& thermo =
|
|
mesh_.lookupObject<basicThermo>(basicThermo::dictName);
|
|
|
|
switch (mode_)
|
|
{
|
|
case tmUniform:
|
|
{
|
|
const scalar t = mesh_.time().value();
|
|
scalarField Tuni(cells_.size(), Tuniform_->value(t));
|
|
eqn.setValues(cells_, thermo.he(thermo.p(), Tuni, cells_));
|
|
|
|
break;
|
|
}
|
|
case tmLookup:
|
|
{
|
|
const volScalarField& T =
|
|
mesh().lookupObject<volScalarField>(TName_);
|
|
|
|
scalarField Tlkp(T, cells_);
|
|
eqn.setValues(cells_, thermo.he(thermo.p(), Tlkp, cells_));
|
|
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
// error handling done by NamedEnum
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
bool Foam::fv::fixedTemperatureConstraint::read(const dictionary& dict)
|
|
{
|
|
if (cellSetOption::read(dict))
|
|
{
|
|
if (coeffs_.found(Tuniform_->name()))
|
|
{
|
|
Tuniform_.reset
|
|
(
|
|
Function1<scalar>::New(Tuniform_->name(), dict).ptr()
|
|
);
|
|
}
|
|
|
|
coeffs_.readIfPresent("T", TName_);
|
|
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
// ************************************************************************* //
|