diff --git a/src/regionModels/Allwmake b/src/regionModels/Allwmake index b8b7bce119300adb0b47eaf866e19bc4396a7305..86638a3ff3716d802eb262d9b149738e804fe043 100755 --- a/src/regionModels/Allwmake +++ b/src/regionModels/Allwmake @@ -6,6 +6,7 @@ set -x wmake $makeType regionModel #wmake $makeType pyrolysisModels wmake $makeType surfaceFilmModels +wmake $makeType thermoBaffleModels #wmake $makeType regionCoupling diff --git a/src/regionModels/thermoBaffleModels/Make/files b/src/regionModels/thermoBaffleModels/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..1a0352a4bf037e64b349f1e99641a36053f793bd --- /dev/null +++ b/src/regionModels/thermoBaffleModels/Make/files @@ -0,0 +1,7 @@ +thermoBaffleModel/thermoBaffleModel.C +thermoBaffleModel/thermoBaffleModelNew.C +thermoBaffle2D/thermoBaffle2D.C +noThermo/noThermo.C + + +LIB = $(FOAM_LIBBIN)/libthermoBaffleModels diff --git a/src/regionModels/thermoBaffleModels/Make/options b/src/regionModels/thermoBaffleModels/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..7328b5d85609fc61117ff7743fb3735fb277d555 --- /dev/null +++ b/src/regionModels/thermoBaffleModels/Make/options @@ -0,0 +1,18 @@ +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 diff --git a/src/regionModels/thermoBaffleModels/noThermo/noThermo.C b/src/regionModels/thermoBaffleModels/noThermo/noThermo.C new file mode 100644 index 0000000000000000000000000000000000000000..6f89110f5e19ac10c3558151e3dc63178db3fa07 --- /dev/null +++ b/src/regionModels/thermoBaffleModels/noThermo/noThermo.C @@ -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/>. + +\*---------------------------------------------------------------------------*/ + +#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 + +// ************************************************************************* // diff --git a/src/regionModels/thermoBaffleModels/noThermo/noThermo.H b/src/regionModels/thermoBaffleModels/noThermo/noThermo.H new file mode 100644 index 0000000000000000000000000000000000000000..387241cca4255ac0859893128155390c32d8f92e --- /dev/null +++ b/src/regionModels/thermoBaffleModels/noThermo/noThermo.H @@ -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 + 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 + +// ************************************************************************* // diff --git a/src/regionModels/thermoBaffleModels/thermoBaffle2D/thermoBaffle2D.C b/src/regionModels/thermoBaffleModels/thermoBaffle2D/thermoBaffle2D.C new file mode 100644 index 0000000000000000000000000000000000000000..1b066e40e26127234074d25b8cb2975259253c0a --- /dev/null +++ b/src/regionModels/thermoBaffleModels/thermoBaffle2D/thermoBaffle2D.C @@ -0,0 +1,284 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +// ************************************************************************* // diff --git a/src/regionModels/thermoBaffleModels/thermoBaffle2D/thermoBaffle2D.H b/src/regionModels/thermoBaffleModels/thermoBaffle2D/thermoBaffle2D.H new file mode 100644 index 0000000000000000000000000000000000000000..d03682e09f8fe1d725b97759af6838f03c835320 --- /dev/null +++ b/src/regionModels/thermoBaffleModels/thermoBaffle2D/thermoBaffle2D.H @@ -0,0 +1,207 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 2 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 + +Class + Foam::thermoBaffle2D + +Description + 2D thermal baffle + +SourceFiles + thermoBaffle2D.C + thermoBaffle2DI.H + +\*---------------------------------------------------------------------------*/ + +#ifndef thermoBaffle2D_H +#define thermoBaffle2D_H + +#include "thermoBaffleModel.H" +#include "basicSolidThermo.H" +#include "volFieldsFwd.H" + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ +namespace thermoBaffleModels +{ + + +/*---------------------------------------------------------------------------*\ + Class thermoBaffle2D Declaration +\*---------------------------------------------------------------------------*/ + +class thermoBaffle2D +: + public thermoBaffleModel +{ +private: + + // Private member functions + + //- Disallow default bitwise copy construct + thermoBaffle2D(const thermoBaffle2D&); + + //- Disallow default bitwise assignment + void operator=(const thermoBaffle2D&); + + +protected: + + // Protected data + + // Solution parameters + + //- Number of non orthogonal correctors + label nNonOrthCorr_; + + // Thermo properties + + //- Solid thermo + autoPtr<basicSolidThermo> thermo_; + + //- Temperature / [K] + volScalarField& T_; + + // Source term fields + + //- Surface energy source / [J/m2/s] + volScalarField Qs_; + + //- Volumetric energy source / [J/m3/s] + volScalarField Q_; + + + // Protected member functions + + //- Read control parameters from dictionary + virtual bool read(); + + // Equations + + //- Solve energy equation + virtual void solveEnergy(); + + +public: + + //- Runtime type information + TypeName("thermoBaffle2D"); + + + // Constructors + + //- Construct from components + thermoBaffle2D(const word& modelType, const fvMesh& mesh); + + + //- Destructor + virtual ~thermoBaffle2D(); + + + // Member Functions + + // Thermo properties + + //- Return const reference to the basicSolidThermo + inline const basicSolidThermo& thermo() const; + + + // 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; + + + // Helper functions + + //- Return sensible enthalpy as a function of temperature + // for a patch + inline tmp<scalarField> hs + ( + const scalarField& T, + const label patchI + ) const; + + //- Return sensible enthalpy as a function of temperature + inline tmp<volScalarField> hs + ( + const volScalarField& T + ) const; + + //- Return temperature as a function of sensible enthalpy + inline tmp<volScalarField> T + ( + const volScalarField& hs + ) const; + + + // Evolution + + //- Pre-evolve film + virtual void preEvolveRegion(); + + //- Evolve the film equations + virtual void evolveRegion(); + + + + // I-O + + //- Provide some feedback + virtual void info() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace thermoBaffleModels +} // End namespace regionModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "thermoBaffle2DI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/regionModels/thermoBaffleModels/thermoBaffle2D/thermoBaffle2DI.H b/src/regionModels/thermoBaffleModels/thermoBaffle2D/thermoBaffle2DI.H new file mode 100644 index 0000000000000000000000000000000000000000..2324f0534aa3d216a0965e2492456b6ac6c732ab --- /dev/null +++ b/src/regionModels/thermoBaffleModels/thermoBaffle2D/thermoBaffle2DI.H @@ -0,0 +1,114 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "zeroGradientFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ +namespace thermoBaffleModels +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +inline const basicSolidThermo& thermoBaffle2D::thermo() const +{ + return thermo_; +} + + +inline tmp<scalarField> thermoBaffle2D::hs +( + const scalarField& T, + const label patchI +) const +{ + const scalarField& Cp = thermo_->Cp()().boundaryField()[patchI]; + return Cp*(T - 298.15); +} + + +inline tmp<volScalarField> thermoBaffle2D::hs +( + const volScalarField& T +) const +{ + const volScalarField Cp = thermo_->Cp()(); + return tmp<volScalarField> + ( + new volScalarField + ( + IOobject + ( + "hs(" + T.name() + ")", + time().timeName(), + regionMesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + Cp*(T - (dimensionedScalar("Tstd", dimTemperature, 298.15))), + zeroGradientFvPatchScalarField::typeName + ) + ); +} + + +inline tmp<volScalarField> thermoBaffle2D::T +( + const volScalarField& hs +) const +{ + const volScalarField Cp = thermo_->Cp()(); + return tmp<volScalarField> + ( + new volScalarField + ( + IOobject + ( + "T(" + hs.name() + ")", + time().timeName(), + regionMesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + hs/Cp + dimensionedScalar("Tstd", dimTemperature, 298.15), + zeroGradientFvPatchScalarField::typeName + ) + ); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace thermoBaffleModels +} // End namespace regionModels +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/regionModels/thermoBaffleModels/thermoBaffleModel/thermoBaffleModel.C b/src/regionModels/thermoBaffleModels/thermoBaffleModel/thermoBaffleModel.C new file mode 100644 index 0000000000000000000000000000000000000000..87883a2df247388cd5b1de5b7b849df506efe962 --- /dev/null +++ b/src/regionModels/thermoBaffleModels/thermoBaffleModel/thermoBaffleModel.C @@ -0,0 +1,215 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "thermoBaffleModel.H" +#include "fvMesh.H" +#include "directMappedVariableThicknessWallPolyPatch.H" +#include "wedgePolyPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ +namespace thermoBaffleModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(thermoBaffleModel, 0); +defineRunTimeSelectionTable(thermoBaffleModel, mesh); + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +bool thermoBaffleModel::read() +{ + regionModel1D::read(); + return true; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +thermoBaffleModel::thermoBaffleModel(const fvMesh& mesh) +: + regionModel1D(mesh), + thickness_(), + delta_("delta", dimLength, 0.0), + oneD_(false) +{} + + +thermoBaffleModel::thermoBaffleModel(const word& modelType, const fvMesh& mesh) +: + regionModel1D(mesh, "thermoBaffle", modelType), + thickness_(), + delta_("delta", dimLength, 0.0), + oneD_(false) +{ + if (active_) + { + const polyBoundaryMesh& rbm = regionMesh().boundaryMesh(); + + // Check if region mesh in oneD + label nTotalEdges = 0; + const label patchi = intCoupledPatchIDs_[0]; + nTotalEdges = 2*nLayers_*rbm[patchi].nInternalEdges(); + nTotalEdges += + nLayers_*(rbm[patchi].nEdges() - rbm[patchi].nInternalEdges()); + + reduce(nTotalEdges, sumOp<label>()); + + label nFaces = 0; + forAll (rbm, patchi) + { + if (rbm[patchi].size() && isA<wedgePolyPatch>(rbm[patchi])) + { + nFaces += rbm[patchi].size(); + } + } + reduce(nFaces, sumOp<label>()); + + if (nTotalEdges == nFaces) + { + oneD_ = true; + Info << "\nThe thermal baffle is 1D \n" << endl; + } + else + { + Info << "\nThe thermal baffle is 3D \n" << endl; + } + + forAll(intCoupledPatchIDs_, i) + { + const label patchI = intCoupledPatchIDs_[i]; + const polyPatch& pp = rbm[patchI]; + + if (!isA<directMappedVariableThicknessWallPolyPatch>(pp) && oneD_) + { + FatalErrorIn + ( + "thermoBaffleModel::thermoBaffleModel" + "(\n" + " const word& modelType," + " const fvMesh& mesh" + ")\n" + ) << "\n patch type '" << pp.type() + << "' not type '" + << directMappedVariableThicknessWallPolyPatch::typeName + << "'. This is necessary for 1D solution" + << "\n for patch. " << pp.name() + << exit(FatalError); + } + else if (!isA<directMappedWallPolyPatch>(pp)) + { + FatalErrorIn + ( + "thermoBaffleModel::thermoBaffleModel" + "(\n" + " const word& modelType," + " const fvMesh& mesh" + ")\n" + ) << "\n patch type '" << pp.type() + << "' not type '" + << directMappedWallPolyPatch::typeName + << "'. This is necessary for 3D solution" + << "\n for patch. " << pp.name() + << exit(FatalError); + } + } + + if (oneD_) + { + const label patchI = intCoupledPatchIDs_[0]; + const polyPatch& pp = rbm[patchI]; + const directMappedVariableThicknessWallPolyPatch& ppCoupled = + refCast + < + const directMappedVariableThicknessWallPolyPatch + >(pp); + + thickness_ = ppCoupled.thickness(); + + // Check that thickness has the right size + if (thickness_.size() != pp.size()) + { + FatalErrorIn + ( + "thermoBaffleModel::thermoBaffleModel" + "(" + " const word& modelType," + " const fvMesh& mesh" + ")" + ) << " coupled patches in thermoBaffle are " << nl + << " different sizes from list thickness" << nl + << exit(FatalError); + } + + // Calculate thickness of the baffle on the first face only. + if (delta_.value() == 0.0) + { + forAll (ppCoupled, localFaceI) + { + label faceI = ppCoupled.start() + localFaceI; + + label faceO = + boundaryFaceOppositeFace_[localFaceI]; + + delta_.value() = mag + ( + regionMesh().faceCentres()[faceI] + - regionMesh().faceCentres()[faceO] + ); + break; + } + } + } + + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +thermoBaffleModel::~thermoBaffleModel() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void thermoBaffleModel::preEvolveRegion() +{ +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace thermoBaffleModels +} // End namespace regionModels +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/regionModels/thermoBaffleModels/thermoBaffleModel/thermoBaffleModel.H b/src/regionModels/thermoBaffleModels/thermoBaffleModel/thermoBaffleModel.H new file mode 100644 index 0000000000000000000000000000000000000000..3d8dabc87661c5bdab0cf6f772c869f0a33b8b7b --- /dev/null +++ b/src/regionModels/thermoBaffleModels/thermoBaffleModel/thermoBaffleModel.H @@ -0,0 +1,190 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::thermoBaffleModel + +Description + +SourceFiles + thermoBaffleModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef thermoBaffleModel_H +#define thermoBaffleModel_H + +#include "runTimeSelectionTables.H" +#include "scalarIOField.H" +#include "autoPtr.H" +#include "volFieldsFwd.H" +#include "regionModel1D.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ +namespace thermoBaffleModels +{ + +/*---------------------------------------------------------------------------*\ + Class thermoBaffleModel Declaration +\*---------------------------------------------------------------------------*/ + +class thermoBaffleModel +: + public regionModel1D +{ +private: + + // Private Member Functions + + //- Disallow default bitwise copy construct + thermoBaffleModel(const thermoBaffleModel&); + + //- Disallow default bitwise assignment + void operator=(const thermoBaffleModel&); + + +protected: + + // Protected Data + + //- Baffle physical thickness + scalarField thickness_; + + //- Baffle geometric thickness + dimensionedScalar delta_; + + //- Is it one dimension + bool oneD_; + + + // Protected Member Functions + + //- Read control parameters from dictionary + virtual bool read(); + + +public: + + //- Runtime type information + TypeName("thermoBaffleModel"); + + + // Declare runtime constructor selection table + + declareRunTimeSelectionTable + ( + autoPtr, + thermoBaffleModel, + mesh, + ( + const word& modelType, + const fvMesh& mesh + ), + (modelType, mesh) + ); + + // Constructors + + //- Construct null from mesh + thermoBaffleModel(const fvMesh& mesh); + + //- Construct from type name and mesh + thermoBaffleModel(const word& modelType, const fvMesh& mesh); + + + // Selectors + + //- Return a reference to the selected model + static autoPtr<thermoBaffleModel> New(const fvMesh& mesh); + + + //- Destructor + virtual ~thermoBaffleModel(); + + + // Member Functions + + // Access + + + //- Return thickness + const scalarField& thickness() const + { + return thickness_; + } + + //- Return geometrical thickness + const dimensionedScalar& delta() const + { + return delta_; + } + + //- Return if region is one dimensional + bool oneD() const + { + return oneD_; + } + + + // Fields + + //- Return density [kg/m3] + virtual const volScalarField& rho() const = 0; + + //- Return const temperature [K] + virtual const volScalarField& T() const = 0; + + //- Return specific heat capacity [J/kg/K] + virtual const tmp<volScalarField> Cp() const = 0; + + //- Return the region absorptivity [1/m] + virtual const volScalarField& kappa() const = 0; + + //- Return the region thermal conductivity [W/m/k] + virtual const volScalarField& K() const = 0; + + + // Evolution + + //- Pre-evolve region + virtual void preEvolveRegion(); + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace thermoBaffleModels +} // End namespace regionModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/regionModels/thermoBaffleModels/thermoBaffleModel/thermoBaffleModelNew.C b/src/regionModels/thermoBaffleModels/thermoBaffleModel/thermoBaffleModelNew.C new file mode 100644 index 0000000000000000000000000000000000000000..976b478e331810869994907b124eb88ebc85fb63 --- /dev/null +++ b/src/regionModels/thermoBaffleModels/thermoBaffleModel/thermoBaffleModelNew.C @@ -0,0 +1,85 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "thermoBaffleModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ +namespace thermoBaffleModels +{ + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + +autoPtr<thermoBaffleModel> thermoBaffleModel::New(const fvMesh& mesh) +{ + + word modelType; + { + IOdictionary thermoBafflePropertiesDict + ( + IOobject + ( + "thermoBaffleProperties", + mesh.time().constant(), + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE, + false + ) + ); + + thermoBafflePropertiesDict.lookup("thermoBaffleModel") >> modelType; + } + Info<< "Selecting baffle model " << modelType << endl; + + meshConstructorTable::iterator cstrIter = + meshConstructorTablePtr_->find(modelType); + + if (cstrIter == meshConstructorTablePtr_->end()) + { + + FatalErrorIn("thermoBaffleModel::New(const fvMesh&)") + << "Unknown thermoBaffleModel type " << modelType + << nl << nl + << "Valid thermoBaffleModel types are:" << nl + << meshConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return autoPtr<thermoBaffleModel>(cstrIter()(modelType, mesh)); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace thermoBaffleModels +} // End namespace regionModels +} // End namespace Foam + +// ************************************************************************* //