mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Added new temperatureLimits constraint
This commit is contained in:
@ -24,6 +24,7 @@ derived/rotorDiskSource/trimModel/trimModel/trimModel.C
|
||||
derived/rotorDiskSource/trimModel/trimModel/trimModelNew.C
|
||||
derived/rotorDiskSource/trimModel/fixed/fixedTrim.C
|
||||
derived/rotorDiskSource/trimModel/targetCoeff/targetCoeffTrim.C
|
||||
derived/temperatureLimits/temperatureLimits.C
|
||||
|
||||
interRegion = derived/interRegionHeatTransferModel
|
||||
$(interRegion)/constantHeatTransfer/constantHeatTransfer.C
|
||||
|
||||
144
src/fieldSources/derived/temperatureLimits/temperatureLimits.C
Normal file
144
src/fieldSources/derived/temperatureLimits/temperatureLimits.C
Normal file
@ -0,0 +1,144 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "temperatureLimits.H"
|
||||
#include "fvMesh.H"
|
||||
#include "basicThermo.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(temperatureLimits, 0);
|
||||
addToRunTimeSelectionTable(basicSource, temperatureLimits, dictionary);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::temperatureLimits::temperatureLimits
|
||||
(
|
||||
const word& name,
|
||||
const word& modelType,
|
||||
const dictionary& dict,
|
||||
const fvMesh& mesh
|
||||
)
|
||||
:
|
||||
basicSource(name, modelType, dict, mesh),
|
||||
Tmin_(readScalar(coeffs_.lookup("Tmin"))),
|
||||
Tmax_(readScalar(coeffs_.lookup("Tmax")))
|
||||
{
|
||||
fieldNames_.setSize(1, "energy");
|
||||
applied_.setSize(1, false);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::temperatureLimits::alwaysApply() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::temperatureLimits::correct(volScalarField& he)
|
||||
{
|
||||
const basicThermo& thermo =
|
||||
mesh_.lookupObject<basicThermo>("thermophysicalProperties");
|
||||
|
||||
if (he.name() == thermo.he().name())
|
||||
{
|
||||
scalarField Tmin(cells_.size(), Tmin_);
|
||||
scalarField Tmax(cells_.size(), Tmax_);
|
||||
|
||||
scalarField heMin(thermo.he(thermo.p(), Tmin, cells_));
|
||||
scalarField heMax(thermo.he(thermo.p(), Tmax, cells_));
|
||||
|
||||
scalarField& hec = he.internalField();
|
||||
|
||||
forAll(cells_, i)
|
||||
{
|
||||
label cellI = cells_[i];
|
||||
hec[cellI]= max(min(hec[cellI], heMax[i]), heMin[i]);
|
||||
}
|
||||
|
||||
// handle boundaries in the case of 'all'
|
||||
if (selectionMode_ == smAll)
|
||||
{
|
||||
volScalarField::GeometricBoundaryField& bf = he.boundaryField();
|
||||
|
||||
forAll(bf, patchI)
|
||||
{
|
||||
fvPatchScalarField& hep = bf[patchI];
|
||||
if (hep.fixesValue())
|
||||
{
|
||||
// not over-riding fixed conditions
|
||||
continue;
|
||||
}
|
||||
|
||||
const scalarField& pp = thermo.p().boundaryField()[patchI];
|
||||
|
||||
scalarField Tminp(pp.size(), Tmin_);
|
||||
scalarField Tmaxp(pp.size(), Tmax_);
|
||||
|
||||
scalarField heMinp(thermo.he(pp, Tminp, patchI));
|
||||
scalarField heMaxp(thermo.he(pp, Tmaxp, patchI));
|
||||
|
||||
forAll(hep, faceI)
|
||||
{
|
||||
hep[faceI] =
|
||||
max(min(hep[faceI], heMaxp[faceI]), heMinp[faceI]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::temperatureLimits::writeData(Ostream& os) const
|
||||
{
|
||||
os << indent << name_ << endl;
|
||||
dict_.write(os);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::temperatureLimits::read(const dictionary& dict)
|
||||
{
|
||||
if (basicSource::read(dict))
|
||||
{
|
||||
coeffs_.readIfPresent("Tmin", Tmin_);
|
||||
coeffs_.readIfPresent("Tmax", Tmax_);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
139
src/fieldSources/derived/temperatureLimits/temperatureLimits.H
Normal file
139
src/fieldSources/derived/temperatureLimits/temperatureLimits.H
Normal file
@ -0,0 +1,139 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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::temperatureLimits
|
||||
|
||||
Description
|
||||
Constraint for temperature to apply limits between minimum and maximum
|
||||
values
|
||||
|
||||
Constraint described by:
|
||||
|
||||
temperatureLimitsCoeffs
|
||||
{
|
||||
minimum 200;
|
||||
maximum 500;
|
||||
}
|
||||
|
||||
|
||||
SourceFiles
|
||||
basicSource.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef temperatureLimits_H
|
||||
#define temperatureLimits_H
|
||||
|
||||
#include "basicSource.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class temperatureLimits Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class temperatureLimits
|
||||
:
|
||||
public basicSource
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Minimum temperature limit [K]
|
||||
scalar Tmin_;
|
||||
|
||||
//- Maximum temperature limit [K]
|
||||
scalar Tmax_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
temperatureLimits(const temperatureLimits&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const temperatureLimits&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("temperatureLimits");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
temperatureLimits
|
||||
(
|
||||
const word& name,
|
||||
const word& modelType,
|
||||
const dictionary& dict,
|
||||
const fvMesh& mesh
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~temperatureLimits()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual bool alwaysApply() const;
|
||||
|
||||
|
||||
// Evaluate
|
||||
|
||||
//- Correct the energy field
|
||||
virtual void correct(volScalarField& he);
|
||||
|
||||
|
||||
// I-O
|
||||
|
||||
//- Write data
|
||||
virtual void writeData(Ostream&) const;
|
||||
|
||||
//- Read dictionary
|
||||
virtual bool read(const dictionary& dict);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user