Skip to content

Commit 34dbc5d

Browse files
committed
cleanup
1 parent 9ce0fad commit 34dbc5d

File tree

9 files changed

+67
-146
lines changed

9 files changed

+67
-146
lines changed

Common/include/CConfig.hpp

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -664,9 +664,11 @@ class CConfig {
664664
su2double Deform_Coeff; /*!< \brief Deform coeffienct */
665665
su2double Deform_Limit; /*!< \brief Deform limit */
666666
DEFORM_KIND Deform_Kind; /*!< \brief Type of mesh deformation */
667-
bool RBF_DataReduction; /*!< \brief Determines use of data reduction methods for RBF mesh deformation. */
668-
su2double RBF_GreedyTolerance; /*!< \brief Tolerance used in the greedy data reduction for RBF mesh deformation. */
669-
su2double RBF_GreedyCorrectionFactor; /*!< \brief Correction factor used in the greedy algorithm for RBF mesh deformation. */
667+
struct CRBFParam {
668+
bool DataReduction; /*!< \brief Determines use of data reduction methods for RBF mesh deformation. */
669+
su2double GreedyTolerance; /*!< \brief Tolerance used in the greedy data reduction for RBF mesh deformation. */
670+
su2double GreedyCorrectionFactor; /*!< \brief Correction factor used in the greedy algorithm for RBF mesh deformation. */
671+
} RBFParam;
670672
unsigned short FFD_Continuity; /*!< \brief Surface continuity at the intersection with the FFD */
671673
unsigned short FFD_CoordSystem; /*!< \brief Define the coordinates system */
672674
su2double Deform_ElasticityMod, /*!< \brief Young's modulus for volume deformation stiffness model */
@@ -3486,7 +3488,6 @@ class CConfig {
34863488
*/
34873489
void SetMarker_All_Deform_Mesh_Internal(unsigned short val_marker, unsigned short val_deform) { Marker_All_Deform_Mesh_Internal[val_marker] = val_deform; }
34883490

3489-
34903491
/*!
34913492
* \brief Set if a in marker <i>val_marker</i> the flow load will be computed/employed.
34923493
* \param[in] val_marker - Index of the marker in which we are interested.
@@ -4382,19 +4383,7 @@ class CConfig {
43824383
* \brief Determines use of data reduction methods for RBF mesh deformation.
43834384
* \return <code>TRUE</code> means that data reduction is used.
43844385
*/
4385-
bool GetRBF_DataReduction(void) const { return RBF_DataReduction; }
4386-
4387-
/*!
4388-
* \brief Determines use of data reduction methods for RBF mesh deformation.
4389-
* \return <code>TRUE</code> means that data reduction is used.
4390-
*/
4391-
su2double GetRBF_DataRedTolerance(void) const { return RBF_GreedyTolerance; }
4392-
4393-
/*!
4394-
* \brief Determines use of data reduction methods for RBF mesh deformation.
4395-
* \return <code>TRUE</code> means that data reduction is used.
4396-
*/
4397-
su2double GetRBF_DataRedCorrectionFactor(void) const { return RBF_GreedyCorrectionFactor; }
4386+
const CRBFParam& GetRBFParam(void) const { return RBFParam; }
43984387

43994388
/*!
44004389
* \brief Get the kind of SU2 software component.

Common/include/grid_movement/CLinearElasticity.hpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
* \brief Class for moving the volumetric numerical grid using the linear elasticity analogy.
3737
* \author F. Palacios, A. Bueno, T. Economon, S. Padron.
3838
*/
39-
4039
class CLinearElasticity final : public CVolumetricMovement {
4140
protected:
4241
unsigned short nVar; /*!< \brief Number of variables. */
@@ -75,8 +74,9 @@ class CLinearElasticity final : public CVolumetricMovement {
7574
* \param[in] Derivative - Compute the derivative (disabled by default). Does not actually deform the grid if enabled.
7675
*/
7776
void SetVolume_Deformation(CGeometry* geometry, CConfig* config, bool UpdateGeo, bool Derivative,
78-
bool ForwardProjectionDerivative);
77+
bool ForwardProjectionDerivative) override;
7978

79+
private:
8080
/*!
8181
* \brief Update the value of the coordinates after the grid movement.
8282
* \param[in] geometry - Geometrical definition of the problem.
@@ -228,16 +228,4 @@ class CLinearElasticity final : public CVolumetricMovement {
228228
* \param[in] config - Definition of the particular problem.
229229
*/
230230
void SetBoundaryDerivatives(CGeometry* geometry, CConfig* config, bool ForwardProjectionDerivative);
231-
232-
/*!
233-
* \brief Store the number of iterations when moving the mesh.
234-
* \param[in] val_nIterMesh - Number of iterations.
235-
*/
236-
inline void Set_nIterMesh(unsigned long val_nIterMesh) { nIterMesh = val_nIterMesh; }
237-
238-
/*!
239-
* \brief Retrieve the number of iterations when moving the mesh.
240-
* \param[out] Number of iterations.
241-
*/
242-
inline unsigned long Get_nIterMesh() const { return nIterMesh; }
243231
};

Common/include/grid_movement/CRadialBasisFunctionInterpolation.hpp

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,12 @@
2828
#pragma once
2929
#include "CVolumetricMovement.hpp"
3030
#include "CRadialBasisFunctionNode.hpp"
31-
#include "../../include/toolboxes/CSymmetricMatrix.hpp"
3231

3332
/*!
3433
* \class CRadialBasisFunctionInterpolation
3534
* \brief Class for moving the volumetric numerical grid using Radial Basis Function interpolation.
3635
* \author F. van Steen
3736
*/
38-
3937
class CRadialBasisFunctionInterpolation : public CVolumetricMovement {
4038
protected:
4139
vector<CRadialBasisFunctionNode*>* ControlNodes = nullptr; /*!< \brief Vector with control nodes*/
@@ -60,7 +58,7 @@ class CRadialBasisFunctionInterpolation : public CVolumetricMovement {
6058
/*!
6159
* \brief Destructor of the class.
6260
*/
63-
~CRadialBasisFunctionInterpolation(void) override;
61+
~CRadialBasisFunctionInterpolation() override;
6462

6563
/*!
6664
* \brief Grid deformation using the spring analogy method.
@@ -70,8 +68,9 @@ class CRadialBasisFunctionInterpolation : public CVolumetricMovement {
7068
* \param[in] Derivative - Compute the derivative (disabled by default). Does not actually deform the grid if enabled.
7169
*/
7270
void SetVolume_Deformation(CGeometry* geometry, CConfig* config, bool UpdateGeo, bool Derivative,
73-
bool ForwardProjectionDerivative);
71+
bool ForwardProjectionDerivative) override;
7472

73+
private:
7574
/*!
7675
* \brief Selecting unique set of boundary nodes based on marker information.
7776
* \param[in] geometry - Geometrical definition of the problem.
@@ -101,8 +100,7 @@ class CRadialBasisFunctionInterpolation : public CVolumetricMovement {
101100
* \param[in] type - Type of radial basis function.
102101
* \param[in] radius - Support radius of the radial basis function.
103102
*/
104-
105-
void SolveRBF_System(CGeometry* geometry, CConfig* config, const RADIAL_BASIS& type, const su2double radius);
103+
void SolveRBFSystem(CGeometry* geometry, CConfig* config, const RADIAL_BASIS& type, su2double radius);
106104

107105
/*!
108106
* \brief Obtaining the interpolation coefficients of the control nodes.
@@ -111,8 +109,7 @@ class CRadialBasisFunctionInterpolation : public CVolumetricMovement {
111109
* \param[in] type - Type of radial basis function.
112110
* \param[in] radius - Support radius of the radial basis function.
113111
*/
114-
115-
void GetInterpCoeffs(CGeometry* geometry, CConfig* config, const RADIAL_BASIS& type, const su2double radius);
112+
void GetInterpCoeffs(CGeometry* geometry, CConfig* config, const RADIAL_BASIS& type, su2double radius);
116113

117114
/*!
118115
* \brief Gathering of all control node coordinates.
@@ -134,7 +131,7 @@ class CRadialBasisFunctionInterpolation : public CVolumetricMovement {
134131
* \param[in] radius - Support radius of the radial basis function.
135132
* \param[in] invInterpMat - Inverse of the interpolation matrix.
136133
*/
137-
void ComputeInterpolationMatrix(CGeometry* geometry, const RADIAL_BASIS& type, const su2double radius,
134+
void ComputeInterpolationMatrix(CGeometry* geometry, const RADIAL_BASIS& type, su2double radius,
138135
su2passivematrix& invInterpMat);
139136

140137
/*!
@@ -162,7 +159,7 @@ class CRadialBasisFunctionInterpolation : public CVolumetricMovement {
162159
/*!
163160
* \brief Compute global number of control nodes.
164161
*/
165-
void Get_nCtrlNodesGlobal();
162+
void ComputeNCtrlNodesGlobal();
166163

167164
/*!
168165
* \brief Compute interpolation error.
@@ -173,7 +170,7 @@ class CRadialBasisFunctionInterpolation : public CVolumetricMovement {
173170
* \param[in] maxErrorNodeLocal - Local maximum error node.
174171
* \param[in] maxErrorLocal - Local maximum error.
175172
*/
176-
void GetInterpError(CGeometry* geometry, CConfig* config, const RADIAL_BASIS& type, const su2double radius,
173+
void GetInterpError(CGeometry* geometry, CConfig* config, const RADIAL_BASIS& type, su2double radius,
177174
unsigned long& maxErrorNodeLocal, su2double& maxErrorLocal);
178175

179176
/*!
@@ -185,7 +182,7 @@ class CRadialBasisFunctionInterpolation : public CVolumetricMovement {
185182
* \param[in] iNode - Local node in consideration.
186183
* \param[in] localError - Local error.
187184
*/
188-
void GetNodalError(CGeometry* geometry, CConfig* config, const RADIAL_BASIS& type, const su2double radius,
185+
void GetNodalError(CGeometry* geometry, CConfig* config, const RADIAL_BASIS& type, su2double radius,
189186
unsigned long iNode, su2double* localError);
190187

191188
/*!
@@ -196,7 +193,7 @@ class CRadialBasisFunctionInterpolation : public CVolumetricMovement {
196193
* \param[in] radius - Support radius of the radial basis function.
197194
* \param[in] internalNodes - Internal nodes.
198195
*/
199-
void UpdateGridCoord(CGeometry* geometry, CConfig* config, const RADIAL_BASIS& type, const su2double radius,
196+
void UpdateGridCoord(CGeometry* geometry, CConfig* config, const RADIAL_BASIS& type, su2double radius,
200197
const vector<unsigned long>& internalNodes);
201198

202199
/*!
@@ -206,7 +203,7 @@ class CRadialBasisFunctionInterpolation : public CVolumetricMovement {
206203
* \param[in] radius - Support radius of the radial basis function.
207204
* \param[in] internalNodes - Internal nodes.
208205
*/
209-
void UpdateInternalCoords(CGeometry* geometry, const RADIAL_BASIS& type, const su2double radius,
206+
void UpdateInternalCoords(CGeometry* geometry, const RADIAL_BASIS& type, su2double radius,
210207
const vector<unsigned long>& internalNodes);
211208

212209
/*!
@@ -216,7 +213,7 @@ class CRadialBasisFunctionInterpolation : public CVolumetricMovement {
216213
* \param[in] type - Type of radial basis function.
217214
* \param[in] radius - Support radius of the radial basis function.
218215
*/
219-
void UpdateBoundCoords(CGeometry* geometry, CConfig* config, const RADIAL_BASIS& type, const su2double radius);
216+
void UpdateBoundCoords(CGeometry* geometry, CConfig* config, const RADIAL_BASIS& type, su2double radius);
220217

221218
/*!
222219
* \brief Apply correction to the nonzero error boundary nodes.
@@ -227,24 +224,4 @@ class CRadialBasisFunctionInterpolation : public CVolumetricMovement {
227224
*/
228225
void SetCorrection(CGeometry* geometry, CConfig* config, const RADIAL_BASIS& type,
229226
const vector<unsigned long>& internalNodes);
230-
231-
/*!
232-
* \brief Custom comparison function, for sorting the CRadialBasisFunctionNode objects based on their index.
233-
* \param[in] a - First considered Radial Basis Function Node.
234-
* \param[in] b - Second considered Radial Basis Function Node.
235-
* \return True if index of a is smaller than index of b.
236-
*/
237-
inline static bool HasSmallerIndex(CRadialBasisFunctionNode* a, CRadialBasisFunctionNode* b) {
238-
return a->GetIndex() < b->GetIndex();
239-
}
240-
241-
/*!
242-
* \brief Custom equality function, for obtaining a unique set of CRadialBasisFunctionNode objects.
243-
* \param[in] a - First considered Radial Basis Function Node.
244-
* \param[in] b - Second considered Radial Basis Function Node.
245-
* \return True if index of a and b are equal.
246-
*/
247-
inline static bool HasEqualIndex(CRadialBasisFunctionNode* a, CRadialBasisFunctionNode* b) {
248-
return a->GetIndex() == b->GetIndex();
249-
}
250227
};

Common/include/grid_movement/CRadialBasisFunctionNode.hpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@
2626
*/
2727

2828
#pragma once
29-
30-
#include "../../../Common/include/geometry/CGeometry.hpp"
29+
#include "../code_config.hpp"
3130

3231
/*!
3332
* \class CRadialBasisFunctionNode
3433
* \brief Class for defining a Radial Basis Function Node
3534
* \author F. van Steen
3635
*/
37-
3836
class CRadialBasisFunctionNode {
3937
protected:
4038
unsigned long idx; /*!< \brief Global index. */
@@ -50,25 +48,26 @@ class CRadialBasisFunctionNode {
5048
* \param[in] marker_val - Local marker index.
5149
* \param[in] vertex_val - Local vertex index.
5250
*/
53-
CRadialBasisFunctionNode(unsigned long idx_val, unsigned short marker_val, unsigned long vertex_val);
51+
CRadialBasisFunctionNode(unsigned long idx_val, unsigned short marker_val, unsigned long vertex_val)
52+
: idx(idx_val), marker_idx(marker_val), vertex_idx(vertex_val) {}
5453

5554
/*!
5655
* \brief Returns local global index.
5756
* \return Local node index.
5857
*/
59-
inline unsigned long GetIndex() { return idx; }
58+
inline unsigned long GetIndex() const { return idx; }
6059

6160
/*!
6261
* \brief Returns local vertex index.
6362
* \return Local vertex index.
6463
*/
65-
inline unsigned long GetVertex() { return vertex_idx; }
64+
inline unsigned long GetVertex() const { return vertex_idx; }
6665

6766
/*!
6867
* \brief Returns local marker index.
6968
* \return Local marker index.
7069
*/
71-
inline unsigned short GetMarker() { return marker_idx; }
70+
inline unsigned short GetMarker() const { return marker_idx; }
7271

7372
/*!
7473
* \brief Set error of the RBF node.
@@ -84,5 +83,5 @@ class CRadialBasisFunctionNode {
8483
* \brief Get nodal error.
8584
* \return Nodal error.
8685
*/
87-
inline su2double* GetError() { return error; }
86+
inline const su2double* GetError() const { return error; }
8887
};

Common/src/CConfig.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,12 +2424,12 @@ void CConfig::SetConfig_Options() {
24242424
addUnsignedLongOption("DEFORM_LINEAR_SOLVER_ITER", Deform_Linear_Solver_Iter, 1000);
24252425
/* DESCRIPTION: Type of mesh deformation */
24262426
addEnumOption("DEFORM_KIND", Deform_Kind, Deform_Kind_Map, DEFORM_KIND::ELASTIC);
2427-
/* DESCRIPTION: Use of data reduction methods for RBF interpolated mesh deformation */
2428-
addBoolOption("RBF_DATA_REDUCTION", RBF_DataReduction, true);
2427+
/* DESCRIPTION: Use of data reduction methods for RBF interpolated mesh deformation. */
2428+
addBoolOption("RBF_DATA_REDUCTION", RBFParam.DataReduction, true);
24292429
/* DESCRIPTION: Tolerance for the data reduction methods used in RBF mesh deformation. */
2430-
addDoubleOption("RBF_GREEDY_TOLERANCE", RBF_GreedyTolerance, 1E-2);
2431-
/* DESCRIPTION: Tolerance for the data reduction methods used in RBF mesh deformation. */
2432-
addDoubleOption("RBF_GREEDY_CORRECTION_FACTOR", RBF_GreedyCorrectionFactor, 1E-2);
2430+
addDoubleOption("RBF_GREEDY_TOLERANCE", RBFParam.GreedyTolerance, 1E-2);
2431+
/* DESCRIPTION: Correction factor for the data reduction methods used in RBF mesh deformation. */
2432+
addDoubleOption("RBF_GREEDY_CORRECTION_FACTOR", RBFParam.GreedyCorrectionFactor, 1E-2);
24332433

24342434
/*!\par CONFIG_CATEGORY: FEM flow solver definition \ingroup Config*/
24352435
/*--- Options related to the finite element flow solver---*/

Common/src/grid_movement/CLinearElasticity.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ particular, the linear elasticity equations hold only for small deformations. --
150150

151151
/*--- Set number of iterations in the mesh update. ---*/
152152

153-
Set_nIterMesh(Tot_Iter);
153+
nIterMesh = Tot_Iter;
154154

155155
if (rank == MASTER_NODE && Screen_Output) {
156156
cout << "Non-linear iter.: " << iNonlinear_Iter + 1 << "/" << Nonlinear_Iter << ". Linear iter.: " << Tot_Iter
@@ -191,17 +191,14 @@ void CLinearElasticity::UpdateGridCoord_Derivatives(CGeometry* geometry, CConfig
191191
bool ForwardProjectionDerivative) {
192192
unsigned short iDim, iMarker;
193193
unsigned long iPoint, total_index, iVertex;
194-
auto* new_coord = new su2double[3];
195194

196195
SU2_COMPONENT Kind_SU2 = config->GetKind_SU2();
197196

198197
/*--- Update derivatives of the grid coordinates using the solution of the linear system
199198
after grid deformation (LinSysSol contains the derivatives of the x, y, z displacements). ---*/
200199
if ((config->GetDirectDiff() == D_DESIGN) && (Kind_SU2 == SU2_COMPONENT::SU2_CFD)) {
201200
for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) {
202-
new_coord[0] = 0.0;
203-
new_coord[1] = 0.0;
204-
new_coord[2] = 0.0;
201+
su2double new_coord[3] = {};
205202
for (iDim = 0; iDim < nDim; iDim++) {
206203
total_index = iPoint * nDim + iDim;
207204
new_coord[iDim] = geometry->nodes->GetCoord(iPoint, iDim);
@@ -240,8 +237,6 @@ void CLinearElasticity::UpdateGridCoord_Derivatives(CGeometry* geometry, CConfig
240237
}
241238
}
242239
}
243-
244-
delete[] new_coord;
245240
}
246241

247242
void CLinearElasticity::ComputeSolid_Wall_Distance(CGeometry* geometry, CConfig* config, su2double& MinDistance,

0 commit comments

Comments
 (0)