Documentation 6b54b78464
Loading...
Searching...
No Matches
CDiscAdjMeshSolver.hpp
Go to the documentation of this file.
1/*!
2 * \file CMeshSolver.hpp
3 * \brief Declaration and inlines of the class to compute the
4 * the discrete adjoint of the linear-elastic mesh solver.
5 * \author Ruben Sanchez
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 "CSolver.hpp"
32#include "../variables/CDiscAdjMeshBoundVariable.hpp"
33
34/*!
35 * \class CDiscAdjMeshSolver
36 * \ingroup DiscAdj
37 * \brief Main class for defining the discrete adjoint solver for mesh deformation problems.
38 * \author R. Sanchez
39 */
40class CDiscAdjMeshSolver final : public CSolver {
41private:
42 static constexpr size_t MAXNDIM = 3; /*!< \brief Max number of space dimensions, used in some static arrays. */
43 static constexpr size_t MAXNVAR = 3; /*!< \brief Max number of variables, for static arrays. */
44
45 static constexpr size_t OMP_MAX_SIZE = 1024; /*!< \brief Max chunk size for light point loops. */
46
47 unsigned long omp_chunk_size; /*!< \brief Chunk size used in light point loops. */
48
49 CSolver *direct_solver = nullptr;
50
51 CDiscAdjMeshBoundVariable* nodes = nullptr; /*!< \brief Variables of the discrete adjoint mesh solver. */
52
53 /*!
54 * \brief Return nodes to allow CSolver::base_nodes to be set.
55 */
56 inline CVariable* GetBaseClassPointerToNodes() override { return nodes; }
57
58public:
59
60 /*!
61 * \brief Constructor of the class.
62 */
63 CDiscAdjMeshSolver() = default;
64
65 /*!
66 * \overload
67 * \param[in] geometry - Geometrical definition of the problem.
68 * \param[in] config - Definition of the particular problem.
69 * \param[in] solver - Initialize the discrete adjoint solver with the corresponding direct solver.
70 */
71 CDiscAdjMeshSolver(CGeometry *geometry, CConfig *config, CSolver* solver);
72
73 /*!
74 * \brief Destructor of the class.
75 */
76 ~CDiscAdjMeshSolver() override;
77
78 /*!
79 * \brief Performs the preprocessing of the AD-based mesh adjoint solver.
80 * Registers all necessary variables on the tape. Called while tape is active.
81 * \param[in] geometry_container - The geometry container holding all grid levels.
82 * \param[in] config_container - The particular config.
83 */
84 void RegisterSolution(CGeometry *geometry, CConfig *config) override;
85
86 /*!
87 * \brief Sets the adjoint values of the input variables of the flow (+turb.) iteration
88 * after tape has been evaluated.
89 * \param[in] geometry - The geometrical definition of the problem.
90 * \param[in] config - The particular config.
91 */
92 void ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config, bool CrossTerm) override;
93
94 /*!
95 * \brief Extract and set the geometrical sensitivity.
96 * \param[in] geometry - Geometrical definition of the problem.
97 * \param[in] config - Definition of the particular problem.
98 * \param[in] target_solver - The target solver to store the sensitivities.
99 */
100 void SetSensitivity(CGeometry *geometry, CConfig *config, CSolver* target_solver) override;
101
102 /*!
103 * \brief Prepare the solver for a new recording.
104 * \param[in] kind_recording - Kind of AD recording.
105 */
106 void SetRecording(CGeometry *geometry, CConfig *config) override;
107
108 /*!
109 * \brief A virtual member.
110 * \param[in] geometry - Geometrical definition of the problem.
111 * \param[in] config - Definition of the particular problem.
112 * \param[in] reset - If true reset variables to their initial values.
113 */
114 void RegisterVariables(CGeometry *geometry,
115 CConfig *config,
116 bool reset = false) override;
117
118 /*!
119 * \brief A virtual member.
120 * \param[in] geometry - Geometrical definition of the problem.
121 * \param[in] config - Definition of the particular problem.
122 */
123 void ExtractAdjoint_Variables(CGeometry *geometry, CConfig *config) override;
124
125 /*!
126 * \brief Load a solution from a restart file.
127 * \param[in] geometry - Geometrical definition of the problem.
128 * \param[in] solver - Container vector with all of the solvers.
129 * \param[in] config - Definition of the particular problem.
130 * \param[in] val_iter - Current external iteration number.
131 * \param[in] val_update_geo - Flag for updating coords and grid velocity.
132 */
133 void LoadRestart(CGeometry **geometry,
134 CSolver ***solver,
135 CConfig *config,
136 int val_iter,
137 bool val_update_geo) override;
138
139};
Headers of the CSolver class which is inherited by all of the other solvers.
Main class for defining the problem; basically this class reads the configuration file,...
Definition CConfig.hpp:64
Main class for defining the variables on the mesh deformation boundaries for adjoint applications.
Definition CDiscAdjMeshBoundVariable.hpp:38
Main class for defining the discrete adjoint solver for mesh deformation problems.
Definition CDiscAdjMeshSolver.hpp:40
void RegisterVariables(CGeometry *geometry, CConfig *config, bool reset=false) override
A virtual member.
Definition CDiscAdjMeshSolver.cpp:110
void SetRecording(CGeometry *geometry, CConfig *config) override
Prepare the solver for a new recording.
Definition CDiscAdjMeshSolver.cpp:89
~CDiscAdjMeshSolver() override
Destructor of the class.
Definition CDiscAdjMeshSolver.cpp:87
void ExtractAdjoint_Variables(CGeometry *geometry, CConfig *config) override
A virtual member.
Definition CDiscAdjMeshSolver.cpp:143
void RegisterSolution(CGeometry *geometry, CConfig *config) override
Performs the preprocessing of the AD-based mesh adjoint solver. Registers all necessary variables on ...
Definition CDiscAdjMeshSolver.cpp:102
void LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *config, int val_iter, bool val_update_geo) override
Load a solution from a restart file.
Definition CDiscAdjMeshSolver.cpp:209
CDiscAdjMeshSolver()=default
Constructor of the class.
void SetSensitivity(CGeometry *geometry, CConfig *config, CSolver *target_solver) override
Extract and set the geometrical sensitivity.
Definition CDiscAdjMeshSolver.cpp:163
void ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config, bool CrossTerm) override
Sets the adjoint values of the input variables of the flow (+turb.) iteration after tape has been eva...
Definition CDiscAdjMeshSolver.cpp:121
Parent class for defining the geometry of the problem (complete geometry, multigrid agglomerated geom...
Definition CGeometry.hpp:75
Definition CSolver.hpp:71
Main class for defining the variables.
Definition CVariable.hpp:50