nonUniformTableThermophysicalFunction.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2020 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::thermophysicalFunctions::nonUniformTable
29 
30 Description
31  Non-uniform tabulated property function that linearly interpolates between
32  the values.
33 
34  To speed-up the search of the non-uniform table a uniform jump-table is
35  created on construction which is used for fast indirect addressing into
36  the table.
37 
38 Usage
39  \nonUniformTable
40  Property | Description
41  values | List of (temperature property) value pairs
42  \endnonUniformTable
43 
44  Example for the density of water between 280 and 350K
45  \verbatim
46  rho
47  {
48  type nonUniformTable;
49 
50  values
51  (
52  (280 999.87)
53  (300 995.1)
54  (350 973.7)
55  );
56  }
57  \endverbatim
58 
59 \*---------------------------------------------------------------------------*/
60 
61 #ifndef nonUniformTableThermophysicalFunction_H
62 #define nonUniformTableThermophysicalFunction_H
63 
64 #include "thermophysicalFunction.H"
65 #include "MinMax.H"
66 #include "Tuple2.H"
67 
68 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69 
70 namespace Foam
71 {
72 
73 /*---------------------------------------------------------------------------*\
74  Class nonUniformTable Declaration
75 \*---------------------------------------------------------------------------*/
76 
77 class nonUniformTable
78 :
80 {
81  // Private Data
82 
83  //- Name of dictionary from which this function is instantiated
84  word name_;
85 
86  //- Table values
88 
89  //- Lowest/highest temperature in the table
90  MinMax<scalar> Trange_;
91 
92  //- Temperature increment, based on Trange_ and values_.size()
93  scalar deltaT_;
94 
95  //- Lookup indices into values_ table based on deltaT_
96  List<label> jumpTable_;
97 
98 
99 protected:
100 
101  //- Return the lower index of the interval in the table
102  //- corresponding to the given temperature.
103  // Checks the temperature range
104  inline label index(scalar p, scalar T) const;
105 
106 
107 public:
108 
109  //- Runtime type information
110  TypeName("nonUniformTable");
111 
112 
113  // Constructors
114 
115  //- Construct from entry name and dictionary
116  nonUniformTable(const word& name, const dictionary& dict);
117 
118  //- Construct from dictionary, using "values" for the lookup
119  explicit nonUniformTable(const dictionary& dict);
120 
121 
122  // Member Functions
123 
124  //- Return the non-uniform table of values
125  const List<Tuple2<scalar, scalar>>& values() const
126  {
127  return values_;
128  }
129 
130  //- Evaluate the function and return the result
131  scalar f(scalar p, scalar T) const;
132 
133  //- Evaluate the derivative of the function and return the result
134  scalar dfdT(scalar p, scalar T) const;
135 
136  //- Write the function coefficients
137  void writeData(Ostream& os) const;
138 };
139 
140 
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 
143 } // End namespace Foam
144 
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 
148 
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 
151 #endif
152 
153 // ************************************************************************* //
Foam::nonUniformTable::nonUniformTable
nonUniformTable(const word &name, const dictionary &dict)
Construct from entry name and dictionary.
Definition: nonUniformTableThermophysicalFunction.C:50
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::thermophysicalFunction
Abstract base class for thermo-physical functions.
Definition: thermophysicalFunction.H:53
Tuple2.H
Foam::nonUniformTable::writeData
void writeData(Ostream &os) const
Write the function coefficients.
Definition: nonUniformTableThermophysicalFunction.C:153
Foam::nonUniformTable::f
scalar f(scalar p, scalar T) const
Evaluate the function and return the result.
Definition: nonUniformTableThermophysicalFunction.C:124
MinMax.H
nonUniformTableThermophysicalFunctionI.H
Foam::nonUniformTable::dfdT
scalar dfdT(scalar p, scalar T) const
Evaluate the derivative of the function and return the result.
Definition: nonUniformTableThermophysicalFunction.C:140
Foam::nonUniformTable::index
label index(scalar p, scalar T) const
Definition: nonUniformTableThermophysicalFunctionI.H:34
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::nonUniformTable::TypeName
TypeName("nonUniformTable")
Runtime type information.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::nonUniformTable::values
const List< Tuple2< scalar, scalar > > & values() const
Return the non-uniform table of values.
Definition: nonUniformTableThermophysicalFunction.H:124
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::nonUniformTable
Definition: nonUniformTableThermophysicalFunction.H:76
Foam::MinMax< scalar >
thermophysicalFunction.H