Skip to content

Commit

Permalink
Merge branch 'develop' into fix_cornernode_normal
Browse files Browse the repository at this point in the history
  • Loading branch information
bigfooted authored Dec 27, 2024
2 parents d5e625c + e2ee3e7 commit 933500a
Show file tree
Hide file tree
Showing 26 changed files with 299 additions and 172 deletions.
24 changes: 18 additions & 6 deletions Common/include/CConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ class CConfig {
bool ExtraOutput; /*!< \brief Check if extra output need. */
bool Wall_Functions; /*!< \brief Use wall functions with the turbulence model */
long ExtraHeatOutputZone; /*!< \brief Heat solver zone with extra screen output */
bool DeadLoad; /*!< \brief Application of dead loads to the FE analysis */
bool CentrifugalForce; /*!< \brief Application of centrifugal forces to the FE analysis */
bool PseudoStatic; /*!< \brief Application of dead loads to the FE analysis */
bool SteadyRestart; /*!< \brief Restart from a steady state for FSI problems. */
su2double Newmark_beta, /*!< \brief Parameter alpha for Newmark method. */
Expand All @@ -1013,10 +1013,13 @@ class CConfig {
su2double *Int_Coeffs; /*!< \brief Time integration coefficients for structural method. */
unsigned short nElasticityMod, /*!< \brief Number of different values for the elasticity modulus. */
nPoissonRatio, /*!< \brief Number of different values for the Poisson ratio modulus. */
nMaterialDensity; /*!< \brief Number of different values for the Material density. */
nMaterialDensity, /*!< \brief Number of different values for the Material density. */
nMaterialThermalExpansion; /*!< \brief Number of different values for thermal expansion coefficient. */
su2double *ElasticityMod, /*!< \brief Value of the elasticity moduli. */
*PoissonRatio, /*!< \brief Value of the Poisson ratios. */
*MaterialDensity; /*!< \brief Value of the Material densities. */
*MaterialDensity, /*!< \brief Value of the Material densities. */
*MaterialThermalExpansion, /*!< \brief Value of the thermal expansion coefficients. */
MaterialReferenceTemperature; /*!< \brief Value of the reference temperature for thermal expansion. */
unsigned short nElectric_Field, /*!< \brief Number of different values for the electric field in the membrane. */
nDim_Electric_Field; /*!< \brief Dimensionality of the problem. */
unsigned short nDim_RefNode; /*!< \brief Dimensionality of the vector . */
Expand Down Expand Up @@ -2389,6 +2392,16 @@ class CConfig {
*/
su2double GetMaterialDensity(unsigned short id_val) const { return MaterialDensity[id_val]; }

/*!
* \brief Get the thermal expansion coefficient.
*/
su2double GetMaterialThermalExpansion(unsigned short id_val) const { return MaterialThermalExpansion[id_val]; }

/*!
* \brief Temperature at which there is no stress from thermal expansion.
*/
su2double GetMaterialReferenceTemperature() const { return MaterialReferenceTemperature; }

/*!
* \brief Compressibility/incompressibility of the solids analysed using the structural solver.
* \return Compressible or incompressible.
Expand Down Expand Up @@ -8929,10 +8942,9 @@ class CConfig {
su2double GetAitkenDynMinInit(void) const { return AitkenDynMinInit; }

/*!
* \brief Decide whether to apply dead loads to the model.
* \return <code>TRUE</code> if the dead loads are to be applied, <code>FALSE</code> otherwise.
* \brief Decide whether to apply centrifugal forces to the model.
*/
bool GetDeadLoad(void) const { return DeadLoad; }
bool GetCentrifugalForce(void) const { return CentrifugalForce; }

/*!
* \brief Identifies if the mesh is matching or not (temporary, while implementing interpolation procedures).
Expand Down
41 changes: 34 additions & 7 deletions Common/include/geometry/elements/CElement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class CElement {
su2activematrix NodalExtrap; /*!< \brief Coordinates of the nodal points for Gaussian extrapolation. */
su2activematrix NodalStress; /*!< \brief Stress at the nodes. */

su2activevector NodalTemperature; /*!< \brief Temperature at the nodes. */

/*--- Stiffness and load matrices. ---*/
std::vector<su2activematrix> Kab; /*!< \brief Structure for the constitutive component of the tangent matrix. */
su2activematrix Mab; /*!< \brief Structure for the nodal components of the mass matrix. */
Expand Down Expand Up @@ -151,7 +153,7 @@ class CElement {
* \param[in] iDim - Dimension.
* \param[in] val_CoordRef - Value of the coordinate.
*/
inline void SetRef_Coord(unsigned short iNode, unsigned short iDim, su2double val_CoordRef) {
inline void SetRef_Coord(unsigned short iNode, unsigned short iDim, const su2double& val_CoordRef) {
RefCoord(iNode, iDim) = val_CoordRef;
}

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

/*!
* \brief Set the value of the temperature of a node.
*/
inline void SetTemperature(unsigned short iNode, const su2double& val_Temperature) {
NodalTemperature[iNode] = val_Temperature;
}

/*!
* \brief Set the value of the temperature of all nodes.
*/
inline void SetTemperature(const su2double& val_Temperature) { NodalTemperature = val_Temperature; }

/*!
* \brief Get the value of the coordinate of the nodes in the reference configuration.
* \param[in] iNode - Index of node.
Expand All @@ -181,6 +195,17 @@ class CElement {
*/
inline su2double GetCurr_Coord(unsigned short iNode, unsigned short iDim) const { return CurrentCoord(iNode, iDim); }

/*!
* \brief Get the value of the temperature at a Gaussian integration point.
*/
inline su2double GetTemperature(unsigned short iGauss) const {
su2double Temperature = 0;
for (auto iNode = 0u; iNode < nNodes; ++iNode) {
Temperature += GetNi(iNode, iGauss) * NodalTemperature[iNode];
}
return Temperature;
}

/*!
* \brief Get the weight of the corresponding Gaussian Point.
* \param[in] iGauss - index of the Gaussian point.
Expand Down Expand Up @@ -214,7 +239,9 @@ class CElement {
* \param[in] nodeB - index of Node b.
* \param[in] val_Ks_ab - value of the term that will constitute the diagonal of the stress contribution.
*/
inline void Add_Mab(unsigned short nodeA, unsigned short nodeB, su2double val_Mab) { Mab(nodeA, nodeB) += val_Mab; }
inline void Add_Mab(unsigned short nodeA, unsigned short nodeB, const su2double& val_Mab) {
Mab(nodeA, nodeB) += val_Mab;
}

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

Expand Down Expand Up @@ -354,7 +381,7 @@ class CElement {
* \param[in] iVar - Variable index.
* \param[in] val_Stress - Value of the stress added.
*/
inline void Add_NodalStress(unsigned short iNode, unsigned short iVar, su2double val_Stress) {
inline void Add_NodalStress(unsigned short iNode, unsigned short iVar, const su2double& val_Stress) {
NodalStress(iNode, iVar) += val_Stress;
}

Expand Down Expand Up @@ -789,7 +816,7 @@ class CQUAD4 final : public CElementWithKnownSizes<4, 4, 2> {
/*!
* \brief Shape functions (Ni) evaluated at point Xi,Eta.
*/
inline static void ShapeFunctions(su2double Xi, su2double Eta, su2double* Ni) {
inline static void ShapeFunctions(const su2double& Xi, const su2double& Eta, su2double* Ni) {
Ni[0] = 0.25 * (1.0 - Xi) * (1.0 - Eta);
Ni[1] = 0.25 * (1.0 + Xi) * (1.0 - Eta);
Ni[2] = 0.25 * (1.0 + Xi) * (1.0 + Eta);
Expand All @@ -799,7 +826,7 @@ class CQUAD4 final : public CElementWithKnownSizes<4, 4, 2> {
/*!
* \brief Shape function Jacobian (dNi) evaluated at point Xi,Eta.
*/
inline static void ShapeFunctionJacobian(su2double Xi, su2double Eta, su2double dNi[][2]) {
inline static void ShapeFunctionJacobian(const su2double& Xi, const su2double& Eta, su2double dNi[][2]) {
dNi[0][0] = -0.25 * (1.0 - Eta);
dNi[0][1] = -0.25 * (1.0 - Xi);
dNi[1][0] = 0.25 * (1.0 - Eta);
Expand Down
31 changes: 23 additions & 8 deletions Common/src/CConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,10 @@ void CConfig::SetPointersNull() {
Inlet_Velocity = nullptr; Inflow_Mach = nullptr; Inflow_Pressure = nullptr;
Outlet_Pressure = nullptr; Isothermal_Temperature = nullptr;

ElasticityMod = nullptr; PoissonRatio = nullptr; MaterialDensity = nullptr;
ElasticityMod = nullptr;
PoissonRatio = nullptr;
MaterialDensity = nullptr;
MaterialThermalExpansion = nullptr;

Load_Dir = nullptr; Load_Dir_Value = nullptr; Load_Dir_Multiplier = nullptr;
Disp_Dir = nullptr; Disp_Dir_Value = nullptr; Disp_Dir_Multiplier = nullptr;
Expand Down Expand Up @@ -2440,6 +2443,10 @@ void CConfig::SetConfig_Options() {
addDoubleListOption("POISSON_RATIO", nPoissonRatio, PoissonRatio);
/* DESCRIPTION: Material density */
addDoubleListOption("MATERIAL_DENSITY", nMaterialDensity, MaterialDensity);
/* DESCRIPTION: Material thermal expansion coefficient */
addDoubleListOption("MATERIAL_THERMAL_EXPANSION_COEFF", nMaterialThermalExpansion, MaterialThermalExpansion);
/* DESCRIPTION: Temperature at which there is no stress from thermal expansion */
addDoubleOption("MATERIAL_REFERENCE_TEMPERATURE", MaterialReferenceTemperature, 288.15);
/* DESCRIPTION: Knowles B constant */
addDoubleOption("KNOWLES_B", Knowles_B, 1.0);
/* DESCRIPTION: Knowles N constant */
Expand Down Expand Up @@ -2500,11 +2507,11 @@ void CConfig::SetConfig_Options() {
addEnumOption("NONLINEAR_FEM_SOLUTION_METHOD", Kind_SpaceIteScheme_FEA, Space_Ite_Map_FEA, STRUCT_SPACE_ITE::NEWTON);
/* DESCRIPTION: Formulation for bidimensional elasticity solver */
addEnumOption("FORMULATION_ELASTICITY_2D", Kind_2DElasForm, ElasForm_2D, STRUCT_2DFORM::PLANE_STRAIN);
/* DESCRIPTION: Apply dead loads
* Options: NO, YES \ingroup Config */
addBoolOption("DEAD_LOAD", DeadLoad, false);
/* DESCRIPTION: Apply centrifugal forces
* Options: NO, YES \ingroup Config */
addBoolOption("CENTRIFUGAL_FORCE", CentrifugalForce, false);
/* DESCRIPTION: Temporary: pseudo static analysis (no density in dynamic analysis)
* Options: NO, YES \ingroup Config */
* Options: NO, YES \ingroup Config */
addBoolOption("PSEUDO_STATIC", PseudoStatic, false);
/* DESCRIPTION: Parameter alpha for Newmark scheme (s) */
addDoubleOption("NEWMARK_BETA", Newmark_beta, 0.25);
Expand Down Expand Up @@ -3063,6 +3070,8 @@ void CConfig::SetConfig_Parsing(istream& config_buffer){
newString.append("DYNAMIC_ANALYSIS is deprecated. Use TIME_DOMAIN instead.\n\n");
else if (!option_name.compare("SPECIES_USE_STRONG_BC"))
newString.append("SPECIES_USE_STRONG_BC is deprecated. Use MARKER_SPECIES_STRONG_BC= (marker1, ...) instead.\n\n");
else if (!option_name.compare("DEAD_LOAD"))
newString.append("DEAD_LOAD is deprecated. Use GRAVITY_FORCE or BODY_FORCE instead.\n\n");
else {
/*--- Find the most likely candidate for the unrecognized option, based on the length
of start and end character sequences shared by candidates and the option. ---*/
Expand Down Expand Up @@ -4834,9 +4843,15 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
MaterialDensity = new su2double[1]; MaterialDensity[0] = 7854;
}

if (nElasticityMod != nPoissonRatio || nElasticityMod != nMaterialDensity) {
SU2_MPI::Error("ELASTICITY_MODULUS, POISSON_RATIO, and MATERIAL_DENSITY need to have the same number "
"of entries (the number of materials).", CURRENT_FUNCTION);
if (nMaterialThermalExpansion == 0) {
nMaterialThermalExpansion = 1;
MaterialThermalExpansion = new su2double[1]();
}

if (nElasticityMod != nPoissonRatio || nElasticityMod != nMaterialDensity ||
nElasticityMod != nMaterialThermalExpansion) {
SU2_MPI::Error("ELASTICITY_MODULUS, POISSON_RATIO, MATERIAL_DENSITY, and THERMAL_EXPANSION_COEFF need "
"to have the same number of entries (the number of materials).", CURRENT_FUNCTION);
}

if (nElectric_Constant == 0) {
Expand Down
2 changes: 2 additions & 0 deletions Common/src/geometry/elements/CElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ CElement::CElement(unsigned short ngauss, unsigned short nnodes, unsigned short

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

NodalTemperature.resize(nNodes) = su2double(0.0);

Mab.resize(nNodes, nNodes);
Ks_ab.resize(nNodes, nNodes);
Kab.resize(nNodes);
Expand Down
1 change: 0 additions & 1 deletion Common/src/geometry/elements/CQUAD4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ CQUAD4::CQUAD4() : CElementWithKnownSizes<NGAUSS, NNODE, NDIM>() {
/*--- Store the extrapolation functions (used to compute nodal stresses) ---*/

su2double ExtrapCoord[4][2], sqrt3 = 1.732050807568877;
;

ExtrapCoord[0][0] = -sqrt3;
ExtrapCoord[0][1] = -sqrt3;
Expand Down
4 changes: 2 additions & 2 deletions SU2_CFD/include/numerics/CNumerics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1483,10 +1483,10 @@ class CNumerics {
inline virtual void Compute_Mass_Matrix(CElement *element_container, const CConfig* config) { }

/*!
* \brief A virtual member to compute the residual component due to dead loads
* \brief A virtual member to compute the residual component due to body forces.
* \param[in] element_container - Element structure for the particular element integrated.
*/
inline virtual void Compute_Dead_Load(CElement *element_container, const CConfig* config) { }
inline virtual void Compute_Body_Forces(CElement *element_container, const CConfig* config) { }

/*!
* \brief A virtual member to compute the averaged nodal stresses
Expand Down
19 changes: 12 additions & 7 deletions SU2_CFD/include/numerics/elasticity/CFEAElasticity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,20 @@ class CFEAElasticity : public CNumerics {
su2double Nu = 0.0; /*!< \brief Aux. variable, Poisson's ratio. */
su2double Rho_s = 0.0; /*!< \brief Aux. variable, Structural density. */
su2double Rho_s_DL = 0.0; /*!< \brief Aux. variable, Structural density (for dead loads). */
su2double Alpha = 0.0; /*!< \brief Aux. variable, thermal expansion coefficient. */

su2double Mu = 0.0; /*!< \brief Aux. variable, Lame's coeficient. */
su2double Lambda = 0.0; /*!< \brief Aux. variable, Lame's coeficient. */
su2double Kappa = 0.0; /*!< \brief Aux. variable, Compressibility constant. */
su2double ThermalStressTerm = 0.0; /*!< \brief Aux. variable, Relationship between stress and delta T. */

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

su2double ReferenceTemperature = 0.0; /*!< \brief Reference temperature for thermal expansion. */

su2double **Ba_Mat = nullptr; /*!< \brief Matrix B for node a - Auxiliary. */
su2double **Bb_Mat = nullptr; /*!< \brief Matrix B for node b - Auxiliary. */
Expand All @@ -72,8 +77,6 @@ class CFEAElasticity : public CNumerics {
su2double **GradNi_Ref_Mat = nullptr; /*!< \brief Gradients of Ni - Auxiliary. */
su2double **GradNi_Curr_Mat = nullptr; /*!< \brief Gradients of Ni - Auxiliary. */

su2double *FAux_Dead_Load = nullptr; /*!< \brief Auxiliar vector for the dead loads */

su2double *DV_Val = nullptr; /*!< \brief For optimization cases, value of the design variables. */
unsigned short n_DV = 0; /*!< \brief For optimization cases, number of design variables. */

Expand Down Expand Up @@ -156,11 +159,11 @@ class CFEAElasticity : public CNumerics {
void Compute_Mass_Matrix(CElement *element_container, const CConfig *config) final;

/*!
* \brief Compute the nodal gravity loads for an element.
* \param[in,out] element_container - The element for which the dead loads are computed.
* \brief Compute the nodal inertial loads for an element.
* \param[in,out] element_container - The element for which the inertial loads are computed.
* \param[in] config - Definition of the problem.
*/
void Compute_Dead_Load(CElement *element_container, const CConfig *config) final;
void Compute_Body_Forces(CElement *element_container, const CConfig *config) final;

/*!
* \brief Build the tangent stiffness matrix of an element.
Expand Down Expand Up @@ -230,6 +233,8 @@ class CFEAElasticity : public CNumerics {
Mu = E / (2.0*(1.0 + Nu));
Lambda = Nu*E/((1.0+Nu)*(1.0-2.0*Nu));
Kappa = Lambda + (2/3)*Mu;
/*--- https://solidmechanics.org/Text/Chapter3_2/Chapter3_2.php ---*/
ThermalStressTerm = -Alpha * E / (1 - (plane_stress ? 1 : 2) * Nu);
}

/*!
Expand All @@ -238,8 +243,8 @@ class CFEAElasticity : public CNumerics {
* \param[in] jVar - Index j.
* \return 1 if i=j, 0 otherwise.
*/
inline static su2double deltaij(unsigned short iVar, unsigned short jVar) {
return su2double(iVar==jVar);
inline static passivedouble deltaij(unsigned short iVar, unsigned short jVar) {
return static_cast<passivedouble>(iVar == jVar);
}

};
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ class CFEANonlinearElasticity : public CFEAElasticity {
* \brief Compute the stress tensor.
* \param[in,out] element_container - The finite element.
* \param[in] config - Definition of the problem.
* \param[in] iGauss - Index of Gaussian integration point.
*/
virtual void Compute_Stress_Tensor(CElement *element_container, const CConfig *config) = 0;
virtual void Compute_Stress_Tensor(CElement *element_container, const CConfig *config, unsigned short iGauss) = 0;

/*!
* \brief Update an element with Maxwell's stress.
Expand Down
8 changes: 4 additions & 4 deletions SU2_CFD/include/numerics/elasticity/nonlinear_models.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class CFEM_NeoHookean_Comp final : public CFEANonlinearElasticity {
* \param[in,out] element_container - The finite element.
* \param[in] config - Definition of the problem.
*/
void Compute_Stress_Tensor(CElement *element_container, const CConfig *config) override;
void Compute_Stress_Tensor(CElement *element_container, const CConfig *config, unsigned short iGauss) override;

};

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

};

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

};

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

};
Loading

0 comments on commit 933500a

Please sign in to comment.