Documentation 6b54b78464
Loading...
Searching...
No Matches
CVerificationSolution.hpp
Go to the documentation of this file.
1/*!
2 * \file CVerificationSolution.hpp
3 * \brief Header file for the base class CVerificationSolution.
4 * The implementations are in the <i>CVerificationSolution.cpp</i> file.
5 * \author T. Economon, E. van der Weide
6 * \version 8.5.0 "Harrier"
7 *
8 * SU2 Project Website: https://su2code.github.io
9 *
10 * The SU2 Project is maintained by the SU2 Foundation
11 * (http://su2foundation.org)
12 *
13 * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md)
14 *
15 * SU2 is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU Lesser General Public
17 * License as published by the Free Software Foundation; either
18 * version 2.1 of the License, or (at your option) any later version.
19 *
20 * SU2 is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with SU2. If not, see <http://www.gnu.org/licenses/>.
27 */
28
29#pragma once
30
31#include <cmath>
32#include "../../CConfig.hpp"
33
34/*!
35 * \class CVerificationSolution
36 * \brief Class for holding verification PDE solutions, e.g., phi = phi(x,y,z,t),
37 * used for initial conditions, analytic solutions, manufactured solutions.
38 * \author T. Economon, E. van der Weide
39 */
41 protected:
42 int rank; /*!< \brief MPI Rank. */
43 int size; /*!< \brief MPI Size. */
44
45 unsigned short nDim; /*!< \brief Number of dimension of the problem. */
46 unsigned short nVar; /*!< \brief Number of variables of the problem */
47
48 MAIN_SOLVER Kind_Solver; /*!< \brief The kind of solver we are running. */
49
50 private:
51 su2double* Error_RMS; /*!< \brief Vector with the global RMS error for each variable in a verification case. */
52 su2double* Error_Max; /*!< \brief Vector with the global max error for each variable in a verification case. */
53 unsigned long* Error_Point_Max; /*!< \brief Global index for the node with the max error in a verification case. */
54 su2double** Error_Point_Max_Coord; /*!< \brief Coordinates for the node with the max error in a verification case. */
55
56 public:
57 /*!
58 * \brief Constructor of the class.
59 */
61
62 /*!
63 * \overload
64 * \param[in] val_nDim - Number of dimensions of the problem.
65 * \param[in] val_nvar - Number of variables of the problem.
66 * \param[in] val_iMesh - Multigrid level of the solver.
67 * \param[in] config - Definition of the particular problem.
68 */
69 CVerificationSolution(unsigned short val_nDim, unsigned short val_nvar, unsigned short val_iMesh, CConfig* config);
70
71 /*!
72 * \brief Destructor of the class.
73 */
74 virtual ~CVerificationSolution(void);
75
76 /*!
77 * \brief Get the exact solution at the current position and time.
78 * \param[in] val_coords - Cartesian coordinates of the current position.
79 * \param[in] val_t - Current physical time.
80 * \param[in] val_solution - Array where the exact solution is stored.
81 */
82 virtual void GetSolution(const su2double* val_coords, const su2double val_t, su2double* val_solution) const;
83
84 /*!
85 * \brief Get the exact solution at the current position and t = 0.
86 * \param[in] val_coords - Cartesian coordinates of the current position.
87 * \param[in] val_solution - Array where the exact solution is stored.
88 */
89 void GetInitialCondition(const su2double* val_coords, su2double* val_solution) const;
90
91 /*!
92 * \brief Get the boundary conditions state for an exact solution.
93 * \param[in] val_coords - Cartesian coordinates of the current position.
94 * \param[in] val_t - Current physical time.
95 * \param[in] val_solution - Array where the exact solution is stored.
96 */
97 virtual void GetBCState(const su2double* val_coords, const su2double val_t, su2double* val_solution) const;
98
99 /*!
100 * \brief Get the source term for the manufactured solution (MMS).
101 * \param[in] val_coords - Cartesian coordinates of the current position.
102 * \param[in] val_t - Current physical time.
103 * \param[in] val_solution - Array where the exact solution is stored.
104 */
105 virtual void GetMMSSourceTerm(const su2double* val_coords, const su2double val_t, su2double* val_source) const;
106
107 /*!
108 * \brief Whether or not this verification solution is a manufactured solution.
109 * \return - False as default value. Overwrite this function for a
110 manufactured solution.
111 */
112 virtual bool IsManufacturedSolution(void) const;
113
114 /*!
115 * \brief Whether or not the exact solution is known for this verification solution.
116 * \return - True as default value. Overwrite this function if the exact
117 solution is not known.
118 */
119 virtual bool ExactSolutionKnown(void) const;
120
121 /*!
122 * \brief Get the local error defined as the local solution minus the verification solution.
123 * \param[in] val_coords - Cartesian coordinates of the current position.
124 * \param[in] val_solution - Array where the exact solution is stored.
125 * \param[out] val_error - Array where the local error is stored.
126 */
127 void GetLocalError(const su2double* val_coords, const su2double val_t, const su2double* GetLocalErrorval_solution,
128 su2double* val_error) const;
129
130 /*!
131 * \brief Set the global RMS error for verification cases.
132 * \param[in] val_var - Index of the variable.
133 * \param[in] val_error - Value of the RMS error to store in the position <i>val_var</i>.
134 */
135 void SetError_RMS(unsigned short val_var, su2double val_error) { Error_RMS[val_var] = val_error; }
136
137 /*!
138 * \brief Increments the global RMS error for verification cases.
139 * \param[in] val_var - Index of the variable.
140 * \param[in] val_error - Value of the RMS error to store in the position <i>val_var</i>.
141 */
142 void AddError_RMS(unsigned short val_var, su2double val_error) { Error_RMS[val_var] += val_error; }
143
144 /*!
145 * \brief Get the global RMS error for verification cases.
146 * \param[in] val_var - Index of the variable.
147 * \return Value of global RMS error for the variable in the position <i>val_var</i>.
148 */
149 su2double GetError_RMS(unsigned short val_var) const { return Error_RMS[val_var]; }
150
151 /*!
152 * \brief Set the global maximum error for verification cases.
153 * \param[in] val_var - Index of the variable.
154 * \param[in] val_error - Value of the maximum error to store in the position <i>val_var</i>.
155 */
156 void SetError_Max(unsigned short val_var, su2double val_error, unsigned long val_point) {
157 Error_Max[val_var] = val_error;
158 Error_Point_Max[val_var] = val_point;
159 }
160
161 /*!
162 * \brief Increment the global maximum error for verification cases.
163 * \param[in] val_var - Index of the variable.
164 * \param[in] val_error - Value of the maximum error to store in the position <i>val_var</i>.
165 * \param[in] val_point - Value of the point index for the max error.
166 * \param[in] val_coord - Location (x, y, z) of the max error point.
167 */
168 void AddError_Max(unsigned short val_var, su2double val_error, unsigned long val_point, const su2double* val_coord) {
169 if (val_error > Error_Max[val_var]) {
170 Error_Max[val_var] = val_error;
171 Error_Point_Max[val_var] = val_point;
172 for (unsigned short iDim = 0; iDim < nDim; iDim++) Error_Point_Max_Coord[val_var][iDim] = val_coord[iDim];
173 }
174 }
175
176 /*!
177 * \brief Get the global maximum error for verification cases.
178 * \param[in] val_var - Index of the variable.
179 * \return Value of global maximum error for the variable in the position <i>val_var</i>.
180 */
181 su2double GetError_Max(unsigned short val_var) const { return Error_Max[val_var]; }
182
183 /*!
184 * \brief Get the global index of the node with the max error for verification cases.
185 * \param[in] val_var - Index of the variable.
186 * \return Global index of the point with the max error for the variable in the position <i>val_var</i>.
187 */
188 unsigned long GetError_Point_Max(unsigned short val_var) const { return Error_Point_Max[val_var]; }
189
190 /*!
191 * \brief Get the coordinates of the node with the max error for verification cases.
192 * \param[in] val_var - Index of the variable.
193 * \return Coordinates of the point with the max error for the variable in the position <i>val_var</i>.
194 */
195 const su2double* GetError_Point_Max_Coord(unsigned short val_var) const { return Error_Point_Max_Coord[val_var]; }
196
197 /*!
198 * \brief Calculate the global error metrics for verification cases.
199 * \param[in] nDOFsGlobal - Global number of degrees of freedom for the current problem.
200 * \param[in] config - Definition of the particular problem.
201 */
202 void SetVerificationError(unsigned long nDOFsGlobal, CConfig* config);
203};
Main class for defining the problem; basically this class reads the configuration file,...
Definition CConfig.hpp:64
Class for holding verification PDE solutions, e.g., phi = phi(x,y,z,t), used for initial conditions,...
Definition CVerificationSolution.hpp:40
int rank
MPI Rank.
Definition CVerificationSolution.hpp:42
virtual void GetSolution(const su2double *val_coords, const su2double val_t, su2double *val_solution) const
Get the exact solution at the current position and time.
Definition CVerificationSolution.cpp:83
void AddError_RMS(unsigned short val_var, su2double val_error)
Increments the global RMS error for verification cases.
Definition CVerificationSolution.hpp:142
su2double GetError_RMS(unsigned short val_var) const
Get the global RMS error for verification cases.
Definition CVerificationSolution.hpp:149
void SetVerificationError(unsigned long nDOFsGlobal, CConfig *config)
Calculate the global error metrics for verification cases.
Definition CVerificationSolution.cpp:122
const su2double * GetError_Point_Max_Coord(unsigned short val_var) const
Get the coordinates of the node with the max error for verification cases.
Definition CVerificationSolution.hpp:195
su2double GetError_Max(unsigned short val_var) const
Get the global maximum error for verification cases.
Definition CVerificationSolution.hpp:181
virtual ~CVerificationSolution(void)
Destructor of the class.
Definition CVerificationSolution.cpp:68
void AddError_Max(unsigned short val_var, su2double val_error, unsigned long val_point, const su2double *val_coord)
Increment the global maximum error for verification cases.
Definition CVerificationSolution.hpp:168
void SetError_Max(unsigned short val_var, su2double val_error, unsigned long val_point)
Set the global maximum error for verification cases.
Definition CVerificationSolution.hpp:156
void GetLocalError(const su2double *val_coords, const su2double val_t, const su2double *GetLocalErrorval_solution, su2double *val_error) const
Get the local error defined as the local solution minus the verification solution.
Definition CVerificationSolution.cpp:109
unsigned long GetError_Point_Max(unsigned short val_var) const
Get the global index of the node with the max error for verification cases.
Definition CVerificationSolution.hpp:188
unsigned short nVar
Number of variables of the problem
Definition CVerificationSolution.hpp:46
CVerificationSolution(void)
Constructor of the class.
Definition CVerificationSolution.cpp:30
void GetInitialCondition(const su2double *val_coords, su2double *val_solution) const
Get the exact solution at the current position and t = 0.
Definition CVerificationSolution.cpp:88
virtual void GetBCState(const su2double *val_coords, const su2double val_t, su2double *val_solution) const
Get the boundary conditions state for an exact solution.
Definition CVerificationSolution.cpp:93
virtual bool ExactSolutionKnown(void) const
Whether or not the exact solution is known for this verification solution.
Definition CVerificationSolution.cpp:107
MAIN_SOLVER Kind_Solver
The kind of solver we are running.
Definition CVerificationSolution.hpp:48
virtual void GetMMSSourceTerm(const su2double *val_coords, const su2double val_t, su2double *val_source) const
Get the source term for the manufactured solution (MMS).
Definition CVerificationSolution.cpp:98
unsigned short nDim
Number of dimension of the problem.
Definition CVerificationSolution.hpp:45
virtual bool IsManufacturedSolution(void) const
Whether or not this verification solution is a manufactured solution.
Definition CVerificationSolution.cpp:105
void SetError_RMS(unsigned short val_var, su2double val_error)
Set the global RMS error for verification cases.
Definition CVerificationSolution.hpp:135
int size
MPI Size.
Definition CVerificationSolution.hpp:43
passivedouble su2double
Definition code_config.hpp:181
MAIN_SOLVER
different solver types for the CFD component
Definition option_structure.hpp:302