FoamTableReader.C
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-2024 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 "FoamTableReader.H"
27 #include "tokenTupleN.H"
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 template<class Type>
33 (
34  ISstream& is,
35  List<Tuple2<scalar, Type>>& data
36 ) const
37 {
38  List<tokenTupleN> dataStr(is);
39 
40  data.resize(dataStr.size());
41 
42  for (label i = 0; i < dataStr.size(); ++ i)
43  {
44  data[i].first() = dataStr[i].get<scalar>(is, columns_.first());
45  data[i].second() = dataStr[i].get<Type>(is, columns_.second());
46  }
47 }
48 
49 
50 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
51 
52 template<class Type>
54 (
55  const word& name,
57  const dictionary& dict
58 )
59 :
60  TableFileReader<Type>(units, dict),
61  columns_(dict.lookupOrDefault<labelPair>("columns", labelPair(0, 1)))
62 {}
63 
64 
65 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
66 
67 template<class Type>
69 {}
70 
71 
72 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
73 
74 template<class Type>
76 (
77  Ostream& os,
79  const List<Tuple2<scalar, Type>>& table,
80  const word&
81 ) const
82 {
84 
85  writeEntry(os, "columns", columns_);
86 }
87 
88 
89 // ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Base class to read table data for tables.
virtual void write(Ostream &os, const Function1s::unitConversions &units, const List< Tuple2< scalar, Type >> &table, const word &valuesKeyword=word::null) const
Write additional information.
Reads an interpolation table from a file in OpenFOAM-format. This is a list of Tuples in which comple...
virtual void write(Ostream &os, const Function1s::unitConversions &units, const List< Tuple2< scalar, Type >> &table, const word &valuesKeyword=word::null) const
Write settings and values.
Foam(const word &name, const Function1s::unitConversions &units, const dictionary &dict)
Construct from name and dictionary.
virtual ~Foam()
Destructor.
A 2-tuple for storing two objects of different types.
Definition: Tuple2.H:66
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A class for handling words, derived from string.
Definition: word.H:62
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
const HashTable< unitConversion > & units()
Get the table of unit conversions.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
dictionary dict