@@ -72,9 +72,11 @@ void CRadialBasisFunctionInterpolation::SetVolume_Deformation(CGeometry* geometr
7272 for (auto iNonlinear_Iter = 0ul ; iNonlinear_Iter < Nonlinear_Iter; iNonlinear_Iter++) {
7373 /* --- Compute min volume in the entire mesh. ---*/
7474
75+ const std::string areaOrVol = nDim == 2 ? " area: " : " volume: " ;
76+
7577 ComputeDeforming_Element_Volume (geometry, MinVolume, MaxVolume, Screen_Output);
7678 if (rank == MASTER_NODE && Screen_Output)
77- cout << " Min. volume: " << MinVolume << " , max. volume: " << MaxVolume << " . " << endl ;
79+ cout << " Min. " << areaOrVol << MinVolume << " , max. " << areaOrVol << MaxVolume << " . \n " ;
7880
7981 /* --- Solving the RBF system, resulting in the interpolation coefficients ---*/
8082 SolveRBFSystem (geometry, config, kindRBF, radius);
@@ -95,11 +97,8 @@ void CRadialBasisFunctionInterpolation::SetVolume_Deformation(CGeometry* geometr
9597 ComputenNonconvexElements (geometry, Screen_Output);
9698
9799 if (rank == MASTER_NODE && Screen_Output) {
98- cout << " Non-linear iter.: " << iNonlinear_Iter + 1 << " /" << Nonlinear_Iter << " . " ;
99- if (nDim == 2 )
100- cout << " Min. area: " << MinVolume << " ." << endl;
101- else
102- cout << " Min. volume: " << MinVolume << " ." << endl;
100+ cout << " Non-linear iter: " << iNonlinear_Iter + 1 << " /" << Nonlinear_Iter << " . " ;
101+ cout << " Min. " << areaOrVol << MinVolume << " .\n " ;
103102 }
104103 }
105104}
@@ -128,6 +127,10 @@ void CRadialBasisFunctionInterpolation::SolveRBFSystem(CGeometry* geometry, CCon
128127 /* --- Number of greedy iterations. ---*/
129128 unsigned short greedyIter = 0 ;
130129
130+ if (rank == MASTER_NODE) {
131+ cout << " Greedy iteration, Max error, Global nr. of ctrl nodes.\n " ;
132+ }
133+
131134 /* --- While the maximum error is above the tolerance, data reduction algorithm is continued. ---*/
132135 while (MaxErrorGlobal > dataReductionTolerance || greedyIter == 0 ) {
133136 /* --- In case of a nonzero local error, control nodes are added ---*/
@@ -146,9 +149,7 @@ void CRadialBasisFunctionInterpolation::SolveRBFSystem(CGeometry* geometry, CCon
146149 SU2_MPI::Allreduce (&maxErrorLocal, &MaxErrorGlobal, 1 , MPI_DOUBLE, MPI_MAX, SU2_MPI::GetComm ());
147150
148151 if (rank == MASTER_NODE) {
149- cout << " Greedy iteration: " << greedyIter << " . Max error: " << MaxErrorGlobal
150- << " . Global nr. of ctrl nodes: " << nCtrlNodesGlobal << " \n "
151- << endl;
152+ cout << " " << greedyIter << " " << MaxErrorGlobal << " " << nCtrlNodesGlobal << " \n " ;
152153 }
153154 greedyIter++;
154155 }
@@ -260,12 +261,12 @@ void CRadialBasisFunctionInterpolation::ComputeInterpolationMatrix(CGeometry* ge
260261
261262void CRadialBasisFunctionInterpolation::SetDeformation (CGeometry* geometry, CConfig* config) {
262263 /* --- Initialization of the deformation vector ---*/
263- CtrlNodeDeformation. resize (ControlNodes->size (), nDim) = su2double ( 0.0 );
264+ su2activematrix localDeformation (ControlNodes->size (), nDim);
264265
265266 /* --- If requested (no by default) impose the surface deflections in
266267 increments and solve the grid deformation with
267268 successive small deformations. ---*/
268- const su2double VarIncrement = 1.0 / ((su2double) config->GetGridDef_Nonlinear_Iter () );
269+ const su2double VarIncrement = 1.0 / config->GetGridDef_Nonlinear_Iter ();
269270
270271 /* --- Loop over the control nodes ---*/
271272 for (auto iNode = 0ul ; iNode < ControlNodes->size (); iNode++) {
@@ -275,48 +276,50 @@ void CRadialBasisFunctionInterpolation::SetDeformation(CGeometry* geometry, CCon
275276 * ---*/
276277 if (IsDeformationMarker (config, iMarker)) {
277278 for (auto iDim = 0u ; iDim < nDim; iDim++) {
278- CtrlNodeDeformation (iNode, iDim) = SU2_TYPE::GetValue (
279+ localDeformation (iNode, iDim) = SU2_TYPE::GetValue (
279280 geometry->vertex [iMarker][(*ControlNodes)[iNode]->GetVertex ()]->GetVarCoord ()[iDim] * VarIncrement);
280281 }
281282 } else {
282283 for (auto iDim = 0u ; iDim < nDim; iDim++) {
283- CtrlNodeDeformation (iNode, iDim) = 0.0 ;
284+ localDeformation (iNode, iDim) = 0.0 ;
284285 }
285286 }
286287 }
287288
288- /* --- In case of a parallel computation, the deformation of all control nodes is send to the master process ---*/
289+ /* --- In case of a parallel computation, the deformation of all control nodes is send to the master process ---*/
289290#ifdef HAVE_MPI
290291
291- /* --- Local number of control nodes ---*/
292- unsigned long Local_nControlNodes = ControlNodes-> size ();
292+ /* --- Local size ---*/
293+ unsigned long localSize = localDeformation. size ();
293294
294295 /* --- Array containing the local number of control nodes ---*/
295- std::vector<unsigned long > Local_nControlNodesArr (size);
296+ std::vector<unsigned long > localSizesArr (size);
296297
297298 /* --- gathering local control node coordinate sizes on all processes. ---*/
298- SU2_MPI::Allgather (&Local_nControlNodes, 1 , MPI_UNSIGNED_LONG, Local_nControlNodesArr.data (), 1 , MPI_UNSIGNED_LONG,
299- SU2_MPI::GetComm ());
299+ SU2_MPI::Allgather (&localSize, 1 , MPI_UNSIGNED_LONG, localSizesArr.data (), 1 , MPI_UNSIGNED_LONG, SU2_MPI::GetComm ());
300300
301301 /* --- Gathering all deformation vectors on the master node ---*/
302302 if (rank == MASTER_NODE) {
303- /* --- resizing the global deformation vector ---*/
303+ /* --- resizing the global deformation vector. ---*/
304304 CtrlNodeDeformation.resize (nCtrlNodesGlobal, nDim);
305305
306306 /* --- Receiving the local deformation vector from other processes ---*/
307307 unsigned long start_idx = 0 ;
308308 for (auto iProc = 0 ; iProc < size; iProc++) {
309309 if (iProc != MASTER_NODE) {
310- SU2_MPI::Recv (CtrlNodeDeformation.data () + start_idx, Local_nControlNodesArr[iProc] * nDim, MPI_DOUBLE, iProc,
311- 0 , SU2_MPI::GetComm (), MPI_STATUS_IGNORE);
310+ SU2_MPI::Recv (CtrlNodeDeformation.data () + start_idx, localSizesArr[iProc], MPI_DOUBLE, iProc, 0 ,
311+ SU2_MPI::GetComm (), MPI_STATUS_IGNORE);
312+ } else {
313+ for (auto i = 0ul ; i < localDeformation.size (); ++i) {
314+ CtrlNodeDeformation.data ()[start_idx + i] = localDeformation.data ()[i];
315+ }
312316 }
313- start_idx += Local_nControlNodesArr [iProc] * nDim ;
317+ start_idx += localSizesArr [iProc];
314318 }
315-
316319 } else {
317320 /* --- Sending the local deformation vector to the master node ---*/
318- SU2_MPI::Send (CtrlNodeDeformation .data (), Local_nControlNodes * nDim , MPI_DOUBLE, MASTER_NODE, 0 ,
319- SU2_MPI::GetComm () );
321+ SU2_MPI::Send (localDeformation .data (), localDeformation. size () , MPI_DOUBLE, MASTER_NODE, 0 , SU2_MPI::GetComm ());
322+ CtrlNodeDeformation = std::move (localDeformation );
320323 }
321324#endif
322325}
@@ -382,9 +385,8 @@ void CRadialBasisFunctionInterpolation::ComputeInterpCoeffs(su2passivematrix& in
382385 /* --- resizing the interpolation coefficient vector ---*/
383386 InterpCoeff.resize (nCtrlNodesGlobal, nDim) = su2double (0.0 );
384387
385- /* --- Coefficients are found on the master process.
386- Resulting coefficient is found by summing the multiplications of inverse interpolation matrix entries with
387- deformation ---*/
388+ /* --- Coefficients are found on the master process. Resulting coefficient is found by summing the
389+ multiplications of inverse interpolation matrix entries with deformation ---*/
388390 if (rank == MASTER_NODE) {
389391 for (auto iNode = 0ul ; iNode < nCtrlNodesGlobal; iNode++) {
390392 for (auto jNode = 0ul ; jNode < nCtrlNodesGlobal; jNode++) {
@@ -405,19 +407,13 @@ void CRadialBasisFunctionInterpolation::UpdateGridCoord(CGeometry* geometry, CCo
405407 const su2double radius,
406408 const vector<unsigned long >& internalNodes) {
407409 if (rank == MASTER_NODE) {
408- cout << " updating the grid coordinates" << endl ;
410+ cout << " Updating the grid coordinates. \n " ;
409411 }
410-
411412 /* --- Update of internal node coordinates ---*/
412413 UpdateInternalCoords (geometry, type, radius, internalNodes);
413414
414415 /* --- Update of boundary node coordinates ---*/
415416 UpdateBoundCoords (geometry, config, type, radius);
416-
417- /* --- In case of data reduction, perform the correction for nonzero error nodes ---*/
418- if (config->GetRBFParam ().DataReduction && BoundNodes.size () > 0 ) {
419- SetCorrection (geometry, config, type, internalNodes);
420- }
421417}
422418
423419void CRadialBasisFunctionInterpolation::UpdateInternalCoords (CGeometry* geometry, const RADIAL_BASIS& type,
@@ -518,13 +514,13 @@ void CRadialBasisFunctionInterpolation::SetCtrlNodeCoords(CGeometry* geometry) {
518514 CtrlCoords.resize (nCtrlNodesGlobal, nDim);
519515
520516 /* --- Array containing the local control node coordinates ---*/
521- std::vector<su2double> localCoords (ControlNodes->size () * nDim);
517+ su2activematrix localCoords (ControlNodes->size (), nDim);
522518
523519 /* --- Storing local control node coordinates ---*/
524520 for (auto iNode = 0ul ; iNode < ControlNodes->size (); iNode++) {
525- auto coord = geometry->nodes ->GetCoord ((*ControlNodes)[iNode]->GetIndex ());
521+ const auto * coord = geometry->nodes ->GetCoord ((*ControlNodes)[iNode]->GetIndex ());
526522 for (auto iDim = 0u ; iDim < nDim; iDim++) {
527- localCoords[ iNode * nDim + iDim] = coord[iDim];
523+ localCoords ( iNode, iDim) = coord[iDim];
528524 }
529525 }
530526
@@ -536,7 +532,7 @@ void CRadialBasisFunctionInterpolation::SetCtrlNodeCoords(CGeometry* geometry) {
536532 /* --- Array containing the starting indices for the allgatherv operation */
537533 std::vector<int > disps (size, 0 );
538534
539- for (auto iProc = 1 ; iProc < SU2_MPI::GetSize () ; iProc++) {
535+ for (auto iProc = 1 ; iProc < size ; iProc++) {
540536 disps[iProc] = disps[iProc - 1 ] + LocalCoordsSizes[iProc - 1 ];
541537 }
542538
@@ -610,75 +606,6 @@ void CRadialBasisFunctionInterpolation::GetNodalError(CGeometry* geometry, CConf
610606 }
611607}
612608
613- void CRadialBasisFunctionInterpolation::SetCorrection (CGeometry* geometry, CConfig* config, const RADIAL_BASIS& type,
614- const vector<unsigned long >& internalNodes) {
615- /* --- The non-selected control nodes still have a nonzero error once the maximum error falls below the data reduction
616- tolerance. This error is applied as correction and interpolated into the volumetric mesh for internal nodes that
617- fall within the correction radius. To evaluate whether an internal node falls within the correction radius an AD
618- tree is constructed of the boundary nodes, making it possible to determine the distance to the nearest boundary
619- node. ---*/
620-
621- /* --- Construction of the AD tree consisting of the non-selected boundary nodes ---*/
622-
623- /* --- Number of non-selected boundary nodes ---*/
624- const unsigned long nVertexBound = BoundNodes.size ();
625-
626- /* --- Vector storing the coordinates of the boundary nodes ---*/
627- vector<su2double> Coord_bound (nDim * nVertexBound);
628-
629- /* --- Vector storing the IDs of the boundary nodes ---*/
630- vector<unsigned long > PointIDs (nVertexBound);
631-
632- /* --- Correction Radius, equal to maximum error times a prescribed constant ---*/
633- const su2double CorrectionRadius = config->GetRBFParam ().GreedyCorrectionFactor * MaxErrorGlobal;
634-
635- /* --- Storing boundary node information ---*/
636- unsigned long i = 0 ;
637- unsigned long j = 0 ;
638- for (auto iVertex = 0ul ; iVertex < nVertexBound; iVertex++) {
639- auto iNode = BoundNodes[iVertex]->GetIndex ();
640- PointIDs[i++] = iVertex;
641- for (auto iDim = 0u ; iDim < nDim; iDim++) {
642- Coord_bound[j++] = geometry->nodes ->GetCoord (iNode, iDim);
643- }
644- }
645-
646- /* --- Construction of AD tree ---*/
647- CADTPointsOnlyClass BoundADT (nDim, nVertexBound, Coord_bound.data (), PointIDs.data (), true );
648-
649- /* --- ID of nearest boundary node ---*/
650- unsigned long pointID;
651- /* --- Distance to nearest boundary node ---*/
652- su2double dist;
653- /* --- rank of nearest boundary node ---*/
654- int rankID;
655-
656- /* --- Interpolation of the correction to the internal nodes that fall within the correction radius ---*/
657- for (auto iNode = 0ul ; iNode < internalNodes.size (); iNode++) {
658- /* --- Find nearest node ---*/
659- BoundADT.DetermineNearestNode (geometry->nodes ->GetCoord (internalNodes[iNode]), dist, pointID, rankID);
660-
661- /* --- Get error of nearest node ---*/
662- auto err = BoundNodes[pointID]->GetError ();
663-
664- /* --- evaluate RBF ---*/
665- auto rbf = SU2_TYPE::GetValue (CRadialBasisFunction::Get_RadialBasisValue (type, CorrectionRadius, dist));
666-
667- /* --- Apply correction to the internal node ---*/
668- for (auto iDim = 0u ; iDim < nDim; iDim++) {
669- geometry->nodes ->AddCoord (internalNodes[iNode], iDim, -rbf * err[iDim]);
670- }
671- }
672-
673- /* --- Applying the correction to the non-selected boundary nodes ---*/
674- for (auto iNode = 0ul ; iNode < BoundNodes.size (); iNode++) {
675- auto err = BoundNodes[iNode]->GetError ();
676- for (auto iDim = 0u ; iDim < nDim; iDim++) {
677- geometry->nodes ->AddCoord (BoundNodes[iNode]->GetIndex (), iDim, -err[iDim]);
678- }
679- }
680- }
681-
682609void CRadialBasisFunctionInterpolation::AddControlNode (unsigned long maxErrorNode) {
683610 /* --- Addition of node to the reduced set of control nodes ---*/
684611 ReducedControlNodes.push_back (BoundNodes[maxErrorNode]);
0 commit comments