From 5325a7263fe9feb86b524e2a91dacd242f867641 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 11 Oct 2013 12:33:59 +0100 Subject: [PATCH] ENH: Surface film - added simple solidification model --- src/regionModels/surfaceFilmModels/Make/files | 1 + .../solidification/solidification.C | 137 ++++++++++++++++++ .../solidification/solidification.H | 130 +++++++++++++++++ 3 files changed, 268 insertions(+) create mode 100644 src/regionModels/surfaceFilmModels/submodels/thermo/phaseChangeModel/solidification/solidification.C create mode 100644 src/regionModels/surfaceFilmModels/submodels/thermo/phaseChangeModel/solidification/solidification.H diff --git a/src/regionModels/surfaceFilmModels/Make/files b/src/regionModels/surfaceFilmModels/Make/files index 80ccb5554d..505638dcc7 100644 --- a/src/regionModels/surfaceFilmModels/Make/files +++ b/src/regionModels/surfaceFilmModels/Make/files @@ -37,6 +37,7 @@ $(THERMOMODELS)/phaseChangeModel/phaseChangeModel/phaseChangeModel.C $(THERMOMODELS)/phaseChangeModel/phaseChangeModel/phaseChangeModelNew.C $(THERMOMODELS)/phaseChangeModel/noPhaseChange/noPhaseChange.C $(THERMOMODELS)/phaseChangeModel/standardPhaseChange/standardPhaseChange.C +$(THERMOMODELS)/phaseChangeModel/solidification/solidification.C $(THERMOMODELS)/heatTransferModel/heatTransferModel/heatTransferModel.C $(THERMOMODELS)/heatTransferModel/heatTransferModel/heatTransferModelNew.C diff --git a/src/regionModels/surfaceFilmModels/submodels/thermo/phaseChangeModel/solidification/solidification.C b/src/regionModels/surfaceFilmModels/submodels/thermo/phaseChangeModel/solidification/solidification.C new file mode 100644 index 0000000000..31eac28522 --- /dev/null +++ b/src/regionModels/surfaceFilmModels/submodels/thermo/phaseChangeModel/solidification/solidification.C @@ -0,0 +1,137 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 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 . + +\*---------------------------------------------------------------------------*/ + +#include "solidification.H" +#include "addToRunTimeSelectionTable.H" +#include "thermoSingleLayer.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ +namespace surfaceFilmModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(solidification, 0); + +addToRunTimeSelectionTable +( + phaseChangeModel, + solidification, + dictionary +); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +solidification::solidification +( + const surfaceFilmModel& owner, + const dictionary& dict +) +: + phaseChangeModel(typeName, owner, dict), + T0_(readScalar(coeffs_.lookup("T0"))), + L_(readScalar(coeffs_.lookup("L"))), + alpha_(readScalar(coeffs_.lookup("alpha"))), + mass_ + ( + IOobject + ( + typeName + ":mass", + owner.regionMesh().time().timeName(), + owner.regionMesh(), + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + owner.regionMesh(), + dimensionedScalar("zero", dimMass, 0.0), + zeroGradientFvPatchScalarField::typeName + ), + thickness_ + ( + IOobject + ( + typeName + ":thickness", + owner.regionMesh().time().timeName(), + owner.regionMesh(), + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + owner.regionMesh(), + dimensionedScalar("zero", dimLength, 0.0), + zeroGradientFvPatchScalarField::typeName + ) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +solidification::~solidification() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void solidification::correctModel +( + const scalar dt, + scalarField& availableMass, + scalarField& dMass, + scalarField& dEnergy +) +{ + const thermoSingleLayer& film = filmType(); + + const scalarField& T = film.T(); + const scalarField& alpha = film.alpha(); + + forAll(alpha, cellI) + { + if (alpha[cellI] > 0.5) + { + if (T[cellI] > T0_) + { + mass_[cellI] += alpha_*availableMass[cellI]; + dMass[cellI] += alpha_*availableMass[cellI]; + dEnergy[cellI] += alpha_*availableMass[cellI]*L_; + } + } + } + + thickness_ = mass_/film.magSf()/film.rho(); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace surfaceFilmModels +} // End namespace regionModels +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/regionModels/surfaceFilmModels/submodels/thermo/phaseChangeModel/solidification/solidification.H b/src/regionModels/surfaceFilmModels/submodels/thermo/phaseChangeModel/solidification/solidification.H new file mode 100644 index 0000000000..334e2ca0ae --- /dev/null +++ b/src/regionModels/surfaceFilmModels/submodels/thermo/phaseChangeModel/solidification/solidification.H @@ -0,0 +1,130 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 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 . + +Class + Foam::solidification + +Description + Solidification phase change model where all film mass is converted when + the local temperature > activation temperature. + +SourceFiles + solidification.C + +\*---------------------------------------------------------------------------*/ + +#ifndef solidification_H +#define solidification_H + +#include "phaseChangeModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ +namespace surfaceFilmModels +{ + +/*---------------------------------------------------------------------------*\ + Class solidification Declaration +\*---------------------------------------------------------------------------*/ + +class solidification +: + public phaseChangeModel +{ +private: + + // Private member functions + + //- Disallow default bitwise copy construct + solidification(const solidification&); + + //- Disallow default bitwise assignment + void operator=(const solidification&); + + +protected: + + // Protected data + + //- Temperature at which solidification starts + scalar T0_; + + //- Latent heat of solidification [J/kg] + scalar L_; + + //- Under-relaxation parameter for solidification process (0-1) + scalar alpha_; + + //- Accumulated solid mass [kg] + volScalarField mass_; + + //- Accumulated solid thickness [m] + volScalarField thickness_; + + +public: + + //- Runtime type information + TypeName("solidification"); + + + // Constructors + + //- Construct from surface film model + solidification(const surfaceFilmModel& owner, const dictionary& dict); + + + //- Destructor + virtual ~solidification(); + + + // Member Functions + + // Evolution + + //- Correct + virtual void correctModel + ( + const scalar dt, + scalarField& availableMass, + scalarField& dMass, + scalarField& dEnergy + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace surfaceFilmModels +} // End namespace regionModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //