fixedTemperatureConstraint.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 
27 #include "fvMesh.H"
28 #include "fvMatrices.H"
29 #include "basicThermo.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  namespace fv
37  {
38  defineTypeNameAndDebug(fixedTemperatureConstraint, 0);
40  (
41  option,
42  fixedTemperatureConstraint,
43  dictionary
44  );
45  }
46 
47  template<>
48  const char* NamedEnum<fv::fixedTemperatureConstraint::temperatureMode, 2>::
49  names[] =
50  {
51  "uniform",
52  "lookup"
53  };
54 }
55 
58 
59 
60 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
61 
63 (
64  const word& name,
65  const word& modelType,
66  const dictionary& dict,
67  const fvMesh& mesh
68 )
69 :
70  cellSetOption(name, modelType, dict, mesh),
71  mode_(temperatureModeNames_.read(coeffs_.lookup("mode"))),
72  Tuniform_(NULL),
73  TName_("T")
74 {
75  switch (mode_)
76  {
77  case tmUniform:
78  {
79  Tuniform_.reset
80  (
81  DataEntry<scalar>::New("temperature", coeffs_).ptr()
82  );
83  break;
84  }
85  case tmLookup:
86  {
87  TName_ = coeffs_.lookupOrDefault<word>("TName", "T");
88  break;
89  }
90  default:
91  {
92  // error handling done by NamedEnum
93  }
94  }
95 
96 
97  // Set the field name to that of the energy field from which the temperature
98  // is obtained
99 
100  const basicThermo& thermo =
101  mesh_.lookupObject<basicThermo>(basicThermo::dictName);
102 
103  fieldNames_.setSize(1, thermo.he().name());
104 
105  applied_.setSize(1, false);
106 }
107 
108 
109 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
110 
112 (
113  fvMatrix<scalar>& eqn,
114  const label
115 )
116 {
117  const basicThermo& thermo =
118  mesh_.lookupObject<basicThermo>(basicThermo::dictName);
119 
120  switch (mode_)
121  {
122  case tmUniform:
123  {
124  const scalar t = mesh_.time().value();
125  scalarField Tuni(cells_.size(), Tuniform_->value(t));
126  eqn.setValues(cells_, thermo.he(thermo.p(), Tuni, cells_));
127 
128  break;
129  }
130  case tmLookup:
131  {
132  const volScalarField& T =
133  mesh().lookupObject<volScalarField>(TName_);
134 
135  scalarField Tlkp(T, cells_);
136  eqn.setValues(cells_, thermo.he(thermo.p(), Tlkp, cells_));
137 
138  break;
139  }
140  default:
141  {
142  // error handling done by NamedEnum
143  }
144  }
145 }
146 
147 
149 {
151  {
152  if (coeffs_.found(Tuniform_->name()))
153  {
154  Tuniform_.reset
155  (
156  DataEntry<scalar>::New(Tuniform_->name(), dict).ptr()
157  );
158  }
159 
160  coeffs_.readIfPresent("TName", TName_);
161 
162  return true;
163  }
164  else
165  {
166  return false;
167  }
168 }
169 
170 
171 // ************************************************************************* //
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
fixedTemperatureConstraint.H
Foam::dictionary::readIfPresent
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
Definition: dictionaryTemplates.C:94
thermo
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
Foam::basicThermo
Abstract base-class for fluid and solid thermodynamic properties.
Definition: basicThermo.H:52
Foam::dimensioned::value
const Type & value() const
Return const reference to value.
Definition: dimensionedType.C:261
Foam::IOobject::time
const Time & time() const
Return time.
Definition: IOobject.C:245
fvMatrices.H
A special matrix type and solver, designed for finite volume solutions of scalar equations.
dictName
const word dictName("particleTrackDict")
Foam::fvMatrix::setValues
void setValues(const labelUList &cells, const UList< Type > &values)
Set solution in given cells to the specified values.
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::dictionary::found
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:304
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::fv::option::coeffs_
dictionary coeffs_
Dictionary containing source coefficients.
Definition: fvOption.H:84
Foam::fv::cellSetOption::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: cellSetOptionIO.C:30
Foam::fv::fixedTemperatureConstraint::read
virtual bool read(const dictionary &dict)
Read dictionary.
Definition: fixedTemperatureConstraint.C:148
Foam::fv::fixedTemperatureConstraint::constrain
virtual void constrain(fvMatrix< scalar > &eqn, const label fieldI)
Constrain energy equation to fix the temperature.
Definition: fixedTemperatureConstraint.C:112
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
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
fv
labelList fv(nPoints)
Foam::fv::defineTypeNameAndDebug
defineTypeNameAndDebug(option, 0)
Foam::fv::fixedTemperatureConstraint::temperatureModeNames_
static const NamedEnum< temperatureMode, 2 > temperatureModeNames_
String representation of temperatureMode enums.
Definition: fixedTemperatureConstraint.H:85
Foam::fv::addToRunTimeSelectionTable
addToRunTimeSelectionTable(option, fixedTemperatureConstraint, dictionary)
T
const volScalarField & T
Definition: createFields.H:25
Foam::fv::fixedTemperatureConstraint::TName_
word TName_
Temperature field name.
Definition: fixedTemperatureConstraint.H:99
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:68
Foam::fv::fixedTemperatureConstraint::Tuniform_
autoPtr< DataEntry< scalar > > Tuniform_
Uniform temperature [K].
Definition: fixedTemperatureConstraint.H:96
Foam::fv::fixedTemperatureConstraint::fixedTemperatureConstraint
fixedTemperatureConstraint(const fixedTemperatureConstraint &)
Disallow default bitwise copy construct.
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::DataEntry
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: DataEntry.H:52
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::NamedEnum
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:52