Documentation 6b54b78464
Loading...
Searching...
No Matches
CFEAElasticity.hpp
Go to the documentation of this file.
1/*!
2 * \file CFEAElasticity.hpp
3 * \brief Declaration and inlines of the base class for elasticity problems.
4 * \author Ruben Sanchez
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 <memory>
31#include "../CNumerics.hpp"
32#include "../../../../Common/include/geometry/elements/CElement.hpp"
33
34/*!
35 * \class CFEAElasticity
36 * \ingroup Elasticity_Equations
37 * \brief Abstract class for computing the tangent matrix and the residual for structural problems.
38 * \note At the next level of abstraction (linear or not) a class must define the constitutive term.
39 * The methods we override in this class with an empty implementation are here just to better
40 * document the public interface of this class hierarchy.
41 * \author R.Sanchez
42 * \version 8.5.0 "Harrier"
43 */
44class CFEAElasticity : public CNumerics {
45
46protected:
47
48 enum : unsigned short {DIM_STRAIN_2D = 3, /*!< \brief Exx, Eyy, Gxy. */
49 DIM_STRAIN_3D = 6}; /*!< \brief Exx, Eyy, Ezz, Gxy, Gxz, Gyz. */
50
51 enum : unsigned short {NNODES_2D = 4, /*!< \brief Maximum number of nodes for 2D problems. */
52 NNODES_3D = 8}; /*!< \brief Maximum number of nodes for 3D problems. */
53
54 su2double E = 1.0; /*!< \brief Aux. variable, Young's modulus of elasticity. */
55 su2double Nu = 0.0; /*!< \brief Aux. variable, Poisson's ratio. */
56 su2double Rho_s = 0.0; /*!< \brief Aux. variable, Structural density. */
57 su2double Rho_s_DL = 0.0; /*!< \brief Aux. variable, Structural density (for dead loads). */
58 su2double Alpha = 0.0; /*!< \brief Aux. variable, thermal expansion coefficient. */
59
60 su2double Mu = 0.0; /*!< \brief Aux. variable, Lame's coeficient. */
61 su2double Lambda = 0.0; /*!< \brief Aux. variable, Lame's coeficient. */
62 su2double Kappa = 0.0; /*!< \brief Aux. variable, Compressibility constant. */
63 su2double ThermalStressTerm = 0.0; /*!< \brief Aux. variable, Relationship between stress and delta T. */
64
65 std::unique_ptr<su2double[]> E_i; /*!< \brief Young's modulus of elasticity. */
66 std::unique_ptr<su2double[]> Nu_i; /*!< \brief Poisson's ratio. */
67 std::unique_ptr<su2double[]> Rho_s_i; /*!< \brief Structural density. */
68 std::unique_ptr<su2double[]> Rho_s_DL_i; /*!< \brief Structural density (for dead loads). */
69 std::unique_ptr<su2double[]> Alpha_i; /*!< \brief Thermal expansion coefficient. */
70
71 su2double ReferenceTemperature = 0.0; /*!< \brief Reference temperature for thermal expansion. */
72
73 su2double D_Mat[DIM_STRAIN_3D][DIM_STRAIN_3D]; /*!< \brief Constitutive matrix - Auxiliary. */
74
75 std::unique_ptr<su2double[]> DV_Val; /*!< \brief For optimization cases, value of the design variables. */
76 unsigned short n_DV = 0; /*!< \brief For optimization cases, number of design variables. */
77
78 bool plane_stress = false; /*!< \brief Checks if we are solving a plane stress case. */
79 bool linear = false; /*!< \brief Checks if we are solving a linear elasticity case. */
80
81public:
82 /*!
83 * \brief Default constructor
84 */
85 CFEAElasticity() = default;
86
87 /*!
88 * \brief Constructor of the class (overload).
89 * \param[in] val_nDim - Number of dimensions of the problem.
90 * \param[in] val_nVar - Number of variables of the problem.
91 * \param[in] config - Definition of the particular problem.
92 */
93 CFEAElasticity(unsigned short val_nDim, unsigned short val_nVar, const CConfig *config);
94
95 /*!
96 * \brief Set elasticity modulus and Poisson ratio.
97 * \param[in] iVal - Index of the property.
98 * \param[in] val_E - Value of the elasticity (Young) modulus.
99 * \param[in] val_Nu - Value of the Poisson ratio.
100 */
101 inline void SetMaterial_Properties(unsigned short iVal, su2double val_E, su2double val_Nu) final {
102 E_i[iVal] = val_E;
103 Nu_i[iVal] = val_Nu;
104 }
105
106 /*!
107 * \brief Set densities, real and for gravity loading purposes.
108 * \param[in] iVal - Index of the property.
109 * \param[in] val_Rho - Material density.
110 * \param[in] val_Rho_DL - Density for gravity (dead) loads.
111 */
112 inline void SetMaterial_Density(unsigned short iVal, su2double val_Rho, su2double val_Rho_DL) final {
113 Rho_s_i[iVal] = val_Rho;
114 Rho_s_DL_i[iVal] = val_Rho_DL;
115 }
116
117 /*!
118 * \brief Set element electric field.
119 * \param[in] i_DV - Index of the variable.
120 * \param[in] val_EField - Value of the field.
121 */
122 inline void Set_ElectricField(unsigned short i_DV, su2double val_EField) override { }
123
124 /*!
125 * \brief Set the element-based local Young's modulus in mesh problems
126 * \param[in] iElem - Element index.
127 * \param[in] val_E - Value of elasticity modulus.
128 */
129 inline void SetMeshElasticProperties(unsigned long iElem, su2double val_E) override { }
130
131 /*!
132 * \brief Set the value of a design variable.
133 * \param[in] i_DV - Index of the variable.
134 * \param[in] val_DV - Value of the variable.
135 */
136 inline void Set_DV_Val(unsigned short i_DV, su2double val_DV) final { DV_Val[i_DV] = val_DV; }
137
138 /*!
139 * \brief Get the value of a design variable.
140 * \param[in] i_DV - Index of the variable.
141 * \return Value of the variable.
142 */
143 inline su2double Get_DV_Val(unsigned short i_DV) const final { return DV_Val[i_DV]; }
144
145 /*!
146 * \brief Build the mass matrix of an element.
147 * \param[in,out] element_container - Element whose mass matrix is being built.
148 * \param[in] config - Definition of the problem.
149 */
150 void Compute_Mass_Matrix(CElement *element_container, const CConfig *config) final;
151
152 /*!
153 * \brief Compute the nodal inertial loads for an element.
154 * \param[in,out] element_container - The element for which the inertial loads are computed.
155 * \param[in] config - Definition of the problem.
156 */
157 void Compute_Body_Forces(CElement *element_container, const CConfig *config) final;
158
159 /*!
160 * \brief Build the tangent stiffness matrix of an element.
161 * \param[in,out] element_container - Element whose tangent matrix is being built.
162 * \param[in] config - Definition of the problem.
163 */
164 inline void Compute_Tangent_Matrix(CElement *element_container, const CConfig *config) override { };
165
166 /*!
167 * \brief Compute averaged nodal stresses (for post processing).
168 * \param[in,out] element_container - The finite element.
169 * \param[in] config - Definition of the problem.
170 */
171 inline su2double Compute_Averaged_NodalStress(CElement *element_container, const CConfig *config) override { return 0; };
172
173 /*!
174 * \brief Compute VonMises stress from components Sxx Syy Sxy Szz Sxz Syz.
175 * \note Szz is required in 2D whereas Sxz and Syz are assumed to be 0.
176 */
177 template <class T>
178 static su2double VonMisesStress(unsigned short nDim, const T& stress) {
179 /*--- In 2D, we only have 4 components: Sxx, Syy, Sxy, Szz. ---*/
180 const auto& Sxx = stress[0];
181 const auto& Syy = stress[1];
182 const auto& Sxy = stress[2];
183 const auto& Szz = stress[3];
184 su2double Sxz = 0, Syz = 0;
185 if (nDim == 3) {
186 Sxz = stress[4];
187 Syz = stress[5];
188 }
189 return sqrt(0.5 * (pow(Sxx - Syy, 2) + pow(Syy - Szz, 2) + pow(Szz - Sxx, 2) + 6 * (Sxy * Sxy + Sxz * Sxz + Syz * Syz)));
190 }
191
192protected:
193 /*!
194 * \brief Compute the constitutive matrix, must be implemented by derived classes.
195 * \param[in,out] element_container - The finite element.
196 * \param[in] config - Definition of the problem.
197 */
198 virtual void Compute_Constitutive_Matrix(CElement *element_container, const CConfig *config) = 0;
199
200 /*!
201 * \brief Set element material properties.
202 * \param[in] element_container - Element defining the properties.
203 * \param[in] config - Definition of the problem.
204 */
205 virtual void SetElement_Properties(const CElement *element_container, const CConfig *config);
206
207 /*!
208 * \brief Read design variables from file.
209 * \param[in] config - Definition of the problem.
210 */
211 void ReadDV(const CConfig *config);
212
213 /*!
214 * \brief Update the Lame parameters (required in AD to account for all dependencies).
215 */
216 inline void Compute_Lame_Parameters(void) {
217 Mu = E / (2.0*(1.0 + Nu));
218 Lambda = Nu*E/((1.0+Nu)*(1.0-2.0*Nu));
219 Kappa = Lambda + (2/3)*Mu;
220 /*--- https://solidmechanics.org/Text/Chapter3_2/Chapter3_2.php
221 * The stress tensor for nonlinear problems is still 3x3 and plane stress is imposed
222 * by determining the deformation that makes sigma_33 = 0, hence this denominator is
223 * only changed for linear elasticity. ---*/
224 const auto nu_mult = (linear && plane_stress) ? 1 : 2;
225 ThermalStressTerm = -Alpha * E / (1 - nu_mult * Nu);
226 }
227
228 /*!
229 * \brief Kronecker delta.
230 * \param[in] iVar - Index i.
231 * \param[in] jVar - Index j.
232 * \return 1 if i=j, 0 otherwise.
233 */
234 inline static passivedouble deltaij(unsigned short iVar, unsigned short jVar) {
235 return static_cast<passivedouble>(iVar == jVar);
236 }
237
238 template <typename Mat1, typename Mat2>
239 void FillBMat(unsigned short iNode, const Mat1& GradNi_Mat, Mat2& B_Mat) const {
240 if (nDim == 2) {
241 B_Mat[0][0] = GradNi_Mat[iNode][0];
242 B_Mat[1][1] = GradNi_Mat[iNode][1];
243 B_Mat[2][0] = GradNi_Mat[iNode][1];
244 B_Mat[2][1] = GradNi_Mat[iNode][0];
245 }
246 else {
247 B_Mat[0][0] = GradNi_Mat[iNode][0];
248 B_Mat[1][1] = GradNi_Mat[iNode][1];
249 B_Mat[2][2] = GradNi_Mat[iNode][2];
250 B_Mat[3][0] = GradNi_Mat[iNode][1];
251 B_Mat[3][1] = GradNi_Mat[iNode][0];
252 B_Mat[4][0] = GradNi_Mat[iNode][2];
253 B_Mat[4][2] = GradNi_Mat[iNode][0];
254 B_Mat[5][1] = GradNi_Mat[iNode][2];
255 B_Mat[5][2] = GradNi_Mat[iNode][1];
256 }
257 }
258
259};
Main class for defining the problem; basically this class reads the configuration file,...
Definition CConfig.hpp:64
Abstract class for defining finite elements.
Definition CElement.hpp:58
Abstract class for computing the tangent matrix and the residual for structural problems.
Definition CFEAElasticity.hpp:44
void Set_DV_Val(unsigned short i_DV, su2double val_DV) final
Set the value of a design variable.
Definition CFEAElasticity.hpp:136
void SetMaterial_Density(unsigned short iVal, su2double val_Rho, su2double val_Rho_DL) final
Set densities, real and for gravity loading purposes.
Definition CFEAElasticity.hpp:112
void Set_ElectricField(unsigned short i_DV, su2double val_EField) override
Set element electric field.
Definition CFEAElasticity.hpp:122
std::unique_ptr< su2double[]> Alpha_i
Thermal expansion coefficient.
Definition CFEAElasticity.hpp:69
su2double ReferenceTemperature
Reference temperature for thermal expansion.
Definition CFEAElasticity.hpp:71
std::unique_ptr< su2double[]> DV_Val
For optimization cases, value of the design variables.
Definition CFEAElasticity.hpp:75
static su2double VonMisesStress(unsigned short nDim, const T &stress)
Compute VonMises stress from components Sxx Syy Sxy Szz Sxz Syz.
Definition CFEAElasticity.hpp:178
@ NNODES_2D
Maximum number of nodes for 2D problems.
Definition CFEAElasticity.hpp:51
@ NNODES_3D
Definition CFEAElasticity.hpp:52
std::unique_ptr< su2double[]> Nu_i
Poisson's ratio.
Definition CFEAElasticity.hpp:66
su2double Compute_Averaged_NodalStress(CElement *element_container, const CConfig *config) override
Compute averaged nodal stresses (for post processing).
Definition CFEAElasticity.hpp:171
void Compute_Body_Forces(CElement *element_container, const CConfig *config) final
Compute the nodal inertial loads for an element.
Definition CFEAElasticity.cpp:169
su2double Get_DV_Val(unsigned short i_DV) const final
Get the value of a design variable.
Definition CFEAElasticity.hpp:143
void Compute_Lame_Parameters(void)
Update the Lame parameters (required in AD to account for all dependencies).
Definition CFEAElasticity.hpp:216
su2double ThermalStressTerm
Aux. variable, Relationship between stress and delta T.
Definition CFEAElasticity.hpp:63
su2double Nu
Aux. variable, Poisson's ratio.
Definition CFEAElasticity.hpp:55
std::unique_ptr< su2double[]> Rho_s_DL_i
Structural density (for dead loads).
Definition CFEAElasticity.hpp:68
su2double Mu
Aux. variable, Lame's coeficient.
Definition CFEAElasticity.hpp:60
su2double Rho_s
Aux. variable, Structural density.
Definition CFEAElasticity.hpp:56
su2double Lambda
Aux. variable, Lame's coeficient.
Definition CFEAElasticity.hpp:61
std::unique_ptr< su2double[]> E_i
Young's modulus of elasticity.
Definition CFEAElasticity.hpp:65
bool plane_stress
Checks if we are solving a plane stress case.
Definition CFEAElasticity.hpp:78
void SetMeshElasticProperties(unsigned long iElem, su2double val_E) override
Set the element-based local Young's modulus in mesh problems.
Definition CFEAElasticity.hpp:129
su2double Kappa
Aux. variable, Compressibility constant.
Definition CFEAElasticity.hpp:62
static passivedouble deltaij(unsigned short iVar, unsigned short jVar)
Kronecker delta.
Definition CFEAElasticity.hpp:234
su2double Alpha
Aux. variable, thermal expansion coefficient.
Definition CFEAElasticity.hpp:58
void ReadDV(const CConfig *config)
Read design variables from file.
Definition CFEAElasticity.cpp:275
void Compute_Tangent_Matrix(CElement *element_container, const CConfig *config) override
Build the tangent stiffness matrix of an element.
Definition CFEAElasticity.hpp:164
void SetMaterial_Properties(unsigned short iVal, su2double val_E, su2double val_Nu) final
Set elasticity modulus and Poisson ratio.
Definition CFEAElasticity.hpp:101
virtual void SetElement_Properties(const CElement *element_container, const CConfig *config)
Set element material properties.
Definition CFEAElasticity.cpp:245
void Compute_Mass_Matrix(CElement *element_container, const CConfig *config) final
Build the mass matrix of an element.
Definition CFEAElasticity.cpp:109
unsigned short n_DV
For optimization cases, number of design variables.
Definition CFEAElasticity.hpp:76
virtual void Compute_Constitutive_Matrix(CElement *element_container, const CConfig *config)=0
Compute the constitutive matrix, must be implemented by derived classes.
CFEAElasticity()=default
Default constructor.
su2double Rho_s_DL
Aux. variable, Structural density (for dead loads).
Definition CFEAElasticity.hpp:57
@ DIM_STRAIN_2D
Exx, Eyy, Gxy.
Definition CFEAElasticity.hpp:48
@ DIM_STRAIN_3D
Definition CFEAElasticity.hpp:49
su2double D_Mat[DIM_STRAIN_3D][DIM_STRAIN_3D]
Constitutive matrix - Auxiliary.
Definition CFEAElasticity.hpp:73
bool linear
Checks if we are solving a linear elasticity case.
Definition CFEAElasticity.hpp:79
std::unique_ptr< su2double[]> Rho_s_i
Structural density.
Definition CFEAElasticity.hpp:67
su2double E
Aux. variable, Young's modulus of elasticity.
Definition CFEAElasticity.hpp:54
void FillBMat(unsigned short iNode, const Mat1 &GradNi_Mat, Mat2 &B_Mat) const
Definition CFEAElasticity.hpp:239
Class for defining the numerical methods.
Definition CNumerics.hpp:48
unsigned short nDim
Definition CNumerics.hpp:52
double passivedouble
Definition code_config.hpp:129
passivedouble su2double
Definition code_config.hpp:181
FORCEINLINE ARRAY_T sqrt(const ARRAY_T &x)
Definition special_vectorization.hpp:116
FORCEINLINE ARRAY_T pow(const ARRAY_T &a, const ARRAY_T &b)
Definition special_vectorization.hpp:179