TableFile.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) 2011-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 "TableFile.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class Type>
32 :
33  TableBase<Type>(entryName, dict.subDict(entryName + "Coeffs")),
34  fName_("none")
35 {
36  const dictionary coeffs(dict.subDict(entryName + "Coeffs"));
37  coeffs.lookup("fileName") >> fName_;
38 
39  if (coeffs.found("dimensions"))
40  {
41  coeffs.lookup("dimensions") >> this->dimensions_;
42  }
43 
44  fileName expandedFile(fName_);
45  IFstream is(expandedFile.expand());
46 
47  if (!is.good())
48  {
50  (
51  "TableFile<Type>::TableFile(const word&, const dictionary&)",
52  is
53  ) << "Cannot open file." << exit(FatalIOError);
54  }
55 
56  is >> this->table_;
57 
59 }
60 
61 
62 template<class Type>
64 :
65  TableBase<Type>(tbl),
66  fName_(tbl.fName_)
67 {}
68 
69 
70 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
71 
72 template<class Type>
74 {}
75 
76 
77 // * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
78 
79 #include "TableFileIO.C"
80 
81 
82 // ************************************************************************* //
virtual ~TableFile()
Destructor.
Definition: TableFile.C:73
string & expand(const bool allowEmpty=false)
Expand initial tildes and all occurences of environment variables.
Definition: string.C:98
Base class for table with bounds handling, interpolation and integration.
Definition: TableBase.H:47
A class for handling words, derived from string.
Definition: word.H:59
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:638
Input from file stream.
Definition: IFstream.H:81
TableFile(const word &entryName, const dictionary &dict)
Construct from entry name and Istream.
Definition: TableFile.C:31
List< Tuple2< scalar, Type > > table_
Table data.
Definition: TableBase.H:95
dictionary dict
IOerror FatalIOError
void check() const
Check the table for size and consistency.
Definition: TableBase.C:186
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
dimensionSet dimensions_
The dimension set.
Definition: TableBase.H:98
A class for handling file names.
Definition: fileName.H:69
Templated table container data entry where data is read from file.
Definition: TableFile.H:68
#define FatalIOErrorIn(functionName, ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:325