@@ -4085,51 +4085,30 @@ void CGeometry::ComputeWallDistance(const CConfig* const* config_container, CGeo
40854085 }
40864086 /* --- Otherwise, set wall roughnesses. ---*/
40874087 if (!allEmpty) {
4088- /* --- Store all marker wall roughnesses in a common data structure. ---*/
4089- std::vector<unsigned short > wall_rough_zone, wall_rough_marker;
4090- std::vector<su2double> wall_rough_val;
4088+ /* --- Store all marker wall roughnesses in a common data structure (rank, zone, marker) -> value. ---*/
4089+ unsigned short nMarkerMax = 0 ;
4090+ for (auto iZone = 0u ; iZone < nZone; ++iZone) {
4091+ nMarkerMax = std::max (nMarkerMax, geometry_container[iZone][iInst][MESH_0]->GetnMarker ());
4092+ }
4093+ const auto tmp = nMarkerMax;
4094+ SU2_MPI::Allreduce (&tmp, &nMarkerMax, 1 , MPI_UNSIGNED_SHORT, MPI_MAX, SU2_MPI::GetComm ());
4095+
4096+ su2activematrix wall_roughness (nZone, nMarkerMax);
40914097 for (auto iZone = 0u ; iZone < nZone; ++iZone) {
40924098 const CConfig* config = config_container[iZone];
40934099 for (auto iMarker = 0u ; iMarker < geometry_container[iZone][iInst][MESH_0]->GetnMarker (); ++iMarker) {
4094- wall_rough_zone.push_back (iZone);
4095- wall_rough_marker.push_back (iMarker);
4096- wall_rough_val.push_back (config->GetWallRoughnessProperties (config->GetMarker_All_TagBound (iMarker)).second );
4100+ wall_roughness (iZone, iMarker) =
4101+ config->GetWallRoughnessProperties (config->GetMarker_All_TagBound (iMarker)).second ;
40974102 }
40984103 }
4099- /* --- Communicate. ---*/
4100- const int wall_rough_size = wall_rough_val.size ();
4101- const int mpi_size = SU2_MPI::GetSize ();
4102- std::vector<int > counts (mpi_size);
4103- SU2_MPI::Allgather (&wall_rough_size, 1 , MPI_INT, counts.data (), 1 , MPI_INT, SU2_MPI::GetComm ());
4104- std::vector<int > displs (mpi_size + 1 , 0 );
4105- for (int i = 1 ; i <= mpi_size; ++i) displs[i] = displs[i - 1 ] + counts[i - 1 ];
4106- const auto total_size = displs.back ();
4107-
4108- std::vector<unsigned short > all_wall_rough_zone (total_size), all_wall_rough_marker (total_size);
4109- std::vector<su2double> all_wall_rough_val (total_size);
4110-
4111- SU2_MPI::Allgatherv (wall_rough_zone.data (), wall_rough_size, MPI_UNSIGNED_SHORT, all_wall_rough_zone.data (),
4112- counts.data (), displs.data (), MPI_UNSIGNED_SHORT, SU2_MPI::GetComm ());
4113- SU2_MPI::Allgatherv (wall_rough_marker.data (), wall_rough_size, MPI_UNSIGNED_SHORT, all_wall_rough_marker.data (),
4114- counts.data (), displs.data (), MPI_UNSIGNED_SHORT, SU2_MPI::GetComm ());
4115- SU2_MPI::Allgatherv (wall_rough_val.data (), wall_rough_size, MPI_DOUBLE, all_wall_rough_val.data (),
4116- counts.data (), displs.data (), MPI_DOUBLE, SU2_MPI::GetComm ());
4117-
4118- /* --- f(iRank, iZone, iMarker) -> roughness value ---*/
4119- auto wall_rough_func = [&](int iRank, unsigned short iZone, unsigned short iMarker) {
4120- /* --- Jump based on rank, then linear search for (iZone, iMarker). ---*/
4121- for (auto k = displs[iRank]; k < displs[iRank + 1 ]; ++k) {
4122- if (all_wall_rough_zone[k] == iZone && all_wall_rough_marker[k] == iMarker) {
4123- return all_wall_rough_val[k];
4124- }
4125- }
4126- SU2_MPI::Error (" Failed to find wall roughness value" , CURRENT_FUNCTION);
4127- return su2double{};
4128- };
4129-
4130- for (auto jZone=0u ; jZone<nZone; jZone++) {
4131- if (wallDistanceNeeded[jZone] && config_container[jZone]->GetnRoughWall () > 0 ) {
4132- geometry_container[jZone][iInst][MESH_0]->nodes ->SetWallRoughness (wall_rough_func);
4104+ const auto nRank = SU2_MPI::GetSize ();
4105+ C3DDoubleMatrix all_wall_roughness (nRank, nZone, nMarkerMax);
4106+ SU2_MPI::Allgather (wall_roughness.data (), wall_roughness.size (), MPI_DOUBLE, all_wall_roughness.data (),
4107+ wall_roughness.size (), MPI_DOUBLE, SU2_MPI::GetComm ());
4108+
4109+ for (auto iZone = 0u ; iZone < nZone; ++iZone) {
4110+ if (wallDistanceNeeded[iZone] && config_container[iZone]->GetnRoughWall () > 0 ) {
4111+ geometry_container[iZone][iInst][MESH_0]->nodes ->SetWallRoughness (all_wall_roughness);
41334112 }
41344113 }
41354114 }
0 commit comments