Commit 48597d98 authored by sergio's avatar sergio
Browse files

ENH: thermal baffles models

parent de3458b7
......@@ -6,6 +6,7 @@ set -x
wmake $makeType regionModel
#wmake $makeType pyrolysisModels
wmake $makeType surfaceFilmModels
wmake $makeType thermoBaffleModels
#wmake $makeType regionCoupling
......
thermoBaffleModel/thermoBaffleModel.C
thermoBaffleModel/thermoBaffleModelNew.C
thermoBaffle2D/thermoBaffle2D.C
noThermo/noThermo.C
LIB = $(FOAM_LIBBIN)/libthermoBaffleModels
EXE_INC = \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basicSolidThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/solid/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel/lnInclude
EXE_LIBS = \
-lregionModels \
-lbasicSolidThermo \
-lfiniteVolume \
-lmeshTools \
-lOpenFOAM \
-lsolid
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "noThermo.H"
#include "addToRunTimeSelectionTable.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace regionModels
{
namespace thermoBaffleModels
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(noThermo, 0);
addToRunTimeSelectionTable(thermoBaffleModel, noThermo, mesh);
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
bool noThermo::read()
{
return regionModel1D::read();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
noThermo::noThermo(const word& modelType, const fvMesh& mesh)
:
thermoBaffleModel(mesh)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
noThermo::~noThermo()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void noThermo::preEvolveRegion()
{
}
void noThermo::evolveRegion()
{
}
const tmp<volScalarField> noThermo::Cp() const
{
FatalErrorIn("const tmp<volScalarField>& noThermo::Cp() const")
<< "Cp field not available for " << type() << abort(FatalError);
return tmp<volScalarField>
(
new volScalarField
(
IOobject
(
"noThermo::Cp",
time().timeName(),
primaryMesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
primaryMesh(),
dimensionedScalar("zero", dimEnergy/dimVolume/dimTime, 0.0)
)
);
}
const volScalarField& noThermo::kappa() const
{
FatalErrorIn("const volScalarField& noThermo::kappa() const")
<< "kappa field not available for " << type() << abort(FatalError);
return volScalarField::null();
}
const volScalarField& noThermo::rho() const
{
FatalErrorIn("const volScalarField& noThermo::rho() const")
<< "rho field not available for " << type() << abort(FatalError);
return volScalarField::null();
}
const volScalarField& noThermo::K() const
{
FatalErrorIn("const volScalarField& noThermo::K() const")
<< "K field not available for " << type() << abort(FatalError);
return volScalarField::null();
}
const volScalarField& noThermo::T() const
{
FatalErrorIn("const volScalarField& noThermo::T() const")
<< "T field not available for " << type() << abort(FatalError);
return volScalarField::null();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace thermoBaffleModels
} // End namespace regionModels
} // End namespace Foam
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Foam::noThermo
Description
Dummy surface pyrolysis model for 'none'
SourceFiles
noThermo.C
\*---------------------------------------------------------------------------*/
#ifndef noThermo_H
#define noThermo_H
#include "thermoBaffleModel.H"
#include "volFieldsFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace regionModels
{
namespace thermoBaffleModels
{
/*---------------------------------------------------------------------------*\
Class noThermo Declaration
\*---------------------------------------------------------------------------*/
class noThermo
:
public thermoBaffleModel
{
private:
// Private member functions
//- Disallow default bitwise copy construct
noThermo(const noThermo&);
//- Disallow default bitwise assignment
void operator=(const noThermo&);
protected:
// Protected member functions
//- Read control parameters from dictionary
virtual bool read();
public:
//- Runtime type information
TypeName("none");
// Constructors
//- Construct from type name and mesh
noThermo(const word& modelType, const fvMesh& mesh);
//- Destructor
virtual ~noThermo();
// Member Functions
// Fields
//- Return the film specific heat capacity [J/kg/K]
virtual const tmp<volScalarField> Cp() const;
//- Return solid absortivity [1/m]
virtual const volScalarField& kappa() const;
//- Return the film mean temperature [K]
virtual const volScalarField& T() const;
//- Return density [Kg/m3]
virtual const volScalarField& rho() const;
//- Return thermal conductivity [W/m/K]
virtual const volScalarField& K() const;
// Evolution
//- Pre-evolve film
virtual void preEvolveRegion();
//- Evolve the film equations
virtual void evolveRegion();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace thermoBaffleModels
} // End namespace regionModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "thermoBaffle2D.H"
#include "fvm.H"
#include "addToRunTimeSelectionTable.H"
#include "zeroGradientFvPatchFields.H"
#include "fvMatrices.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace regionModels
{
namespace thermoBaffleModels
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(thermoBaffle2D, 0);
addToRunTimeSelectionTable(thermoBaffleModel, thermoBaffle2D, mesh);
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
bool thermoBaffle2D::read()
{
this->solution().lookup("nNonOrthCorr") >> nNonOrthCorr_;
return regionModel1D::read();
}
void thermoBaffle2D::solveEnergy()
{
if (debug)
{
Info<< "thermoBaffle2D::solveEnergy()" << endl;
}
const polyBoundaryMesh& rbm = regionMesh().boundaryMesh();
tmp<volScalarField> tQ
(
new volScalarField
(
IOobject
(
"tQ",
regionMesh().time().timeName(),
regionMesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
regionMesh(),
dimensionedScalar("zero", dimEnergy/dimVolume/dimTime, 0.0)
)
);
volScalarField& Q = tQ();
volScalarField rhoCp("rhoCp", thermo_->rho()*thermo_->Cp()());
volScalarField K("K", thermo_->K());
//If region is one-dimension variable thickness can be used.
if (oneD_)
{
// Scale K and rhoCp and fill Q in the internal baffle region.
const label patchI = intCoupledPatchIDs_[0];
const polyPatch& ppCoupled = rbm[patchI];
forAll(ppCoupled, localFaceI)
{
const labelList& cells = boundaryFaceCells_[localFaceI];
forAll (cells, i)
{
const label cellId = cells[i];
Q[cellId] =
Qs_.boundaryField()[patchI][localFaceI]
/thickness_[localFaceI];
rhoCp[cellId] *= delta_.value()/thickness_[localFaceI];
K[cellId] *= delta_.value()/thickness_[localFaceI];
}
}
}
else
{
Q = Q_;
}
fvScalarMatrix TEqn
(
fvm::ddt(rhoCp, T_)
- fvm::laplacian(K, T_)
==
Q
);
TEqn.relax();
TEqn.solve();
thermo_->correct();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
thermoBaffle2D::thermoBaffle2D
(
const word& modelType,
const fvMesh& mesh
)
:
thermoBaffleModel(modelType, mesh),
nNonOrthCorr_(readLabel(solution().lookup("nNonOrthCorr"))),
thermo_(basicSolidThermo::New(regionMesh())),
T_(thermo_->T()),
Qs_
(
IOobject
(
"Qs",
regionMesh().time().timeName(),
regionMesh(),
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
regionMesh(),
dimensionedScalar
(
"zero",
dimEnergy/dimArea/dimTime,
pTraits<scalar>::zero
)
),
Q_
(
IOobject
(
"Q",
regionMesh().time().timeName(),
regionMesh(),
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
regionMesh(),
dimensionedScalar
(
"zero",
dimEnergy/dimVolume/dimTime,
pTraits<scalar>::zero
)
)
{
if (oneD_)
{
label patchI = intCoupledPatchIDs_[0];
const label Qsb = Qs_.boundaryField()[patchI].size();
if (Qsb!= thickness_.size())
{
FatalErrorIn
(
"thermoBaffle2D::thermoBaffle2D"
"("
" const word& modelType,"
" const fvMesh& mesh"
")"
) << "the boundary field of Qs is "
<< Qsb << " and " << nl
<< "the field 'thickness' is " << thickness_.size() << nl
<< exit(FatalError);
}
}
thermo_->correct();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
thermoBaffle2D::~thermoBaffle2D()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void thermoBaffle2D::preEvolveRegion()
{
}
void thermoBaffle2D::evolveRegion()
{
for (int nonOrth=0; nonOrth<=nNonOrthCorr_; nonOrth++)
{
solveEnergy();
}
}
const tmp<volScalarField> thermoBaffle2D::Cp() const
{
return thermo_->Cp();
}
const volScalarField& thermoBaffle2D::kappa() const
{
return thermo_->kappa();
}
const volScalarField& thermoBaffle2D::rho() const
{
return thermo_->rho();
}
const volScalarField& thermoBaffle2D::K() const
{
return thermo_->K();
}
const volScalarField& thermoBaffle2D::T() const
{
return T_;
}
void thermoBaffle2D::info() const
{
Info<< indent << "min/max(T) = " << min(T_).value() << ", "
<< max(T_).value() << nl;
const labelList& coupledPatches = intCoupledPatchIDs();
forAll (coupledPatches, i)
{
const label patchI = coupledPatches[i];
const fvPatchScalarField& pT = T_.boundaryField()[patchI];
const word patchName = regionMesh().boundary()[patchI].name();
Info << indent << "Q : " << patchName << indent <<
gSum
(
mag(regionMesh().Sf().boundaryField()[patchI])
* pT.snGrad()
* thermo_->K().boundaryField()[patchI]
) << endl;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // end namespace thermoBaffleModels
} // end namespace regionModels
} // end namespace Foam
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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.