Documentation 6b54b78464
Loading...
Searching...
No Matches
COutput.hpp
Go to the documentation of this file.
1/*!
2 * \file COutput.hpp
3 * \brief Headers of the output class.
4 * \author T.Albring
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
28#pragma once
29
30#include <fstream>
31#include <cmath>
32#include <map>
33#include <sstream>
34#include <iomanip>
35#include <limits>
36#include <vector>
37
38#include "../../../Common/include/toolboxes/printing_toolbox.hpp"
40#include "../../../Common/include/option_structure.hpp"
41#include "CTurboOutput.hpp"
42
43/*--- AD workaround for a cmath function not defined in CoDi. ---*/
44namespace mel {
45namespace internal {
46inline su2double hypot(const su2double& a, const su2double& b) {
47 return sqrt(a*a + b*b);
48}
49}
50}
51#include "mel.hpp"
52
53class CGeometry;
54class CSolver;
55class CFileWriter;
57class CConfig;
58class CHeatOutput;
59class CAdjHeatOutput;
60
61using namespace std;
62
63/*!
64 * \brief Class for writing the convergence history and to write solution data to file.
65 * \author T.Albring
66 * \ingroup Output
67 */
68class COutput {
69protected:
70 friend class CHeatOutput;
71 friend class CAdjHeatOutput;
72
73 /*----------------------------- General ----------------------------*/
74
75 const int rank; /*!< \brief MPI Rank. */
76 const int size; /*!< \brief MPI Size. */
77
78 const unsigned short nDim; /*!< \brief Physical Dimension */
79
80 const bool multiZone; /*!< \brief Boolean to store whether we are running a multizone problem */
81 const bool gridMovement; /*!< \brief Boolean to store whether we have grid movement enabled */
82 const bool femOutput; /*!< \brief Boolean to store whether we should use the FEM routines */
83 const bool si_units;
84 const bool us_units;
85
86 /*----------------------------- Screen and history output ----------------------------*/
87
88 const unsigned short fieldWidth = 12; /*!< \brief Width of each column for the screen output (hardcoded for now) */
89 string historySep; /*!< \brief Character which separates values in the history file */
90 bool noWriting; /*!< \brief Boolean indicating whether a screen/history output should be written */
91 unsigned long curTimeIter, /*!< \brief Current value of the time iteration index */
92 curAbsTimeIter, /*!< \brief Current value of the time iteration index */
93 curOuterIter, /*!< \brief Current value of the outer iteration index */
94 curInnerIter; /*!< \brief Current value of the inner iteration index */
95
96 su2double PrevStopTime; /*!< \brief Previous stop time for iteration timing. */
97
98 string historyFilename; /*!< \brief The history filename*/
99 ofstream histFile; /*!< \brief Output file stream for the history */
100
101 bool cauchyTimeConverged; /*! \brief: Flag indicating that solver is already converged. Needed for writing restart files. */
102 bool maxTimeDelayActive; /*! \brief: Flag for delaying stop at max_time with 2nd order time stepping. */
103
104 /** \brief Enum to identify the screen output format. */
106 INTEGER, /*!< \brief Integer format. Example: 34 */
107 FIXED, /*!< \brief Format with fixed precision for floating point values. Example: 344.54 */
108 SCIENTIFIC, /*!< \brief Scientific format for floating point values. Example: 3.4454E02 */
109 PERCENT /*!< \brief Format with fixed precision for floating point values with a % signs. Example: 99.52% */
110 };
111
112 /** \brief Enum to identify the screen/history field type. */
113 enum class HistoryFieldType {
114 RESIDUAL, /*!< \brief A user-defined residual field type*/
115 AUTO_RESIDUAL, /*!< \brief An automatically generated residual field type */
116 COEFFICIENT, /*!< \brief User defined coefficient field type */
117 AUTO_COEFFICIENT, /*!< \brief Automatically generated coefficient field type */
118 DEFAULT /*!< \brief Default field type */
119 };
120
121 /** \brief Structure to store information for a history output field.
122 *
123 * The stored information is printed to the history file and to screen.
124 * Each individual instance represents a single field (i.e. column) in the history file or on screen.
125 */
127 /*! \brief The name of the field, i.e. the name that is printed in the screen or file header.*/
128 string fieldName = "";
129 /*! \brief The value of the field. */
131 /*! \brief The format that is used to print this value to screen. */
133 /*! \brief The group this field belongs to. */
134 string outputGroup ="";
135 /*! \brief The field type*/
137 /*! \brief String containing the description of the field */
138 string description = "";
139 /*! \brief Default constructor. */
141 /*! \brief Constructor to initialize all members. */
142 HistoryOutputField(string fieldName_, ScreenOutputFormat screenFormat_, string OutputGroup_,
143 HistoryFieldType fieldType_, string description_):
144 fieldName(std::move(fieldName_)), value(0.0), screenFormat(screenFormat_),
145 outputGroup(std::move(OutputGroup_)), fieldType(fieldType_), description(std::move(description_)){}
146 };
147
148 /*! \brief Associative map to access data stored in the history output fields by a string identifier. */
149 std::map<string, HistoryOutputField > historyOutput_Map;
150 /*! \brief Vector that contains the keys of the ::historyOutput_Map in the order of their insertion. */
151 std::vector<string> historyOutput_List;
152 /*! \brief Associative map to access data stored in the history per surface output fields by a string identifier. */
153 std::map<string, vector<HistoryOutputField> > historyOutputPerSurface_Map;
154 /*! \brief Vector that contains the keys of the ::historyOutputPerSurface_Map in the order of their insertion. */
155 std::vector<string> historyOutputPerSurface_List;
156
157 /*! \brief Requested history field names in the config file. */
158 std::vector<string> requestedHistoryFields;
159 /*! \brief Number of requested history field names in the config file. */
161 /*! \brief Requested screen field names in the config file. */
162 std::vector<string> requestedScreenFields;
163 /*! \brief Number of requested screen field names in the config file. */
165
166 /*! \brief Caches to avoid hashing the output maps to retrieve field values. */
167 std::vector<const su2double*> requestedHistoryFieldCache;
168 std::vector<const HistoryOutputField*> requestedScreenFieldCache;
169
170 PrintingToolbox::CTablePrinter* convergenceTable; //!< Convergence output table structure
171 PrintingToolbox::CTablePrinter* multiZoneHeaderTable; //!< Multizone header output structure
172 PrintingToolbox::CTablePrinter* historyFileTable; //!< Table structure for writing to history file
174 std::string multiZoneHeaderString; //!< Multizone header string
175 bool headerNeeded; //!< Boolean that stores whether a screen header is needed
176
177 //! Structure to store the value of the running averages
178 map<string, CWindowedAverage> windowedTimeAverages;
179
180 //! Structure to store the value initial residuals for relative residual computation
181 std::map<string, su2double> initialResiduals;
182
183 /*! \brief Struct to hold a parsed user-defined expression. */
185 mel::ExpressionTree<passivedouble> expression;
186 /*--- Pointers to values in the history output maps, to avoid key lookup every time. ---*/
187 std::vector<const su2double*> symbolValues;
188 bool ready = false;
189
190 su2double Eval() const {
191 return mel::Eval<su2double>(expression, [&](int i) {return *symbolValues[i];});
192 }
193 };
194
195 CustomHistoryOutput customObjFunc; /*!< \brief User-defined expression for a custom objective. */
196
197 /*! \brief Type of operation for custom outputs. */
199
200 /*! \brief Struct to hold a parsed custom output function. */
202 /*--- First level of parsing the syntax "name : type{func}[markers];". ---*/
203 std::string name;
205 std::string func;
206 std::vector<std::string> markers;
207
208 /*--- Second level, func into expression, and acceleration structures. ---*/
209 mel::ExpressionTree<passivedouble> expression;
210 std::vector<std::string> varSymbols;
211 std::vector<unsigned short> markerIndices;
212 static constexpr long PROBE_NOT_SETUP = -2;
213 static constexpr long PROBE_NOT_OWNED = -1;
215
216 /*--- The symbols (strings) are associated with an integer index for efficiency. For evaluation this index
217 is passed to a functor that returns the value associated with the symbol. This functor is an input to "eval()"
218 and needs to be generated on-the-fly for each point. The functor approach is more generic than a pointer, for
219 example it allows wrapping the access to multiple solvers. The interpretation of these indices is dictated by
220 the functor used in eval, for example indices may be established as 32 * solver_idx + variable_idx.
221 The parts of the code that assign and interpret indices need to be in sync. ---*/
222 std::vector<unsigned long> varIndices;
223
224 /*--- Offset between varIndices of different solvers (see above). Power of 2 to make decoding faster. ---*/
225 static constexpr unsigned long MAX_VARS_PER_SOLVER = 32;
226
227 /*--- Arbitrary number to indicate that a string did not match a variable. ---*/
228 static constexpr unsigned long NOT_A_VARIABLE = MAX_SOLS * MAX_VARS_PER_SOLVER;
229
230 /*--- Other outputs can be referenced in expressions, e.g. to compute variance.
231 We store pointers to the required outputs to speed-up access. ---*/
232 std::vector<const su2double*> otherOutputs;
233
234 /*--- For discrete adjoint we may need to skip some expressions because there is one output class
235 for the primal solver and one for the discrete adjoint (each with different variables). ---*/
236 bool skip = false;
237
238 /*--- For evaluation, "vars" is a functor (i.e. has operator()) that returns the value of a variable at a given
239 point. For example, it can be a wrapper to the primitives pointer, in which case varIndices needs to be setup
240 with primitive indices. ---*/
241 template <class Variables>
242 su2double Eval(const Variables& vars) const {
243 return mel::Eval<su2double>(expression, [&](int iSymbol) {return vars(varIndices[iSymbol]);});
244 }
245 };
246
247 std::vector<CustomOutput> customOutputs; /*!< \brief User-defined outputs. */
248
249 /*----------------------------- Volume output ----------------------------*/
250
251 CParallelDataSorter* volumeDataSorter; //!< Volume data sorter.
252 CParallelDataSorter* volumeDataSorterCompact; //!< Volume data sorter for compact files.
253 CParallelDataSorter* surfaceDataSorter; //!< Surface data sorter.
254
255 vector<string> volumeFieldNames; //!< Vector containing the volume field names.
256 vector<string> requiredVolumeFieldNames; //!< Vector containing the minimum required volume field names.
257
258 string volumeFilename, //!< Volume output filename.
259 surfaceFilename, //!< Surface output filename.
260 restartFilename; //!< Restart output filename.
261
262 /** \brief Structure to store information for a volume output field.
263 *
264 * The stored information is used to create the volume solution file.
265 */
267 /*! \brief The name of the field, i.e. the name that is printed in the file header.*/
268 string fieldName;
269 /*! \brief This value identifies the position of the values of this field at each node in the ::Local_Data array. */
270 short offset = -1;
271 /*! \brief This offset is used for the compact formulation. */
272 short offsetCompact = -1;
273 /*! \brief The group this field belongs to. */
275 /*! \brief String containing the description of the field. */
277 /*! \brief Default constructor. */
278 VolumeOutputField() = default;
279 /*! \brief Constructor to initialize all members. */
280 VolumeOutputField(string fieldName_, string volumeOutputGroup_, string description_):
281 fieldName(std::move(fieldName_)),
282 outputGroup(std::move(volumeOutputGroup_)),
283 description(std::move(description_)) {}
284 };
285
286 /*! \brief Associative map to access data stored in the volume output fields by a string identifier. */
287 std::map<string, VolumeOutputField > volumeOutput_Map;
288 /*! \brief Vector that contains the keys of the ::volumeOutput_Map in the order of their insertion. */
289 std::vector<string> volumeOutput_List;
290
291 /*! \brief Whether the field index caches should be build. */
293
294 /*! \brief Vectors to cache the positions of the fields in the data array. */
296 /*! \brief Current value of the cache indices. */
297 unsigned short cachePosition;
298
299 /*! \brief Vector to cache the positions of the field in the data array. */
300 std::vector<short> fieldGetIndexCache;
301 /*! \brief Current value of the cache index. */
302 unsigned short curGetFieldIndex;
303
304 /*! \brief Requested volume field names in the config file. */
305 std::vector<string> requestedVolumeFields;
306 /*! \brief Number of requested volume field names in the config file. */
308
309 /*! \brief Minimum required volume fields for restart file. */
310 const std::vector<string> restartVolumeFields = {"COORDINATES", "SOLUTION", "SENSITIVITY", "GRID_VELOCITY"};
311
312 /*----------------------------- Convergence monitoring ----------------------------*/
313
314 su2double cauchyValue, /*!< \brief Summed value of the convergence indicator. */
315 cauchyFunc; /*!< \brief Current value of the convergence indicator at one iteration. */
316 unsigned short Cauchy_Counter; /*!< \brief Number of elements of the Cauchy serial. */
317 vector<vector<su2double> > cauchySerie; /*!< \brief Complete Cauchy serial. */
318 unsigned long nCauchy_Elems; /*!< \brief Total number of cauchy elems to monitor */
319 su2double cauchyEps; /*!< \brief Defines the threshold when to stop the solver. */
320 su2double minLogResidual; /*!< \brief Minimum value of the residual to reach */
321 vector<su2double> oldFunc, /*!< \brief Old value of the coefficient. */
322 newFunc; /*!< \brief Current value of the coefficient. */
323 bool convergence; /*!< \brief To indicate if the solver has converged or not. */
324 bool convergenceInterrupted; /*!< \brief To indicate that the exit was forced by an interrupt signal instead of the convergence criteria. */
325 su2double initResidual; /*!< \brief Initial value of the residual to evaluate the convergence level. */
326 vector<string> convFields; /*!< \brief Name of the field to be monitored for convergence. */
327 unsigned long convergenceStartIter = 0; /*!< \brief Iteration the convergence history is counted from. */
328
329 /*----------------------------- Adaptive CFL ----------------------------*/
330
331 su2double rhoResNew, /*!< New value of the residual for adaptive CFL routine. */
332 rhoResOld; /*!< Old value of the residual for adaptive CFL routine. */
333
334 /*----------------------------- Time Convergence monitoring ----------------------------*/
335 vector<string> wndConvFields; /*!< \brief Name of the field to be monitored for convergence. */
336 vector<vector<su2double> > WndCauchy_Serie; /*!< \brief Complete Cauchy serial. */
337 unsigned long nWndCauchy_Elems; /*!< \brief Total number of cauchy elems to monitor */
338 su2double wndCauchyEps; /*!< \brief Defines the threshold when to stop the solver. */
339
340 vector<su2double> WndOld_Func; /*!< \brief Old value of the objective function (the function which is monitored). */
341 vector<su2double> WndNew_Func; /*!< \brief Current value of the objective function (the function which is monitored). */
342 su2double WndCauchy_Func; /*!< \brief Current value of the convergence indicator at one iteration. */
343 su2double WndCauchy_Value; /*!< \brief Summed value of the convergence indicator. */
344 bool TimeConvergence; /*!< \brief To indicate, if the windowed time average of the time loop has converged*/
345
346public:
347 /*----------------------------- Public member functions ----------------------------*/
348
349 /*!
350 * \brief Constructor of the class.
351 */
352 COutput(const CConfig *config, unsigned short nDim, bool femOutput);
353
354 /*!
355 * \brief Preprocess the volume output by setting the requested volume output fields.
356 * \param[in] config - Definition of the particular problem.
357 */
358 void PreprocessVolumeOutput(CConfig *config);
359
360 /*!
361 * \brief Load the data from the solvers into the data sorters and sort it for the linear partitioning.
362 *
363 * \param[in] geometry - Geometrical definition of the problem.
364 * \param[in] config - Definition of the particular problem.
365 * \param[in] solver_container - The container holding all solution data.
366 */
367 void LoadData(CGeometry *geometry, CConfig *config, CSolver **solver_container);
368
369 /*!
370 * \brief Preprocess the history output by setting the history fields and opening the history file.
371 * \param[in] config - Definition of the particular problem.
372 * \param[in] wrt - If <TRUE> prepares history file for writing.
373 */
374 void PreprocessHistoryOutput(CConfig *config, bool wrt = true);
375
376 /*!
377 * \brief Preprocess the history output by setting the history fields and opening the history file.
378 * \param[in] output - Container holding the output instances per zone.
379 * \param[in] config - Definition of the particular problem per zone.
380 * \param[in] driver_config - Base definition of the particular problem.
381 * \param[in] wrt - If <TRUE> prepares history file for writing.
382 */
383 void PreprocessMultizoneHistoryOutput(COutput **output, CConfig **config, CConfig *driver_config, bool wrt = true);
384
385 /*!
386 * \brief Collects history data from the solvers, monitors the convergence and writes to screen and history file.
387 * \param[in] geometry - Geometrical definition of the problem.
388 * \param[in] solver_container - Container vector with all the solutions.
389 * \param[in] config - Definition of the particular problem.
390 * \param[in] TimeIter - Value of the time iteration index
391 * \param[in] OuterIter - Value of outer iteration index
392 * \param[in] InnerIter - Value of the inner iteration index
393 */
394 void SetHistoryOutput(CGeometry *geometry, CSolver **solver_container, CConfig *config,
395 unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter);
396 /*!
397 * \brief Collects history data from the solvers and monitors the convergence. Does not write to screen or file.
398 * \param[in] geometry - Geometrical definition of the problem.
399 * \param[in] solver_container - Container vector with all the solutions.
400 * \param[in] config - Definition of the particular problem.
401 */
402 void SetHistoryOutput(CGeometry *geometry, CSolver **solver_container, CConfig *config);
403
404 /*!
405 * \brief Collects history data from the solvers, monitors the convergence and writes to screen and history file.
406 * \param[in] geometry - Geometrical definition of the problem.
407 * \param[in] solver_container - Container vector with all the solutions.
408 * \param[in] config - Definition of the particular problem.
409 * \param[in] TimeIter - Value of the time iteration index
410 * \param[in] OuterIter - Value of outer iteration index
411 * \param[in] InnerIter - Value of the inner iteration index
412 * \param[in] val_iInst - Index of the instance layer
413 */
414 void SetHistoryOutput(CGeometry ****geometry, CSolver *****solver_container, CConfig **config,
415 std::shared_ptr<CTurbomachineryStagePerformance> TurboStagePerf,
416 su2vector<std::shared_ptr<CTurboOutput>> TurboBladePerfs, unsigned short val_iZone,
417 unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter, unsigned short val_iInst);
418
419 /*!
420 * Collects history data from the individual output per zone,
421 * monitors the convergence and writes to screen and history file.
422 * \param[in] output - Container holding the output instances per zone.
423 * \param[in] config - Definition of the particular problem per zone.
424 * \param[in] driver_config - Base definition of the particular problem.
425 * \param[in] TimeIter - Value of the time iteration index
426 * \param[in] OuterIter - Value of outer iteration index
427 */
428 void SetMultizoneHistoryOutput(COutput** output, CConfig **config, CConfig *driver_config,
429 unsigned long TimeIter, unsigned long OuterIter);
430
431 /*!
432 * \brief Evaluates objective functions in the (multiphysics) discrete adjoint solver.
433 * \note Uses the same subroutines for objective function evaluation as SetHistoryOutput, but omits unnecessary evaluations (e.g. residuals, convergence data) to avoid AD complications.
434 * \param[in] geometry - Geometrical definition of the problem.
435 * \param[in] solver_container - Container vector with all the solutions.
436 * \param[in] config - Definition of the particular problem.
437 */
438 void SetObjectiveFunctionValues(CGeometry *geometry, CSolver **solver_container, CConfig *config);
439
440 /*!
441 * \brief Sets the volume output filename
442 * \param[in] filename - the new filename
443 */
444 inline void SetVolumeFilename(string filename) {volumeFilename = filename;}
445
446 /*!
447 * \brief Sets the surface output filename
448 * \param[in] filename - the new filename
449 */
450 inline void SetSurfaceFilename(string filename) {surfaceFilename = filename;}
451
452 /*!
453 * \brief Returns the current volume filename
454 * \return - The current volume filename
455 */
456 inline string GetVolumeFilename() {return volumeFilename;}
457
458 /*!
459 * \brief Returns the current surface filename
460 * \return - The current surface filename
461 */
462 inline string GetSurfaceFilename() {return surfaceFilename;}
463
464 /*!
465 * \brief Sets the restart filename
466 * \param[in] filename - the new filename
467 */
468 inline void SetRestartFilename(string filename) {restartFilename = filename;}
469
470 /*!
471 * \brief Returns the current restart filename
472 * \return - The current restart filename
473 */
474 inline string GetRestartFilename() {return restartFilename;}
475
476 /*!
477 * \brief Set the current iteration indices
478 * \param[in] TimeIter - Timer iteration index
479 * \param[in] OuterIter - Outer iteration index
480 * \param[in] InnerIter - Inner iteration index
481 */
482 inline void SetIteration(unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter){
483 curTimeIter = TimeIter;
484 curOuterIter = OuterIter;
485 curInnerIter = InnerIter;
486 }
487
488 /*!
489 * \brief Get the value of particular history output field
490 * \param[in] field - Name of the field
491 * \return Value of the field
492 */
493 su2double GetHistoryFieldValue(const string& name) const {
494 auto it = historyOutput_Map.find(name);
495 if (it != historyOutput_Map.end()) return it->second.value;
496 SU2_MPI::Error("Cannot find output field with name " + name, CURRENT_FUNCTION);
497 return 0;
498 }
499
500 /*!
501 * \brief Discard the convergence history and count it from the given iteration instead.
502 * \param[in] Iteration - Iteration the history restarts from.
503 */
504 void ResetConvergenceMonitoring(unsigned long Iteration) { convergenceStartIter = Iteration; }
505
506 /*!
507 * \brief Names and values of the fields convergence is monitored on that are residuals.
508 * \return Name and current value of every monitored residual field, in CONV_FIELD order.
509 */
510 vector<pair<string, passivedouble>> GetResidualConvFields() const {
511 vector<pair<string, passivedouble>> fields;
512 for (const auto& name : convFields) {
513 const auto it = historyOutput_Map.find(name);
514 if (it == historyOutput_Map.end()) continue;
515 if ((it->second.fieldType != HistoryFieldType::RESIDUAL) &&
516 (it->second.fieldType != HistoryFieldType::AUTO_RESIDUAL)) continue;
517 fields.emplace_back(name, SU2_TYPE::GetValue(it->second.value));
518 }
519 return fields;
520 }
521
522 /*!
523 * \brief Get the value of particular surface history output field
524 * \param[in] field - Name of the field
525 * \param[in] iMarker - Index of the surface marker
526 * \return Value of the field
527 */
528 su2double GetHistoryFieldValuePerSurface(const string& name, unsigned short iMarker) const {
529 auto it = historyOutputPerSurface_Map.find(name);
530 if (it != historyOutputPerSurface_Map.end()) return it->second[iMarker].value;
531 SU2_MPI::Error("Cannot find output field with name " + name, CURRENT_FUNCTION);
532 return 0;
533 }
534
535 /*!
536 * \brief Get a vector with all output fields in a particular group
537 * \param groupname - Name of the history group
538 * \return Vector containing all output fields of a group
539 */
540 vector<HistoryOutputField> GetHistoryGroup(string groupname){
541 vector<HistoryOutputField> HistoryGroup;
542 for (unsigned short iField = 0; iField < historyOutput_Map.size(); iField++){
543 if (historyOutput_Map.at(historyOutput_List[iField]).outputGroup == groupname){
544 HistoryGroup.push_back((historyOutput_Map[historyOutput_List[iField]]));
545 }
546 }
547 return HistoryGroup;
548 }
549
550 /*!
551 * \brief Get the list of all output fields
552 * \return Vector container all output fields
553 */
554 const vector<string>& GetHistoryOutputList() const {
555 return historyOutput_List;
556 }
557
558 /*!
559 * \brief Get the list of all per-surface fields
560 * \return Vector container all output per-surface fields
561 */
562 const vector<string>& GetHistoryOutputPerSurfaceList() const {
564 }
565
566 /*!
567 * \brief Get the map containing all output fields
568 * \return Map containing all output fields
569 */
570 const map<string, HistoryOutputField>& GetHistoryFields() const {
571 return historyOutput_Map;
572 }
573
574 /*!
575 * \brief Get the map containing all output per-surface fields
576 * \return Map containing all output per-surface fields
577 */
578 const map<string, vector<HistoryOutputField>>& GetHistoryPerSurfaceFields() const {
580 }
581
582 /*!
583 * \brief Monitor the convergence of an output field
584 * \param[in] config - Definition of the particular problem.
585 * \param[in] Iteration - Index of the current iteration.
586 * \return Boolean indicating whether the problem is converged.
587 */
588 bool ConvergenceMonitoring(CConfig *config, unsigned long Iteration);
589
590 /*!
591 * \brief Print a summary of the convergence to screen.
592 */
594
595 /*!
596 * \brief Get convergence of the problem.
597 * \return Boolean indicating whether the problem is converged.
598 */
599 bool GetConvergence() const {return convergence;}
600
601 /*!
602 * \brief Get whether the exit was forced by an interrupt signal (e.g. SIGTERM) instead of the convergence criteria.
603 * \return Boolean indicating whether an interrupt signal forced the exit.
604 */
606
607 /*!
608 * \brief Set the value of the convergence flag.
609 * \param[in] conv - New value of the convergence flag.
610 */
611 void SetConvergence(const bool conv) {convergence = conv;}
612
613 /*!
614 * \brief Monitor the time convergence of the specified windowed-time-averaged ouput
615 * \param[in] config - Definition of the particular problem.
616 * \param[in] Iteration - Index of the current iteration.
617 * \return Boolean indicating whether the problem is converged.
618 */
619 bool MonitorTimeConvergence(CConfig *config, unsigned long Iteration);
620
621 /*!
622 * \brief Print a list of all history output fields to screen.
623 */
624 void PrintHistoryFields() const;
625
626 /*!
627 * \brief Print a list of all volume output fields to screen.
628 */
629 void PrintVolumeFields();
630
631 /*!
632 * \brief Loop through all requested output files and write the volume output data.
633 * \param[in] geometry - Geometrical definition of the problem.
634 * \param[in] config - Definition of the particular problem.
635 * \param[in] solver_container - Container vector with all the solutions.
636 * \param[in] iter - The current time, outer or inner iteration index.
637 * \param[in] force_writing - If <TRUE>, writing of output files is forced without checking the output frequency.
638 * \return <TRUE> if output files have been written to disk.
639 */
640 bool SetResultFiles(CGeometry *geometry, CConfig *config, CSolver** solver_container,
641 unsigned long iter, bool force_writing = false);
642
643 /*!
644 * \brief Get convergence time convergence of the specified windowed-time-averaged ouput of the problem.
645 * Delays solver stop, if Cauchy time convergence criterion is fullfilled, but 2nd order
646 * time marching is active, to ensure that enough restart files are written.
647 * \param[in] config - Definition of the particular problem.
648 * \return <TRUE> if Solver has converged and has run another iteration.
649 */
650 bool GetCauchyCorrectedTimeConvergence(const CConfig *config);
651
652 /*!
653 * \brief Allocates the appropriate file writer based on the chosen format and writes sorted data to file.
654 * \param[in] config - Definition of the particular problem.
655 * \param[in] geometry - Geometrical definition of the problem.
656 * \param[in] format - The output format.
657 * \param[in] fileName - The file name. If empty, the filenames are automatically determined.
658 */
659 void WriteToFile(CConfig *config, CGeometry *geometry, OUTPUT_TYPE format, string fileName = "");
660
661protected:
662
663 /*----------------------------- Protected member functions ----------------------------*/
664
665 /*!
666 * \brief Set the history file header
667 * \param[in] config - Definition of the particular problem.
668 */
669 void SetHistoryFileHeader(const CConfig *config);
670
671 /*!
672 * \brief Write the history file output
673 * \param[in] config - Definition of the particular problem.
674 */
675 void SetHistoryFileOutput(const CConfig *config);
676
677 /*!
678 * \brief Write the screen header.
679 * \param[in] config - Definition of the particular problem.
680 */
681 void SetScreenHeader(const CConfig *config);
682
683 /*!
684 * \brief Write the screen output.
685 * \param[in] config - Definition of the particular problem.
686 */
687 void SetScreenOutput(const CConfig *config);
688
689 /*!
690 * \brief Add a new field to the history output.
691 * \param[in] name - Name for referencing it (in the config file and in the code).
692 * \param[in] field_name - Header that is printed on screen and in the history file.
693 * \param[in] format - The screen printing format (::ScreenOutputFormat).
694 * \param[in] groupname - The name of the group this field belongs to.
695 * \param[in] description - A description of the field.
696 * \param[in] field_type - The type of the field (::HistoryFieldType).
697 */
698 inline void AddHistoryOutput(string name, string field_name, ScreenOutputFormat format,
699 string groupname, string description,
701 historyOutput_Map[name] = HistoryOutputField(field_name, format, groupname, field_type, description);
702 historyOutput_List.push_back(name);
703 }
704
705 /*!
706 * \brief Set the value of a history output field
707 * \param[in] name - Name of the field.
708 * \param[in] value - The new value of this field.
709 */
710 inline void SetHistoryOutputValue(string name, su2double value){
711 auto it = historyOutput_Map.find(name);
712 if (it != historyOutput_Map.end()){
713 it->second.value = value;
714 } else {
715 SU2_MPI::Error("Cannot find output field with name " + name, CURRENT_FUNCTION);
716 }
717 }
718
719 /*!
720 * \brief Add a new field per surface marker to the history output.
721 * \param[in] name - Name for referencing it (in the config file and in the code).
722 * \param[in] field_name - Header that is printed on screen and in the history file.
723 * \param[in] format - The screen printing format (::ScreenOutputFormat).
724 * \param[in] groupname - The name of the group this field belongs to.
725 * \param[in] marker_names - A list of markers. For every marker in this list a new field is created with "field_name + _marker_names[i]".
726 * \param[in] field_type - The type of the field (::HistoryFieldType).
727 */
728 inline void AddHistoryOutputPerSurface(string name, string field_name, ScreenOutputFormat format,
729 string groupname, const vector<string>& marker_names,
731 if (!marker_names.empty()) {
732 historyOutputPerSurface_List.push_back(name);
733 vector<HistoryOutputField> fields;
734 fields.reserve(marker_names.size());
735 for (const auto& marker : marker_names) {
736 fields.push_back(HistoryOutputField(field_name+"("+marker+")", format, groupname, field_type, ""));
737 }
738 historyOutputPerSurface_Map[name] = std::move(fields);
739 }
740 }
741
742 /*!
743 * \brief Set the value of a history output field for a specific surface marker
744 * \param[in] name - Name of the field.
745 * \param[in] value - The new value of this field.
746 * \param[in] iMarker - The index of the marker.
747 */
748 inline void SetHistoryOutputPerSurfaceValue(string name, su2double value, unsigned short iMarker) {
749 auto it = historyOutputPerSurface_Map.find(name);
750 if (it != historyOutputPerSurface_Map.end()) {
751 it->second[iMarker].value = value;
752 } else {
753 SU2_MPI::Error("Cannot find output field with name " + name, CURRENT_FUNCTION);
754 }
755 }
756
757 /*!
758 * \brief Returns a pointer to the value of an history output.
759 * \note For per-surface outputs the marker index is specified as "name[index]".
760 */
761 inline const su2double* GetPtrToHistoryOutput(const string& name) const {
762 /*--- Decide if it should be per surface. ---*/
763 const auto pos = name.find('[');
764 const su2double* ptr = nullptr;
765 if (pos == std::string::npos) {
766 const auto it = historyOutput_Map.find(name);
767 if (it != historyOutput_Map.end()) {
768 ptr = &(it->second.value);
769 }
770 } else {
771 const auto idx = std::stoi(std::string(name.begin()+pos+1, name.end()-1));
772 const auto it = historyOutputPerSurface_Map.find(std::string(name, 0, pos));
773 if (it != historyOutputPerSurface_Map.end()) {
774 ptr = &(it->second[idx].value);
775 }
776 }
777 return ptr;
778 }
779
780 /*!
781 * \brief Setup a custom history output object for a given expression.
782 * \param[in] expression - Some user-defined math with the history field names as variables.
783 * \param[out] output - Custom output ready to evaluate.
784 */
785 void SetupCustomHistoryOutput(const string& expression, CustomHistoryOutput& output) const;
786
787 /*!
788 * \brief Add a new field to the volume output.
789 * \param[in] name - Name for referencing it (in the config file and in the code).
790 * \param[in] field_name - Header that is printed in the output files.
791 * \param[in] groupname - The name of the group this field belongs to.
792 * \param[in] description - Description of the volume field.
793 */
794 inline void AddVolumeOutput(const string& name, const string& field_name,
795 const string& group_name, const string& description) {
796 volumeOutput_Map[name] = VolumeOutputField(field_name, group_name, description);
797 volumeOutput_List.push_back(name);
798 }
799
800 /*!
801 * \brief Set the value of a volume output field
802 * \param[in] name - Name of the field.
803 * \param[in] iPoint - The point location in the field.
804 */
805 su2double GetVolumeOutputValue(const string& name, unsigned long iPoint);
806
807 /*!
808 * \brief Set the value of a volume output field
809 * \param[in] name - Name of the field.
810 * \param[in] iPoint - The point location in the field.
811 * \param[in] value - The new value of this field.
812 */
813 void SetVolumeOutputValue(const string& name, unsigned long iPoint, su2double value);
814
815 /*!
816 * \brief Set the value of a volume output field
817 * \param[in] name - Name of the field.
818 * \param[in] iPoint - The point location in the field.
819 * \param[in] value - The new value of this field.
820 */
821 void SetAvgVolumeOutputValue(const string& name, unsigned long iPoint, su2double value);
822
823 /*!
824 * \brief CheckHistoryOutput
825 */
826 void CheckHistoryOutput(unsigned short nZone);
827
828 /*!
829 * \brief Check that the Full-MG startup has a criterion left to promote the active level on.
830 * \param[in] config - Definition of the particular problem.
831 */
832 void CheckFullMG_Startup(const CConfig *config) const;
833
834 /*!
835 * \brief Open the history file and write the header.
836 * \param[in] config - Definition of the particular problem.
837 */
838 void PrepareHistoryFile(CConfig *config);
839
840 /*!
841 * \brief Load up the values of the requested volume fields into ::Local_Data array.
842 * \param[in] config - Definition of the particular problem.
843 * \param[in] geometry - Geometrical definition of the problem.
844 * \param[in] solver_container - The container holding all solution data.
845 */
846 void LoadDataIntoSorter(CConfig* config, CGeometry* geometry, CSolver** solver);
847
848 /*!
849 * \brief Postprocess_HistoryData
850 * \param[in] config - Definition of the particular problem.
851 */
852 void PostprocessHistoryData(CConfig *config);
853
854 /*!
855 * \brief Postprocess_HistoryFields
856 * \param[in] config - Definition of the particular problem.
857 */
858 void PostprocessHistoryFields(CConfig *config);
859
860 /*!
861 * \brief Check whether we should print output.
862 * \param[in] iIter - Current iteration.
863 * \param[in] iFreq - Frequency of output printing.
864 */
865 inline bool PrintOutput(unsigned long iIter, unsigned long iFreq) {
866 if (iFreq == 0){
867 return false;
868 }
869
870 return (iIter % iFreq == 0);
871 }
872
873 /*!
874 * \brief Write screen and history output.
875 * \param[in] config - Definition of the particular problem.
876 */
877 void OutputScreenAndHistory(CConfig *config);
878
879 /*!
880 * \brief Set the history fields common for all solvers.
881 */
883
884 /*!
885 * \brief Request the history fields common for all solvers.
886 */
887 void RequestCommonHistory(bool dynamic);
888
889 /*!
890 * \brief Parses user-defined outputs.
891 */
892 void SetCustomOutputs(const CConfig *config);
893
894 /*!
895 * \brief Evaluates function-type custom outputs.
896 * Derived classes can use this to compute simple expressions of other outputs if they
897 * do not implement surface averages. This should be called just before evaluating the
898 * custom objective function.
899 */
900 void ComputeSimpleCustomOutputs(const CConfig *config);
901
902 /*!
903 * \brief Load values of the history fields common for all solvers.
904 * \param[in] config - Definition of the particular problem.
905 */
906 void LoadCommonHistoryData(const CConfig *config);
907
908 /*!
909 * \brief Allocates the data sorters if necessary.
910 * \param[in] config - Definition of the particular problem.
911 * \param[in] geometry - Geometrical definition of the problem.
912 */
913 void AllocateDataSorters(CConfig *config, CGeometry *geometry);
914
915 /*!
916 * \brief Computes the custom and combo objectives.
917 * \note To be called after all other history outputs are set.
918 * \param[in] idxSol - Index of the main solver.
919 * \param[in] config - Definition of the particular problem.
920 * \param[in] solver - The container holding all solution data.
921 */
922 void SetCustomAndComboObjectives(int idxSol, const CConfig *config, CSolver **solver);
923
924 /*--------------------------------- Virtual functions ---------------------------------------- */
925public:
926
927 /*!
928 * \brief Destructor of the class.
929 */
930 virtual ~COutput(void);
931
932protected:
933
934 /*!
935 * \brief Determines if the history file output.
936 * \param[in] config - Definition of the particular problem.
937 */
938 virtual bool WriteHistoryFileOutput(const CConfig *config);
939
940 /*!
941 * \brief Determines if the screen header should be written.
942 * \param[in] config - Definition of the particular problem.
943 */
944 virtual bool WriteScreenHeader(const CConfig *config);
945
946 /*!
947 * \brief Determines if the screen header should be written.
948 * \param[in] config - Definition of the particular problem.
949 */
950 virtual bool WriteScreenOutput(const CConfig *config);
951
952 /*!
953 * \brief Determines if the the volume output should be written.
954 * \param[in] config - Definition of the particular problem.
955 * \param[in] Iter - Current iteration index.
956 * \param[in] force_writing - boolean that forces writing of volume output
957 * \param[in] iFile - index to the file that we need to consider for volume output
958 */
959 virtual bool WriteVolumeOutput(CConfig *config, unsigned long Iter, bool force_writing, unsigned short iFile);
960
961 /*!
962 * \brief Set the values of the volume output fields for a point.
963 * \param[in] config - Definition of the particular problem.
964 * \param[in] geometry - Geometrical definition of the problem.
965 * \param[in] solver - The container holding all solution data.
966 * \param[in] iPoint - Index of the point.
967 */
968 inline virtual void LoadVolumeData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint){}
969
970 /*!
971 * \brief Set the values of the volume output fields for a point.
972 * \param[in] config - Definition of the particular problem.
973 * \param[in] geometry - Geometrical definition of the problem.
974 * \param[in] solver - The container holding all solution data.
975 * \param[in] iElem - Index of the element.
976 * \param[in] index - Index of the value.
977 * \param[in] dof - Index of the local degree of freedom.
978 */
979 inline virtual void LoadVolumeDataFEM(CConfig *config, CGeometry *geometry, CSolver **solver,
980 unsigned long iElem, unsigned long index, unsigned short dof){}
981
982 /*!
983 * \brief Check whether the base values for relative residuals should be initialized
984 * \param[in] config - Definition of the particular problem.
985 * \return <TRUE> if the residuals should be initialized.
986 */
987 inline virtual bool SetInitResiduals(const CConfig *config) {return false;}
988
989 /*!
990 * \brief Set the values of the volume output fields for a surface point.
991 * \param[in] config - Definition of the particular problem.
992 * \param[in] geometry - Geometrical definition of the problem.
993 * \param[in] solver - The container holding all solution data.
994 * \param[in] iPoint - Index of the point.
995 * \param[in] iMarker - Index of the surface marker.
996 * \param[in] iVertex - Index of the vertex on the marker.
997 */
998 inline virtual void LoadSurfaceData(CConfig *config, CGeometry *geometry, CSolver **solver,
999 unsigned long iPoint, unsigned short iMarker, unsigned long iVertex){}
1000
1001 /*!
1002 * \brief Set the available volume output fields
1003 * \param[in] config - Definition of the particular problem.
1004 */
1005 inline virtual void SetVolumeOutputFields(CConfig *config){}
1006
1007 /*!
1008 * \brief Load the history output field values
1009 * \param[in] config - Definition of the particular problem.
1010 * \param[in] geometry - Geometrical definition of the problem.
1011 * \param[in] solver - The container holding all solution data.
1012 */
1013 inline virtual void LoadHistoryData(CConfig *config, CGeometry *geometry, CSolver **solver) {}
1014
1015 /*!
1016 * \brief Recompute history output field values that can be used as objective functions in the (multiphysics) discrete adjoint solver.
1017 * \param[in] config - Definition of the particular problem.
1018 * \param[in] geometry - Geometrical definition of the problem.
1019 * \param[in] solver - The container holding all solution data.
1020 */
1021 inline virtual void LoadCustomAndComboObjectiveFunctions(CConfig *config, CGeometry *geometry, CSolver **solver) {
1022 /*--- Unless LoadCustomAndComboObjectiveFunctions is implemented in a derived output class, we use LoadHistoryData (not ideal for AD). ---*/
1023 LoadHistoryData(config, geometry, solver);
1024 }
1025
1026 /*!
1027 * \brief Load the multizone history output field values
1028 * \param[in] output - Container holding the output instances per zone.
1029 * \param[in] config - Definition of the particular problem.
1030 */
1031 inline virtual void LoadMultizoneHistoryData(const COutput* const* output, const CConfig* const* config) {}
1032
1033 /*!
1034 * \brief Sets the turboperformance screen output
1035 * \param[in] TurboPerf - Turboperformance class
1036 * \param[in] config - Definition of the particular problem
1037 * \param[in] TimeIter - Index of the current time-step
1038 * \param[in] OuterIter - Index of current outer iteration
1039 * \param[in] InnerIter - Index of current inner iteration
1040 */
1041 inline virtual void SetTurboPerformance_Output(su2vector<std::shared_ptr<CTurboOutput>> TurboBladePerfs, CConfig *config, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter) {}
1042
1043 /*!
1044 * \brief Sets the multizone turboperformacne screen output
1045 * \param[in] TurboStagePerf - Stage turboperformance class
1046 * \param[in] TurboPerf - Turboperformance class
1047 * \param[in] config - Definition of the particular problem
1048 */
1049 inline virtual void SetTurboMultiZonePerformance_Output(std::shared_ptr<CTurbomachineryStagePerformance> TurboStagePerf, su2vector<std::shared_ptr<CTurboOutput>> TurboPerf, CConfig *config) {}
1050
1051 /*!
1052 * \brief Loads the turboperformacne history data
1053 * \param[in] TurboStagePerf - Stage turboperformance class
1054 * \param[in] TurboPerf - Turboperformance class
1055 * \param[in] config - Definition of the particular problem
1056 */
1057 inline virtual void LoadTurboHistoryData(std::shared_ptr<CTurbomachineryStagePerformance> TurboStagePerf, su2vector<std::shared_ptr<CTurboOutput>> TurboPerf, CConfig *config) {}
1058
1059 /*!
1060 * \brief Write the kinematic and thermodynamic variables at each spanwise division
1061 * \param[in] solver - The container hold all solution data
1062 * \param[in] geometry - Geometrical definiton of the problem
1063 * \param[in] config - Descripiton of the particular problem
1064 * \param[in] val_iZone - Idientifier of current zone
1065 */
1066 inline virtual void WriteTurboSpanwisePerformance(su2vector<std::shared_ptr<CTurboOutput>> TurboBladePerfs, CGeometry *geometry, CConfig **config,
1067 unsigned short val_iZone) {};
1068
1069 /*!
1070 * \brief Set the available history output fields
1071 * \param[in] config - Definition of the particular problem.
1072 */
1073 inline virtual void SetHistoryOutputFields(CConfig *config) {}
1074
1075 /*!
1076 * \brief Set the available multizone history output fields
1077 * \param[in] output - Container holding the output instances per zone.
1078 */
1079 inline virtual void SetMultizoneHistoryOutputFields(const COutput* const* output, const CConfig* const* config) {}
1080
1081 /*!
1082 * \brief Write any additional files defined for the current solver.
1083 * \param[in] config - Definition of the particular problem per zone.
1084 * \param[in] geometry - Geometrical definition of the problem.
1085 * \param[in] solver_container - The container holding all solution data.
1086 */
1087 inline virtual void WriteAdditionalFiles(CConfig *config, CGeometry* geometry, CSolver** solver_container){}
1088
1089 /*!
1090 * \brief Write any additional output defined for the current solver.
1091 * \param[in] config - Definition of the particular problem per zone.
1092 */
1093 inline virtual void SetAdditionalScreenOutput(const CConfig *config){}
1094
1095};
Headers of the Turbomachinery Performance class.
A templated matrix/vector-like object.
Definition C2DContainer.hpp:374
Output class for adjoint heat output.
Definition CAdjHeatOutput.hpp:37
static void Error(const std::string &ErrorMsg, const std::string &FunctionName)
Definition mpi_structure.cpp:131
Main class for defining the problem; basically this class reads the configuration file,...
Definition CConfig.hpp:64
Definition CFileWriter.hpp:42
Parent class for defining the geometry of the problem (complete geometry, multigrid agglomerated geom...
Definition CGeometry.hpp:75
Output class for heat problems.
Definition CHeatOutput.hpp:38
Class for writing the convergence history and to write solution data to file.
Definition COutput.hpp:68
void SetAvgVolumeOutputValue(const string &name, unsigned long iPoint, su2double value)
Set the value of a volume output field.
Definition COutput.cpp:1866
virtual void LoadSurfaceData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint, unsigned short iMarker, unsigned long iVertex)
Set the values of the volume output fields for a surface point.
Definition COutput.hpp:998
ScreenOutputFormat
: Flag for delaying stop at max_time with 2nd order time stepping.
Definition COutput.hpp:105
@ INTEGER
Integer format. Example: 34.
@ PERCENT
Format with fixed precision for floating point values with a % signs. Example: 99....
@ SCIENTIFIC
Scientific format for floating point values. Example: 3.4454E02.
@ FIXED
Format with fixed precision for floating point values. Example: 344.54
unsigned short nRequestedScreenFields
Number of requested screen field names in the config file.
Definition COutput.hpp:164
const map< string, HistoryOutputField > & GetHistoryFields() const
Get the map containing all output fields.
Definition COutput.hpp:570
PrintingToolbox::CTablePrinter * fileWritingTable
File writing header.
Definition COutput.hpp:173
vector< su2double > oldFunc
Old value of the coefficient.
Definition COutput.hpp:321
vector< vector< su2double > > cauchySerie
Complete Cauchy serial.
Definition COutput.hpp:317
string historyFilename
The history filename.
Definition COutput.hpp:98
const int size
MPI Size.
Definition COutput.hpp:76
const std::vector< string > restartVolumeFields
Minimum required volume fields for restart file.
Definition COutput.hpp:310
bool SetResultFiles(CGeometry *geometry, CConfig *config, CSolver **solver_container, unsigned long iter, bool force_writing=false)
Loop through all requested output files and write the volume output data.
Definition COutput.cpp:870
virtual void LoadHistoryData(CConfig *config, CGeometry *geometry, CSolver **solver)
Load the history output field values.
Definition COutput.hpp:1013
unsigned short Cauchy_Counter
Number of elements of the Cauchy serial.
Definition COutput.hpp:316
unsigned short nRequestedVolumeFields
Number of requested volume field names in the config file.
Definition COutput.hpp:307
bool GetConvergenceInterrupted() const
Get whether the exit was forced by an interrupt signal (e.g. SIGTERM) instead of the convergence crit...
Definition COutput.hpp:605
void WriteToFile(CConfig *config, CGeometry *geometry, OUTPUT_TYPE format, string fileName="")
Allocates the appropriate file writer based on the chosen format and writes sorted data to file.
Definition COutput.cpp:379
su2double cauchyFunc
Current value of the convergence indicator at one iteration.
Definition COutput.hpp:315
void SetScreenHeader(const CConfig *config)
Write the screen header.
Definition COutput.cpp:1207
void SetSurfaceFilename(string filename)
Sets the surface output filename.
Definition COutput.hpp:450
virtual bool WriteHistoryFileOutput(const CConfig *config)
Determines if the history file output.
Definition COutput.cpp:2128
vector< string > wndConvFields
Name of the field to be monitored for convergence.
Definition COutput.hpp:335
void RequestCommonHistory(bool dynamic)
Request the history fields common for all solvers.
Definition COutput.cpp:2207
unsigned short nRequestedHistoryFields
Number of requested history field names in the config file.
Definition COutput.hpp:160
void SetHistoryOutputPerSurfaceValue(string name, su2double value, unsigned short iMarker)
Set the value of a history output field for a specific surface marker.
Definition COutput.hpp:748
void SetHistoryOutputValue(string name, su2double value)
Set the value of a history output field.
Definition COutput.hpp:710
void SetHistoryFileOutput(const CConfig *config)
Write the history file output.
Definition COutput.cpp:1175
CParallelDataSorter * volumeDataSorter
Volume data sorter.
Definition COutput.hpp:251
ofstream histFile
Output file stream for the history.
Definition COutput.hpp:99
void PrintVolumeFields()
Print a list of all volume output fields to screen.
Definition COutput.cpp:2528
void PrintHistoryFields() const
Print a list of all history output fields to screen.
Definition COutput.cpp:2413
unsigned long curInnerIter
Current value of the inner iteration index.
Definition COutput.hpp:94
virtual void LoadCustomAndComboObjectiveFunctions(CConfig *config, CGeometry *geometry, CSolver **solver)
Recompute history output field values that can be used as objective functions in the (multiphysics) d...
Definition COutput.hpp:1021
void CheckHistoryOutput(unsigned short nZone)
CheckHistoryOutput.
Definition COutput.cpp:1399
std::string multiZoneHeaderString
Multizone header string.
Definition COutput.hpp:174
virtual void LoadTurboHistoryData(std::shared_ptr< CTurbomachineryStagePerformance > TurboStagePerf, su2vector< std::shared_ptr< CTurboOutput > > TurboPerf, CConfig *config)
Loads the turboperformacne history data.
Definition COutput.hpp:1057
vector< string > volumeFieldNames
Vector containing the volume field names.
Definition COutput.hpp:255
virtual void SetMultizoneHistoryOutputFields(const COutput *const *output, const CConfig *const *config)
Set the available multizone history output fields.
Definition COutput.hpp:1079
su2double GetHistoryFieldValue(const string &name) const
Get the value of particular history output field.
Definition COutput.hpp:493
const unsigned short nDim
Physical Dimension.
Definition COutput.hpp:78
const su2double * GetPtrToHistoryOutput(const string &name) const
Returns a pointer to the value of an history output.
Definition COutput.hpp:761
virtual bool WriteScreenOutput(const CConfig *config)
Determines if the screen header should be written.
Definition COutput.cpp:2087
const bool femOutput
Boolean to store whether we should use the FEM routines.
Definition COutput.hpp:82
std::vector< string > requestedVolumeFields
Requested volume field names in the config file.
Definition COutput.hpp:305
void PrepareHistoryFile(CConfig *config)
Open the history file and write the header.
Definition COutput.cpp:1379
su2double GetVolumeOutputValue(const string &name, unsigned long iPoint)
Set the value of a volume output field.
Definition COutput.cpp:1834
virtual void LoadVolumeDataFEM(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iElem, unsigned long index, unsigned short dof)
Set the values of the volume output fields for a point.
Definition COutput.hpp:979
void PrintConvergenceSummary()
Print a summary of the convergence to screen.
Definition COutput.cpp:924
string volumeFilename
Volume output filename.
Definition COutput.hpp:258
void SetHistoryOutput(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter)
Collects history data from the solvers, monitors the convergence and writes to screen and history fil...
Definition COutput.cpp:192
void SetupCustomHistoryOutput(const string &expression, CustomHistoryOutput &output) const
Setup a custom history output object for a given expression.
Definition COutput.cpp:301
su2double WndCauchy_Func
Current value of the convergence indicator at one iteration.
Definition COutput.hpp:342
std::map< string, su2double > initialResiduals
Structure to store the value initial residuals for relative residual computation.
Definition COutput.hpp:181
unsigned long convergenceStartIter
Iteration the convergence history is counted from.
Definition COutput.hpp:327
vector< su2double > WndNew_Func
Current value of the objective function (the function which is monitored).
Definition COutput.hpp:341
const bool multiZone
Boolean to store whether we are running a multizone problem.
Definition COutput.hpp:80
const bool si_units
Definition COutput.hpp:83
void PreprocessVolumeOutput(CConfig *config)
Preprocess the volume output by setting the requested volume output fields.
Definition COutput.cpp:1625
su2double rhoResNew
Definition COutput.hpp:331
unsigned long curAbsTimeIter
Current value of the time iteration index.
Definition COutput.hpp:92
string GetVolumeFilename()
Returns the current volume filename.
Definition COutput.hpp:456
void SetObjectiveFunctionValues(CGeometry *geometry, CSolver **solver_container, CConfig *config)
Evaluates objective functions in the (multiphysics) discrete adjoint solver.
Definition COutput.cpp:235
const int rank
MPI Rank.
Definition COutput.hpp:75
unsigned short cachePosition
Current value of the cache indices.
Definition COutput.hpp:297
std::vector< string > volumeOutput_List
Vector that contains the keys of the volumeOutput_Map in the order of their insertion.
Definition COutput.hpp:289
void SetScreenOutput(const CConfig *config)
Write the screen output.
Definition COutput.cpp:1214
void SetVolumeOutputValue(const string &name, unsigned long iPoint, su2double value)
Set the value of a volume output field.
Definition COutput.cpp:1794
void SetHistoryFileHeader(const CConfig *config)
Set the history file header.
Definition COutput.cpp:1131
const bool us_units
Definition COutput.hpp:84
virtual bool SetInitResiduals(const CConfig *config)
Check whether the base values for relative residuals should be initialized.
Definition COutput.hpp:987
virtual ~COutput(void)
Destructor of the class.
Definition COutput.cpp:180
const bool gridMovement
Boolean to store whether we have grid movement enabled.
Definition COutput.hpp:81
void SetCustomOutputs(const CConfig *config)
Parses user-defined outputs.
Definition COutput.cpp:2214
void AllocateDataSorters(CConfig *config, CGeometry *geometry)
Allocates the data sorters if necessary.
Definition COutput.cpp:329
bool GetConvergence() const
Get convergence of the problem.
Definition COutput.hpp:599
std::map< string, vector< HistoryOutputField > > historyOutputPerSurface_Map
Associative map to access data stored in the history per surface output fields by a string identifier...
Definition COutput.hpp:153
virtual void LoadMultizoneHistoryData(const COutput *const *output, const CConfig *const *config)
Load the multizone history output field values.
Definition COutput.hpp:1031
string GetRestartFilename()
Returns the current restart filename.
Definition COutput.hpp:474
unsigned long nWndCauchy_Elems
Total number of cauchy elems to monitor.
Definition COutput.hpp:337
map< string, CWindowedAverage > windowedTimeAverages
Structure to store the value of the running averages.
Definition COutput.hpp:178
virtual void WriteAdditionalFiles(CConfig *config, CGeometry *geometry, CSolver **solver_container)
Write any additional files defined for the current solver.
Definition COutput.hpp:1087
void PreprocessMultizoneHistoryOutput(COutput **output, CConfig **config, CConfig *driver_config, bool wrt=true)
Preprocess the history output by setting the history fields and opening the history file.
Definition COutput.cpp:1307
PrintingToolbox::CTablePrinter * multiZoneHeaderTable
Multizone header output structure.
Definition COutput.hpp:171
vector< vector< su2double > > WndCauchy_Serie
Complete Cauchy serial.
Definition COutput.hpp:336
void SetHistoryOutput(CGeometry ****geometry, CSolver *****solver_container, CConfig **config, std::shared_ptr< CTurbomachineryStagePerformance > TurboStagePerf, su2vector< std::shared_ptr< CTurboOutput > > TurboBladePerfs, unsigned short val_iZone, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter, unsigned short val_iInst)
Collects history data from the solvers, monitors the convergence and writes to screen and history fil...
void LoadCommonHistoryData(const CConfig *config)
Load values of the history fields common for all solvers.
Definition COutput.cpp:2379
void CheckFullMG_Startup(const CConfig *config) const
Check that the Full-MG startup has a criterion left to promote the active level on.
Definition COutput.cpp:1354
virtual void SetTurboMultiZonePerformance_Output(std::shared_ptr< CTurbomachineryStagePerformance > TurboStagePerf, su2vector< std::shared_ptr< CTurboOutput > > TurboPerf, CConfig *config)
Sets the multizone turboperformacne screen output.
Definition COutput.hpp:1049
std::vector< string > requestedHistoryFields
Requested history field names in the config file.
Definition COutput.hpp:158
void PostprocessHistoryFields(CConfig *config)
Postprocess_HistoryFields.
Definition COutput.cpp:1958
su2double rhoResOld
Definition COutput.hpp:332
virtual void SetHistoryOutputFields(CConfig *config)
Set the available history output fields.
Definition COutput.hpp:1073
void ResetConvergenceMonitoring(unsigned long Iteration)
Discard the convergence history and count it from the given iteration instead.
Definition COutput.hpp:504
bool GetCauchyCorrectedTimeConvergence(const CConfig *config)
Get convergence time convergence of the specified windowed-time-averaged ouput of the problem....
Definition COutput.cpp:838
vector< string > requiredVolumeFieldNames
Vector containing the minimum required volume field names.
Definition COutput.hpp:256
string historySep
Character which separates values in the history file.
Definition COutput.hpp:89
su2double cauchyValue
Summed value of the convergence indicator.
Definition COutput.hpp:314
virtual void SetAdditionalScreenOutput(const CConfig *config)
Write any additional output defined for the current solver.
Definition COutput.hpp:1093
su2double minLogResidual
Minimum value of the residual to reach.
Definition COutput.hpp:320
unsigned long curOuterIter
Current value of the outer iteration index.
Definition COutput.hpp:93
void AddHistoryOutputPerSurface(string name, string field_name, ScreenOutputFormat format, string groupname, const vector< string > &marker_names, HistoryFieldType field_type=HistoryFieldType::DEFAULT)
Add a new field per surface marker to the history output.
Definition COutput.hpp:728
const vector< string > & GetHistoryOutputList() const
Get the list of all output fields.
Definition COutput.hpp:554
const vector< string > & GetHistoryOutputPerSurfaceList() const
Get the list of all per-surface fields.
Definition COutput.hpp:562
std::vector< CustomOutput > customOutputs
User-defined outputs.
Definition COutput.hpp:247
string restartFilename
Restart output filename.
Definition COutput.hpp:260
bool ConvergenceMonitoring(CConfig *config, unsigned long Iteration)
Monitor the convergence of an output field.
Definition COutput.cpp:955
void SetRestartFilename(string filename)
Sets the restart filename.
Definition COutput.hpp:468
const unsigned short fieldWidth
Width of each column for the screen output (hardcoded for now)
Definition COutput.hpp:88
su2double GetHistoryFieldValuePerSurface(const string &name, unsigned short iMarker) const
Get the value of particular surface history output field.
Definition COutput.hpp:528
virtual void WriteTurboSpanwisePerformance(su2vector< std::shared_ptr< CTurboOutput > > TurboBladePerfs, CGeometry *geometry, CConfig **config, unsigned short val_iZone)
Write the kinematic and thermodynamic variables at each spanwise division.
Definition COutput.hpp:1066
std::vector< short > fieldIndexCacheCompact
Definition COutput.hpp:295
vector< string > convFields
Name of the field to be monitored for convergence.
Definition COutput.hpp:326
void SetIteration(unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter)
Set the current iteration indices.
Definition COutput.hpp:482
HistoryFieldType
Enum to identify the screen/history field type.
Definition COutput.hpp:113
@ COEFFICIENT
User defined coefficient field type
@ AUTO_RESIDUAL
An automatically generated residual field type.
@ DEFAULT
Default field type.
@ AUTO_COEFFICIENT
Automatically generated coefficient field type
@ RESIDUAL
A user-defined residual field type.
bool convergence
To indicate if the solver has converged or not.
Definition COutput.hpp:323
std::map< string, VolumeOutputField > volumeOutput_Map
Associative map to access data stored in the volume output fields by a string identifier.
Definition COutput.hpp:287
su2double WndCauchy_Value
Summed value of the convergence indicator.
Definition COutput.hpp:343
su2double cauchyEps
Defines the threshold when to stop the solver.
Definition COutput.hpp:319
std::vector< short > fieldGetIndexCache
Vector to cache the positions of the field in the data array.
Definition COutput.hpp:300
void SetCommonHistoryFields()
Set the history fields common for all solvers.
Definition COutput.cpp:2179
std::vector< string > historyOutput_List
Vector that contains the keys of the historyOutput_Map in the order of their insertion.
Definition COutput.hpp:151
virtual bool WriteScreenHeader(const CConfig *config)
Determines if the screen header should be written.
Definition COutput.cpp:2035
void AddVolumeOutput(const string &name, const string &field_name, const string &group_name, const string &description)
Add a new field to the volume output.
Definition COutput.hpp:794
su2double wndCauchyEps
Defines the threshold when to stop the solver.
Definition COutput.hpp:338
vector< pair< string, passivedouble > > GetResidualConvFields() const
Names and values of the fields convergence is monitored on that are residuals.
Definition COutput.hpp:510
bool convergenceInterrupted
To indicate that the exit was forced by an interrupt signal instead of the convergence criteria.
Definition COutput.hpp:324
unsigned long curTimeIter
Current value of the time iteration index.
Definition COutput.hpp:91
vector< su2double > WndOld_Func
Old value of the objective function (the function which is monitored).
Definition COutput.hpp:340
void SetCustomAndComboObjectives(int idxSol, const CConfig *config, CSolver **solver)
Computes the custom and combo objectives.
Definition COutput.cpp:317
virtual void SetTurboPerformance_Output(su2vector< std::shared_ptr< CTurboOutput > > TurboBladePerfs, CConfig *config, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter)
Sets the turboperformance screen output.
Definition COutput.hpp:1041
OperationType
Type of operation for custom outputs.
Definition COutput.hpp:198
bool MonitorTimeConvergence(CConfig *config, unsigned long Iteration)
Monitor the time convergence of the specified windowed-time-averaged ouput.
Definition COutput.cpp:1060
void PostprocessHistoryData(CConfig *config)
Postprocess_HistoryData.
Definition COutput.cpp:1909
bool noWriting
Boolean indicating whether a screen/history output should be written.
Definition COutput.hpp:90
PrintingToolbox::CTablePrinter * convergenceTable
Convergence output table structure.
Definition COutput.hpp:170
void LoadData(CGeometry *geometry, CConfig *config, CSolver **solver_container)
Load the data from the solvers into the data sorters and sort it for the linear partitioning.
Definition COutput.cpp:362
void LoadDataIntoSorter(CConfig *config, CGeometry *geometry, CSolver **solver)
Load up the values of the requested volume fields into ::Local_Data array.
Definition COutput.cpp:1725
CParallelDataSorter * surfaceDataSorter
Surface data sorter.
Definition COutput.hpp:253
PrintingToolbox::CTablePrinter * historyFileTable
Table structure for writing to history file.
Definition COutput.hpp:172
virtual bool WriteVolumeOutput(CConfig *config, unsigned long Iter, bool force_writing, unsigned short iFile)
Determines if the the volume output should be written.
Definition COutput.cpp:2169
std::vector< const HistoryOutputField * > requestedScreenFieldCache
Definition COutput.hpp:168
virtual void SetVolumeOutputFields(CConfig *config)
Set the available volume output fields.
Definition COutput.hpp:1005
CustomHistoryOutput customObjFunc
User-defined expression for a custom objective.
Definition COutput.hpp:195
bool headerNeeded
Boolean that stores whether a screen header is needed.
Definition COutput.hpp:175
std::vector< const su2double * > requestedHistoryFieldCache
Caches to avoid hashing the output maps to retrieve field values.
Definition COutput.hpp:167
void AddHistoryOutput(string name, string field_name, ScreenOutputFormat format, string groupname, string description, HistoryFieldType field_type=HistoryFieldType::DEFAULT)
Add a new field to the history output.
Definition COutput.hpp:698
std::vector< string > historyOutputPerSurface_List
Vector that contains the keys of the historyOutputPerSurface_Map in the order of their insertion.
Definition COutput.hpp:155
su2double initResidual
Initial value of the residual to evaluate the convergence level.
Definition COutput.hpp:325
virtual void LoadVolumeData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint)
Set the values of the volume output fields for a point.
Definition COutput.hpp:968
CParallelDataSorter * volumeDataSorterCompact
Volume data sorter for compact files.
Definition COutput.hpp:252
void SetMultizoneHistoryOutput(COutput **output, CConfig **config, CConfig *driver_config, unsigned long TimeIter, unsigned long OuterIter)
Definition COutput.cpp:266
bool TimeConvergence
To indicate, if the windowed time average of the time loop has converged.
Definition COutput.hpp:344
vector< HistoryOutputField > GetHistoryGroup(string groupname)
Get a vector with all output fields in a particular group.
Definition COutput.hpp:540
string GetSurfaceFilename()
Returns the current surface filename.
Definition COutput.hpp:462
std::vector< string > requestedScreenFields
Requested screen field names in the config file.
Definition COutput.hpp:162
std::vector< short > fieldIndexCache
Vectors to cache the positions of the fields in the data array.
Definition COutput.hpp:295
std::map< string, HistoryOutputField > historyOutput_Map
Associative map to access data stored in the history output fields by a string identifier.
Definition COutput.hpp:149
bool buildFieldIndexCache
Whether the field index caches should be build.
Definition COutput.hpp:292
string surfaceFilename
Surface output filename.
Definition COutput.hpp:259
bool maxTimeDelayActive
: Flag indicating that solver is already converged. Needed for writing restart files.
Definition COutput.hpp:102
void OutputScreenAndHistory(CConfig *config)
Write screen and history output.
Definition COutput.cpp:288
void SetConvergence(const bool conv)
Set the value of the convergence flag.
Definition COutput.hpp:611
void ComputeSimpleCustomOutputs(const CConfig *config)
Evaluates function-type custom outputs. Derived classes can use this to compute simple expressions of...
Definition COutput.cpp:2339
unsigned short curGetFieldIndex
Current value of the cache index.
Definition COutput.hpp:302
unsigned long nCauchy_Elems
Total number of cauchy elems to monitor.
Definition COutput.hpp:318
bool PrintOutput(unsigned long iIter, unsigned long iFreq)
Check whether we should print output.
Definition COutput.hpp:865
const map< string, vector< HistoryOutputField > > & GetHistoryPerSurfaceFields() const
Get the map containing all output per-surface fields.
Definition COutput.hpp:578
void PreprocessHistoryOutput(CConfig *config, bool wrt=true)
Preprocess the history output by setting the history fields and opening the history file.
Definition COutput.cpp:1254
bool cauchyTimeConverged
Definition COutput.hpp:101
vector< su2double > newFunc
Current value of the coefficient.
Definition COutput.hpp:322
su2double PrevStopTime
Previous stop time for iteration timing.
Definition COutput.hpp:96
void SetVolumeFilename(string filename)
Sets the volume output filename.
Definition COutput.hpp:444
Definition CParallelDataSorter.hpp:39
Definition CSolver.hpp:71
Class for writing output in a table.
Definition printing_toolbox.hpp:74
passivedouble su2double
Definition code_config.hpp:181
FORCEINLINE ARRAY_T sqrt(const ARRAY_T &x)
Definition special_vectorization.hpp:116
#define CURRENT_FUNCTION
Definition mpi_structure.hpp:59
passivedouble GetValue(const su2double &data)
Get the (primitive) value of the datatype (needs to be specialized for active types).
Definition datatype_structure.hpp:113
su2double hypot(const su2double &a, const su2double &b)
Definition COutput.hpp:46
Definition COutput.hpp:44
@ MAX_SOLS
Definition option_structure.hpp:80
OUTPUT_TYPE
Type of solution output file formats.
Definition option_structure.hpp:2340
Struct to hold a parsed user-defined expression.
Definition COutput.hpp:184
bool ready
Definition COutput.hpp:188
std::vector< const su2double * > symbolValues
Definition COutput.hpp:187
mel::ExpressionTree< passivedouble > expression
Definition COutput.hpp:185
su2double Eval() const
Definition COutput.hpp:190
Struct to hold a parsed custom output function.
Definition COutput.hpp:201
std::vector< std::string > markers
Definition COutput.hpp:206
OperationType type
Definition COutput.hpp:204
static constexpr unsigned long MAX_VARS_PER_SOLVER
Definition COutput.hpp:225
std::vector< unsigned short > markerIndices
Definition COutput.hpp:211
static constexpr long PROBE_NOT_SETUP
Definition COutput.hpp:212
static constexpr long PROBE_NOT_OWNED
Definition COutput.hpp:213
su2double Eval(const Variables &vars) const
Definition COutput.hpp:242
bool skip
Definition COutput.hpp:236
std::vector< const su2double * > otherOutputs
Definition COutput.hpp:232
long iPoint
Definition COutput.hpp:214
std::vector< unsigned long > varIndices
Definition COutput.hpp:222
std::vector< std::string > varSymbols
Definition COutput.hpp:210
static constexpr unsigned long NOT_A_VARIABLE
Definition COutput.hpp:228
std::string func
Definition COutput.hpp:205
std::string name
Definition COutput.hpp:203
mel::ExpressionTree< passivedouble > expression
Definition COutput.hpp:209
Structure to store information for a history output field.
Definition COutput.hpp:126
string outputGroup
The group this field belongs to.
Definition COutput.hpp:134
HistoryOutputField(string fieldName_, ScreenOutputFormat screenFormat_, string OutputGroup_, HistoryFieldType fieldType_, string description_)
Constructor to initialize all members.
Definition COutput.hpp:142
HistoryFieldType fieldType
The field type.
Definition COutput.hpp:136
string description
String containing the description of the field.
Definition COutput.hpp:138
string fieldName
The name of the field, i.e. the name that is printed in the screen or file header.
Definition COutput.hpp:128
ScreenOutputFormat screenFormat
The format that is used to print this value to screen.
Definition COutput.hpp:132
HistoryOutputField()
Default constructor.
Definition COutput.hpp:140
su2double value
The value of the field.
Definition COutput.hpp:130
Structure to store information for a volume output field.
Definition COutput.hpp:266
string outputGroup
The group this field belongs to.
Definition COutput.hpp:274
VolumeOutputField(string fieldName_, string volumeOutputGroup_, string description_)
Constructor to initialize all members.
Definition COutput.hpp:280
short offsetCompact
This offset is used for the compact formulation.
Definition COutput.hpp:272
string description
String containing the description of the field.
Definition COutput.hpp:276
VolumeOutputField()=default
Default constructor.
short offset
This value identifies the position of the values of this field at each node in the ::Local_Data array...
Definition COutput.hpp:270
string fieldName
The name of the field, i.e. the name that is printed in the file header.
Definition COutput.hpp:268