Skip to content

Commit 458e732

Browse files
committed
thermal stress term, not coupled to heat solver
1 parent 68747ef commit 458e732

File tree

14 files changed

+110
-70
lines changed

14 files changed

+110
-70
lines changed

Common/include/CConfig.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,8 @@ class CConfig {
10181018
su2double *ElasticityMod, /*!< \brief Value of the elasticity moduli. */
10191019
*PoissonRatio, /*!< \brief Value of the Poisson ratios. */
10201020
*MaterialDensity, /*!< \brief Value of the Material densities. */
1021-
*MaterialThermalExpansion; /*!< \brief Value of the thermal expansion coefficients. */
1021+
*MaterialThermalExpansion, /*!< \brief Value of the thermal expansion coefficients. */
1022+
MaterialReferenceTemperature; /*!< \brief Value of the reference temperature for thermal expansion. */
10221023
unsigned short nElectric_Field, /*!< \brief Number of different values for the electric field in the membrane. */
10231024
nDim_Electric_Field; /*!< \brief Dimensionality of the problem. */
10241025
unsigned short nDim_RefNode; /*!< \brief Dimensionality of the vector . */
@@ -2396,6 +2397,11 @@ class CConfig {
23962397
*/
23972398
su2double GetMaterialThermalExpansion(unsigned short id_val) const { return MaterialThermalExpansion[id_val]; }
23982399

2400+
/*!
2401+
* \brief Temperature at which there is no stress from thermal expansion.
2402+
*/
2403+
su2double GetMaterialReferenceTemperature() const { return MaterialReferenceTemperature; }
2404+
23992405
/*!
24002406
* \brief Compressibility/incompressibility of the solids analysed using the structural solver.
24012407
* \return Compressible or incompressible.

Common/include/geometry/elements/CElement.hpp

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ class CElement {
6767
su2activematrix NodalExtrap; /*!< \brief Coordinates of the nodal points for Gaussian extrapolation. */
6868
su2activematrix NodalStress; /*!< \brief Stress at the nodes. */
6969

70+
su2activevector NodalTemperature; /*!< \brief Temperature at the nodes. */
71+
7072
/*--- Stiffness and load matrices. ---*/
7173
std::vector<su2activematrix> Kab; /*!< \brief Structure for the constitutive component of the tangent matrix. */
7274
su2activematrix Mab; /*!< \brief Structure for the nodal components of the mass matrix. */
@@ -151,7 +153,7 @@ class CElement {
151153
* \param[in] iDim - Dimension.
152154
* \param[in] val_CoordRef - Value of the coordinate.
153155
*/
154-
inline void SetRef_Coord(unsigned short iNode, unsigned short iDim, su2double val_CoordRef) {
156+
inline void SetRef_Coord(unsigned short iNode, unsigned short iDim, const su2double& val_CoordRef) {
155157
RefCoord(iNode, iDim) = val_CoordRef;
156158
}
157159

@@ -161,10 +163,22 @@ class CElement {
161163
* \param[in] iDim - Dimension.
162164
* \param[in] val_CoordRef - Value of the coordinate.
163165
*/
164-
inline void SetCurr_Coord(unsigned short iNode, unsigned short iDim, su2double val_CoordCurr) {
166+
inline void SetCurr_Coord(unsigned short iNode, unsigned short iDim, const su2double& val_CoordCurr) {
165167
CurrentCoord(iNode, iDim) = val_CoordCurr;
166168
}
167169

170+
/*!
171+
* \brief Set the value of the temperature of a node.
172+
*/
173+
inline void SetTemperature(unsigned short iNode, const su2double& val_Temperature) {
174+
NodalTemperature[iNode] = val_Temperature;
175+
}
176+
177+
/*!
178+
* \brief Set the value of the temperature of all nodes.
179+
*/
180+
inline void SetTemperature(const su2double& val_Temperature) { NodalTemperature = val_Temperature; }
181+
168182
/*!
169183
* \brief Get the value of the coordinate of the nodes in the reference configuration.
170184
* \param[in] iNode - Index of node.
@@ -181,6 +195,17 @@ class CElement {
181195
*/
182196
inline su2double GetCurr_Coord(unsigned short iNode, unsigned short iDim) const { return CurrentCoord(iNode, iDim); }
183197

198+
/*!
199+
* \brief Get the value of the temperature at a Gaussian integration point.
200+
*/
201+
inline su2double GetTemperature(unsigned short iGauss) const {
202+
su2double Temperature = 0;
203+
for (auto iNode = 0u; iNode < nNodes; ++iNode) {
204+
Temperature += GetNi(iNode, iGauss) * NodalTemperature[iNode];
205+
}
206+
return Temperature;
207+
}
208+
184209
/*!
185210
* \brief Get the weight of the corresponding Gaussian Point.
186211
* \param[in] iGauss - index of the Gaussian point.
@@ -214,7 +239,9 @@ class CElement {
214239
* \param[in] nodeB - index of Node b.
215240
* \param[in] val_Ks_ab - value of the term that will constitute the diagonal of the stress contribution.
216241
*/
217-
inline void Add_Mab(unsigned short nodeA, unsigned short nodeB, su2double val_Mab) { Mab(nodeA, nodeB) += val_Mab; }
242+
inline void Add_Mab(unsigned short nodeA, unsigned short nodeB, const su2double& val_Mab) {
243+
Mab(nodeA, nodeB) += val_Mab;
244+
}
218245

219246
/*!
220247
* \brief Add the value of a submatrix K relating nodes a and b, for the constitutive term.
@@ -243,7 +270,7 @@ class CElement {
243270
* \param[in] nodeB - index of Node b.
244271
* \param[in] val_Ks_ab - value of the term that will constitute the diagonal of the stress contribution.
245272
*/
246-
inline void Add_Ks_ab(unsigned short nodeA, unsigned short nodeB, su2double val_Ks_ab) {
273+
inline void Add_Ks_ab(unsigned short nodeA, unsigned short nodeB, const su2double& val_Ks_ab) {
247274
Ks_ab(nodeA, nodeB) += val_Ks_ab;
248275
}
249276

@@ -354,7 +381,7 @@ class CElement {
354381
* \param[in] iVar - Variable index.
355382
* \param[in] val_Stress - Value of the stress added.
356383
*/
357-
inline void Add_NodalStress(unsigned short iNode, unsigned short iVar, su2double val_Stress) {
384+
inline void Add_NodalStress(unsigned short iNode, unsigned short iVar, const su2double& val_Stress) {
358385
NodalStress(iNode, iVar) += val_Stress;
359386
}
360387

@@ -789,7 +816,7 @@ class CQUAD4 final : public CElementWithKnownSizes<4, 4, 2> {
789816
/*!
790817
* \brief Shape functions (Ni) evaluated at point Xi,Eta.
791818
*/
792-
inline static void ShapeFunctions(su2double Xi, su2double Eta, su2double* Ni) {
819+
inline static void ShapeFunctions(const su2double& Xi, const su2double& Eta, su2double* Ni) {
793820
Ni[0] = 0.25 * (1.0 - Xi) * (1.0 - Eta);
794821
Ni[1] = 0.25 * (1.0 + Xi) * (1.0 - Eta);
795822
Ni[2] = 0.25 * (1.0 + Xi) * (1.0 + Eta);
@@ -799,7 +826,7 @@ class CQUAD4 final : public CElementWithKnownSizes<4, 4, 2> {
799826
/*!
800827
* \brief Shape function Jacobian (dNi) evaluated at point Xi,Eta.
801828
*/
802-
inline static void ShapeFunctionJacobian(su2double Xi, su2double Eta, su2double dNi[][2]) {
829+
inline static void ShapeFunctionJacobian(const su2double& Xi, const su2double& Eta, su2double dNi[][2]) {
803830
dNi[0][0] = -0.25 * (1.0 - Eta);
804831
dNi[0][1] = -0.25 * (1.0 - Xi);
805832
dNi[1][0] = 0.25 * (1.0 - Eta);

Common/src/CConfig.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2442,6 +2442,8 @@ void CConfig::SetConfig_Options() {
24422442
addDoubleListOption("MATERIAL_DENSITY", nMaterialDensity, MaterialDensity);
24432443
/* DESCRIPTION: Material thermal expansion coefficient */
24442444
addDoubleListOption("MATERIAL_THERMAL_EXPANSION_COEFF", nMaterialThermalExpansion, MaterialThermalExpansion);
2445+
/* DESCRIPTION: Temperature at which there is no stress from thermal expansion */
2446+
addDoubleOption("MATERIAL_REFERENCE_TEMPERATURE", MaterialReferenceTemperature, 288.15);
24452447
/* DESCRIPTION: Knowles B constant */
24462448
addDoubleOption("KNOWLES_B", Knowles_B, 1.0);
24472449
/* DESCRIPTION: Knowles N constant */

Common/src/geometry/elements/CElement.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ CElement::CElement(unsigned short ngauss, unsigned short nnodes, unsigned short
4747

4848
NodalStress.resize(nNodes, 6) = su2double(0.0);
4949

50+
NodalTemperature.resize(nNodes) = su2double(0.0);
51+
5052
Mab.resize(nNodes, nNodes);
5153
Ks_ab.resize(nNodes, nNodes);
5254
Kab.resize(nNodes);

Common/src/geometry/elements/CQUAD4.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ CQUAD4::CQUAD4() : CElementWithKnownSizes<NGAUSS, NNODE, NDIM>() {
6767
/*--- Store the extrapolation functions (used to compute nodal stresses) ---*/
6868

6969
su2double ExtrapCoord[4][2], sqrt3 = 1.732050807568877;
70-
;
7170

7271
ExtrapCoord[0][0] = -sqrt3;
7372
ExtrapCoord[0][1] = -sqrt3;

SU2_CFD/include/numerics/elasticity/CFEAElasticity.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,16 @@ class CFEAElasticity : public CNumerics {
5959
su2double Mu = 0.0; /*!< \brief Aux. variable, Lame's coeficient. */
6060
su2double Lambda = 0.0; /*!< \brief Aux. variable, Lame's coeficient. */
6161
su2double Kappa = 0.0; /*!< \brief Aux. variable, Compressibility constant. */
62+
su2double ThermalStressTerm = 0.0; /*!< \brief Aux. variable, Relationship between stress and delta T. */
6263

6364
su2double *E_i = nullptr; /*!< \brief Young's modulus of elasticity. */
6465
su2double *Nu_i = nullptr; /*!< \brief Poisson's ratio. */
6566
su2double *Rho_s_i = nullptr; /*!< \brief Structural density. */
6667
su2double *Rho_s_DL_i = nullptr; /*!< \brief Structural density (for dead loads). */
6768
su2double *Alpha_i = nullptr; /*!< \brief Thermal expansion coefficient. */
6869

70+
su2double ReferenceTemperature = 0.0; /*!< \brief Reference temperature for thermal expansion. */
71+
6972
su2double **Ba_Mat = nullptr; /*!< \brief Matrix B for node a - Auxiliary. */
7073
su2double **Bb_Mat = nullptr; /*!< \brief Matrix B for node b - Auxiliary. */
7174
su2double *Ni_Vec = nullptr; /*!< \brief Vector of shape functions - Auxiliary. */
@@ -74,8 +77,6 @@ class CFEAElasticity : public CNumerics {
7477
su2double **GradNi_Ref_Mat = nullptr; /*!< \brief Gradients of Ni - Auxiliary. */
7578
su2double **GradNi_Curr_Mat = nullptr; /*!< \brief Gradients of Ni - Auxiliary. */
7679

77-
su2double *FAux_Dead_Load = nullptr; /*!< \brief Auxiliar vector for the dead loads */
78-
7980
su2double *DV_Val = nullptr; /*!< \brief For optimization cases, value of the design variables. */
8081
unsigned short n_DV = 0; /*!< \brief For optimization cases, number of design variables. */
8182

@@ -232,6 +233,8 @@ class CFEAElasticity : public CNumerics {
232233
Mu = E / (2.0*(1.0 + Nu));
233234
Lambda = Nu*E/((1.0+Nu)*(1.0-2.0*Nu));
234235
Kappa = Lambda + (2/3)*Mu;
236+
/*--- https://solidmechanics.org/Text/Chapter3_2/Chapter3_2.php ---*/
237+
ThermalStressTerm = -Alpha * E / (1 - (plane_stress ? 1 : 2) * Nu);
235238
}
236239

237240
/*!
@@ -240,8 +243,8 @@ class CFEAElasticity : public CNumerics {
240243
* \param[in] jVar - Index j.
241244
* \return 1 if i=j, 0 otherwise.
242245
*/
243-
inline static su2double deltaij(unsigned short iVar, unsigned short jVar) {
244-
return su2double(iVar==jVar);
246+
inline static passivedouble deltaij(unsigned short iVar, unsigned short jVar) {
247+
return static_cast<passivedouble>(iVar == jVar);
245248
}
246249

247250
};

SU2_CFD/include/numerics/elasticity/CFEANonlinearElasticity.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,9 @@ class CFEANonlinearElasticity : public CFEAElasticity {
141141
* \brief Compute the stress tensor.
142142
* \param[in,out] element_container - The finite element.
143143
* \param[in] config - Definition of the problem.
144+
* \param[in] iGauss - Index of Gaussian integration point.
144145
*/
145-
virtual void Compute_Stress_Tensor(CElement *element_container, const CConfig *config) = 0;
146+
virtual void Compute_Stress_Tensor(CElement *element_container, const CConfig *config, unsigned short iGauss) = 0;
146147

147148
/*!
148149
* \brief Update an element with Maxwell's stress.

SU2_CFD/include/numerics/elasticity/nonlinear_models.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class CFEM_NeoHookean_Comp final : public CFEANonlinearElasticity {
7373
* \param[in,out] element_container - The finite element.
7474
* \param[in] config - Definition of the problem.
7575
*/
76-
void Compute_Stress_Tensor(CElement *element_container, const CConfig *config) override;
76+
void Compute_Stress_Tensor(CElement *element_container, const CConfig *config, unsigned short iGauss) override;
7777

7878
};
7979

@@ -124,7 +124,7 @@ class CFEM_Knowles_NearInc final : public CFEANonlinearElasticity {
124124
* \param[in,out] element_container - The finite element.
125125
* \param[in] config - Definition of the problem.
126126
*/
127-
void Compute_Stress_Tensor(CElement *element_container, const CConfig *config) override;
127+
void Compute_Stress_Tensor(CElement *element_container, const CConfig *config, unsigned short iGauss) override;
128128

129129
};
130130

@@ -172,7 +172,7 @@ class CFEM_DielectricElastomer final : public CFEANonlinearElasticity {
172172
* \param[in,out] element_container - The finite element.
173173
* \param[in] config - Definition of the problem.
174174
*/
175-
void Compute_Stress_Tensor(CElement *element_container, const CConfig *config) override;
175+
void Compute_Stress_Tensor(CElement *element_container, const CConfig *config, unsigned short iGauss) override;
176176

177177
};
178178

@@ -222,6 +222,6 @@ class CFEM_IdealDE final : public CFEANonlinearElasticity {
222222
* \param[in,out] element_container - The finite element.
223223
* \param[in] config - Definition of the problem.
224224
*/
225-
void Compute_Stress_Tensor(CElement *element_container, const CConfig *config) override;
225+
void Compute_Stress_Tensor(CElement *element_container, const CConfig *config, unsigned short iGauss) override;
226226

227227
};

SU2_CFD/src/numerics/elasticity/CFEAElasticity.cpp

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ CFEAElasticity::CFEAElasticity(unsigned short val_nDim, unsigned short val_nVar,
3535
nDim = val_nDim;
3636
nVar = val_nVar;
3737

38-
bool body_forces = config->GetDeadLoad(); // Body forces (dead loads).
3938
bool pseudo_static = config->GetPseudoStatic();
4039

4140
unsigned short iVar;
@@ -62,14 +61,11 @@ CFEAElasticity::CFEAElasticity(unsigned short val_nDim, unsigned short val_nVar,
6261
Rho_s = Rho_s_i[0];
6362
Rho_s_DL = Rho_s_DL_i[0];
6463
Alpha = Alpha_i[0];
64+
ReferenceTemperature = config->GetMaterialReferenceTemperature();
6565

6666
Compute_Lame_Parameters();
6767

68-
// Auxiliary vector for body forces (dead load)
69-
FAux_Dead_Load = nullptr;
70-
if (body_forces) FAux_Dead_Load = new su2double [nDim];
71-
72-
plane_stress = (config->GetElas2D_Formulation() == STRUCT_2DFORM::PLANE_STRESS);
68+
plane_stress = (nDim == 2) && (config->GetElas2D_Formulation() == STRUCT_2DFORM::PLANE_STRESS);
7369

7470
KAux_ab = new su2double* [nDim];
7571
for (iVar = 0; iVar < nDim; iVar++) {
@@ -162,12 +158,11 @@ CFEAElasticity::~CFEAElasticity() {
162158

163159
delete[] DV_Val;
164160

165-
delete [] FAux_Dead_Load;
166-
167161
delete [] E_i;
168162
delete [] Nu_i;
169163
delete [] Rho_s_i;
170164
delete [] Rho_s_DL_i;
165+
delete [] Alpha_i;
171166
delete [] Ni_Vec;
172167
}
173168

@@ -242,43 +237,32 @@ void CFEAElasticity::Compute_Dead_Load(CElement *element, const CConfig *config)
242237
AD::SetPreaccIn(Rho_s_DL);
243238
element->SetPreaccIn_Coords(false);
244239

245-
unsigned short iGauss, nGauss;
246-
unsigned short iNode, iDim, nNode;
247-
248-
su2double Weight, Jac_X;
249-
250240
/* -- Gravity directionality:
251241
* -- For 2D problems, we assume the direction for gravity is -y
252242
* -- For 3D problems, we assume the direction for gravity is -z
253243
*/
254244
su2double g_force[3] = {0.0,0.0,0.0};
255-
256-
if (nDim == 2) g_force[1] = -1*STANDARD_GRAVITY;
257-
else if (nDim == 3) g_force[2] = -1*STANDARD_GRAVITY;
245+
g_force[nDim - 1] = -STANDARD_GRAVITY;
258246

259247
element->ClearElement(); /*--- Restart the element to avoid adding over previous results. --*/
260248
element->ComputeGrad_Linear(); /*--- Need to compute the gradients to obtain the Jacobian. ---*/
261249

262-
nNode = element->GetnNodes();
263-
nGauss = element->GetnGaussPoints();
264-
265-
for (iGauss = 0; iGauss < nGauss; iGauss++) {
250+
const auto nNode = element->GetnNodes();
251+
const auto nGauss = element->GetnGaussPoints();
266252

267-
Weight = element->GetWeight(iGauss);
268-
Jac_X = element->GetJ_X(iGauss); /*--- The dead load is computed in the reference configuration ---*/
253+
for (auto iGauss = 0u; iGauss < nGauss; iGauss++) {
269254

270-
/*--- Retrieve the values of the shape functions for each node ---*/
271-
/*--- This avoids repeated operations ---*/
272-
for (iNode = 0; iNode < nNode; iNode++) {
273-
Ni_Vec[iNode] = element->GetNi(iNode,iGauss);
274-
}
255+
const auto Weight = element->GetWeight(iGauss);
256+
/*--- The dead load is computed in the reference configuration ---*/
257+
const auto Jac_X = element->GetJ_X(iGauss);
275258

276-
for (iNode = 0; iNode < nNode; iNode++) {
259+
for (auto iNode = 0; iNode < nNode; iNode++) {
260+
const auto Ni = element->GetNi(iNode,iGauss);
277261

278-
for (iDim = 0; iDim < nDim; iDim++) {
279-
FAux_Dead_Load[iDim] = Weight * Ni_Vec[iNode] * Jac_X * Rho_s_DL * g_force[iDim];
262+
su2double FAux_Dead_Load[3] = {0.0,0.0,0.0};
263+
for (auto iDim = 0u; iDim < nDim; iDim++) {
264+
FAux_Dead_Load[iDim] = Weight * Ni * Jac_X * Rho_s_DL * g_force[iDim];
280265
}
281-
282266
element->Add_FDL_a(iNode, FAux_Dead_Load);
283267

284268
}

SU2_CFD/src/numerics/elasticity/CFEALinearElasticity.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,11 @@ void CFEALinearElasticity::Compute_Tangent_Matrix(CElement *element, const CConf
9797
}
9898
}
9999

100+
const su2double thermalStress = ThermalStressTerm * (element->GetTemperature(iGauss) - ReferenceTemperature);
101+
100102
for (iNode = 0; iNode < nNode; iNode++) {
101103

102104
su2double KAux_t_a[3] = {0.0};
103-
const su2double thermalStress = -E * 2e-4 / (1 - 2 * Nu);
104105
for (iVar = 0; iVar < nDim; iVar++) {
105106
KAux_t_a[iVar] += Weight * thermalStress * GradNi_Ref_Mat[iNode][iVar] * Jac_X;
106107
}
@@ -321,14 +322,17 @@ su2double CFEALinearElasticity::Compute_Averaged_NodalStress(CElement *element,
321322

322323
}
323324

324-
/*--- Compute the Stress Vector as D*epsilon ---*/
325+
/*--- Compute the Stress Vector as D*epsilon + thermal stress ---*/
325326

326327
su2double Stress[DIM_STRAIN_3D] = {0.0};
327328

329+
const su2double thermalStress = ThermalStressTerm * (element->GetTemperature(iGauss) - ReferenceTemperature);
330+
328331
for (iVar = 0; iVar < bDim; iVar++) {
329332
for (jVar = 0; jVar < bDim; jVar++) {
330333
Stress[iVar] += D_Mat[iVar][jVar]*Strain[jVar];
331334
}
335+
if (iVar < nDim) Stress[iVar] += thermalStress;
332336
avgStress[iVar] += Stress[iVar] / nGauss;
333337
}
334338

@@ -370,10 +374,10 @@ CFEAMeshElasticity::CFEAMeshElasticity(unsigned short val_nDim, unsigned short v
370374
unsigned long val_nElem, const CConfig *config) :
371375
CFEALinearElasticity() {
372376
DV_Val = nullptr;
373-
FAux_Dead_Load = nullptr;
374377
Rho_s_i = nullptr;
375378
Rho_s_DL_i = nullptr;
376379
Nu_i = nullptr;
380+
Alpha_i = nullptr;
377381

378382
nDim = val_nDim;
379383
nVar = val_nVar;

0 commit comments

Comments
 (0)