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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2019-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::Function1Types::TableFile
29 
30 Description
31  Templated table container function where data are read from file.
32 
33  Usage:
34  \verbatim
35  <entryName> tableFile;
36  <entryName>Coeffs
37  {
38  file dataFile; // name of data file
39  outOfBounds clamp; // optional out-of-bounds handling
40  interpolationScheme linear; // optional interpolation method
41  }
42  \endverbatim
43 
44  Data are stored as a list of Tuple2's. First column is always stored as
45  scalar entries. Data are read in the form, e.g. for an entry <entryName>
46  that is (scalar, vector):
47  \verbatim
48  (
49  (0.0 (1 2 3))
50  (1.0 (4 5 6))
51  );
52  \endverbatim
53 
54 See Also
55  Foam::Function1Types::Table
56 
57 SourceFiles
58  TableFile.C
59 
60 \*---------------------------------------------------------------------------*/
61 
62 #ifndef Function1Types_TableFile_H
63 #define Function1Types_TableFile_H
64 
65 #include "TableBase.H"
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 namespace Foam
70 {
71 namespace Function1Types
72 {
73 
74 /*---------------------------------------------------------------------------*\
75  Class TableFile Declaration
76 \*---------------------------------------------------------------------------*/
77 
78 template<class Type>
79 class TableFile
80 :
81  public TableBase<Type>
82 {
83  // Private Data
84 
85  //- File name for table (mandatory)
86  fileName fName_;
87 
88 
89  // Private Member Functions
90 
91  //- No copy assignment
92  void operator=(const TableFile<Type>&) = delete;
93 
94 
95 public:
96 
97  //- Runtime type information
98  TypeName("tableFile");
99 
100 
101  // Constructors
102 
103  //- Construct from entry name and "file" found in dictionary
104  TableFile
105  (
106  const word& entryName,
107  const dictionary& dict,
108  const objectRegistry* obrPtr = nullptr
109  );
110 
111  //- Copy construct
112  explicit TableFile(const TableFile<Type>& tbl);
113 
114  //- Construct and return a clone
115  virtual tmp<Function1<Type>> clone() const
116  {
117  return tmp<Function1<Type>>(new TableFile<Type>(*this));
118  }
119 
120 
121  //- Destructor
122  virtual ~TableFile() = default;
123 
124 
125  // Member Functions
126 
127  //- Write in dictionary format
128  virtual void writeData(Ostream& os) const;
129 };
130 
131 
132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
133 
134 } // End namespace Function1Types
135 } // End namespace Foam
136 
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 
139 #ifdef NoRepository
140  #include "TableFile.C"
141 #endif
142 
143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144 
145 #endif
146 
147 // ************************************************************************* //
Foam::Function1Types::TableFile::writeData
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: TableFile.C:75
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
TableFile.C
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Function1::entryName
const word & entryName
Definition: Function1.H:133
Foam::Function1Types::TableFile::TypeName
TypeName("tableFile")
Runtime type information.
Foam::Function1::dict
const word const dictionary & dict
Definition: Function1.H:134
Foam::Function1Types::TableFile::clone
virtual tmp< Function1< Type > > clone() const
Construct and return a clone.
Definition: TableFile.H:114
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
TableBase.H
Foam::Function1::obrPtr
const word const dictionary const objectRegistry * obrPtr
Definition: Function1.H:136
Foam::Function1Types::TableFile
Templated table container function where data are read from file.
Definition: TableFile.H:78
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::Function1Types::TableFile::~TableFile
virtual ~TableFile()=default
Destructor.
Foam::Function1Types::TableFile::TableFile
TableFile(const word &entryName, const dictionary &dict, const objectRegistry *obrPtr=nullptr)
Construct from entry name and "file" found in dictionary.
Definition: TableFile.C:35
Foam::Function1Types::TableBase
Base class for table with bounds handling, interpolation and integration.
Definition: TableBase.H:60
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56