TableFile.H
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 Class
25  Foam::Function1s::TableFile
26 
27 Description
28  Templated table container function where data is read from file. Data is
29  stored as a list of Tuple2's. The first column is scalar. Data is read in
30  the form specified by the format entry, which defaults to the native
31  OpenFOAM format.
32 
33  Usage:
34  \verbatim
35  <entryName> tableFile;
36  <entryName>Coeffs
37  {
38  file dataFile; // name of data file
39  format foam; // data format (optional)
40  outOfBounds clamp; // optional out-of-bounds handling
41  interpolationScheme linear; // optional interpolation method
42  }
43  \endverbatim
44 
45 SourceFiles
46  TableFile.C
47 
48 See also
49  FoamTableReader.C
50  CsvTableReader.C
51 
52 \*---------------------------------------------------------------------------*/
53 
54 #ifndef TableFile_H
55 #define TableFile_H
56 
57 #include "TableBase.H"
58 #include "TableReader.H"
59 
60 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61 
62 namespace Foam
63 {
64 namespace Function1s
65 {
66 
67 /*---------------------------------------------------------------------------*\
68  Class TableFile Declaration
69 \*---------------------------------------------------------------------------*/
70 
71 template<class Type>
72 class TableFile
73 :
74  public TableBase<Type, TableFile<Type>>
75 {
76  // Private Data
77 
78  //- File name for table
79  const fileName fName_;
80 
81  //- Table reader
82  const autoPtr<TableReader<Type>> reader_;
83 
84 
85 public:
86 
87  //- Runtime type information
88  TypeName("tableFile");
89 
90 
91  // Constructors
92 
93  //- Construct from entry name and dictionary
94  TableFile(const word& entryName, const dictionary& dict);
95 
96  //- Copy constructor
97  TableFile(const TableFile<Type>& tbl);
98 
99 
100  //- Destructor
101  virtual ~TableFile();
102 
103 
104  // Access
105 
106  //- Return the file name
107  inline const fileName& fName() const
108  {
109  return fName_;
110  }
111 
112 
113  // I/O
114 
115  //- Write entries only in dictionary format
116  virtual void writeEntries(Ostream& os) const;
117 
118 
119  // Member Operators
120 
121  //- Disallow default bitwise assignment
122  void operator=(const TableFile<Type>&) = delete;
123 };
124 
125 
126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
127 
128 } // End namespace Function1s
129 } // End namespace Foam
130 
131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132 
133 #ifdef NoRepository
134  #include "TableFile.C"
135 #endif
136 
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 
139 #endif
140 
141 // ************************************************************************* //
A class for handling file names.
Definition: fileName.H:79
const word const dictionary & dict
Definition: Function1.H:84
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
const word & entryName
Definition: Function1.H:84
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
TypeName("tableFile")
Runtime type information.
void operator=(const TableFile< Type > &)=delete
Disallow default bitwise assignment.
Templated table container function where data is read from file. Data is stored as a list of Tuple2&#39;s...
Definition: TableFile.H:71
const fileName & fName() const
Return the file name.
Definition: TableFile.H:106
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
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
Namespace for OpenFOAM.