TableFile.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 | Copyright (C) 2011-2017 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::Function1Types::TableFile
26 
27 Description
28  Templated table container function where data is read from file.
29 
30  Usage:
31  \verbatim
32  <entryName> tableFile;
33  <entryName>Coeffs
34  {
35  fileName dataFile; // name of data file
36  outOfBounds clamp; // optional out-of-bounds handling
37  interpolationScheme linear; // optional interpolation method
38  }
39  \endverbatim
40 
41  Data is stored as a list of Tuple2's. First column is always stored as
42  scalar entries. Data is read in the form, e.g. for an entry <entryName>
43  that is (scalar, vector):
44  \verbatim
45  (
46  (0.0 (1 2 3))
47  (1.0 (4 5 6))
48  );
49  \endverbatim
50 
51 SourceFiles
52  TableFile.C
53 
54 \*---------------------------------------------------------------------------*/
55 
56 #ifndef TableFile_H
57 #define TableFile_H
58 
59 #include "Function1.H"
60 #include "Tuple2.H"
61 
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63 
64 namespace Foam
65 {
66 namespace Function1Types
67 {
68 
69 /*---------------------------------------------------------------------------*\
70  Class TableFile Declaration
71 \*---------------------------------------------------------------------------*/
72 
73 template<class Type>
74 class TableFile
75 :
76  public TableBase<Type>
77 {
78  // Private data
79 
80  //- File name for csv table (optional)
81  fileName fName_;
82 
83 
84  // Private Member Functions
85 
86  //- Disallow default bitwise assignment
87  void operator=(const TableFile<Type>&);
88 
89 
90 public:
91 
92  //- Runtime type information
93  TypeName("tableFile");
94 
95 
96  // Constructors
97 
98  //- Construct from entry name and Istream
99  TableFile(const word& entryName, const dictionary& dict);
100 
101  //- Copy constructor
102  TableFile(const TableFile<Type>& tbl);
103 
104  //- Construct and return a clone
105  virtual tmp<Function1<Type>> clone() const
106  {
107  return tmp<Function1<Type>>(new TableFile<Type>(*this));
108  }
109 
110 
111  //- Destructor
112  virtual ~TableFile();
113 
114 
115  // I/O
116 
117  //- Write in dictionary format
118  virtual void writeData(Ostream& os) const;
119 };
120 
121 
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123 
124 } // End namespace Function1Types
125 } // End namespace Foam
126 
127 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128 
129 #ifdef NoRepository
130  #include "TableFile.C"
131 #endif
132 
133 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 
135 #endif
136 
137 // ************************************************************************* //
virtual tmp< Function1< Type > > clone() const
Construct and return a clone.
Definition: TableFile.H:104
virtual ~TableFile()
Destructor.
Definition: TableFile.C:72
A class for handling file names.
Definition: fileName.H:69
Templated table container function where data is read from file.
Definition: TableFile.H:73
const word const dictionary & dict
Definition: Function1.H:88
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
TypeName("tableFile")
Runtime type information.
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: TableFile.C:79
TableFile(const word &entryName, const dictionary &dict)
Construct from entry name and Istream.
Definition: TableFile.C:32
const word & entryName
Definition: Function1.H:88
Base class for table with bounds handling, interpolation and integration.
Definition: TableBase.H:55
A class for handling words, derived from string.
Definition: word.H:59
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.