ENH: adding radiation to multi region solvers, radiotionCouple, etc

This commit is contained in:
sergio
2011-02-09 15:11:42 +00:00
parent a909be7d9b
commit a3c08b7c37
17 changed files with 1307 additions and 5 deletions

View File

@ -0,0 +1,227 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 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 "radiationCoupledBase.H"
#include "volFields.H"
#include "basicSolidThermo.H"
#include "directMappedPatchBase.H"
#include "fvPatchFieldMapper.H"
// * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * //
namespace Foam
{
template<>
const char* Foam::NamedEnum
<
Foam::radiationCoupledBase::emissivityMethodType,
2
>::names[] =
{
"solidThermo",
"lookup"
};
}
const Foam::NamedEnum<Foam::radiationCoupledBase::emissivityMethodType, 2>
Foam::radiationCoupledBase::emissivityMethodTypeNames_;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::radiationCoupledBase::radiationCoupledBase
(
const fvPatch& patch,
const word& calculationType
)
:
patch_(patch),
method_(emissivityMethodTypeNames_[calculationType]),
emissivity_(patch.size(), 0.0)
{}
Foam::radiationCoupledBase::radiationCoupledBase
(
const fvPatch& patch,
const dictionary& dict
)
:
patch_(patch),
method_(emissivityMethodTypeNames_.read(dict.lookup("emissivityMode")))
{
switch (method_)
{
case SOLIDTHERMO:
{
if (!isA<directMappedPatchBase>(patch_.patch()))
{
FatalErrorIn
(
"radiationCoupledBase::radiationCoupledBase\n"
"(\n"
" const fvPatch& p,\n"
" const dictionary& dict\n"
")\n"
) << "\n patch type '" << patch_.type()
<< "' not type '" << directMappedPatchBase::typeName << "'"
<< "\n for patch " << patch_.name()
<< exit(FatalError);
}
const directMappedPatchBase& mpp = refCast
<
const directMappedPatchBase
>
(
patch_.patch()
);
const polyMesh& nbrMesh = mpp.sampleMesh();
if
(
!nbrMesh.foundObject<basicSolidThermo>
(
"solidThermophysicalProperties"
)
)
{
FatalErrorIn
(
"radiationCoupledBase::radiationCoupledBase\n"
"(\n"
" const fvPatch& p,\n"
" const dictionary& dict\n"
")\n"
) << "\n solidThermophysicalProperties does not exist "
<< "\n in mesh ' " << nbrMesh.name() << "'"
<< exit(FatalError);
}
}
break;
case LOOKUP:
{
if(!dict.found("emissivity"))
{
FatalErrorIn
(
"radiationCoupledBase::radiationCoupledBase\n"
"(\n"
" const fvPatch& p,\n"
" const dictionary& dict\n"
")\n"
) << "\n emissivity key"
<< "\n does not exist "
<< "\n for patch " << patch_.name()
<< exit(FatalError);
}
else
{
emissivity_ = scalarField("emissivity", dict, patch_.size());
}
}
break;
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::scalarField> Foam::radiationCoupledBase::emissivity() const
{
switch (method_)
{
case SOLIDTHERMO:
{
// Get the coupling information from the directMappedPatchBase
const directMappedPatchBase& mpp =
refCast<const directMappedPatchBase>
(
patch_.patch()
);
const polyMesh& nbrMesh = mpp.sampleMesh();
const fvPatch& nbrPatch = refCast<const fvMesh>
(
nbrMesh
).boundary()[mpp.samplePolyPatch().index()];
scalarField emissivity
(
nbrPatch.lookupPatchField<volScalarField, scalar>("emissivity")
);
// Force recalculation of mapping and schedule
const mapDistribute& distMap = mpp.map();
distMap.distribute(emissivity);
return tmp<scalarField>
(
new scalarField(emissivity)
);
}
break;
case LOOKUP:
{
// return local value
return emissivity_;
}
default:
{
FatalErrorIn
(
"radiationCoupledBase::emissivity(const scalarField&)"
)
<< "Unimplemented method " << method_ << endl
<< "Please set 'emissivity' to one of "
<< emissivityMethodTypeNames_.toc()
<< " and 'emissivityName' to the name of the volScalar"
<< exit(FatalError);
}
break;
}
return scalarField(0);
}
void Foam::radiationCoupledBase::write(Ostream& os) const
{
os.writeKeyword("emissivityMode") << emissivityMethodTypeNames_[method_]
<< token::END_STATEMENT << nl;
os.writeKeyword("emissivity") << emissivity_
<< token::END_STATEMENT << nl;
}
// ************************************************************************* //

View File

@ -0,0 +1,134 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 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
radiationCoupledBase
Description
Common functions for use in temperature coupled boundaries when
radiation is used. For now only emissivity() : emissivity
gets supplied from lookup or calculate:
- 'lookup' : lookup volScalarField with name
- 'solidThermo' : use basicSolidThermo emissivity()
SourceFiles
radiationCoupledBase.C
\*---------------------------------------------------------------------------*/
#ifndef radiationCoupledBase_H
#define radiationCoupledBase_H
#include "scalarField.H"
#include "NamedEnum.H"
#include "fvPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class radiationCoupledBase Declaration
\*---------------------------------------------------------------------------*/
class radiationCoupledBase
{
public:
//- Type of supplied emissivity
enum emissivityMethodType
{
SOLIDTHERMO,
LOOKUP
};
private:
// Private data
static const NamedEnum<emissivityMethodType, 2>
emissivityMethodTypeNames_;
//- Underlying patch
const fvPatch& patch_;
//- How to get emissivity
const emissivityMethodType method_;
//- Emissivity
// Cached locally when is read from dictionary
scalarField emissivity_;
public:
// Constructors
//- Construct from patch and emissivity name
radiationCoupledBase
(
const fvPatch& patch,
const word& calculationMethod
);
//- Construct from patch and dictionary
radiationCoupledBase
(
const fvPatch& patch,
const dictionary& dict
);
// Member functions
//- Method to obtain emissivity
word emissivityMethod() const
{
return emissivityMethodTypeNames_[method_];
}
/*
//- Name of thermal conductivity field
const word& emissivityName() const
{
return emissivityName_;
}
*/
//- Calculate corresponding emissivity field
tmp<scalarField> emissivity() const;
//- Write
void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //