Newer
Older
Henry Weller
committed
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
-------------------------------------------------------------------------------
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 "temperatureCoupledBase.H"
#include "volFields.H"
andy
committed
#include "fluidThermo.H"
#include "solidThermo.H"
#include "turbulentFluidThermoModel.H"
// * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * //
const Foam::Enum
<
Foam::temperatureCoupledBase::KMethodType
>
Foam::temperatureCoupledBase::KMethodTypeNames_
{ KMethodType::mtFluidThermo, "fluidThermo" },
{ KMethodType::mtSolidThermo, "solidThermo" },
{ KMethodType::mtDirectionalSolidThermo, "directionalSolidThermo" },
{ KMethodType::mtLookup, "lookup" },
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::temperatureCoupledBase::temperatureCoupledBase
(
const fvPatch& patch,
const word& calculationType,
const word& kappaName,
const word& alphaAniName
)
:
patch_(patch),
method_(KMethodTypeNames_[calculationType]),
kappaName_(kappaName),
alphaAniName_(alphaAniName)
{}
Foam::temperatureCoupledBase::temperatureCoupledBase
(
const fvPatch& patch,
const dictionary& dict
)
:
patch_(patch),
method_(KMethodTypeNames_.get("kappaMethod", dict)),
Henry Weller
committed
kappaName_(dict.lookupOrDefault<word>("kappa", "none")),
alphaAniName_(dict.lookupOrDefault<word>("alphaAni","none"))
Henry Weller
committed
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
{
switch (method_)
{
case mtDirectionalSolidThermo:
{
if (!dict.found("alphaAni"))
{
FatalIOErrorInFunction(dict)
<< "Did not find entry 'alphaAni'"
" required for 'kappaMethod' "
<< KMethodTypeNames_[method_]
<< exit(FatalIOError);
}
break;
}
case mtLookup:
{
if (!dict.found("kappa"))
{
FatalIOErrorInFunction(dict)
<< "Did not find entry 'kappa'"
" required for 'kappaMethod' "
<< KMethodTypeNames_[method_] << nl
<< " Please set 'kappa' to the name of a volScalarField"
" or volSymmTensorField"
<< exit(FatalIOError);
}
break;
}
default:
{
break;
}
}
}
Foam::temperatureCoupledBase::temperatureCoupledBase
(
const fvPatch& patch,
const temperatureCoupledBase& base
)
:
patch_(patch),
method_(base.method_),
kappaName_(base.kappaName_),
alphaAniName_(base.alphaAniName_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::kappa
(
const scalarField& Tp
) const
{
const fvMesh& mesh = patch_.boundaryMesh().mesh();
const label patchi = patch_.index();
switch (method_)
{
andy
committed
case mtFluidThermo:
andy
committed
typedef compressible::turbulenceModel turbulenceModel;
const word turbName(turbulenceModel::propertiesName);
if
(
mesh.foundObject<turbulenceModel>(turbName)
)
andy
committed
{
const turbulenceModel& turbModel =
mesh.lookupObject<turbulenceModel>(turbName);
andy
committed
return turbModel.kappaEff(patchi);
andy
committed
}
else if (mesh.foundObject<fluidThermo>(basicThermo::dictName))
andy
committed
{
const fluidThermo& thermo =
mesh.lookupObject<fluidThermo>(basicThermo::dictName);
andy
committed
return thermo.kappa(patchi);
andy
committed
}
else if (mesh.foundObject<basicThermo>(basicThermo::dictName))
{
const basicThermo& thermo =
mesh.lookupObject<basicThermo>(basicThermo::dictName);
return thermo.kappa(patchi);
}
else if (mesh.foundObject<basicThermo>("phaseProperties"))
{
const basicThermo& thermo =
mesh.lookupObject<basicThermo>("phaseProperties");
return thermo.kappa(patchi);
andy
committed
else
{
Henry Weller
committed
<< "kappaMethod defined to employ "
<< KMethodTypeNames_[method_]
andy
committed
<< " method, but thermo package not available"
<< exit(FatalError);
}
andy
committed
break;
andy
committed
case mtSolidThermo:
const solidThermo& thermo =
mesh.lookupObject<solidThermo>(basicThermo::dictName);
andy
committed

Andrew Heather
committed
if (!thermo.isotropic())
{
word regionName = "";
if (mesh.name() != polyMesh::defaultRegion)
{
regionName = " for region " + mesh.name();
}
const word& patchName = mesh.boundaryMesh()[patchi].name();
WarningInFunction
<< "Applying isotropic thermal conductivity assumption to "
<< "anisotropic model" << regionName << " at patch "
<< patchName << nl
<< "Consider using an isotropic conductivity model or "
<< "set 'kappaMethod' to "
<< KMethodTypeNames_[mtDirectionalSolidThermo]
<< nl << endl;
}
return thermo.kappa(patchi);
andy
committed
break;
andy
committed
case mtDirectionalSolidThermo:
const solidThermo& thermo =
mesh.lookupObject<solidThermo>(basicThermo::dictName);
andy
committed
const symmTensorField& alphaAni =
patch_.lookupPatchField<volSymmTensorField, scalar>
(
alphaAniName_
);
const scalarField& pp = thermo.p().boundaryField()[patchi];
const symmTensorField kappa(alphaAni*thermo.Cp(pp, Tp, patchi));
const vectorField n(patch_.nf());
return n & kappa & n;
andy
committed
case mtLookup:
andy
committed
if (mesh.foundObject<volScalarField>(kappaName_))
andy
committed
return patch_.lookupPatchField<volScalarField, scalar>
(
kappaName_
);
andy
committed
else if (mesh.foundObject<volSymmTensorField>(kappaName_))
{
const symmTensorField& KWall =
andy
committed
patch_.lookupPatchField<volSymmTensorField, scalar>
(
kappaName_
);
const vectorField n(patch_.nf());
return n & KWall & n;
}
else
{
<< "Did not find field " << kappaName_
<< " on mesh " << mesh.name() << " patch " << patch_.name()
andy
committed
<< nl
Henry Weller
committed
<< " Please set 'kappa' to the name of a volScalarField"
<< " or volSymmTensorField."
<< exit(FatalError);
}
andy
committed
andy
committed
break;
}
default:
{
andy
committed
<< "Unimplemented method " << KMethodTypeNames_[method_] << nl
<< "Please set 'kappaMethod' to one of "
<< flatOutput(KMethodTypeNames_.sortedToc()) << nl
<< "and 'kappa' to the name of the volScalar"
<< " or volSymmTensor field (if kappaMethod=lookup)"
<< exit(FatalError);
andy
committed
return scalarField(0);
}
void Foam::temperatureCoupledBase::write(Ostream& os) const
{
os.writeEntry("kappaMethod", KMethodTypeNames_[method_]);
os.writeEntry("kappa", kappaName_);
os.writeEntry("alphaAni", alphaAniName_);