Documentation a537f1bdf2
Loading...
Searching...
No Matches
CElementProperty.hpp
Go to the documentation of this file.
1/*!
2 * \file CElementProperty.hpp
3 * \brief Light classes to define finite element properties.
4 * \author R. 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/*!
31 * \class CProperty
32 * \ingroup Elasticity_Equations
33 * \brief Base class for defining element properties.
34 * \author R. Sanchez
35 * \version 8.5.0 "Harrier"
36 */
37class CProperty {
38 protected:
39 unsigned long iMat_Prop = 0; /*!< \brief Index of the properties (E, Nu) for the structural model used. */
40
41 public:
42 /*!
43 * \brief Constructor of the class.
44 * \param[in] valMat_Prop - Index of the physical properties (E,nu,rho,rho_dead_load) assigned to the element.
45 */
46 CProperty(unsigned long valMat_Prop) : iMat_Prop(valMat_Prop) {}
47
48 /*!
49 * \brief Destructor of the class.
50 */
51 virtual ~CProperty(void) {}
52
53 /*!
54 * \brief Get the material model to use for the element.
55 */
56 inline virtual unsigned long GetMat_Mod(void) const { return 0; }
57
58 /*!
59 * \brief Get index of the physical properties.
60 */
61 inline unsigned long GetMat_Prop(void) const { return iMat_Prop; }
62
63 /*!
64 * \brief Get index of the electric properties.
65 */
66 inline virtual unsigned long GetElectric_Prop(void) const { return 0; }
67
68 /*!
69 * \brief Get index of the design variable.
70 */
71 inline virtual unsigned long GetDV(void) const { return 0; }
72
73 /*!
74 * \brief Set the Design density (topology optimization variable).
75 */
76 inline virtual void SetDesignDensity(su2double valDensity) {}
77
78 /*!
79 * \brief Get the value of the Design density.
80 */
81 inline virtual su2double GetDesignDensity(void) const { return 0.0; }
82
83 /*!
84 * \brief Set the Physical density (used to penalize element stiffness by the FEM solver).
85 */
86 inline virtual void SetPhysicalDensity(su2double valDensity) {}
87
88 /*!
89 * \brief Get the value of the Physical density.
90 */
91 inline virtual su2double GetPhysicalDensity(void) const { return 0.0; }
92
93 /*!
94 * \brief Extract the derivative of the Design density.
95 */
96 inline virtual su2double GetAdjointDensity(void) { return 0.0; }
97
98 /*!
99 * \brief Register the Design density as an AD input variable.
100 */
101 inline virtual void RegisterDensity(void) {}
102};
103
104/*!
105 * \class CElementProperty
106 * \ingroup Elasticity_Equations
107 * \brief Class for defining element properties for the structural solver.
108 * \author R. Sanchez
109 * \version 8.5.0 "Harrier"
110 */
111class CElementProperty final : public CProperty {
112 private:
113 unsigned long iMat_Mod = 0; /*!< \brief Index of the material model used. */
114 unsigned long iElectric_Prop = 0; /*!< \brief Index of the electric properties (Em) for the structural model used. */
115 unsigned long iDV = 0; /*!< \brief Index of the group of design variables to which the element belongs. */
116 su2double design_rho = 1.0; /*!< \brief Value of the design density for material-based topology optimization. */
117 su2double physical_rho = 1.0; /*!< \brief Value of the physical density for material-based topology optimization. */
118
119 public:
120 /*!
121 * \brief Constructor of the class.
122 * \param[in] valMat_Model - Type of material model (i.e. numerics) for the element, see FEA_TERM etc. in
123 * option_structure.hpp. \param[in] valMat_Prop - Index of the physical properties (E,nu,rho,rho_dead_load) assigned
124 * to the element. \param[in] valElectric_Prop - Index of the electric properties. \param[in] valDV - Index of the
125 * design variable assigned to the element (bound to a material property by "DESIGN_VARIABLE_FEA"). \param[in]
126 * valDensity - Value for Design and Physical densities (topology optimization variables).
127 */
128 CElementProperty(unsigned long valMat_Model, unsigned long valMat_Prop, unsigned long valElectric_Prop,
129 unsigned long valDV, su2double valDensity = 1.0)
130 : CProperty(valMat_Prop),
131 iMat_Mod(valMat_Model),
132 iElectric_Prop(valElectric_Prop),
133 iDV(valDV),
134 design_rho(valDensity),
135 physical_rho(valDensity) {}
136
137 /*!
138 * \brief Destructor of the class.
139 */
140 ~CElementProperty(void) override {}
141
142 /*!
143 * \brief Get the material model to use for the element.
144 */
145 inline unsigned long GetMat_Mod(void) const override { return iMat_Mod; }
146
147 /*!
148 * \brief Get index of the electric properties.
149 */
150 inline unsigned long GetElectric_Prop(void) const override { return iElectric_Prop; }
151
152 /*!
153 * \brief Get index of the design variable.
154 */
155 inline unsigned long GetDV(void) const override { return iDV; }
156
157 /*!
158 * \brief Set the Design density (topology optimization variable).
159 */
160 inline void SetDesignDensity(su2double valDensity) override { design_rho = valDensity; }
161
162 /*!
163 * \brief Get the value of the Design density.
164 */
165 inline su2double GetDesignDensity(void) const override { return design_rho; }
166
167 /*!
168 * \brief Set the Physical density (used to penalize element stiffness by the FEM solver).
169 */
170 inline void SetPhysicalDensity(su2double valDensity) override { physical_rho = valDensity; }
171
172 /*!
173 * \brief Get the value of the Physical density.
174 */
175 inline su2double GetPhysicalDensity(void) const override { return physical_rho; }
176
177 /*!
178 * \brief Extract the derivative of the Design density.
179 */
180 inline su2double GetAdjointDensity(void) override {
181 su2double der = SU2_TYPE::GetDerivative(design_rho);
182 AD::ResetInput(design_rho);
183 return der;
184 }
185
186 /*!
187 * \brief Register the Design density as an AD input variable.
188 */
189 inline void RegisterDensity(void) override { AD::RegisterInput(design_rho); }
190};
Class for defining element properties for the structural solver.
Definition CElementProperty.hpp:111
void RegisterDensity(void) override
Register the Design density as an AD input variable.
Definition CElementProperty.hpp:189
void SetPhysicalDensity(su2double valDensity) override
Set the Physical density (used to penalize element stiffness by the FEM solver).
Definition CElementProperty.hpp:170
CElementProperty(unsigned long valMat_Model, unsigned long valMat_Prop, unsigned long valElectric_Prop, unsigned long valDV, su2double valDensity=1.0)
Constructor of the class.
Definition CElementProperty.hpp:128
su2double GetAdjointDensity(void) override
Extract the derivative of the Design density.
Definition CElementProperty.hpp:180
void SetDesignDensity(su2double valDensity) override
Set the Design density (topology optimization variable).
Definition CElementProperty.hpp:160
~CElementProperty(void) override
Destructor of the class.
Definition CElementProperty.hpp:140
su2double GetPhysicalDensity(void) const override
Get the value of the Physical density.
Definition CElementProperty.hpp:175
unsigned long GetElectric_Prop(void) const override
Get index of the electric properties.
Definition CElementProperty.hpp:150
su2double GetDesignDensity(void) const override
Get the value of the Design density.
Definition CElementProperty.hpp:165
unsigned long GetMat_Mod(void) const override
Get the material model to use for the element.
Definition CElementProperty.hpp:145
unsigned long GetDV(void) const override
Get index of the design variable.
Definition CElementProperty.hpp:155
Base class for defining element properties.
Definition CElementProperty.hpp:37
virtual su2double GetPhysicalDensity(void) const
Get the value of the Physical density.
Definition CElementProperty.hpp:91
CProperty(unsigned long valMat_Prop)
Constructor of the class.
Definition CElementProperty.hpp:46
virtual su2double GetAdjointDensity(void)
Extract the derivative of the Design density.
Definition CElementProperty.hpp:96
virtual ~CProperty(void)
Destructor of the class.
Definition CElementProperty.hpp:51
virtual unsigned long GetElectric_Prop(void) const
Get index of the electric properties.
Definition CElementProperty.hpp:66
unsigned long iMat_Prop
Index of the properties (E, Nu) for the structural model used.
Definition CElementProperty.hpp:39
virtual su2double GetDesignDensity(void) const
Get the value of the Design density.
Definition CElementProperty.hpp:81
virtual void RegisterDensity(void)
Register the Design density as an AD input variable.
Definition CElementProperty.hpp:101
virtual unsigned long GetMat_Mod(void) const
Get the material model to use for the element.
Definition CElementProperty.hpp:56
virtual void SetDesignDensity(su2double valDensity)
Set the Design density (topology optimization variable).
Definition CElementProperty.hpp:76
virtual unsigned long GetDV(void) const
Get index of the design variable.
Definition CElementProperty.hpp:71
virtual void SetPhysicalDensity(su2double valDensity)
Set the Physical density (used to penalize element stiffness by the FEM solver).
Definition CElementProperty.hpp:86
unsigned long GetMat_Prop(void) const
Get index of the physical properties.
Definition CElementProperty.hpp:61
passivedouble su2double
Definition code_config.hpp:181
void RegisterInput(su2double &data)
Registers the variable as an input. I.e. as a leaf of the computational graph.
Definition ad_structure.hpp:101
void ResetInput(su2double &data)
Reset the variable (set index to zero).
Definition ad_structure.hpp:179
passivedouble GetDerivative(const su2double &data)
Get the derivative value of the datatype (needs to be implemented for each new type).
Definition datatype_structure.hpp:117