Documentation 6b54b78464
Loading...
Searching...
No Matches
CFEAVariable.hpp
Go to the documentation of this file.
1/*!
2 * \file CFEAVariable.hpp
3 * \brief Class for defining the variables of the FEM structural problem.
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 CFEAVariable
34 * \brief Class for defining the variables of the FEM structural problem.
35 * \ingroup Structural Finite Element Analysis Variables
36 * \author F. Palacios, R. Sanchez.
37 * \version 8.5.0 "Harrier"
38 */
39class CFEAVariable : public CVariable {
40protected:
41
42 MatrixType Stress; /*!< \brief Stress tensor. */
43
44 MatrixType Residual_Ext_Body; /*!< \brief Term of the residual due to body forces */
45
46 VectorType VonMises_Stress; /*!< \brief Von Mises stress. */
47
48 MatrixType Solution_Pred; /*!< \brief Predictor of the solution for FSI purposes */
49 MatrixType Solution_Pred_Old; /*!< \brief Predictor of the solution at time n for FSI purposes */
50 MatrixType Solution_Vel_Pred; /*!< \brief Predictor of the velocity solution for FSI purposes */
51
52 MatrixType Reference_Geometry; /*!< \brief Reference solution for optimization problems */
53
54 MatrixType Prestretch; /*!< \brief Prestretch geometry */
55
56 /*!
57 * \brief Wrappers to solution to access velocity and acceleration by name.
58 */
59 FORCEINLINE su2double& Solution_Vel(unsigned long iPoint, unsigned long iVar) {
60 return Solution(iPoint,iVar+nVar);
61 }
62 FORCEINLINE const su2double& Solution_Vel(unsigned long iPoint, unsigned long iVar) const {
63 return Solution(iPoint,iVar+nVar);
64 }
65 FORCEINLINE su2double& Solution_Accel(unsigned long iPoint, unsigned long iVar) {
66 return Solution(iPoint,iVar+2*nVar);
67 }
68 FORCEINLINE const su2double& Solution_Accel(unsigned long iPoint, unsigned long iVar) const {
69 return Solution(iPoint,iVar+2*nVar);
70 }
71 FORCEINLINE su2double& Solution_Vel_time_n(unsigned long iPoint, unsigned long iVar) {
72 return Solution_time_n(iPoint,iVar+nVar);
73 }
74 FORCEINLINE const su2double& Solution_Vel_time_n(unsigned long iPoint, unsigned long iVar) const {
75 return Solution_time_n(iPoint,iVar+nVar);
76 }
77 FORCEINLINE su2double& Solution_Accel_time_n(unsigned long iPoint, unsigned long iVar) {
78 return Solution_time_n(iPoint,iVar+2*nVar);
79 }
80 FORCEINLINE const su2double& Solution_Accel_time_n(unsigned long iPoint, unsigned long iVar) const {
81 return Solution_time_n(iPoint,iVar+2*nVar);
82 }
83
84 /*!
85 * \brief Constructor of the class.
86 * \note This class is not supposed to be instantiated, it is only a building block for CFEABoundVariable
87 * \param[in] val_fea - Values of the fea solution (initialization value).
88 * \param[in] npoint - Number of points/nodes/vertices in the domain.
89 * \param[in] ndim - Number of dimensions of the problem.
90 * \param[in] nvar - Number of variables of the problem.
91 * \param[in] config - Definition of the particular problem.
92 */
93 CFEAVariable(const su2double *val_fea, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config);
94
95public:
96 /*!
97 * \brief Destructor of the class.
98 */
99 ~CFEAVariable() override = default;
100
101 /*!
102 * \brief Get the value of the stress.
103 * \return Value of the stress.
104 */
105 inline const su2double *GetStress_FEM(unsigned long iPoint) const final { return Stress[iPoint]; }
106
107 /*!
108 * \brief Set the value of the stress at the node
109 * \param[in] iVar - index of the stress term
110 * \param[in] val_stress - value of the stress
111 */
112 inline void SetStress_FEM(unsigned long iPoint, unsigned long iVar, su2double val_stress) final { Stress(iPoint,iVar) = val_stress; }
113
114 /*!
115 * \brief Add a certain value to the value of the stress at the node
116 * \param[in] iVar - index of the stress term
117 * \param[in] val_stress - value of the stress
118 */
119 inline void AddStress_FEM(unsigned long iPoint, unsigned long iVar, su2double val_stress) final { Stress(iPoint,iVar) += val_stress; }
120
121 /*!
122 * \brief Add body forces to the residual term.
123 */
124 inline void Add_BodyForces_Res(unsigned long iPoint, const su2double *val_bodyForce) final {
125 for (unsigned long iVar = 0; iVar < nVar; iVar++)
126 Residual_Ext_Body(iPoint,iVar) += val_bodyForce[iVar];
127 }
128
129 /*!
130 * \brief Clear the surface load residual
131 */
132 inline void Clear_BodyForces_Res(unsigned long iPoint) final {
133 for (unsigned long iVar = 0; iVar < nVar; iVar++) Residual_Ext_Body(iPoint,iVar) = 0.0;
134 }
135
136 /*!
137 * \brief Get the body forces.
138 */
139 inline su2double Get_BodyForces_Res(unsigned long iPoint, unsigned long iVar) const final { return Residual_Ext_Body(iPoint,iVar); }
140
141 /*!
142 * \brief Set the value of the velocity (Structural Analysis).
143 * \param[in] val_solution_vel - Solution of the problem (velocity).
144 */
145 inline void SetSolution_Vel(unsigned long iPoint, const su2double *val_solution_vel) final {
146 for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel(iPoint,iVar) = val_solution_vel[iVar];
147 }
148
149 /*!
150 * \overload
151 * \param[in] iVar - Index of the variable.
152 * \param[in] val_solution_vel - Value of the solution for the index <i>iVar</i>.
153 */
154 inline void SetSolution_Vel(unsigned long iPoint, unsigned long iVar, su2double val_solution_vel) final {
155 Solution_Vel(iPoint,iVar) = val_solution_vel;
156 }
157
158 /*!
159 * \brief Set the value of the velocity (Structural Analysis) at time n.
160 * \param[in] val_solution_vel_time_n - Pointer to the residual vector.
161 */
162 inline void SetSolution_Vel_time_n(unsigned long iPoint, const su2double *val_solution_vel_time_n) final {
163 for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel_time_n(iPoint,iVar) = val_solution_vel_time_n[iVar];
164 }
165
166 /*!
167 * \overload
168 * \param[in] iVar - Index of the variable.
169 * \param[in] val_solution_vel_time_n - Value of the old solution for the index <i>iVar</i>.
170 */
171 inline void SetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar, su2double val_solution_vel_time_n) final {
172 Solution_Vel_time_n(iPoint,iVar) = val_solution_vel_time_n;
173 }
174
175 /*!
176 * \brief Get the velocity (Structural Analysis).
177 * \param[in] iVar - Index of the variable.
178 * \return Value of the solution for the index <i>iVar</i>.
179 */
180 inline su2double GetSolution_Vel(unsigned long iPoint, unsigned long iVar) const final { return Solution_Vel(iPoint,iVar); }
181
182 /*!
183 * \brief Get the solution of the problem.
184 * \return Pointer to the solution vector.
185 */
186 inline su2double *GetSolution_Vel(unsigned long iPoint) final { return &Solution_Vel(iPoint,0); }
187
188 /*!
189 * \brief Get the velocity of the nodes (Structural Analysis) at time n.
190 * \param[in] iVar - Index of the variable.
191 * \return Pointer to the old solution vector.
192 */
193 inline su2double GetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar) const final {
194 return Solution_Vel_time_n(iPoint,iVar);
195 }
196
197 /*!
198 * \brief Get the solution at time n.
199 * \return Pointer to the solution (at time n) vector.
200 */
201 inline su2double *GetSolution_Vel_time_n(unsigned long iPoint) final { return &Solution_Vel_time_n(iPoint,0); }
202
203 /*!
204 * \brief Set the value of the acceleration (Structural Analysis).
205 * \param[in] val_solution_accel - Solution of the problem (acceleration).
206 */
207 inline void SetSolution_Accel(unsigned long iPoint, const su2double *val_solution_accel) final {
208 for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Accel(iPoint,iVar) = val_solution_accel[iVar];
209 }
210
211 /*!
212 * \overload
213 * \param[in] iVar - Index of the variable.
214 * \param[in] val_solution_accel - Value of the solution for the index <i>iVar</i>.
215 */
216 inline void SetSolution_Accel(unsigned long iPoint, unsigned long iVar, su2double val_solution_accel) final {
217 Solution_Accel(iPoint,iVar) = val_solution_accel;
218 }
219
220 /*!
221 * \brief Set the value of the acceleration (Structural Analysis) at time n.
222 * \param[in] val_solution_old - Pointer to the residual vector.
223 */
224 inline void SetSolution_Accel_time_n(unsigned long iPoint, const su2double *val_solution_accel_time_n) final {
225 for (unsigned long iVar = 0; iVar < nVar; iVar++)
226 Solution_Accel_time_n(iPoint,iVar) = val_solution_accel_time_n[iVar];
227 }
228
229 /*!
230 * \overload
231 * \param[in] iVar - Index of the variable.
232 * \param[in] val_solution_accel_time_n - Value of the old solution for the index <i>iVar</i>.
233 */
234 inline void SetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar, su2double val_solution_accel_time_n) final {
235 Solution_Accel_time_n(iPoint,iVar) = val_solution_accel_time_n;
236 }
237
238 /*!
239 * \brief Get the acceleration (Structural Analysis).
240 * \param[in] iVar - Index of the variable.
241 * \return Value of the solution for the index <i>iVar</i>.
242 */
243 inline su2double GetSolution_Accel(unsigned long iPoint, unsigned long iVar) const final { return Solution_Accel(iPoint,iVar); }
244
245 /*!
246 * \brief Get the solution of the problem.
247 * \return Pointer to the solution vector.
248 */
249 inline su2double *GetSolution_Accel(unsigned long iPoint) final { return &Solution_Accel(iPoint,0); }
250
251 /*!
252 * \brief Get the acceleration of the nodes (Structural Analysis) at time n.
253 * \param[in] iVar - Index of the variable.
254 * \return Pointer to the old solution vector.
255 */
256 inline su2double GetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar) const final {
257 return Solution_Accel_time_n(iPoint,iVar);
258 }
259
260 /*!
261 * \brief Get the solution at time n.
262 * \return Pointer to the solution (at time n) vector.
263 */
264 inline su2double *GetSolution_Accel_time_n(unsigned long iPoint) final { return &Solution_Accel_time_n(iPoint,0); }
265
266 /*!
267 * \brief Set the value of the solution velocity predictor.
268 */
269 inline void SetSolution_Vel_Pred(unsigned long iPoint, const su2double *val_solution_pred) final {
270 for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel_Pred(iPoint,iVar) = val_solution_pred[iVar];
271 }
272
273 /*!
274 * \brief Set the value of the old solution.
275 * \param[in] val_solution_pred - Pointer to the residual vector.
276 */
277 inline void SetSolution_Pred(unsigned long iPoint, const su2double *val_solution_pred) final {
278 for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Pred(iPoint,iVar) = val_solution_pred[iVar];
279 }
280
281 /*!
282 * \brief Get the velocity solution.
283 * \return Pointer to velocity solution vector.
284 */
285 inline const su2double *GetSolution_Vel_Pred(unsigned long iPoint) const final { return Solution_Vel_Pred[iPoint]; }
286
287 /*!
288 * \brief Get the solution at time n.
289 * \return Pointer to the solution (at time n) vector.
290 */
291 inline const su2double *GetSolution_Pred(unsigned long iPoint) const final { return Solution_Pred[iPoint]; }
292
293 /*!
294 * \brief Set the value of the old solution.
295 * \param[in] val_solution_pred_old - Pointer to the residual vector.
296 */
297 inline void SetSolution_Pred_Old(unsigned long iPoint, const su2double *val_solution_pred_old) final {
298 for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Pred_Old(iPoint,iVar) = val_solution_pred_old[iVar];
299 }
300
301 /*!
302 * \brief Get the solution at time n.
303 * \return Pointer to the solution (at time n) vector.
304 */
305 inline const su2double *GetSolution_Pred_Old(unsigned long iPoint) const final { return Solution_Pred_Old[iPoint]; }
306
307 /*!
308 * \brief A virtual member.
309 */
310 inline void SetPrestretch(unsigned long iPoint, unsigned long iVar, su2double val_prestretch) final {
311 Prestretch(iPoint,iVar) = val_prestretch;
312 }
313
314 /*!
315 * \brief A virtual member.
316 */
317 inline const su2double *GetPrestretch(unsigned long iPoint) const final { return Prestretch[iPoint]; }
318
319 /*!
320 * \brief A virtual member.
321 */
322 inline su2double GetPrestretch(unsigned long iPoint, unsigned long iVar) const final { return Prestretch(iPoint,iVar); }
323
324 /*!
325 * \brief Set the value of the Von Mises stress.
326 * \param[in] val_stress - Value of the Von Mises stress.
327 */
328 inline void SetVonMises_Stress(unsigned long iPoint, su2double val_stress) final { VonMises_Stress(iPoint) = val_stress; }
329
330 /*!
331 * \brief Get the value of the Von Mises stress.
332 * \return Value of the Von Mises stress.
333 */
334 inline su2double GetVonMises_Stress(unsigned long iPoint) const final { return VonMises_Stress(iPoint); }
335
336 /*!
337 * \brief Set the reference geometry.
338 * \return Pointer to the solution (at time n) vector.
339 */
340 inline void SetReference_Geometry(unsigned long iPoint, unsigned long iVar, su2double ref_geometry) final {
341 Reference_Geometry(iPoint,iVar) = ref_geometry;
342 }
343
344 /*!
345 * \brief Get the pointer to the reference geometry
346 */
347 inline const su2double* GetReference_Geometry(unsigned long iPoint) const final { return Reference_Geometry[iPoint]; }
348
349};
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
Class for defining the variables of the FEM structural problem.
Definition CFEAVariable.hpp:39
void SetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar, su2double val_solution_accel_time_n) final
Definition CFEAVariable.hpp:234
void AddStress_FEM(unsigned long iPoint, unsigned long iVar, su2double val_stress) final
Add a certain value to the value of the stress at the node.
Definition CFEAVariable.hpp:119
su2double GetSolution_Accel(unsigned long iPoint, unsigned long iVar) const final
Get the acceleration (Structural Analysis).
Definition CFEAVariable.hpp:243
MatrixType Reference_Geometry
Reference solution for optimization problems.
Definition CFEAVariable.hpp:52
su2double GetVonMises_Stress(unsigned long iPoint) const final
Get the value of the Von Mises stress.
Definition CFEAVariable.hpp:334
MatrixType Prestretch
Prestretch geometry.
Definition CFEAVariable.hpp:54
const su2double & Solution_Accel_time_n(unsigned long iPoint, unsigned long iVar) const
Definition CFEAVariable.hpp:80
su2double * GetSolution_Accel(unsigned long iPoint) final
Get the solution of the problem.
Definition CFEAVariable.hpp:249
void SetSolution_Accel_time_n(unsigned long iPoint, const su2double *val_solution_accel_time_n) final
Set the value of the acceleration (Structural Analysis) at time n.
Definition CFEAVariable.hpp:224
const su2double & Solution_Accel(unsigned long iPoint, unsigned long iVar) const
Definition CFEAVariable.hpp:68
void Clear_BodyForces_Res(unsigned long iPoint) final
Clear the surface load residual.
Definition CFEAVariable.hpp:132
su2double * GetSolution_Accel_time_n(unsigned long iPoint) final
Get the solution at time n.
Definition CFEAVariable.hpp:264
const su2double * GetPrestretch(unsigned long iPoint) const final
A virtual member.
Definition CFEAVariable.hpp:317
su2double & Solution_Vel(unsigned long iPoint, unsigned long iVar)
Wrappers to solution to access velocity and acceleration by name.
Definition CFEAVariable.hpp:59
MatrixType Solution_Pred_Old
Predictor of the solution at time n for FSI purposes.
Definition CFEAVariable.hpp:49
su2double * GetSolution_Vel_time_n(unsigned long iPoint) final
Get the solution at time n.
Definition CFEAVariable.hpp:201
const su2double * GetSolution_Vel_Pred(unsigned long iPoint) const final
Get the velocity solution.
Definition CFEAVariable.hpp:285
VectorType VonMises_Stress
Von Mises stress.
Definition CFEAVariable.hpp:46
void SetSolution_Accel(unsigned long iPoint, const su2double *val_solution_accel) final
Set the value of the acceleration (Structural Analysis).
Definition CFEAVariable.hpp:207
su2double Get_BodyForces_Res(unsigned long iPoint, unsigned long iVar) const final
Get the body forces.
Definition CFEAVariable.hpp:139
void SetStress_FEM(unsigned long iPoint, unsigned long iVar, su2double val_stress) final
Set the value of the stress at the node.
Definition CFEAVariable.hpp:112
void SetSolution_Accel(unsigned long iPoint, unsigned long iVar, su2double val_solution_accel) final
Definition CFEAVariable.hpp:216
void SetSolution_Pred(unsigned long iPoint, const su2double *val_solution_pred) final
Set the value of the old solution.
Definition CFEAVariable.hpp:277
const su2double & Solution_Vel(unsigned long iPoint, unsigned long iVar) const
Definition CFEAVariable.hpp:62
su2double & Solution_Accel_time_n(unsigned long iPoint, unsigned long iVar)
Definition CFEAVariable.hpp:77
su2double * GetSolution_Vel(unsigned long iPoint) final
Get the solution of the problem.
Definition CFEAVariable.hpp:186
su2double GetSolution_Vel(unsigned long iPoint, unsigned long iVar) const final
Get the velocity (Structural Analysis).
Definition CFEAVariable.hpp:180
su2double & Solution_Vel_time_n(unsigned long iPoint, unsigned long iVar)
Definition CFEAVariable.hpp:71
MatrixType Residual_Ext_Body
Term of the residual due to body forces.
Definition CFEAVariable.hpp:44
MatrixType Solution_Pred
Predictor of the solution for FSI purposes.
Definition CFEAVariable.hpp:48
MatrixType Solution_Vel_Pred
Predictor of the velocity solution for FSI purposes.
Definition CFEAVariable.hpp:50
MatrixType Stress
Stress tensor.
Definition CFEAVariable.hpp:42
su2double GetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar) const final
Get the acceleration of the nodes (Structural Analysis) at time n.
Definition CFEAVariable.hpp:256
const su2double * GetStress_FEM(unsigned long iPoint) const final
Get the value of the stress.
Definition CFEAVariable.hpp:105
void SetSolution_Vel_Pred(unsigned long iPoint, const su2double *val_solution_pred) final
Set the value of the solution velocity predictor.
Definition CFEAVariable.hpp:269
const su2double & Solution_Vel_time_n(unsigned long iPoint, unsigned long iVar) const
Definition CFEAVariable.hpp:74
void SetVonMises_Stress(unsigned long iPoint, su2double val_stress) final
Set the value of the Von Mises stress.
Definition CFEAVariable.hpp:328
void SetSolution_Vel(unsigned long iPoint, unsigned long iVar, su2double val_solution_vel) final
Definition CFEAVariable.hpp:154
void SetSolution_Pred_Old(unsigned long iPoint, const su2double *val_solution_pred_old) final
Set the value of the old solution.
Definition CFEAVariable.hpp:297
void SetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar, su2double val_solution_vel_time_n) final
Definition CFEAVariable.hpp:171
const su2double * GetSolution_Pred(unsigned long iPoint) const final
Get the solution at time n.
Definition CFEAVariable.hpp:291
~CFEAVariable() override=default
Destructor of the class.
void SetSolution_Vel_time_n(unsigned long iPoint, const su2double *val_solution_vel_time_n) final
Set the value of the velocity (Structural Analysis) at time n.
Definition CFEAVariable.hpp:162
su2double GetPrestretch(unsigned long iPoint, unsigned long iVar) const final
A virtual member.
Definition CFEAVariable.hpp:322
const su2double * GetSolution_Pred_Old(unsigned long iPoint) const final
Get the solution at time n.
Definition CFEAVariable.hpp:305
const su2double * GetReference_Geometry(unsigned long iPoint) const final
Get the pointer to the reference geometry.
Definition CFEAVariable.hpp:347
void SetPrestretch(unsigned long iPoint, unsigned long iVar, su2double val_prestretch) final
A virtual member.
Definition CFEAVariable.hpp:310
su2double GetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar) const final
Get the velocity of the nodes (Structural Analysis) at time n.
Definition CFEAVariable.hpp:193
void SetReference_Geometry(unsigned long iPoint, unsigned long iVar, su2double ref_geometry) final
Set the reference geometry.
Definition CFEAVariable.hpp:340
su2double & Solution_Accel(unsigned long iPoint, unsigned long iVar)
Definition CFEAVariable.hpp:65
void SetSolution_Vel(unsigned long iPoint, const su2double *val_solution_vel) final
Set the value of the velocity (Structural Analysis).
Definition CFEAVariable.hpp:145
void Add_BodyForces_Res(unsigned long iPoint, const su2double *val_bodyForce) final
Add body forces to the residual term.
Definition CFEAVariable.hpp:124
Main class for defining the variables.
Definition CVariable.hpp:50
MatrixType Solution
Solution of the problem.
Definition CVariable.hpp:55
MatrixType Solution_time_n
Solution of the problem at time n for dual-time stepping technique.
Definition CVariable.hpp:70
unsigned long nVar
Number of variables of the problem.
Definition CVariable.hpp:108
#define FORCEINLINE
Definition code_config.hpp:44
passivedouble su2double
Definition code_config.hpp:181