Skip to content

Commit a451770

Browse files
committed
Improved version parallel computation
1 parent 636b611 commit a451770

5 files changed

Lines changed: 540 additions & 520 deletions

File tree

Common/include/CConfig.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4414,13 +4414,13 @@ class CConfig {
44144414
* \brief Determines use of data reduction methods for RBF mesh deformation.
44154415
* \return <code>TRUE</code> means that data reduction is used.
44164416
*/
4417-
su2double GetRBF_GreedyTolerance(void) const { return RBF_GreedyTolerance; }
4417+
su2double GetRBF_DataRedTolerance(void) const { return RBF_GreedyTolerance; }
44184418

44194419
/*!
44204420
* \brief Determines use of data reduction methods for RBF mesh deformation.
44214421
* \return <code>TRUE</code> means that data reduction is used.
44224422
*/
4423-
su2double GetRBF_GreedyCorrectionFactor(void) const { return RBF_GreedyCorrectionFactor; }
4423+
su2double GetRBF_DataRedCorrectionFactor(void) const { return RBF_GreedyCorrectionFactor; }
44244424

44254425
/*!
44264426
* \brief Get the kind of SU2 software component.

Common/include/grid_movement/CRadialBasisFunctionInterpolation.hpp

Lines changed: 127 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -31,50 +31,26 @@
3131
#include "../../include/toolboxes/CSymmetricMatrix.hpp"
3232

3333
/*!
34-
* \class CLinearElasticity
34+
* \class CRadialBasisFunctionInterpolation
3535
* \brief Class for moving the volumetric numerical grid using Radial Basis Function interpolation.
3636
* \author F. van Steen
3737
*/
3838

3939
class CRadialBasisFunctionInterpolation : public CVolumetricMovement {
4040
protected:
4141

42-
vector<CRadialBasisFunctionNode*> boundaryNodes; /*!< \brief Vector with boundary nodes.*/
43-
vector<unsigned long> internalNodes; /*!< \brief Vector with internal nodes.*/
44-
unsigned long nBoundaryNodes, /*!< \brief Number of boundary nodes*/
45-
nInternalNodes; /*!< \brief Number of internal nodes*/
46-
47-
vector<CRadialBasisFunctionNode*>* controlNodes; /*!< \brief Vector with control nodes*/
42+
vector<CRadialBasisFunctionNode*>* ControlNodes = nullptr; /*!< \brief Vector with control nodes*/
43+
vector<CRadialBasisFunctionNode*> BoundNodes; /*!< \brief Vector with boundary nodes.*/
44+
vector<CRadialBasisFunctionNode*> ReducedControlNodes; /*!< \brief Vector with selected control nodes in data reduction algorithm. */
4845

49-
vector<passivedouble> deformationVector; /*!< \brief Deformation vector.*/
50-
51-
vector<passivedouble> coefficients; /*!< \brief Control node interpolation coefficients.*/
52-
CSymmetricMatrix interpMat; /*!< \brief Interpolation matrix.*/
53-
// su2activematrix interpMat;
54-
55-
RADIAL_BASIS kindRBF; /*!< \brief Type of Radial Basis Function.*/
56-
su2double radius; /*!< \brief Support radius of compact Radial Basis Function.*/
57-
58-
59-
/*--- data reduction parameters ---*/
60-
vector<CRadialBasisFunctionNode*> greedyNodes; /*!< \brief Vector with selected control nodes in greedy algorithm. */
61-
bool dataReduction; /*!< \brief Determines whether data reduction is used. */
62-
unsigned long MaxErrorNode;
63-
su2double MaxError;
64-
su2double GreedyTolerance;
65-
su2double GreedyCorrectionFactor;
66-
67-
unsigned long Global_nControlNodes{0};
68-
/*--- mpi related*/
69-
70-
unsigned long Local_nControlNodes;
71-
vector<unsigned long> Local_nControlNodesVec;
72-
73-
// vector<su2double> LocalCoords;
74-
vector<su2double> GlobalCoords;
7546

47+
vector<su2double> CtrlNodeDeformation; /*!< \brief Control Node Deformation.*/
48+
vector<su2double> InterpCoeff; /*!< \brief Control node interpolation coefficients.*/
7649

50+
unsigned long nCtrlNodesGlobal{0}; /*!< \brief Total number of control nodes.*/
51+
su2activematrix CtrlCoords; /*!< \brief Coordinates of the control nodes.*/
7752

53+
su2double MaxErrorGlobal{0.0}; /*!< \brief Maximum error data reduction algorithm.*/
7854

7955

8056
public:
@@ -99,53 +75,155 @@ class CRadialBasisFunctionInterpolation : public CVolumetricMovement {
9975
void SetVolume_Deformation(CGeometry* geometry, CConfig* config, bool UpdateGeo, bool Derivative,
10076
bool ForwardProjectionDerivative);
10177

102-
/*!
103-
* \brief Obtaining the interpolation coefficients based on displacement of the control nodes.
78+
/*!
79+
* \brief Selecting unique set of boundary nodes based on marker information.
10480
* \param[in] geometry - Geometrical definition of the problem.
10581
* \param[in] config - Definition of the particular problem.
106-
* \param[in] iNonlinear_Iter - Surface deformation step.
10782
*/
108-
void GetInterpolationCoefficients(CGeometry* geometry, CConfig* config, unsigned long iNonlinear_Iter);
83+
void SetBoundNodes(CGeometry* geometry, CConfig* config);
84+
85+
/*!
86+
* \brief Selecting internal nodes for the volumetric deformation.
87+
* \param[in] geometry - Geometrical definition of the problem.
88+
* \param[in] config - Definition of the particular problem.
89+
* \param[in] internalNode - Internal nodes.
90+
*/
91+
void SetInternalNodes(CGeometry* geometry, CConfig* config, vector<unsigned long>& internalNodes);
92+
93+
/*!
94+
* \brief Assigning the control nodes.
95+
* \param[in] config -Definition of the particular problem.
96+
* */
97+
98+
void SetCtrlNodes(CConfig* config);
10999

110100
/*!
111-
* \brief Compute the interpolation matrix with Radial Basis Function evaluations.
101+
* \brief Solving the RBF system to obtain the interpolation coefficients.
112102
* \param[in] geometry - Geometrical definition of the problem.
113103
* \param[in] config - Definition of the particular problem.
104+
* \param[in] type - Type of radial basis function.
105+
* \param[in] radius - Support radius of the radial basis function.
114106
*/
115-
void SetInterpolationMatrix(CGeometry* geometry, CConfig* config);
107+
108+
void SolveRBF_System(CGeometry* geometry, CConfig* config, const RADIAL_BASIS& type, const su2double radius);
116109

117110
/*!
118-
* \brief Build the deformation vector with surface displacements of the control nodes.
111+
* \brief Obtaining the interpolation coefficients of the control nodes.
119112
* \param[in] geometry - Geometrical definition of the problem.
120113
* \param[in] config - Definition of the particular problem.
114+
* \param[in] type - Type of radial basis function.
115+
* \param[in] radius - Support radius of the radial basis function.
121116
*/
122-
void SetDeformationVector(CGeometry* geometry, CConfig* config);
117+
118+
void GetInterpCoeffs(CGeometry* geometry, CConfig* config, const RADIAL_BASIS& type, const su2double radius);
119+
123120

124121
/*!
125-
* \brief Selecting unique set of control nodes based on marker information.
122+
* \brief Gathering of all control node coordinates.
123+
* \param[in] geometry - Geometrical definition of the problem.
124+
*/
125+
void SetCtrlNodeCoords(CGeometry* geometry);
126+
127+
/*!
128+
* \brief Build the deformation vector with surface displacements of the control nodes.
126129
* \param[in] geometry - Geometrical definition of the problem.
127130
* \param[in] config - Definition of the particular problem.
128131
*/
129-
void SetControlNodes(CGeometry* geometry, CConfig* config);
132+
void SetDeformation(CGeometry* geometry, CConfig* config);
130133

131134
/*!
132-
* \brief Selecting internal nodes for the volumetric deformation.
135+
* \brief Computation of the interpolation matrix and inverting in.
133136
* \param[in] geometry - Geometrical definition of the problem.
137+
* \param[in] type - Type of radial basis function.
138+
* \param[in] radius - Support radius of the radial basis function.
139+
* \param[in] invInterpMat - Inverse of the interpolation matrix.
134140
*/
135-
void SetInternalNodes(CGeometry* geometry, CConfig* config);
141+
void ComputeInterpolationMatrix(CGeometry* geometry, const RADIAL_BASIS& type, const su2double radius, su2passivematrix& invInterpMat);
136142

137143
/*!
138-
* \brief Solving of the Radial Basis Function interpolation system, yielding the interpolation coefficients
144+
* \brief Computation of interpolation coefficients
145+
* \param[in] invInterpMat - Inverse of interpolation matrix
139146
*/
140-
void SolveRBF_System(void);
147+
void ComputeInterpCoeffs(su2passivematrix& invInterpMat);
148+
149+
/*!
150+
* \brief Finding initial data reduction control nodes based on maximum deformation.
151+
* \param[in] geometry - Geometrical definition of the problem.
152+
* \param[in] config - Definition of the particular problem.
153+
* \param[in] maxErrorNodeLocal - Local maximum error node.
154+
* \param[in] maxErrorLocal - Local maximum error.
155+
*/
156+
void GetInitMaxErrorNode(CGeometry* geometry, CConfig* config, unsigned long& maxErrorNodeLocal, su2double& maxErrorLocal);
157+
158+
/*!
159+
* \brief Addition of control node to the reduced set.
160+
* \param[in] maxErrorNode - Node with maximum error to be added.
161+
*/
162+
void AddControlNode(unsigned long maxErrorNode);
163+
164+
/*!
165+
* \brief Compute global number of control nodes.
166+
*/
167+
void Get_nCtrlNodesGlobal();
168+
169+
/*!
170+
* \brief Compute interpolation error.
171+
* \param[in] geometry - Geometrical definition of the problem.
172+
* \param[in] config - Definition of the particular problem.
173+
* \param[in] type - Type of radial basis function.
174+
* \param[in] radius - Support radius of the radial basis function.
175+
* \param[in] maxErrorNodeLocal - Local maximum error node.
176+
* \param[in] maxErrorLocal - Local maximum error.
177+
*/
178+
void GetInterpError(CGeometry* geometry, CConfig* config, const RADIAL_BASIS& type, const su2double radius, unsigned long& maxErrorNodeLocal, su2double& maxErrorLocal);
179+
180+
/*!
181+
* \brief Compute error of single node.
182+
* \param[in] geometry - Geometrical definition of the problem.
183+
* \param[in] config - Definition of the particular problem.
184+
* \param[in] type - Type of radial basis function.
185+
* \param[in] radius - Support radius of the radial basis function.
186+
* \param[in] iNode - Local node in consideration.
187+
* \param[in] localError - Local error.
188+
*/
189+
void GetNodalError(CGeometry* geometry, CConfig* config, const RADIAL_BASIS& type, const su2double radius, unsigned long iNode, su2double* localError);
141190

142-
143191
/*!
144192
* \brief Updating the grid coordinates.
145193
* \param[in] geometry - Geometrical definition of the problem.
146194
* \param[in] config - Definition of the particular problem.
195+
* \param[in] type - Type of radial basis function.
196+
* \param[in] radius - Support radius of the radial basis function.
197+
* \param[in] internalNodes - Internal nodes.
198+
*/
199+
void UpdateGridCoord(CGeometry* geometry, CConfig* config, const RADIAL_BASIS& type, const su2double radius, const vector<unsigned long>& internalNodes);
200+
201+
/*!
202+
* \brief Updating the internal node coordinates.
203+
* \param[in] geometry - Geometrical definition of the problem.
204+
* \param[in] type - Type of radial basis function.
205+
* \param[in] radius - Support radius of the radial basis function.
206+
* \param[in] internalNodes - Internal nodes.
207+
*/
208+
void UpdateInternalCoords(CGeometry* geometry, const RADIAL_BASIS& type, const su2double radius, const vector<unsigned long>& internalNodes);
209+
210+
/*!
211+
* \brief Updating the internal node coordinates.
212+
* \param[in] geometry - Geometrical definition of the problem.
213+
* \param[in] config - Definition of the particular problem.
214+
* \param[in] type - Type of radial basis function.
215+
* \param[in] radius - Support radius of the radial basis function.
216+
*/
217+
void UpdateBoundCoords(CGeometry* geometry, CConfig* config, const RADIAL_BASIS& type, const su2double radius);
218+
219+
/*!
220+
* \brief Apply correction to the nonzero error boundary nodes.
221+
* \param[in] geometry - Geometrical definition of the problem.
222+
* \param[in] config - Definition of the particular problem.
223+
* \param[in] type - Type of radial basis function.
224+
* \param[in] internalNodes - Internal nodes.
147225
*/
148-
void UpdateGridCoord(CGeometry* geometry, CConfig* config);
226+
void SetCorrection(CGeometry* geometry, CConfig* config, const RADIAL_BASIS& type, const vector<unsigned long>& internalNodes);
149227

150228
/*!
151229
* \brief Custom comparison function, for sorting the CRadialBasisFunctionNode objects based on their index.
@@ -164,22 +242,4 @@ class CRadialBasisFunctionInterpolation : public CVolumetricMovement {
164242
inline static bool Equal(CRadialBasisFunctionNode* a, CRadialBasisFunctionNode* b){
165243
return a->GetIndex() == b->GetIndex();
166244
}
167-
168-
inline static bool Equal2(unsigned long a, unsigned long b){
169-
return a == b;
170-
};
171-
172-
173-
/*--- Data reduction functions ---*/
174-
void GreedyIteration(CGeometry* geometry, CConfig* config);
175-
176-
void GetInitMaxErrorNode(CGeometry* geometry, CConfig* config);
177-
178-
void MPI_Operations(CGeometry* geometry);
179-
180-
su2double GetError(CGeometry* geometry, CConfig* config);
181-
182-
su2double* GetNodalError(CGeometry* geometry, CConfig* config, unsigned long iNode, su2double* localError);
183-
184-
void SetCorrection(CGeometry* geometry);
185245
};

Common/include/grid_movement/CRadialBasisFunctionNode.hpp

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,35 +41,49 @@ class CRadialBasisFunctionNode{
4141
unsigned short marker_idx; /*!< \brief Marker index. */
4242
unsigned long vertex_idx; /*!< \brief Vertex index. */
4343

44-
su2double error[3];
45-
44+
su2double error[3]; /*!< \brief Nodal data reduction error; */
4645

4746
public:
4847

4948
/*!
5049
* \brief Constructor of the class.
50+
* \param[in] idx_val - Local node index.
51+
* \param[in] marker_val - Local marker index.
52+
* \param[in] vertex_val - Local vertex index.
5153
*/
5254
CRadialBasisFunctionNode(unsigned long idx_val, unsigned short marker_val, unsigned long vertex_val);
5355

5456
/*!
55-
* \brief Returns global index.
57+
* \brief Returns local global index.
58+
* \return Local node index.
59+
*/
60+
inline unsigned long GetIndex(){return idx;}
61+
62+
/*!
63+
* \brief Returns local vertex index.
64+
* \return Local vertex index.
5665
*/
57-
inline unsigned long GetIndex(void){return idx;}
66+
inline unsigned long GetVertex(){return vertex_idx;}
5867

5968
/*!
60-
* \brief Returns vertex index.
69+
* \brief Returns local marker index.
70+
* \return Local marker index.
6171
*/
62-
inline unsigned long GetVertex(void){return vertex_idx;}
72+
inline unsigned short GetMarker(){return marker_idx;}
6373

6474
/*!
65-
* \brief Returns marker index.
75+
* \brief Set error of the RBF node.
76+
* \param val_error - Nodal error.
77+
* \param nDim - Number of dimensions.
6678
*/
67-
inline unsigned short GetMarker(void){return marker_idx;}
6879

6980
inline void SetError(const su2double* val_error, unsigned short nDim) {
70-
for (unsigned short iDim = 0; iDim < nDim; iDim++) error[iDim] = val_error[iDim];
81+
for (auto iDim = 0u; iDim < nDim; iDim++) error[iDim] = val_error[iDim];
7182
}
7283

73-
inline su2double* GetError(void){ return error;}
74-
84+
/*!
85+
* \brief Get nodal error.
86+
* \return Nodal error.
87+
*/
88+
inline su2double* GetError(){ return error;}
7589
};

0 commit comments

Comments
 (0)