EmbeddedTableReader.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) 2020-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 "EmbeddedTableReader.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class Type>
32 :
33  TableReader<Type>()
34 {}
35 
36 
37 template<class Type>
39 (
40  const word& name,
42  const dictionary& dict
43 )
44 :
45  TableReader<Type>()
46 {}
47 
48 
49 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
50 
51 template<class Type>
53 {}
54 
55 
56 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
57 
58 template<class Type>
61 (
62  const Function1s::unitConversions& defaultUnits,
63  const dictionary& dict
64 ) const
65 {
66  Function1s::unitConversions units(defaultUnits);
67  units.readIfPresent("units", dict);
68  return TableReader<Type>::convertRead(units, dict.lookup("values"));
69 }
70 
71 
72 template<class Type>
75 (
77  Istream& is
78 )
79 {
81 }
82 
83 
84 template<class Type>
86 (
87  Ostream& os,
89  const List<Tuple2<scalar, Type>>& table
90 ) const
91 {
92  TableReader<Type>::write(os, units, table);
93 
94  writeEntry(os, "values", TableReader<Type>::convertWrite(units, table));
95 }
96 
97 
98 // ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
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
Macros for creating standard TableReader-s.
Definition: TableReader.H:51
void convertRead(const Function1s::unitConversions &units, List< Tuple2< scalar, Type >> &table) const
Do unit conversions on input data.
Definition: TableReader.C:32
virtual void write(Ostream &os, const Function1s::unitConversions &units, const List< Tuple2< scalar, Type >> &table) const
Write settings and values.
Definition: TableReader.C:97
virtual ~Embedded()
Destructor.
virtual void write(Ostream &os, const Function1s::unitConversions &units, const List< Tuple2< scalar, Type >> &table) const
Write settings and values.
virtual List< Tuple2< scalar, Type > > read(const Function1s::unitConversions &units, const dictionary &dict) const
Read values.
A 2-tuple for storing two objects of different types.
Definition: Tuple2.H:66
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
A class for handling words, derived from string.
Definition: word.H:62
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
const HashTable< unitConversion > & units()
Get the table of unit conversions.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
dictionary dict