Table.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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 "Table.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class Type>
32 (
33  const word& entryName,
34  const dictionary& dict
35 )
36 :
38 {
39  if (!dict.found(entryName))
40  {
41  dict.lookup("values") >> this->table_;
42  }
43  else
44  {
45  Istream& is(dict.lookup(entryName));
46  word entryType(is);
47  if (is.eof())
48  {
49  dict.lookup("values") >> this->table_;
50  }
51  else
52  {
53  is >> this->table_;
54  }
55  }
56 
58 }
59 
60 
61 template<class Type>
63 (
64  const word& name,
65  const tableBase::boundsHandling boundsHandling,
66  const word& interpolationScheme,
67  const List<Tuple2<scalar, Type>>& table
68 )
69 :
71  (
72  name,
73  boundsHandling,
74  interpolationScheme,
75  table
76  )
77 {}
78 
79 
80 template<class Type>
82 :
83  TableBase<Type, Table<Type>>(tbl)
84 {}
85 
86 
87 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
88 
89 template<class Type>
91 {}
92 
93 
94 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
95 
96 template<class Type>
98 {
99  TableBase<Type, Table<Type>>::writeEntries(os);
100 
101  os << indent << "values" << this->table_
102  << token::END_STATEMENT << endl;
103 }
104 
105 
106 // ************************************************************************* //
dictionary dict
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:667
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
A 2-tuple for storing two objects of different types.
Definition: HashTable.H:65
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
virtual void writeEntries(Ostream &os) const
Write entries only in dictionary format.
Definition: Table.C:97
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Templated table container function.
Definition: Table.H:63
Table(const word &entryName, const dictionary &dict)
Construct from entry name and Istream.
Definition: Table.C:32
A class for handling words, derived from string.
Definition: word.H:59
virtual ~Table()
Destructor.
Definition: Table.C:90
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
boundsHandling
Enumeration for handling out-of-bound values.
Definition: tableBase.H:54
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Base class for table with bounds handling, interpolation and integration.
Definition: TableBase.H:56
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:812