From f3467d4d03c5dc7469f0fe863d0414b87df9538b Mon Sep 17 00:00:00 2001 From: andy <andy> Date: Fri, 19 Oct 2012 10:58:05 +0100 Subject: [PATCH] ENH: Added fixed temperature field constraint --- src/fieldSources/Make/files | 45 +++--- .../fixedTemperatureSource.C | 104 ++++++++++++++ .../fixedTemperatureSource.H | 132 ++++++++++++++++++ 3 files changed, 259 insertions(+), 22 deletions(-) create mode 100644 src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.C create mode 100644 src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.H diff --git a/src/fieldSources/Make/files b/src/fieldSources/Make/files index eced302bfde..41fecea8008 100644 --- a/src/fieldSources/Make/files +++ b/src/fieldSources/Make/files @@ -1,34 +1,35 @@ -basicSource/basicSource/basicSource.C -basicSource/basicSource/basicSourceIO.C -basicSource/basicSource/basicSourceList.C -basicSource/basicSource/IObasicSourceList.C +basicSource/basicSource.C +basicSource/basicSourceIO.C +basicSource/basicSourceList.C +basicSource/IObasicSourceList.C -basicSource/pressureGradientExplicitSource/pressureGradientExplicitSource.C -basicSource/pressureGradientExplicitSource/pressureGradientExplicitSourceIO.C +general/explicitSource/explicitSource.C +general/explicitSetValue/explicitSetValue.C +general/codedSource/codedSource.C -basicSource/explicitSource/explicitSource.C -basicSource/explicitSetValue/explicitSetValue.C +derived/pressureGradientExplicitSource/pressureGradientExplicitSource.C +derived/pressureGradientExplicitSource/pressureGradientExplicitSourceIO.C -basicSource/rotorDiskSource/rotorDiskSource.C -basicSource/rotorDiskSource/bladeModel/bladeModel.C -basicSource/rotorDiskSource/profileModel/profileModel.C -basicSource/rotorDiskSource/profileModel/profileModelList.C -basicSource/rotorDiskSource/profileModel/lookup/lookupProfile.C -basicSource/rotorDiskSource/profileModel/series/seriesProfile.C -basicSource/rotorDiskSource/trimModel/trimModel/trimModel.C -basicSource/rotorDiskSource/trimModel/trimModel/trimModelNew.C -basicSource/rotorDiskSource/trimModel/fixed/fixedTrim.C -basicSource/rotorDiskSource/trimModel/targetCoeff/targetCoeffTrim.C +derived/rotorDiskSource/rotorDiskSource.C +derived/rotorDiskSource/bladeModel/bladeModel.C +derived/rotorDiskSource/profileModel/profileModel.C +derived/rotorDiskSource/profileModel/profileModelList.C +derived/rotorDiskSource/profileModel/lookup/lookupProfile.C +derived/rotorDiskSource/profileModel/series/seriesProfile.C +derived/rotorDiskSource/trimModel/trimModel/trimModel.C +derived/rotorDiskSource/trimModel/trimModel/trimModelNew.C +derived/rotorDiskSource/trimModel/fixed/fixedTrim.C +derived/rotorDiskSource/trimModel/targetCoeff/targetCoeffTrim.C -basicSource/actuationDiskSource/actuationDiskSource.C -basicSource/radialActuationDiskSource/radialActuationDiskSource.C +derived/actuationDiskSource/actuationDiskSource.C +derived/radialActuationDiskSource/radialActuationDiskSource.C -interRegion = basicSource/interRegionHeatTransferModel +interRegion = derived/interRegionHeatTransferModel $(interRegion)/interRegionHeatTransferModel/interRegionHeatTransferModel.C $(interRegion)/constantHeatTransfer/constantHeatTransfer.C $(interRegion)/tabulatedHeatTransfer/tabulatedHeatTransfer.C $(interRegion)/variableHeatTransfer/variableHeatTransfer.C -basicSource/codedSource/codedSource.C +derived/fixedTemperatureSource/fixedTemperatureSource.C LIB = $(FOAM_LIBBIN)/libfieldSources diff --git a/src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.C b/src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.C new file mode 100644 index 00000000000..7795aef8796 --- /dev/null +++ b/src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.C @@ -0,0 +1,104 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*----------------------------------------------------------------------------*/ + +#include "fixedTemperatureSource.H" +#include "fvMesh.H" +#include "fvMatrices.H" +#include "basicThermo.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(fixedTemperatureSource, 0); + addToRunTimeSelectionTable + ( + basicSource, + fixedTemperatureSource, + dictionary + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fixedTemperatureSource::fixedTemperatureSource +( + const word& name, + const word& modelType, + const dictionary& dict, + const fvMesh& mesh +) +: + ExplicitSetValue<scalar>(name, modelType, dict, mesh), + T_(readScalar(coeffs_.lookup("temperature"))) +{ + coeffs_.lookup("fieldNames") >> fieldNames_; + applied_.setSize(fieldNames_.size(), false); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::fixedTemperatureSource::setValue +( + fvMatrix<scalar>& eqn, + const label fieldI +) +{ + const basicThermo& thermo = + mesh_.lookupObject<basicThermo>("thermophsicalProperties"); + + const scalarField Tfield(cells_.size(), T_); + + eqn.setValues(cells_, thermo.he(thermo.p(), Tfield, cells_)); +} + + +void Foam::fixedTemperatureSource::writeData(Ostream& os) const +{ + os << indent << name_ << endl; + dict_.write(os); +} + + +bool Foam::fixedTemperatureSource::read(const dictionary& dict) +{ + if (basicSource::read(dict)) + { + coeffs_.readIfPresent("T", T_); + + return true; + } + else + { + return false; + } +} + + +// ************************************************************************* // diff --git a/src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.H b/src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.H new file mode 100644 index 00000000000..3e5f77d3d57 --- /dev/null +++ b/src/fieldSources/derived/fixedTemperatureSource/fixedTemperatureSource.H @@ -0,0 +1,132 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::fixedTemperatureSource + +Description + Fixed temperature equation constraint + + Sources described by: + + fixedTemperatureSourceCoeffs + { + fieldNames (h e hs); // names of fields to apply source + temperature 500; // fixed temperature [K] + } + + +SourceFiles + fixedTemperatureSource.C + +\*---------------------------------------------------------------------------*/ + +#ifndef fixedTemperatureSource_H +#define fixedTemperatureSource_H + +#include "ExplicitSetValue.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class fixedTemperatureSource Declaration +\*---------------------------------------------------------------------------*/ + +class fixedTemperatureSource +: + public ExplicitSetValue<scalar> +{ + +protected: + + // Protected data + + //- Fixed temperature [K] + scalar T_; + + +private: + + // Private Member Functions + + //- Disallow default bitwise copy construct + fixedTemperatureSource(const fixedTemperatureSource&); + + //- Disallow default bitwise assignment + void operator=(const fixedTemperatureSource&); + + +public: + + //- Runtime type information + TypeName("fixedTemperatureSource"); + + + // Constructors + + //- Construct from components + fixedTemperatureSource + ( + const word& name, + const word& modelType, + const dictionary& dict, + const fvMesh& mesh + ); + + + //- Destructor + virtual ~fixedTemperatureSource() + {} + + + // Member Functions + + // Set values directly + + //- Scalar + virtual void setValue(fvMatrix<scalar>& eqn, const label fieldI); + + + // I-O + + //- Write data + virtual void writeData(Ostream&) const; + + //- Read dictionary + virtual bool read(const dictionary& dict); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // -- GitLab