Skip to content

Commit 02da4b6

Browse files
Merge pull request #2057 from su2code/feature_new_flamelet
Feature new flamelet: partial premixed flamelet-generated manifold simulations are enabled through these features.
2 parents 8f5d770 + 74b893a commit 02da4b6

32 files changed

Lines changed: 852 additions & 413 deletions

File tree

Common/include/CConfig.hpp

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,7 @@ class CConfig {
909909
Tke_FreeStreamND, /*!< \brief Farfield kinetic energy (external flow). */
910910
Omega_FreeStreamND, /*!< \brief Specific dissipation (external flow). */
911911
Omega_FreeStream; /*!< \brief Specific dissipation (external flow). */
912+
bool Variable_Density; /*!< \brief Variable density for incompressible flow. */
912913
unsigned short nElectric_Constant; /*!< \brief Number of different electric constants. */
913914
su2double *Electric_Constant; /*!< \brief Dielectric constant modulus. */
914915
su2double Knowles_B, /*!< \brief Knowles material model constant B. */
@@ -1229,9 +1230,10 @@ class CConfig {
12291230
unsigned short n_user_sources = 0; /*!< \brief Number of source terms for user defined (auxiliary) scalar transport equations. */
12301231
unsigned short n_control_vars = 0; /*!< \brief Number of controlling variables (independent variables) for the LUT. */
12311232

1233+
string* controlling_variable_names;
1234+
string* cv_source_names;
12321235
vector<string> table_scalar_names; /*!< \brief Names of transported scalar variables. */
1233-
string* table_lookup_names; /*!< \brief Names of LUT variables. */
1234-
string file_name_lut; /*!< \brief Filename of the LUT. */
1236+
string* lookup_names; /*!< \brief Names of passive look-up variables. */
12351237
string* user_scalar_names; /*!< \brief Names of the user defined (auxiliary) transported scalars .*/
12361238
string* user_source_names; /*!< \brief Names of the source terms for the user defined transported scalars. */
12371239

@@ -2151,6 +2153,19 @@ class CConfig {
21512153
*/
21522154
unsigned short GetNUserScalars() const { return n_user_scalars; }
21532155

2156+
/*!
2157+
* \brief Get the name of a specific controlling variable.
2158+
*/
2159+
const string& GetControllingVariableName(unsigned short i_cv) const {
2160+
return controlling_variable_names[i_cv];
2161+
}
2162+
2163+
/*!
2164+
* \brief Get the name of the source term variable for a specific controlling variable.
2165+
*/
2166+
const string& GetControllingVariableSourceName(unsigned short i_cv) const {
2167+
return cv_source_names[i_cv];
2168+
}
21542169
/*!
21552170
* \brief Get the name of the user scalar.
21562171
*/
@@ -2175,13 +2190,7 @@ class CConfig {
21752190
/*!
21762191
* \brief Get the name of the variable that we want to retrieve from the lookup table.
21772192
*/
2178-
const string& GetLUTLookupName(unsigned short i_lookup) const { return table_lookup_names[i_lookup]; }
2179-
2180-
/*!
2181-
* \brief Get the file name of the look up table.
2182-
* \return File name of the look up table.
2183-
*/
2184-
const string& GetFileNameLUT() const { return file_name_lut; }
2193+
const string& GetLookupName(unsigned short i_lookup) const { return lookup_names[i_lookup]; }
21852194

21862195
/*!
21872196
* \brief Get the Young's modulus of elasticity.
@@ -3884,6 +3893,12 @@ class CConfig {
38843893
*/
38853894
INC_DENSITYMODEL GetKind_DensityModel() const { return Kind_DensityModel; }
38863895

3896+
/*!
3897+
* \brief Selection of variable density option for incompressible flows.
3898+
* \return Flag for variable density for incompressible flows.
3899+
*/
3900+
bool GetVariable_Density_Model() const { return Variable_Density; }
3901+
38873902
/*!
38883903
* \brief Flag for whether to solve the energy equation for incompressible flows.
38893904
* \return Flag for energy equation

Common/include/containers/CLookUpTable.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ class CLookUpTable {
7676
*/
7777
su2vector<su2activematrix> table_data;
7878

79+
double memory_footprint_data = 0; /*!< \brief Memory footprint of the loaded table data. */
80+
7981
/*! \brief
8082
* Holds all connectivity data stored in the table for each level. First index
8183
* addresses the variable while second index addresses the point.
@@ -216,7 +218,7 @@ class CLookUpTable {
216218
*/
217219
void Linear_Interpolation(const su2double val_CV3, const unsigned long lower_level, const unsigned long upper_level,
218220
std::vector<su2double>& lower_values, std::vector<su2double>& upper_values,
219-
std::vector<su2double*>& var_vals) const;
221+
std::vector<su2double>& var_vals) const;
220222

221223
/*!
222224
* \brief Find the point on the hull (boundary of the table) that is closest to the point P(val_CV1,val_CV2).
@@ -345,7 +347,7 @@ class CLookUpTable {
345347
* \param[in] val_CV3 - Value of controlling variable 3.
346348
* \returns 1 if the lookup and subsequent interpolation was a success, 0 if not.
347349
*/
348-
unsigned long LookUp_XYZ(const std::vector<std::string>& val_names_var, std::vector<su2double*>& val_vars,
350+
unsigned long LookUp_XYZ(const std::vector<std::string>& val_names_var, std::vector<su2double>& val_vars,
349351
su2double val_CV1, su2double val_CV2, su2double val_CV3 = 0);
350352

351353
/*!

Common/include/containers/CTrapezoidalMap.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ class CTrapezoidalMap {
5454
* same band. Used to sort the edges */
5555
su2vector<std::vector<std::pair<su2double, unsigned long> > > y_edge_at_band_mid;
5656

57+
double memory_footprint = 0;
58+
5759
public:
5860
CTrapezoidalMap() = default;
5961

6062
CTrapezoidalMap(const su2double* samples_x, const su2double* samples_y, const unsigned long size,
6163
const std::vector<std::array<unsigned long, 2> >& edges,
62-
const su2vector<std::vector<unsigned long> >& edge_to_triangle);
64+
const su2vector<std::vector<unsigned long> >& edge_to_triangle, bool display = false);
6365

6466
/*!
6567
* \brief return the index to the triangle that contains the coordinates (val_x,val_y)
@@ -97,4 +99,10 @@ class CTrapezoidalMap {
9799
inline bool IsInsideHullX(su2double val_x) {
98100
return (val_x >= unique_bands_x.front()) && (val_x <= unique_bands_x.back());
99101
}
102+
103+
/*!
104+
* \brief get memory footprint of trapezoidal map.
105+
* \return - memory footprint in mega bytes.
106+
*/
107+
double GetMemoryFootprint() const { return memory_footprint; }
100108
};

Common/include/option_structure.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,11 +628,13 @@ enum class INC_DENSITYMODEL {
628628
CONSTANT, /*!< \brief Constant density. */
629629
BOUSSINESQ, /*!< \brief Boussinesq density model. */
630630
VARIABLE, /*!< \brief Variable density model. */
631+
FLAMELET, /*!< \brief Density according to flamelet manifold. */
631632
};
632633
static const MapType<std::string, INC_DENSITYMODEL> DensityModel_Map = {
633634
MakePair("CONSTANT", INC_DENSITYMODEL::CONSTANT)
634635
MakePair("BOUSSINESQ", INC_DENSITYMODEL::BOUSSINESQ)
635636
MakePair("VARIABLE", INC_DENSITYMODEL::VARIABLE)
637+
MakePair("FLAMELET", INC_DENSITYMODEL::FLAMELET)
636638
};
637639

638640
/*!
@@ -1317,6 +1319,7 @@ static const MapType<std::string, SPECIES_MODEL> Species_Model_Map = {
13171319
enum FLAMELET_SCALAR_VARIABLES {
13181320
I_PROGVAR,
13191321
I_ENTH,
1322+
I_MIXFRAC,
13201323
};
13211324

13221325
/*!
@@ -1326,6 +1329,15 @@ enum FLAMELET_SCALAR_SOURCES {
13261329
I_SRC_TOT_PROGVAR
13271330
};
13281331

1332+
/*!
1333+
* \brief Look-up operations for the flamelet scalar solver.
1334+
*/
1335+
enum FLAMELET_LOOKUP_OPS {
1336+
TD, /*!< \brief Thermochemical properties (temperature, density, diffusivity, etc.). */
1337+
SOURCES, /*!< \brief Scalar source terms (controlling variables, passive species).*/
1338+
LOOKUP, /*!< \brief Passive look-up variables specified in config. */
1339+
};
1340+
13291341
/*!
13301342
* \brief Types of subgrid scale models
13311343
*/

Common/src/CConfig.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,11 +2101,14 @@ void CConfig::SetConfig_Options() {
21012101
/* DESCRIPTION: Determine if we need to allocate memory to store the multizone residual. \n DEFAULT: true (temporarily) */
21022102
addBoolOption("MULTIZONE_RESIDUAL", Multizone_Residual, false);
21032103

2104-
/*!\brief File name of the flamelet look up table.*/
2105-
addStringOption("FILENAME_LUT", file_name_lut, string("LUT"));
2104+
/* !\brief CONTROLLING_VARIABLE_NAMES \n DESCRIPTION: Names of the variables used as inputs for the data regression method in flamelet or data-driven fluid models. */
2105+
addStringListOption("CONTROLLING_VARIABLE_NAMES", n_control_vars, controlling_variable_names);
2106+
2107+
/* !\brief CONTROLLING_VARIABLE_SOURCE_NAMES \n DESCRIPTION: Names of the variables in the flamelet manifold corresponding to the source terms of the controlling variables. */
2108+
addStringListOption("CONTROLLING_VARIABLE_SOURCE_NAMES", n_control_vars, cv_source_names);
21062109

21072110
/* DESCRIPTION: Names of the passive lookup variables for flamelet LUT */
2108-
addStringListOption("LOOKUP_NAMES", n_lookups, table_lookup_names);
2111+
addStringListOption("LOOKUP_NAMES", n_lookups, lookup_names);
21092112

21102113
/* DESCRIPTION: Names of the user transport equations solved in the flamelet problem. */
21112114
addStringListOption("USER_SCALAR_NAMES", n_user_scalars, user_scalar_names);
@@ -3840,6 +3843,8 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
38403843
SetDefaultIfEmpty(Prandtl_Turb, nPrandtl_Turb, Prandtl_Turb_Default);
38413844
SetDefaultIfEmpty(Constant_Lewis_Number, nConstant_Lewis_Number, Lewis_Number_Default);
38423845

3846+
Variable_Density = ((Kind_DensityModel == INC_DENSITYMODEL::VARIABLE) || (Kind_DensityModel == INC_DENSITYMODEL::FLAMELET));
3847+
38433848
/*--- Check whether inputs for FLUID_MIXTURE are correctly specified. ---*/
38443849

38453850
if (Kind_FluidModel == FLUID_MIXTURE) {
@@ -3935,8 +3940,8 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
39353940
CURRENT_FUNCTION);
39363941
}
39373942

3938-
if (Kind_DensityModel != INC_DENSITYMODEL::VARIABLE) {
3939-
SU2_MPI::Error("The use of FLUID_FLAMELET requires the INC_DENSITY_MODEL option to be VARIABLE",
3943+
if (!Variable_Density) {
3944+
SU2_MPI::Error("The use of FLUID_FLAMELET requires the INC_DENSITY_MODEL option to be VARIABLE or FLAMELET",
39403945
CURRENT_FUNCTION);
39413946
}
39423947

@@ -5480,8 +5485,10 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
54805485

54815486
/*--- Define some variables for flamelet model. ---*/
54825487
if (Kind_Species_Model == SPECIES_MODEL::FLAMELET) {
5483-
/*--- The controlling variables are progress variable and total enthalpy ---*/
5484-
n_control_vars = 2;
5488+
/*--- The controlling variables are progress variable, total enthalpy, and optionally mixture fraction ---*/
5489+
//n_control_vars = nSpecies - n_user_scalars;
5490+
if (n_control_vars != (nSpecies - n_user_scalars))
5491+
SU2_MPI::Error("Number of initial species incompatbile with number of controlling variables and user scalars.", CURRENT_FUNCTION);
54855492
/*--- We can have additional user defined transported scalars ---*/
54865493
n_scalars = n_control_vars + n_user_scalars;
54875494
}

Common/src/containers/CLookUpTable.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,13 @@ CLookUpTable::CLookUpTable(const string& var_file_name_lut, string name_CV1_in,
7373
trap_map_x_y.resize(n_table_levels);
7474
su2double startTime = SU2_MPI::Wtime();
7575
unsigned short barwidth = 65;
76+
bool display_map_info = (n_table_levels < 2);
77+
double tmap_memory_footprint = 0;
7678
for (auto i_level = 0ul; i_level < n_table_levels; i_level++) {
77-
trap_map_x_y[i_level] = CTrapezoidalMap(GetDataP(name_CV1, i_level), GetDataP(name_CV2, i_level),
78-
table_data[i_level].cols(), edges[i_level], edge_to_triangle[i_level]);
79+
trap_map_x_y[i_level] =
80+
CTrapezoidalMap(GetDataP(name_CV1, i_level), GetDataP(name_CV2, i_level), table_data[i_level].cols(),
81+
edges[i_level], edge_to_triangle[i_level], display_map_info);
82+
tmap_memory_footprint += trap_map_x_y[i_level].GetMemoryFootprint();
7983
/* Display a progress bar to monitor table generation process */
8084
if (rank == MASTER_NODE) {
8185
su2double progress = su2double(i_level) / n_table_levels;
@@ -100,6 +104,8 @@ CLookUpTable::CLookUpTable(const string& var_file_name_lut, string name_CV1_in,
100104
default:
101105
break;
102106
}
107+
cout << "Trapezoidal map memory footprint: " << tmap_memory_footprint << " MB\n";
108+
cout << "Table data memory footprint: " << memory_footprint_data << " MB\n" << endl;
103109
}
104110

105111
ComputeInterpCoeffs();
@@ -133,7 +139,9 @@ void CLookUpTable::LoadTableRaw(const string& var_file_name_lut) {
133139
table_data[i_level] = file_reader.GetTableData(i_level);
134140
triangles[i_level] = file_reader.GetTriangles(i_level);
135141
hull[i_level] = file_reader.GetHull(i_level);
142+
memory_footprint_data += n_points[i_level] * sizeof(su2double);
136143
}
144+
memory_footprint_data /= 1e6;
137145

138146
n_variables = file_reader.GetNVariables();
139147
version_lut = file_reader.GetVersionLUT();
@@ -164,7 +172,7 @@ void CLookUpTable::FindTableLimits(const string& name_cv1, const string& name_cv
164172
}
165173

166174
if (table_dim == 3) {
167-
limits_table_z = minmax_element(z_values_levels.data(), z_values_levels.data() + z_values_levels.cols());
175+
limits_table_z = minmax_element(z_values_levels.data(), z_values_levels.data() + z_values_levels.size());
168176
}
169177
}
170178

@@ -451,7 +459,7 @@ unsigned long CLookUpTable::LookUp_XYZ(const std::string& val_name_var, su2doubl
451459
return 1;
452460
}
453461
}
454-
unsigned long CLookUpTable::LookUp_XYZ(const std::vector<std::string>& val_names_var, std::vector<su2double*>& val_vars,
462+
unsigned long CLookUpTable::LookUp_XYZ(const std::vector<std::string>& val_names_var, std::vector<su2double>& val_vars,
455463
su2double val_CV1, su2double val_CV2, su2double val_CV3) {
456464
/*--- Perform quasi-3D interpolation for a vector of variables with names val_names_var
457465
on a query point with coordinates val_CV1, val_CV2, and val_CV3 ---*/
@@ -509,7 +517,7 @@ void CLookUpTable::Linear_Interpolation(const su2double val_CV3, const unsigned
509517

510518
void CLookUpTable::Linear_Interpolation(const su2double val_CV3, const unsigned long lower_level,
511519
const unsigned long upper_level, std::vector<su2double>& lower_values,
512-
std::vector<su2double>& upper_values, std::vector<su2double*>& var_vals) const {
520+
std::vector<su2double>& upper_values, std::vector<su2double>& var_vals) const {
513521
/* Perform linear interpolation along the z-direction of the table for multiple variables */
514522

515523
/* Retrieve constant z-values of inclusion levels */
@@ -522,7 +530,7 @@ void CLookUpTable::Linear_Interpolation(const su2double val_CV3, const unsigned
522530

523531
/* Perform linear interpolation */
524532
for (size_t iVar = 0; iVar < var_vals.size(); iVar++) {
525-
*var_vals[iVar] = lower_values[iVar] * factor_lower + upper_values[iVar] * factor_upper;
533+
var_vals[iVar] = lower_values[iVar] * factor_lower + upper_values[iVar] * factor_upper;
526534
}
527535
}
528536

Common/src/containers/CTrapezoidalMap.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ using namespace std;
4040
*/
4141
CTrapezoidalMap::CTrapezoidalMap(const su2double* samples_x, const su2double* samples_y, const unsigned long size,
4242
vector<std::array<unsigned long, 2> > const& edges,
43-
su2vector<vector<unsigned long> > const& val_edge_to_triangle) {
43+
su2vector<vector<unsigned long> > const& val_edge_to_triangle, bool display) {
4444
int rank = SU2_MPI::GetRank();
4545
su2double startTime = SU2_MPI::Wtime();
4646

@@ -148,11 +148,11 @@ CTrapezoidalMap::CTrapezoidalMap(const su2double* samples_x, const su2double* sa
148148
for (unsigned long j_y = 0; j_y < y_edge_at_band_mid[i_y].size(); j_y++)
149149
size_y_edge_at_band_mid += sizeof(su2double) / 1e6 + sizeof(unsigned long) / 1e6;
150150

151-
double size_total =
151+
memory_footprint =
152152
size_unique_bands + size_edge_limits_x + size_edge_limits_y + size_edge_to_triangle + size_y_edge_at_band_mid;
153153

154154
/* print size of trapezoidal map components to screen */
155-
if (rank == MASTER_NODE) {
155+
if ((rank == MASTER_NODE) && display) {
156156
cout << setfill(' ');
157157
cout << "\n" << endl;
158158
cout << "+------------------------------------------------------------------+\n";
@@ -171,7 +171,7 @@ CTrapezoidalMap::CTrapezoidalMap(const su2double* samples_x, const su2double* sa
171171
<< " |" << endl;
172172
cout << "| Size of y_edge_at_band_mid in memory: " << setw(22) << size_y_edge_at_band_mid << " MB "
173173
<< " |" << endl;
174-
cout << "| Total: " << setw(22) << size_total << " MB "
174+
cout << "| Total: " << setw(22) << memory_footprint << " MB "
175175
<< " |" << endl;
176176
cout << "+------------------------------------------------------------------+" << endl;
177177
cout << "\n" << endl;
@@ -198,9 +198,14 @@ unsigned long CTrapezoidalMap::GetTriangle(su2double val_x, su2double val_y) {
198198
sort(triangles_edge_up.begin(), triangles_edge_up.end());
199199

200200
/* The intersection of the faces to which upper or lower belongs is the face that both belong to. */
201-
vector<unsigned long> triangle(1);
201+
vector<unsigned long> triangle;
202202
set_intersection(triangles_edge_up.begin(), triangles_edge_up.end(), triangles_edge_low.begin(),
203-
triangles_edge_low.end(), triangle.begin());
203+
triangles_edge_low.end(), std::back_inserter(triangle));
204+
205+
/*--- We failed to find an intersection, so take the lower triangle inside the band enclosing the point---*/
206+
if (triangle.size() < 1) {
207+
triangle.resize(1, triangles_edge_low[0]);
208+
}
204209

205210
return triangle[0];
206211
}

SU2_CFD/include/fluid/CDataDrivenFluid.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class CDataDrivenFluid final : public CFluidModel {
210210
* \brief Get fluid model extrapolation instance.
211211
* \return Query point lies outside fluid model data range.
212212
*/
213-
unsigned long GetExtrapolation() override { return outside_dataset; }
213+
unsigned long GetExtrapolation() const override { return outside_dataset; }
214214

215215
/*!
216216
* \brief Get number of Newton solver iterations.

0 commit comments

Comments
 (0)