Documentation 6b54b78464
Loading...
Searching...
No Matches
CDiscAdjVariable.hpp
Go to the documentation of this file.
1/*!
2 * \file CDiscAdjVariable.hpp
3 * \brief Main class for defining the variables of the adjoint 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 CDiscAdjVariable
34 * \ingroup DiscAdj
35 * \brief Main class for defining the variables of the adjoint solver.
36 * \author T. Albring.
37 */
39private:
40 MatrixType Sensitivity; /*!< \brief Vector holding the derivative of target functional with respect to the coordinates at this node. */
41 MatrixType Solution_Direct; /*!< \brief Stores the primal solution of the current timestep in order to be able to reset. */
42 MatrixType DualTime_Derivative; /*!< \brief Container holding all/sum-of dual time contributions to the adjoint variable. */
43 MatrixType DualTime_Derivative_n; /*!< \brief Container holding dual time contributions to the adjoint variable used in the next timestep. */
44
45public:
46 /*!
47 * \brief Constructor of the class.
48 * \param[in] sol - Pointer to the adjoint value (initialization value).
49 * \param[in] npoint - Number of points/nodes/vertices in the domain.
50 * \param[in] ndim - Number of dimensions of the problem.
51 * \param[in] nvar - Number of variables of the problem.
52 * \param[in] config - Definition of the particular problem.
53 */
54 CDiscAdjVariable(const su2double* sol, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config);
55
56 /*!
57 * \brief Allocate extra adjoint variables.
58 * \param[in] nVarExtra - Number of extra variables.
59 */
60 void AllocateAdjointSolutionExtra(unsigned long nVarExtra);
61
62 /*!
63 * \brief Set the sensitivity at the node
64 */
65 inline void SetSensitivity(unsigned long iPoint, unsigned long iDim, su2double val) final {
66 Sensitivity(iPoint,iDim) = val;
67 }
68
69 /*!
70 * \brief Get the Sensitivity at the node
71 */
72 inline su2double GetSensitivity(unsigned long iPoint, unsigned long iDim) const final {
73 return Sensitivity(iPoint,iDim);
74 }
75 inline const MatrixType& GetSensitivity() const final { return Sensitivity; }
76
77 /*!
78 * \brief Set/store the dual time contributions to the adjoint variable.
79 * Contains sum of contributions from 2 timesteps for dual time 2nd order.
80 */
81 inline void SetDual_Time_Derivative(unsigned long iPoint, unsigned long iVar, su2double der) {
82 DualTime_Derivative(iPoint,iVar) = der;
83 }
84
85 /*!
86 * \brief Set/store the dual time contributions to the adjoint variable for upcoming timestep.
87 */
88 inline void SetDual_Time_Derivative_n(unsigned long iPoint, unsigned long iVar, su2double der) {
89 DualTime_Derivative_n(iPoint,iVar) = der;
90 }
91
92 /*!
93 * \brief Return the dual time contributions to the adjoint variable.
94 * Contains sum of contributions from 2 timesteps for dual time 2nd order.
95 */
96 inline su2double GetDual_Time_Derivative(unsigned long iPoint, unsigned long iVar) const {
97 return DualTime_Derivative(iPoint,iVar);
98 }
99
100 /*!
101 * \brief Return the dual time contributions to the adjoint variable for upcoming timestep.
102 */
103 inline su2double GetDual_Time_Derivative_n(unsigned long iPoint, unsigned long iVar) const {
104 return DualTime_Derivative_n(iPoint,iVar);
105 }
106
107 /*!
108 * \brief Set/store the primal solution for all variables of one point.
109 */
110 inline void SetSolution_Direct(unsigned long iPoint, const su2double *val_solution_direct) final {
111 for (unsigned long iVar = 0; iVar < nVar; iVar++)
112 Solution_Direct(iPoint,iVar) = val_solution_direct[iVar];
113 }
114
115 /*!
116 * \brief Returns the primal solution for all variables of one point.
117 */
118 inline su2double* GetSolution_Direct(unsigned long iPoint) final {
119 return Solution_Direct[iPoint];
120 }
121
122 /*!
123 * \brief Set Dual-time derivative contributions to the external.
124 */
125 void Set_External_To_DualTimeDer() final;
126
127};
Declaration and inlines of the parent class for defining problem variables, function definitions in f...
Main class for defining the problem; basically this class reads the configuration file,...
Definition CConfig.hpp:64
Main class for defining the variables of the adjoint solver.
Definition CDiscAdjVariable.hpp:38
void AllocateAdjointSolutionExtra(unsigned long nVarExtra)
Allocate extra adjoint variables.
Definition CDiscAdjVariable.cpp:53
su2double GetDual_Time_Derivative(unsigned long iPoint, unsigned long iVar) const
Return the dual time contributions to the adjoint variable. Contains sum of contributions from 2 time...
Definition CDiscAdjVariable.hpp:96
su2double GetDual_Time_Derivative_n(unsigned long iPoint, unsigned long iVar) const
Return the dual time contributions to the adjoint variable for upcoming timestep.
Definition CDiscAdjVariable.hpp:103
void SetSolution_Direct(unsigned long iPoint, const su2double *val_solution_direct) final
Set/store the primal solution for all variables of one point.
Definition CDiscAdjVariable.hpp:110
void SetDual_Time_Derivative_n(unsigned long iPoint, unsigned long iVar, su2double der)
Set/store the dual time contributions to the adjoint variable for upcoming timestep.
Definition CDiscAdjVariable.hpp:88
const MatrixType & GetSensitivity() const final
Definition CDiscAdjVariable.hpp:75
void Set_External_To_DualTimeDer() final
Set Dual-time derivative contributions to the external.
Definition CDiscAdjVariable.cpp:48
void SetSensitivity(unsigned long iPoint, unsigned long iDim, su2double val) final
Set the sensitivity at the node.
Definition CDiscAdjVariable.hpp:65
su2double GetSensitivity(unsigned long iPoint, unsigned long iDim) const final
Get the Sensitivity at the node.
Definition CDiscAdjVariable.hpp:72
void SetDual_Time_Derivative(unsigned long iPoint, unsigned long iVar, su2double der)
Set/store the dual time contributions to the adjoint variable. Contains sum of contributions from 2 t...
Definition CDiscAdjVariable.hpp:81
su2double * GetSolution_Direct(unsigned long iPoint) final
Returns the primal solution for all variables of one point.
Definition CDiscAdjVariable.hpp:118
Main class for defining the variables.
Definition CVariable.hpp:50
unsigned long nVar
Number of variables of the problem.
Definition CVariable.hpp:108
passivedouble su2double
Definition code_config.hpp:181