@@ -312,9 +312,6 @@ CPhysicalGeometry::CPhysicalGeometry(CGeometry *geometry,
312312 delete [] Elem_ID_BoundTria_Linear;
313313 delete [] Elem_ID_BoundQuad_Linear;
314314
315- delete[] GlobalMarkerStorageDispl;
316- delete[] GlobalRoughness_Height;
317-
318315}
319316
320317CPhysicalGeometry::~CPhysicalGeometry (void ) {
@@ -11242,8 +11239,6 @@ void CPhysicalGeometry::SetWallDistance(const CConfig *config, CADTElemClass *Wa
1124211239 /* --- Step 3: Loop over all interior mesh nodes and compute minimum ---*/
1124311240 /* --- distance to a solid wall element ---*/
1124411241 /* --------------------------------------------------------------------------*/
11245- int rank;
11246- SU2_MPI::Comm_rank (MPI_COMM_WORLD, &rank);
1124711242
1124811243 /* --- Store marker list and roughness in a global array. ---*/
1124911244 if (config->GetnRoughWall () > 0 ) SetGlobalMarkerRoughness (config);
@@ -11263,65 +11258,47 @@ void CPhysicalGeometry::SetWallDistance(const CConfig *config, CADTElemClass *Wa
1126311258 WallADT->DetermineNearestElement (nodes->GetCoord (iPoint), dist, markerID, elemID, rankID);
1126411259
1126511260 nodes->SetWall_Distance (iPoint, min (dist,nodes->GetWall_Distance (iPoint)));
11261+
1126611262 if (config->GetnRoughWall () > 0 ) {
11267- auto index = GlobalMarkerStorageDispl[rankID]+ markerID;
11263+ auto index = GlobalMarkerStorageDispl[rankID] + markerID;
1126811264 auto localRoughness = GlobalRoughness_Height[index];
1126911265 nodes->SetRoughnessHeight (iPoint, localRoughness);
11270- }
11266+ }
1127111267 }
11272-
11268+
1127311269 }
1127411270 // end SU2_OMP_PARALLEL
1127511271}
1127611272
1127711273void CPhysicalGeometry::SetGlobalMarkerRoughness (const CConfig* config) {
1127811274
11279- unsigned short iMarker;
11280- unsigned short nMarker_All = config->GetnMarker_All ();
11281-
11282- int *displs = new int [size];
11283- int * recvCounts = new int [size];
11284- int sizeLocal = (int ) nMarker_All; // number of local markers
11285-
11286- // Communicate size of local marker array and make an array large enough to hold all data
11287- SU2_MPI::Allgather (&sizeLocal, 1 , MPI_INT, recvCounts, 1 ,
11288- MPI_INT, MPI_COMM_WORLD);
11289-
11290- // displacements based on size on each rank
11291- displs[0 ] = 0 ;
11292- for (int i=1 ; i<size; ++i) displs[i] = displs[i-1 ] + recvCounts[i-1 ];
11275+ const auto nMarker_All = config->GetnMarker_All ();
11276+
11277+ vector<int > recvCounts (size);
11278+ auto sizeLocal = static_cast <int >(nMarker_All); // number of local markers
11279+
11280+ /* --- Communicate size of local marker array and make an array large enough to hold all data. ---*/
11281+ SU2_MPI::Allgather (&sizeLocal, 1 , MPI_INT, recvCounts.data (), 1 , MPI_INT, MPI_COMM_WORLD);
1129311282
1129411283 /* --- Set the global array of displacements, needed to access the correct roughness element. ---*/
11295- if ( GlobalMarkerStorageDispl == nullptr ) GlobalMarkerStorageDispl = new int [ size] ;
11284+ GlobalMarkerStorageDispl. resize ( size) ;
1129611285 GlobalMarkerStorageDispl[0 ] = 0 ;
11297- for (int iRank = 1 ; iRank < size; iRank++)
11298- GlobalMarkerStorageDispl[iRank] = displs [iRank];
11299-
11300- // total size
11301- int sizeGlobal = displs [size-1 ] + recvCounts[size-1 ];
11286+ for (int iRank = 1 ; iRank < size; iRank++)
11287+ GlobalMarkerStorageDispl[iRank] = GlobalMarkerStorageDispl [iRank- 1 ] + recvCounts[iRank- 1 ];
11288+
11289+ /* --- Total size --- */
11290+ const auto sizeGlobal = GlobalMarkerStorageDispl [size-1 ] + recvCounts[size-1 ];
1130211291
1130311292 /* --- Allocate local and global arrays to hold roughness. ---*/
11304- su2double *localRough = new su2double [nMarker_All]; // local number of markers
11305- su2double *globalRough = new su2double[sizeGlobal]; // all markers including send recieve
11306- pair<unsigned short , su2double> wallprop;
11293+ vector<su2double> localRough (nMarker_All); // local number of markers
11294+ GlobalRoughness_Height.resize (sizeGlobal); // all markers including send recieve
1130711295
11308- for (iMarker = 0 ; iMarker < nMarker_All; iMarker++) {
11309- wallprop = config->GetWallRoughnessProperties (config->GetMarker_All_TagBound (iMarker));
11296+ for (auto iMarker = 0u ; iMarker < nMarker_All; iMarker++) {
11297+ auto wallprop = config->GetWallRoughnessProperties (config->GetMarker_All_TagBound (iMarker));
1131011298 localRough[iMarker] = wallprop.second ;
1131111299 }
1131211300
11313- SU2_MPI::Allgatherv ( localRough, sizeLocal, MPI_DOUBLE, globalRough ,
11314- recvCounts, displs, MPI_DOUBLE,
11315- MPI_COMM_WORLD);
11316-
11317- /* --- Set the global array of roughness per marker. ---*/
11318- if (GlobalRoughness_Height == nullptr ) GlobalRoughness_Height = new su2double [sizeGlobal];
11319- for (int iMarker = 0 ; iMarker < sizeGlobal; iMarker++)
11320- GlobalRoughness_Height[iMarker] = globalRough[iMarker];
11321-
11322- /* --- Deallocate local variables. ---*/
11323- delete [] displs;
11324- delete [] recvCounts;
11325- delete [] localRough;
11326- delete [] globalRough;
11301+ /* --- Finally, gather the roughness of all markers. ---*/
11302+ SU2_MPI::Allgatherv (localRough.data (), sizeLocal, MPI_DOUBLE, GlobalRoughness_Height.data (),
11303+ recvCounts.data (), GlobalMarkerStorageDispl.data (), MPI_DOUBLE, MPI_COMM_WORLD);
1132711304}
0 commit comments