TableReader.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 "TableReader.H"
27 
28 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
29 
30 template<class Type>
32 (
35 ) const
36 {
37  forAll(table, i)
38  {
39  table[i].first() = units.x.toStandard(table[i].first());
40  table[i].second() = units.value.toStandard(table[i].second());
41  }
42 }
43 
44 
45 template<class Type>
48 (
50  const List<Tuple2<scalar, Type>>& table
51 ) const
52 {
53  List<Tuple2<scalar, Type>> tableCopy(table);
54  convertRead(units, tableCopy);
55  return tableCopy;
56 }
57 
58 
59 template<class Type>
62 (
64  const List<Tuple2<scalar, Type>>& table
65 ) const
66 {
67  List<Tuple2<scalar, Type>> tableCopy(table);
68 
69  forAll(tableCopy, i)
70  {
71  tableCopy[i].first() = units.x.toUser(tableCopy[i].first());
72  tableCopy[i].second() = units.value.toUser(tableCopy[i].second());
73  }
74 
75  return tableCopy;
76 }
77 
78 
79 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
80 
81 template<class Type>
83 {}
84 
85 
86 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
87 
88 template<class Type>
90 {}
91 
92 
93 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
94 
95 template<class Type>
97 (
98  Ostream& os,
100  const List<Tuple2<scalar, Type>>& table
101 ) const
102 {}
103 
104 
105 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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
TableReader()
Default construct.
Definition: TableReader.C:82
virtual ~TableReader()
Destructor.
Definition: TableReader.C:89
List< Tuple2< scalar, Type > > convertWrite(const Function1s::unitConversions &units, const List< Tuple2< scalar, Type >> &table) const
Do unit conversions in order to output data.
Definition: TableReader.C:62
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
A 2-tuple for storing two objects of different types.
Definition: Tuple2.H:66
T & first()
Return the first element of the list.
Definition: UListI.H:114
labelList second(const UList< labelPair > &p)
Definition: patchToPatch.C:49
labelList first(const UList< labelPair > &p)
Definition: patchToPatch.C:39
const HashTable< unitConversion > & units()
Get the table of unit conversions.