Documentation a537f1bdf2
Loading...
Searching...
No Matches
CAdjEulerVariable.hpp
Go to the documentation of this file.
1/*!
2 * \file CAdjEulerVariable.hpp
3 * \brief Main class for defining the variables of the adjoint Euler solver.
4 * \author F. Palacios, T. Economon
5 * \version 8.5.0 "Harrier"
6 *
7 * SU2 Project Website: https://su2code.github.io
8 *
9 * The SU2 Project is maintained by the SU2 Foundation
10 * (http://su2foundation.org)
11 *
12 * Copyright 2012-2026, SU2 Contributors (cf. AUTHORS.md)
13 *
14 * SU2 is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Lesser General Public
16 * License as published by the Free Software Foundation; either
17 * version 2.1 of the License, or (at your option) any later version.
18 *
19 * SU2 is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * Lesser General Public License for more details.
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with SU2. If not, see <http://www.gnu.org/licenses/>.
26 */
27
28#pragma once
29
30#include "CVariable.hpp"
31
32/*!
33 * \class CAdjEulerVariable
34 * \brief Main class for defining the variables of the adjoint Euler solver.
35 * \ingroup Euler_Equations
36 * \author F. Palacios, T. Economon
37 */
39protected:
40 MatrixType Psi; /*!< \brief Vector of the adjoint variables. */
41 MatrixType ForceProj_Vector; /*!< \brief Vector d. */
42 MatrixType ObjFuncSource; /*!< \brief Vector containing objective function sensitivity for discrete adjoint. */
43 MatrixType HB_Source; /*!< \brief Harmonic balance source term. */
44
45 CVectorOfMatrix& Gradient_Reconstruction; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */
46 CVectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */
47
48public:
49 /*!
50 * \brief Constructor of the class.
51 * \param[in] psirho - Value of the adjoint density (initialization value).
52 * \param[in] phi - Value of the adjoint velocity (initialization value).
53 * \param[in] psie - Value of the adjoint energy (initialization value).
54 * \param[in] npoint - Number of points/nodes/vertices in the domain.
55 * \param[in] ndim - Number of dimensions of the problem.
56 * \param[in] nvar - Number of variables of the problem.
57 * \param[in] config - Definition of the particular problem.
58 */
59 CAdjEulerVariable(su2double psirho, const su2double *phi, su2double psie,
60 unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config);
61
62 /*!
63 * \brief Destructor of the class.
64 */
65 ~CAdjEulerVariable() override = default;
66
67 /*!
68 * \brief Set all the primitive variables for compressible flows.
69 */
70 bool SetPrimVar(unsigned long iPoint, su2double SharpEdge_Distance, bool check, CConfig *config) final;
71
72 /*!
73 * \brief Set the value of the adjoint velocity.
74 * \param[in] val_phi - Value of the adjoint velocity.
75 */
76 inline void SetPhi_Old(unsigned long iPoint, const su2double *val_phi) final {
77 for (unsigned long iDim = 0; iDim < nDim; iDim++) Solution_Old(iPoint,iDim+1)=val_phi[iDim];
78 }
79
80 /*!
81 * \brief Set the value of the force projection vector.
82 * \param[in] val_ForceProj_Vector - Pointer to the force projection vector.
83 */
84 inline void SetForceProj_Vector(unsigned long iPoint, const su2double *val_ForceProj_Vector) final {
85 for (unsigned long iDim = 0; iDim < nDim; iDim++) ForceProj_Vector(iPoint,iDim) = val_ForceProj_Vector[iDim];
86 }
87
88 /*!
89 * \brief Set the value of the objective function source.
90 * \param[in] val_ObjFuncSource - Pointer to the objective function source.
91 */
92 inline void SetObjFuncSource(unsigned long iPoint, const su2double *val_ObjFuncSource) final {
93 for (unsigned long iVar = 0; iVar < nVar; iVar++) ObjFuncSource(iPoint,iVar) = val_ObjFuncSource[iVar];
94 }
95
96 /*!
97 * \brief Set the velocity vector from the old solution.
98 * \param[in] val_velocity - Pointer to the velocity.
99 */
100 inline void SetVelocity_Old(unsigned long iPoint, const su2double *val_velocity) final {
101 for (unsigned long iDim = 0; iDim < nDim; iDim++)
102 Solution_Old(iPoint,iDim+1) = val_velocity[iDim]*Solution(iPoint,0);
103 }
104
105 /*!
106 * \brief Set the momentum part of the truncation error to zero.
107 * \param[in] iPoint - Point index.
108 */
109 inline void SetVel_ResTruncError_Zero(unsigned long iPoint) final {
110 for (unsigned long iDim = 0; iDim < nDim; iDim++) Res_TruncError(iPoint,iDim+1) = 0.0;
111 }
112
113 /*!
114 * \brief Specify a vector to set the velocity components of the solution. Multiplied by density for compressible cases.
115 * \param[in] iPoint - Point index.
116 * \param[in] val_vector - Pointer to the vector.
117 */
118 inline void SetVelSolutionVector(unsigned long iPoint, const su2double *val_vector) final {
119 for (unsigned long iDim = 0; iDim < nDim; iDim++) Solution(iPoint, iDim+1) = GetDensity(iPoint) * val_vector[iDim];
120 }
121
122 /*!
123 * \brief Get the value of the force projection vector.
124 * \return Pointer to the force projection vector.
125 */
126 inline su2double *GetForceProj_Vector(unsigned long iPoint) final { return ForceProj_Vector[iPoint]; }
127
128 /*!
129 * \brief Get the value of the objective function source.
130 * \param[in] val_SetObjFuncSource - Pointer to the objective function source.
131 */
132 inline su2double *GetObjFuncSource(unsigned long iPoint) final { return ObjFuncSource[iPoint]; }
133
134 /*!
135 * \brief Set the harmonic balance source term.
136 * \param[in] iVar - Index of the variable.
137 * \param[in] val_solution - Value of the harmonic balance source term. for the index <i>iVar</i>.
138 */
139 inline void SetHarmonicBalance_Source(unsigned long iPoint, unsigned long iVar, su2double val_source) final {
140 HB_Source(iPoint,iVar) = val_source;
141 }
142
143 /*!
144 * \brief Get the harmonic balance source term.
145 * \param[in] iVar - Index of the variable.
146 * \return Value of the harmonic balance source term for the index <i>iVar</i>.
147 */
148 inline su2double GetHarmonicBalance_Source(unsigned long iPoint, unsigned long iVar) const final {
149 return HB_Source(iPoint,iVar);
150 }
151
152 /*!
153 * \brief Get the array of the reconstruction variables gradient at a node.
154 * \param[in] iPoint - Index of the current node.
155 * \return Array of the reconstruction variables gradient at a node.
156 */
157 inline CMatrixView<su2double> GetGradient_Reconstruction(unsigned long iPoint) final {
158 return Gradient_Reconstruction[iPoint];
159 }
160
161 /*!
162 * \brief Get the reconstruction gradient for variables at all points.
163 * \return Reference to reconstruction gradient.
164 */
167
168};
Declaration and inlines of the parent class for defining problem variables, function definitions in f...
Main class for defining the variables of the adjoint Euler solver.
Definition CAdjEulerVariable.hpp:38
bool SetPrimVar(unsigned long iPoint, su2double SharpEdge_Distance, bool check, CConfig *config) final
Set all the primitive variables for compressible flows.
Definition CAdjEulerVariable.cpp:112
void SetVel_ResTruncError_Zero(unsigned long iPoint) final
Set the momentum part of the truncation error to zero.
Definition CAdjEulerVariable.hpp:109
su2double * GetForceProj_Vector(unsigned long iPoint) final
Get the value of the force projection vector.
Definition CAdjEulerVariable.hpp:126
su2double GetHarmonicBalance_Source(unsigned long iPoint, unsigned long iVar) const final
Get the harmonic balance source term.
Definition CAdjEulerVariable.hpp:148
MatrixType HB_Source
Harmonic balance source term.
Definition CAdjEulerVariable.hpp:43
CVectorOfMatrix Gradient_Aux
Auxiliary structure to store a second gradient for reconstruction, if required.
Definition CAdjEulerVariable.hpp:46
void SetObjFuncSource(unsigned long iPoint, const su2double *val_ObjFuncSource) final
Set the value of the objective function source.
Definition CAdjEulerVariable.hpp:92
CMatrixView< su2double > GetGradient_Reconstruction(unsigned long iPoint) final
Get the array of the reconstruction variables gradient at a node.
Definition CAdjEulerVariable.hpp:157
~CAdjEulerVariable() override=default
Destructor of the class.
MatrixType Psi
Vector of the adjoint variables.
Definition CAdjEulerVariable.hpp:40
const CVectorOfMatrix & GetGradient_Reconstruction() const final
Definition CAdjEulerVariable.hpp:166
su2double * GetObjFuncSource(unsigned long iPoint) final
Get the value of the objective function source.
Definition CAdjEulerVariable.hpp:132
void SetForceProj_Vector(unsigned long iPoint, const su2double *val_ForceProj_Vector) final
Set the value of the force projection vector.
Definition CAdjEulerVariable.hpp:84
void SetVelSolutionVector(unsigned long iPoint, const su2double *val_vector) final
Specify a vector to set the velocity components of the solution. Multiplied by density for compressib...
Definition CAdjEulerVariable.hpp:118
MatrixType ForceProj_Vector
Vector d.
Definition CAdjEulerVariable.hpp:41
void SetVelocity_Old(unsigned long iPoint, const su2double *val_velocity) final
Set the velocity vector from the old solution.
Definition CAdjEulerVariable.hpp:100
MatrixType ObjFuncSource
Vector containing objective function sensitivity for discrete adjoint.
Definition CAdjEulerVariable.hpp:42
void SetHarmonicBalance_Source(unsigned long iPoint, unsigned long iVar, su2double val_source) final
Set the harmonic balance source term.
Definition CAdjEulerVariable.hpp:139
void SetPhi_Old(unsigned long iPoint, const su2double *val_phi) final
Set the value of the adjoint velocity.
Definition CAdjEulerVariable.hpp:76
CVectorOfMatrix & Gradient_Reconstruction
Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term...
Definition CAdjEulerVariable.hpp:45
CVectorOfMatrix & GetGradient_Reconstruction() final
Get the reconstruction gradient for variables at all points.
Definition CAdjEulerVariable.hpp:165
Main class for defining the problem; basically this class reads the configuration file,...
Definition CConfig.hpp:64
Class to represent a matrix (without owning the data, this just wraps a pointer).
Definition container_decorators.hpp:40
Main class for defining the variables.
Definition CVariable.hpp:50
virtual su2double GetDensity(unsigned long iPoint) const
A virtual member.
Definition CVariable.hpp:1009
MatrixType Solution
Solution of the problem.
Definition CVariable.hpp:55
unsigned long nVar
Number of variables of the problem.
Definition CVariable.hpp:108
MatrixType Solution_Old
Old solution of the problem R-K.
Definition CVariable.hpp:56
MatrixType Res_TruncError
Truncation error for multigrid cycle.
Definition CVariable.hpp:91
unsigned long nDim
Number of dimension of the problem.
Definition CVariable.hpp:107
passivedouble su2double
Definition code_config.hpp:181