Skip to content

Commit a0e588d

Browse files
authored
Merge pull request #2530 from su2code/rbf_deformation
RBF deformation
2 parents 1d61b75 + dca7bcc commit a0e588d

20 files changed

+3023
-1643
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,10 @@ su2preconfig.timestamp
103103

104104
# Clangd server files
105105
.cache
106+
107+
108+
109+
ninja-win.zip
110+
ninja.exe
111+
.gitignore
112+
Docs/html

Common/include/CConfig.hpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ class CConfig {
190190
nMarker_ActDiskBemOutlet_Axis, /*!< \brief Number of actuator disk BEM outlet markers passed to MARKER_ACTDISK_BEM_AXIS. */
191191
nMarker_Deform_Mesh_Sym_Plane, /*!< \brief Number of markers with symmetric deformation */
192192
nMarker_Deform_Mesh, /*!< \brief Number of deformable markers at the boundary. */
193+
nMarker_Deform_Mesh_Internal, /*!< \brief Number of internal markers allowed to freely deform. */
193194
nMarker_Fluid_Load, /*!< \brief Number of markers in which the flow load is computed/employed. */
194195
nMarker_Fluid_InterfaceBound, /*!< \brief Number of fluid interface markers. */
195196
nMarker_CHTInterface, /*!< \brief Number of conjugate heat transfer interface markers. */
@@ -241,6 +242,7 @@ class CConfig {
241242
*Marker_NearFieldBound, /*!< \brief Near Field boundaries markers. */
242243
*Marker_Deform_Mesh, /*!< \brief Deformable markers at the boundary. */
243244
*Marker_Deform_Mesh_Sym_Plane, /*!< \brief Marker with symmetric deformation. */
245+
*Marker_Deform_Mesh_Internal, /*!< \brief Internal marker allowed to freely deform. */
244246
*Marker_Fluid_Load, /*!< \brief Markers in which the flow load is computed/employed. */
245247
*Marker_Fluid_InterfaceBound, /*!< \brief Fluid interface markers. */
246248
*Marker_CHTInterface, /*!< \brief Conjugate heat transfer interface markers. */
@@ -664,6 +666,11 @@ class CConfig {
664666
su2double Deform_Tol_Factor; /*!< \brief Factor to multiply smallest volume for deform tolerance (0.001 default) */
665667
su2double Deform_Coeff; /*!< \brief Deform coeffienct */
666668
su2double Deform_Limit; /*!< \brief Deform limit */
669+
DEFORM_KIND Deform_Kind; /*!< \brief Type of mesh deformation */
670+
struct CRBFParam {
671+
bool DataReduction; /*!< \brief Determines use of data reduction methods for RBF mesh deformation. */
672+
su2double GreedyTolerance; /*!< \brief Tolerance used in the greedy data reduction for RBF mesh deformation. */
673+
} RBFParam;
667674
unsigned short FFD_Continuity; /*!< \brief Surface continuity at the intersection with the FFD */
668675
unsigned short FFD_CoordSystem; /*!< \brief Define the coordinates system */
669676
su2double Deform_ElasticityMod, /*!< \brief Young's modulus for volume deformation stiffness model */
@@ -761,6 +768,7 @@ class CConfig {
761768
*Marker_All_Moving, /*!< \brief Global index for moving surfaces using the grid information. */
762769
*Marker_All_Deform_Mesh, /*!< \brief Global index for deformable markers at the boundary. */
763770
*Marker_All_Deform_Mesh_Sym_Plane, /*!< \brief Global index for markers with symmetric deformations. */
771+
*Marker_All_Deform_Mesh_Internal, /*!< \brief Global index for internal markers with free deformation. */
764772
*Marker_All_Fluid_Load, /*!< \brief Global index for markers in which the flow load is computed/employed. */
765773
*Marker_All_PyCustom, /*!< \brief Global index for Python customizable surfaces using the grid information. */
766774
*Marker_All_Designing, /*!< \brief Global index for moving using the grid information. */
@@ -778,6 +786,7 @@ class CConfig {
778786
*Marker_CfgFile_Moving, /*!< \brief Global index for moving surfaces using the config information. */
779787
*Marker_CfgFile_Deform_Mesh, /*!< \brief Global index for deformable markers at the boundary. */
780788
*Marker_CfgFile_Deform_Mesh_Sym_Plane, /*!< \brief Global index for markers with symmetric deformations. */
789+
*Marker_CfgFile_Deform_Mesh_Internal, /*!< \brief Global index for internal markers with free deformation. */
781790
*Marker_CfgFile_Fluid_Load, /*!< \brief Global index for markers in which the flow load is computed/employed. */
782791
*Marker_CfgFile_PyCustom, /*!< \brief Global index for Python customizable surfaces using the config information. */
783792
*Marker_CfgFile_DV, /*!< \brief Global index for design variable markers using the config information. */
@@ -3482,6 +3491,13 @@ class CConfig {
34823491
*/
34833492
void SetMarker_All_Deform_Mesh_Sym_Plane(unsigned short val_marker, unsigned short val_deform) { Marker_All_Deform_Mesh_Sym_Plane[val_marker] = val_deform; }
34843493

3494+
/*!
3495+
* \brief Set if a marker <i>val_marker</i> allows deformation at the boundary.
3496+
* \param[in] val_marker - Index of the marker in which we are interested.
3497+
* \param[in] val_interface - 0 or 1 depending if the the marker is or not a DEFORM_MESH_SYM_PLANE marker.
3498+
*/
3499+
void SetMarker_All_Deform_Mesh_Internal(unsigned short val_marker, unsigned short val_deform) { Marker_All_Deform_Mesh_Internal[val_marker] = val_deform; }
3500+
34853501
/*!
34863502
* \brief Set if a in marker <i>val_marker</i> the flow load will be computed/employed.
34873503
* \param[in] val_marker - Index of the marker in which we are interested.
@@ -3647,6 +3663,13 @@ class CConfig {
36473663
*/
36483664
unsigned short GetMarker_All_Deform_Mesh_Sym_Plane(unsigned short val_marker) const { return Marker_All_Deform_Mesh_Sym_Plane[val_marker]; }
36493665

3666+
/*!
3667+
* \brief Get whether marker <i>val_marker</i> is a DEFORM_MESH_SYM_PLANE marker
3668+
* \param[in] val_marker - 0 or 1 depending if the the marker belongs to the DEFORM_MESH_SYM_PLANE subset.
3669+
* \return 0 or 1 depending if the marker belongs to the DEFORM_MESH_SYM_PLANE subset.
3670+
*/
3671+
unsigned short GetMarker_All_Deform_Mesh_Internal(unsigned short val_marker) const { return Marker_All_Deform_Mesh_Internal[val_marker]; }
3672+
36503673
/*!
36513674
* \brief Get whether marker <i>val_marker</i> is a Fluid_Load marker
36523675
* \param[in] val_marker - 0 or 1 depending if the the marker belongs to the Fluid_Load subset.
@@ -4378,6 +4401,18 @@ class CConfig {
43784401
*/
43794402
bool GetFFD_Symmetry_Plane(void) const { return FFD_Symmetry_Plane; }
43804403

4404+
/*!
4405+
* \brief Get the type of mesh deformation method.
4406+
* \return type of mesh deformation.
4407+
*/
4408+
DEFORM_KIND GetDeform_Kind() const { return Deform_Kind; }
4409+
4410+
/*!
4411+
* \brief Determines use of data reduction methods for RBF mesh deformation.
4412+
* \return <code>TRUE</code> means that data reduction is used.
4413+
*/
4414+
const CRBFParam& GetRBFParam(void) const { return RBFParam; }
4415+
43814416
/*!
43824417
* \brief Get the kind of SU2 software component.
43834418
* \return Kind of the SU2 software component.
@@ -6392,6 +6427,12 @@ class CConfig {
63926427
*/
63936428
unsigned short GetMarker_CfgFile_Deform_Mesh_Sym_Plane(const string& val_marker) const;
63946429

6430+
/*!
6431+
* \brief Get the DEFORM_MESH_INTERNAL information from the config definition for the marker <i>val_marker</i>.
6432+
* \return DEFORM_MESH_INTERNAL information of the boundary in the config information for the marker <i>val_marker</i>.
6433+
*/
6434+
unsigned short GetMarker_CfgFile_Deform_Mesh_Internal(const string& val_marker) const;
6435+
63956436
/*!
63966437
* \brief Get the Fluid_Load information from the config definition for the marker <i>val_marker</i>.
63976438
* \return Fluid_Load information of the boundary in the config information for the marker <i>val_marker</i>.
@@ -6753,6 +6794,12 @@ class CConfig {
67536794
*/
67546795
unsigned short GetMarker_Deform_Mesh_Sym_Plane(const string& val_marker) const;
67556796

6797+
/*!
6798+
* \brief Get the internal index for a DEFORM_MESH_SYM_PLANE boundary <i>val_marker</i>.
6799+
* \return Internal index for a DEFORM_MESH_SYM_PLANE boundary <i>val_marker</i>.
6800+
*/
6801+
unsigned short GetMarker_Deform_Mesh_Internal(const string& val_marker) const;
6802+
67566803
/*!
67576804
* \brief Get a bool for whether the marker is deformed. <i>val_marker</i>.
67586805
* \param[in] val_marker - Name of the marker to test.
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
/*!
2+
* \file CLinearElasticity.hpp
3+
* \brief Headers of the CLinearElasticity class.
4+
* \author F. Palacios, A. Bueno, T. Economon, S. Padron.
5+
* \version 8.2.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-2025, 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+
#include "CVolumetricMovement.hpp"
30+
#include "../linear_algebra/CSysMatrix.hpp"
31+
#include "../linear_algebra/CSysVector.hpp"
32+
#include "../linear_algebra/CSysSolve.hpp"
33+
34+
/*!
35+
* \class CLinearElasticity
36+
* \brief Class for moving the volumetric numerical grid using the linear elasticity analogy.
37+
* \author F. Palacios, A. Bueno, T. Economon, S. Padron.
38+
*/
39+
class CLinearElasticity final : public CVolumetricMovement {
40+
protected:
41+
unsigned short nVar; /*!< \brief Number of variables. */
42+
43+
unsigned long nPoint; /*!< \brief Number of points. */
44+
unsigned long nPointDomain; /*!< \brief Number of points in the domain. */
45+
46+
unsigned long nIterMesh; /*!< \brief Number of iterations in the mesh update. +*/
47+
48+
#ifndef CODI_FORWARD_TYPE
49+
CSysMatrix<su2mixedfloat> StiffMatrix; /*!< \brief Stiffness matrix of the elasticity problem. */
50+
CSysSolve<su2mixedfloat> System; /*!< \brief Linear solver/smoother. */
51+
#else
52+
CSysMatrix<su2double> StiffMatrix;
53+
CSysSolve<su2double> System;
54+
#endif
55+
CSysVector<su2double> LinSysSol;
56+
CSysVector<su2double> LinSysRes;
57+
58+
public:
59+
/*!
60+
* \brief Constructor of the class.
61+
*/
62+
CLinearElasticity(CGeometry* geometry, CConfig* config);
63+
64+
/*!
65+
* \brief Destructor of the class.
66+
*/
67+
~CLinearElasticity() override;
68+
69+
/*!
70+
* \brief Grid deformation using the spring analogy method.
71+
* \param[in] geometry - Geometrical definition of the problem.
72+
* \param[in] config - Definition of the particular problem.
73+
* \param[in] UpdateGeo - Update geometry.
74+
* \param[in] Derivative - Compute the derivative (disabled by default). Does not actually deform the grid if enabled.
75+
*/
76+
void SetVolume_Deformation(CGeometry* geometry, CConfig* config, bool UpdateGeo, bool Derivative,
77+
bool ForwardProjectionDerivative) override;
78+
79+
private:
80+
/*!
81+
* \brief Update the value of the coordinates after the grid movement.
82+
* \param[in] geometry - Geometrical definition of the problem.
83+
* \param[in] config - Definition of the particular problem.
84+
*/
85+
void UpdateGridCoord(CGeometry* geometry, CConfig* config);
86+
87+
/*!
88+
* \brief Update the derivatives of the coordinates after the grid movement.
89+
* \param[in] geometry - Geometrical definition of the problem.
90+
* \param[in] config - Definition of the particular problem.
91+
*/
92+
void UpdateGridCoord_Derivatives(CGeometry* geometry, CConfig* config, bool ForwardProjectionDerivative);
93+
94+
/*!
95+
* \brief Compute the minimum distance to the nearest solid surface.
96+
* \param[in] geometry - Geometrical definition of the problem.
97+
* \param[in] config - Definition of the particular problem.
98+
*/
99+
void ComputeSolid_Wall_Distance(CGeometry* geometry, CConfig* config, su2double& MinDistance,
100+
su2double& MaxDistance) const;
101+
102+
/*!
103+
* \brief Compute the stiffness matrix for grid deformation using spring analogy.
104+
* \param[in] geometry - Geometrical definition of the problem.
105+
* \param[in] config - Definition of the particular problem.
106+
* \return Value of the length of the smallest edge of the grid.
107+
*/
108+
su2double SetFEAMethodContributions_Elem(CGeometry* geometry, CConfig* config);
109+
110+
/*!
111+
* \brief Build the stiffness matrix for a 3-D hexahedron element. The result will be placed in StiffMatrix_Elem.
112+
* \param[in] geometry - Geometrical definition of the problem.
113+
* \param[in] config - Definition of the particular problem.
114+
* \param[in] StiffMatrix_Elem - Element stiffness matrix to be filled.
115+
* \param[in] CoordCorners - Index value for Node 1 of the current hexahedron.
116+
* \param[in] PointCorners - Index values for element corners
117+
* \param[in] nNodes - Number of nodes defining the element.
118+
* \param[in] scale
119+
*/
120+
void SetFEA_StiffMatrix2D(CGeometry* geometry, CConfig* config, su2double** StiffMatrix_Elem,
121+
unsigned long PointCorners[8], su2double CoordCorners[8][3], unsigned short nNodes,
122+
su2double ElemVolume, su2double ElemDistance);
123+
124+
/*!
125+
* \brief Build the stiffness matrix for a 3-D hexahedron element. The result will be placed in StiffMatrix_Elem.
126+
* \param[in] geometry - Geometrical definition of the problem.
127+
* \param[in] config - Definition of the particular problem.
128+
* \param[in] StiffMatrix_Elem - Element stiffness matrix to be filled.
129+
* \param[in] CoordCorners - Index value for Node 1 of the current hexahedron.
130+
* \param[in] PointCorners - Index values for element corners
131+
* \param[in] nNodes - Number of nodes defining the element.
132+
* \param[in] scale
133+
*/
134+
void SetFEA_StiffMatrix3D(CGeometry* geometry, CConfig* config, su2double** StiffMatrix_Elem,
135+
unsigned long PointCorners[8], su2double CoordCorners[8][3], unsigned short nNodes,
136+
su2double ElemVolume, su2double ElemDistance);
137+
138+
/*!
139+
* \brief Add the stiffness matrix for a 2-D triangular element to the global stiffness matrix for the entire mesh
140+
* (node-based). \param[in] geometry - Geometrical definition of the problem. \param[in] StiffMatrix_Elem - Element
141+
* stiffness matrix to be filled. \param[in] PointCorners - Index values for element corners \param[in] nNodes -
142+
* Number of nodes defining the element.
143+
*/
144+
void AddFEA_StiffMatrix(CGeometry* geometry, su2double** StiffMatrix_Elem, unsigned long PointCorners[8],
145+
unsigned short nNodes);
146+
147+
/*!
148+
* \brief Shape functions and derivative of the shape functions
149+
* \param[in] Xi - Local coordinates.
150+
* \param[in] Eta - Local coordinates.
151+
* \param[in] Zeta - Local coordinates.
152+
* \param[in] CoordCorners - Coordiantes of the corners.
153+
* \param[in] DShapeFunction - Shape function information
154+
*/
155+
su2double ShapeFunc_Hexa(su2double Xi, su2double Eta, su2double Zeta, su2double CoordCorners[8][3],
156+
su2double DShapeFunction[8][4]);
157+
158+
/*!
159+
* \brief Shape functions and derivative of the shape functions
160+
* \param[in] Xi - Local coordinates.
161+
* \param[in] Eta - Local coordinates.
162+
* \param[in] Zeta - Local coordinates.
163+
* \param[in] CoordCorners - Coordiantes of the corners.
164+
* \param[in] DShapeFunction - Shape function information
165+
*/
166+
su2double ShapeFunc_Tetra(su2double Xi, su2double Eta, su2double Zeta, su2double CoordCorners[8][3],
167+
su2double DShapeFunction[8][4]);
168+
169+
/*!
170+
* \brief Shape functions and derivative of the shape functions
171+
* \param[in] Xi - Local coordinates.
172+
* \param[in] Eta - Local coordinates.
173+
* \param[in] Zeta - Local coordinates.
174+
* \param[in] CoordCorners - Coordiantes of the corners.
175+
* \param[in] DShapeFunction - Shape function information
176+
*/
177+
su2double ShapeFunc_Pyram(su2double Xi, su2double Eta, su2double Zeta, su2double CoordCorners[8][3],
178+
su2double DShapeFunction[8][4]);
179+
180+
/*!
181+
* \brief Shape functions and derivative of the shape functions
182+
* \param[in] Xi - Local coordinates.
183+
* \param[in] Eta - Local coordinates.
184+
* \param[in] Zeta - Local coordinates.
185+
* \param[in] CoordCorners - Coordiantes of the corners.
186+
* \param[in] DShapeFunction - Shape function information
187+
*/
188+
su2double ShapeFunc_Prism(su2double Xi, su2double Eta, su2double Zeta, su2double CoordCorners[8][3],
189+
su2double DShapeFunction[8][4]);
190+
191+
/*!
192+
* \brief Shape functions and derivative of the shape functions
193+
* \param[in] Xi - Local coordinates.
194+
* \param[in] Eta - Local coordinates.
195+
* \param[in] CoordCorners - Coordiantes of the corners.
196+
* \param[in] DShapeFunction - Shape function information
197+
*/
198+
su2double ShapeFunc_Triangle(su2double Xi, su2double Eta, su2double CoordCorners[8][3],
199+
su2double DShapeFunction[8][4]);
200+
201+
/*!
202+
* \brief Shape functions and derivative of the shape functions
203+
* \param[in] Xi - Local coordinates.
204+
* \param[in] Eta - Local coordinates.
205+
* \param[in] CoordCorners - Coordiantes of the corners.
206+
* \param[in] DShapeFunction - Shape function information
207+
*/
208+
su2double ShapeFunc_Quadrilateral(su2double Xi, su2double Eta, su2double CoordCorners[8][3],
209+
su2double DShapeFunction[8][4]);
210+
211+
/*!
212+
* \brief Check the domain points vertex that are going to be moved.
213+
* \param[in] geometry - Geometrical definition of the problem.
214+
* \param[in] config - Definition of the particular problem.
215+
*/
216+
void SetDomainDisplacements(CGeometry* geometry, CConfig* config);
217+
218+
/*!
219+
* \brief Check the boundary vertex that are going to be moved.
220+
* \param[in] geometry - Geometrical definition of the problem.
221+
* \param[in] config - Definition of the particular problem.
222+
*/
223+
void SetBoundaryDisplacements(CGeometry* geometry, CConfig* config);
224+
225+
/*!
226+
* \brief Set the derivatives of the boundary nodes.
227+
* \param[in] geometry - Geometrical definition of the problem.
228+
* \param[in] config - Definition of the particular problem.
229+
*/
230+
void SetBoundaryDerivatives(CGeometry* geometry, CConfig* config, bool ForwardProjectionDerivative);
231+
};

0 commit comments

Comments
 (0)