csvTableReader.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-2016 OpenFOAM Foundation
9 Copyright (C) 2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::csvTableReader
29
30Description
31 Reads an interpolation table from a file - CSV-format
32
33SourceFiles
34 tableReader.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef csvTableReader_H
39#define csvTableReader_H
40
41#include "tableReader.H"
42#include "labelList.H"
43
44// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46namespace Foam
47{
48
49/*---------------------------------------------------------------------------*\
50 Class csvTableReader Declaration
51\*---------------------------------------------------------------------------*/
52
53template<class Type>
55:
56 public tableReader<Type>
57{
58 // Private Data
59
60 //- Does the file have a header line?
61 const bool headerLine_;
62
63 //- Column for reference (lookup) value
64 const label refColumn_;
65
66 //- Labels of the components
67 const labelList componentColumns_;
68
69 //- Separator character
70 const char separator_;
71
72
73 // Private Member Functions
74
75 //- Get component columns entry
76 static labelList getComponentColumns
77 (
78 const word& name,
79 std::initializer_list<std::pair<const char*,int>> compat,
80 const dictionary& dict
81 );
82
83 //- Read component values from the split string
84 Type readValue(const List<string>& strings) const;
85
86
87public:
88
89 //- Declare type-name, virtual type (with debug switch)
90 TypeName("csv");
91
92
93 // Constructors
94
95 //- Construct from dictionary
97
98 //- Construct and return a copy
99 virtual autoPtr<tableReader<Type>> clone() const
100 {
102 (
104 (
105 *this
106 )
107 );
108 }
109
110
111 //- Destructor
112 virtual ~csvTableReader() = default;
113
114
115 // Member Functions
116
117 //- Read 1D table
118 virtual void operator()
119 (
120 const fileName& fName,
122 );
123
124 //- Read 2D table - NotImplemented
125 virtual void operator()
126 (
127 const fileName& fName,
129 );
130
131 //- Write the remaining parameters
132 virtual void write(Ostream& os) const;
133};
134
135
136// Template specialisations
137template<>
138label csvTableReader<label>::readValue(const List<string>& strings) const;
139
140template<>
141scalar csvTableReader<scalar>::readValue(const List<string>& strings) const;
142
143
144// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145
146} // End namespace Foam
147
148// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149
150#ifdef NoRepository
151 #include "csvTableReader.C"
152#endif
153
154// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155
156#endif
157
158// ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Reads an interpolation table from a file - CSV-format.
virtual autoPtr< tableReader< Type > > clone() const
Construct and return a copy.
virtual ~csvTableReader()=default
Destructor.
TypeName("csv")
Declare type-name, virtual type (with debug switch)
Database for solution data, solver performance and other reduced data.
Definition: data.H:58
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A class for handling file names.
Definition: fileName.H:76
Base class to read table data for the interpolationTable.
Definition: tableReader.H:61
A class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
runTime write()
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73