-
Notifications
You must be signed in to change notification settings - Fork 989
Expand file tree
/
Copy pathCFileReaderLUT.hpp
More file actions
152 lines (127 loc) · 5.33 KB
/
Copy pathCFileReaderLUT.hpp
File metadata and controls
152 lines (127 loc) · 5.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*!
* \file CFileReaderLUT.hpp
* \brief reading lookup table for tabulated fluid properties
* \author D. Mayer, T. Economon
* \version 8.3.0 "Harrier"
*
* SU2 Project Website: https://su2code.github.io
*
* The SU2 Project is maintained by the SU2 Foundation
* (http://su2foundation.org)
*
* Copyright 2012-2025, SU2 Contributors (cf. AUTHORS.md)
*
* SU2 is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* SU2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with SU2. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <fstream>
#include <string>
#include <vector>
#include "../../Common/include/parallelization/mpi_structure.hpp"
#include "../../../Common/include/linear_algebra/blas_structure.hpp"
#include "../../../Common/include/toolboxes/CSquareMatrixCM.hpp"
/*!
* \brief File reader for look up tables.
* \ingroup LookUpInterp
*/
class CFileReaderLUT {
protected:
int rank;
unsigned short table_dim = 2;
std::string version_lut;
std::string version_reader;
unsigned long n_levels = 1;
su2vector<unsigned long> n_points, n_triangles, n_hull_points;
unsigned long n_variables;
su2vector<su2double> table_levels;
/*! \brief Holds the variable names stored in the table file.
* Order is in sync with tableFlamelet.
*/
su2vector<std::string> names_var;
/*! \brief Holds all data stored in the table.
* First index addresses the variable while second index addresses the point.
*/
su2vector<su2activematrix> table_data;
su2vector<su2matrix<unsigned long>> triangles;
su2vector<su2vector<unsigned long>> hull;
/*! \brief Searches for the position of flag in file_stream and
* sets the stream position of file_stream to that position.
*/
void SkipToFlag(std::ifstream& file_stream, const std::string& current_line, const std::string& flag) const;
/*! \brief Extracts the next non-empty characters from file_stream and stores them into line.
*/
bool GetNextNonEmptyLine(std::ifstream& file_stream, std::string& line) const;
/*! \brief Extracts characters from file_stream, removes trailing control characters,
* and stores them into line.
*/
bool GetStrippedLine(std::ifstream& file_stream, std::string& line) const;
public:
/*! \brief Get table version as listed in input file.
*/
inline const std::string& GetVersionLUT() const { return version_lut; }
/*! \brief Get table reader version.
*/
inline const std::string& GetVersionReader() const { return version_reader; }
/*! \brief Get number of data points at specific table level.
* \param[in] i_level - table level index.
* \returns data point count at table level.
*/
inline unsigned long GetNPoints(std::size_t i_level = 0) const { return n_points[i_level]; }
/*! \brief Get number of triangles at specific table level.
* \param[in] i_level - table level index.
* \returns triangle count at table level.
*/
inline unsigned long GetNTriangles(std::size_t i_level = 0) const { return n_triangles[i_level]; }
/*! \brief Get number of hull points at specific table level.
* \param[in] i_level - table level index.
* \returns hull point count at table level.
*/
inline unsigned long GetNHullPoints(std::size_t i_level = 0) const { return n_hull_points[i_level]; }
/*! \brief Get number of variables for which data is stored in the table
*/
inline unsigned long GetNVariables() const { return n_variables; }
/*! \brief Get number of table levels.
*/
inline unsigned long GetNLevels() const { return n_levels; }
/*! \brief Get variable names for which data is stored in the table
*/
inline const su2vector<std::string>& GetNamesVar() const { return names_var; }
/*! \brief Get table data at a specific level.
* \param[in] i_level - table level index.
* \returns table data
*/
inline const su2activematrix& GetTableData(std::size_t i_level = 0) const { return table_data[i_level]; }
/*! \brief Get table connectivity at a specific level.
* \param[in] i_level - table level index.
* \returns data connectivity
*/
inline const su2matrix<unsigned long>& GetTriangles(std::size_t i_level = 0) const { return triangles[i_level]; }
/*! \brief Get hull node information at a specific table level.
* \param[in] i_level - table level index.
* \returns hull node indices.
*/
inline const su2vector<unsigned long>& GetHull(std::size_t i_level = 0) const { return hull[i_level]; }
/*! \brief Get table level value.
* \param[in] i_level - table level index.
* \returns value of the third controlling variable at table level.
*/
inline su2double GetTableLevel(std::size_t i_level) const { return table_levels[i_level]; }
/*! \brief Get table dimension
*/
inline unsigned short GetTableDim() const { return table_dim; }
/*! \brief Read LUT file and store information
* \param[in] file_name - LUT input file name.
*/
void ReadRawLUT(const std::string& file_name);
};