limitTemperature.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "limitTemperature.H"
27 #include "fvMesh.H"
28 #include "basicThermo.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace fv
36 {
37  defineTypeNameAndDebug(limitTemperature, 0);
39  (
40  option,
41  limitTemperature,
42  dictionary
43  );
44 }
45 }
46 
47 
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 
51 (
52  const word& name,
53  const word& modelType,
54  const dictionary& dict,
55  const fvMesh& mesh
56 )
57 :
58  cellSetOption(name, modelType, dict, mesh),
59  Tmin_(readScalar(coeffs_.lookup("Tmin"))),
60  Tmax_(readScalar(coeffs_.lookup("Tmax")))
61 {
62  // Set the field name to that of the energy field from which the temperature
63  // is obtained
64 
65  const basicThermo& thermo =
66  mesh_.lookupObject<basicThermo>(basicThermo::dictName);
67 
68  fieldNames_.setSize(1, thermo.he().name());
69 
70  applied_.setSize(1, false);
71 }
72 
73 
74 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
75 
77 {
78  const basicThermo& thermo =
80 
81  scalarField Tmin(cells_.size(), Tmin_);
82  scalarField Tmax(cells_.size(), Tmax_);
83 
84  scalarField heMin(thermo.he(thermo.p(), Tmin, cells_));
85  scalarField heMax(thermo.he(thermo.p(), Tmax, cells_));
86 
87  scalarField& hec = he.internalField();
88 
89  forAll(cells_, i)
90  {
91  label cellI = cells_[i];
92  hec[cellI]= max(min(hec[cellI], heMax[i]), heMin[i]);
93  }
94 
95  // handle boundaries in the case of 'all'
96  if (selectionMode_ == smAll)
97  {
98  volScalarField::GeometricBoundaryField& bf = he.boundaryField();
99 
100  forAll(bf, patchi)
101  {
102  fvPatchScalarField& hep = bf[patchi];
103 
104  if (!hep.fixesValue())
105  {
106  const scalarField& pp = thermo.p().boundaryField()[patchi];
107 
108  scalarField Tminp(pp.size(), Tmin_);
109  scalarField Tmaxp(pp.size(), Tmax_);
110 
111  scalarField heMinp(thermo.he(pp, Tminp, patchi));
112  scalarField heMaxp(thermo.he(pp, Tmaxp, patchi));
113 
114  forAll(hep, facei)
115  {
116  hep[facei] =
117  max(min(hep[facei], heMaxp[facei]), heMinp[facei]);
118  }
119  }
120  }
121  }
122 }
123 
124 
126 {
128  {
129  coeffs_.readIfPresent("Tmin", Tmin_);
130  coeffs_.readIfPresent("Tmax", Tmax_);
131 
132  return true;
133  }
134  else
135  {
136  return false;
137  }
138 }
139 
140 
141 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
Foam::fv::limitTemperature::read
virtual bool read(const dictionary &dict)
Read dictionary.
Definition: limitTemperature.C:125
basicThermo.H
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::fv::cellSetOption
Cell-set options abtract base class. Provides a base set of controls, e.g.
Definition: cellSetOption.H:71
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::fv::cellSetOption::selectionMode_
selectionModeType selectionMode_
Cell selection mode.
Definition: cellSetOption.H:104
Foam::basicThermo::dictName
static const word dictName
Definition: basicThermo.H:176
thermo
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
Foam::fv::limitTemperature::limitTemperature
limitTemperature(const limitTemperature &)
Disallow default bitwise copy construct.
Foam::basicThermo
Abstract base-class for fluid and solid thermodynamic properties.
Definition: basicThermo.H:52
Foam::fvPatchField::fixesValue
virtual bool fixesValue() const
Return true if this patch field fixes a value.
Definition: fvPatchField.H:336
Foam::fv::option::mesh_
const fvMesh & mesh_
Reference to the mesh database.
Definition: fvOption.H:78
dictName
const word dictName("particleTrackDict")
limitTemperature.H
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::fv::cellSetOption::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: cellSetOptionIO.C:30
Foam::fv::cellSetOption::cells_
labelList cells_
Set of cells to apply source to.
Definition: cellSetOption.H:113
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::fv::limitTemperature::Tmin_
scalar Tmin_
Minimum temperature limit [K].
Definition: limitTemperature.H:69
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
readScalar
#define readScalar
Definition: doubleScalar.C:38
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
fv
labelList fv(nPoints)
Foam::fv::defineTypeNameAndDebug
defineTypeNameAndDebug(option, 0)
Foam::fv::addToRunTimeSelectionTable
addToRunTimeSelectionTable(option, fixedTemperatureConstraint, dictionary)
he
volScalarField & he
Definition: YEEqn.H:56
Foam::fv::limitTemperature::correct
virtual void correct(volScalarField &he)
Correct the energy field.
Definition: limitTemperature.C:76
patchi
label patchi
Definition: getPatchFieldScalar.H:1
Foam::fv::limitTemperature::Tmax_
scalar Tmax_
Maximum temperature limit [K].
Definition: limitTemperature.H:72
Foam::objectRegistry::lookupObject
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
Definition: objectRegistryTemplates.C:165
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::min
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::GeometricField::GeometricBoundaryField
Definition: GeometricField.H:105
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::fv::cellSetOption::smAll
@ smAll
Definition: cellSetOption.H:85