All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TableFile.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 "TableFile.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class Type>
32 (
33  const word& entryName,
34  const dictionary& dict
35 )
36 :
38  fName_(dict.lookup("file")),
39  reader_
40  (
42  (
43  dict.lookupOrDefault<word>
44  (
45  "format",
47  ),
48  dict
49  )
50  )
51 {
52  reader_()(fName_, this->table_);
53 
55 }
56 
57 
58 template<class Type>
60 :
61  TableBase<Type, TableFile<Type>>(tbl),
62  fName_(tbl.fName_),
63  reader_(tbl.reader_, false)
64 {}
65 
66 
67 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
68 
69 template<class Type>
71 {}
72 
73 
74 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
75 
76 template<class Type>
78 {
79  TableBase<Type, TableFile<Type>>::writeEntries(os);
80 
81  writeEntry(os, "file", fName_);
82  writeEntry(os, "format", reader_->type());
83  reader_->write(os);
84 }
85 
86 
87 // ************************************************************************* //
Base class to read table data for tables.
Definition: TableReader.H:52
dictionary dict
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
Reads an interpolation table from a file in OpenFOAM-format. This is a list of Tuple2&#39;s where the fir...
A class for handling words, derived from string.
Definition: word.H:59
TableFile(const word &entryName, const dictionary &dict)
Construct from entry name and dictionary.
Definition: TableFile.C:32
virtual ~TableFile()
Destructor.
Definition: TableFile.C:70
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Templated table container function where data is read from file. Data is stored as a list of Tuple2&#39;s...
Definition: TableFile.H:71
virtual void writeEntries(Ostream &os) const
Write entries only in dictionary format.
Definition: TableFile.C:77
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