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