@@ -209,6 +209,9 @@ void CMarkerProfileReaderFVM::MergeProfileMarkers() {
209209 unsigned long index, iChar;
210210
211211 char str_buf[MAX_STRING_SIZE];
212+ char name_buf[MAX_STRING_SIZE];
213+ char value_buf[MAX_STRING_SIZE];
214+
212215 vector<string> Marker_Tags;
213216
214217 vector<unsigned long > nRowCum_Counter;
@@ -221,6 +224,7 @@ void CMarkerProfileReaderFVM::MergeProfileMarkers() {
221224 nLocalPoint = 0 ; numberOfProfiles = 0 ;
222225 for (iMarker = 0 ; iMarker < config->GetnMarker_All (); iMarker++) {
223226 if (config->GetMarker_All_KindBC (iMarker) == markerType) {
227+
224228 numberOfProfiles++;
225229 for (iVertex = 0 ; iVertex < geometry->nVertex [iMarker]; iVertex++) {
226230 iPoint = geometry->vertex [iMarker][iVertex]->GetNode ();
@@ -240,7 +244,8 @@ void CMarkerProfileReaderFVM::MergeProfileMarkers() {
240244 SU2_MPI::Gather (&Buffer_Send_nPoin, 1 , MPI_UNSIGNED_LONG,
241245 Buffer_Recv_nPoin, 1 , MPI_UNSIGNED_LONG, MASTER_NODE, SU2_MPI::GetComm ());
242246 SU2_MPI::Allreduce (&nLocalPoint, &MaxLocalPoint, 1 , MPI_UNSIGNED_LONG, MPI_MAX, SU2_MPI::GetComm ());
243- SU2_MPI::Allreduce (&numberOfProfiles, &maxProfiles, 1 , MPI_UNSIGNED_LONG, MPI_MAX, SU2_MPI::GetComm ());
247+ SU2_MPI::Reduce (&numberOfProfiles, &maxProfiles, 1 , MPI_UNSIGNED_LONG, MPI_SUM, MASTER_NODE,
248+ SU2_MPI::GetComm ());
244249
245250 /* --- Send and Recv buffers. ---*/
246251
@@ -256,14 +261,23 @@ void CMarkerProfileReaderFVM::MergeProfileMarkers() {
256261 char *Buffer_Send_Str = new char [MaxLocalPoint*MAX_STRING_SIZE];
257262 char *Buffer_Recv_Str = nullptr ;
258263
264+ char *Buffer_Send_Name = new char [MaxLocalPoint*MAX_STRING_SIZE];
265+ char *Buffer_Recv_Name = nullptr ;
266+
267+ char *Buffer_Send_Value = new char [MaxLocalPoint*MAX_STRING_SIZE];
268+ char *Buffer_Recv_Value = nullptr ;
269+
259270 /* --- Prepare the receive buffers in the master node only. ---*/
260271
261272 if (rank == MASTER_NODE) {
262273
263274 Buffer_Recv_X = new su2double[nProcessor*MaxLocalPoint];
264275 Buffer_Recv_Y = new su2double[nProcessor*MaxLocalPoint];
265276 if (dimension == 3 ) Buffer_Recv_Z = new su2double[nProcessor*MaxLocalPoint];
277+
266278 Buffer_Recv_Str = new char [nProcessor*MaxLocalPoint*MAX_STRING_SIZE];
279+ Buffer_Recv_Name = new char [nProcessor*MaxLocalPoint*MAX_STRING_SIZE];
280+ Buffer_Recv_Value = new char [nProcessor*MaxLocalPoint*MAX_STRING_SIZE];
267281
268282 /* --- Sum total number of nodes to be written and allocate arrays ---*/
269283
@@ -277,6 +291,9 @@ void CMarkerProfileReaderFVM::MergeProfileMarkers() {
277291 profileCoords[iMarker].resize (dimension);
278292 }
279293
294+ totalColumnNames.resize (maxProfiles);
295+ totalColumnValues.resize (maxProfiles);
296+
280297 }
281298
282299 /* --- Main communication routine. Loop over each coordinate and perform
@@ -318,6 +335,16 @@ void CMarkerProfileReaderFVM::MergeProfileMarkers() {
318335 SPRINTF (&Buffer_Send_Str[jPoint*MAX_STRING_SIZE], " %s" ,
319336 config->GetMarker_All_TagBound (iMarker).c_str ());
320337
338+ /* --- Store the column names ---*/
339+
340+ SPRINTF (&Buffer_Send_Name[jPoint*MAX_STRING_SIZE], " %s" ,
341+ columnNames[iMarker].c_str ());
342+
343+ /* --- Store the column values ---*/
344+
345+ SPRINTF (&Buffer_Send_Value[jPoint*MAX_STRING_SIZE], " %s" ,
346+ columnValues[iMarker].c_str ());
347+
321348 /* --- Increment jPoint as the counter. We need this because iPoint
322349 may include halo nodes that we skip over during this loop. ---*/
323350
@@ -341,11 +368,18 @@ void CMarkerProfileReaderFVM::MergeProfileMarkers() {
341368 SU2_MPI::Gather (Buffer_Send_Str, (int )MaxLocalPoint*MAX_STRING_SIZE, MPI_CHAR,
342369 Buffer_Recv_Str, (int )MaxLocalPoint*MAX_STRING_SIZE, MPI_CHAR, MASTER_NODE, SU2_MPI::GetComm ());
343370
371+ SU2_MPI::Gather (Buffer_Send_Name, (int )MaxLocalPoint*MAX_STRING_SIZE, MPI_CHAR,
372+ Buffer_Recv_Name, (int )MaxLocalPoint*MAX_STRING_SIZE, MPI_CHAR, MASTER_NODE, SU2_MPI::GetComm ());
373+ SU2_MPI::Gather (Buffer_Send_Value, (int )MaxLocalPoint*MAX_STRING_SIZE, MPI_CHAR,
374+ Buffer_Recv_Value, (int )MaxLocalPoint*MAX_STRING_SIZE, MPI_CHAR, MASTER_NODE, SU2_MPI::GetComm ());
375+
344376 /* --- The master node unpacks and sorts this variable by marker tag. ---*/
345377
346378 if (rank == MASTER_NODE) {
347379
348380 profileTags.clear ();
381+ totalColumnNames.clear ();
382+ totalColumnValues.clear ();
349383
350384 /* --- First, parse the marker tags to count how many total profile markers
351385 we have now on the master. ---*/
@@ -355,30 +389,34 @@ void CMarkerProfileReaderFVM::MergeProfileMarkers() {
355389 index = (iProcessor*MaxLocalPoint + iPoint)*MAX_STRING_SIZE;
356390 for (iChar = 0 ; iChar < MAX_STRING_SIZE; iChar++) {
357391 str_buf[iChar] = Buffer_Recv_Str[index + iChar];
392+ name_buf[iChar] = Buffer_Recv_Name[index + iChar];
393+ value_buf[iChar] = Buffer_Recv_Value[index + iChar];
358394 }
359- Marker_Tags.emplace_back (str_buf);
360- profileTags.emplace_back (str_buf);
361- }
362- }
363395
364- /* --- Remove the duplicate profile marker strings. From 1 per point to 1 per marker. ---*/
396+ Marker_Tags.push_back (str_buf);
397+
398+ /* --- only add if not already in the list ---*/
399+ if (std::find (profileTags.begin (), profileTags.end (), str_buf) == profileTags.end ()) {
400+ profileTags.push_back (str_buf);
401+ totalColumnNames.push_back (name_buf);
402+ totalColumnValues.push_back (value_buf);
403+ }
365404
366- profileTags.erase (unique (profileTags.begin (),
367- profileTags.end ()),
368- profileTags.end ());
405+ }
369406
370- /* --- Store the unique number of markers for writing later. --- */
407+ }
371408
372409 numberOfProfiles = profileTags.size ();
373410
374411 /* --- Count the number of rows (nodes) per marker. ---*/
375412
376- numberOfRowsInProfile.resize (numberOfProfiles ,0.0 );
413+ numberOfRowsInProfile.resize (maxProfiles ,0.0 );
377414 jPoint = 0 ;
378415 for (iProcessor = 0 ; iProcessor < nProcessor; iProcessor++) {
379416 for (iPoint = 0 ; iPoint < Buffer_Recv_nPoin[iProcessor]; iPoint++) {
380- for (iMarker = 0 ; iMarker < numberOfProfiles ; iMarker++) {
417+ for (iMarker = 0 ; iMarker < maxProfiles ; iMarker++) {
381418 if (profileTags[iMarker] == Marker_Tags[jPoint]) {
419+
382420 numberOfRowsInProfile[iMarker]++;
383421 }
384422 }
@@ -391,7 +429,7 @@ void CMarkerProfileReaderFVM::MergeProfileMarkers() {
391429 jPoint = 0 ; kPoint = 0 ;
392430 for (iProcessor = 0 ; iProcessor < nProcessor; iProcessor++) {
393431 for (iPoint = 0 ; iPoint < Buffer_Recv_nPoin[iProcessor]; iPoint++) {
394- for (iMarker = 0 ; iMarker < numberOfProfiles ; iMarker++) {
432+ for (iMarker = 0 ; iMarker < maxProfiles ; iMarker++) {
395433
396434 if (profileTags[iMarker] == Marker_Tags[kPoint ]) {
397435
@@ -417,22 +455,26 @@ void CMarkerProfileReaderFVM::MergeProfileMarkers() {
417455 jPoint = (iProcessor+1 )*MaxLocalPoint;
418456
419457 }
458+
420459 }
421460
422461 /* --- Immediately release the temporary data buffers. ---*/
423-
424462 delete [] Buffer_Send_X;
425463 delete [] Buffer_Send_Y;
426464 delete [] Buffer_Send_Z;
427465 delete [] Buffer_Send_Str;
466+ delete [] Buffer_Send_Name;
467+ delete [] Buffer_Send_Value;
468+
428469 if (rank == MASTER_NODE) {
429470 delete [] Buffer_Recv_X;
430471 delete [] Buffer_Recv_Y;
431472 delete [] Buffer_Recv_Z;
432473 delete [] Buffer_Recv_nPoin;
433474 delete [] Buffer_Recv_Str;
475+ delete [] Buffer_Recv_Name;
476+ delete [] Buffer_Recv_Value;
434477 }
435-
436478}
437479
438480void CMarkerProfileReaderFVM::WriteMarkerProfileTemplate () {
@@ -450,43 +492,38 @@ void CMarkerProfileReaderFVM::WriteMarkerProfileTemplate() {
450492 if (rank == MASTER_NODE) {
451493
452494 ofstream node_file (" example_" +filename);
453-
454495 node_file << " NMARK= " << numberOfProfiles << endl;
455496
456- unsigned short iMarkerCounter = 0 ;
457- for (unsigned short iMarker = 0 ; iMarker < config->GetnMarker_All (); iMarker++) {
458- if (config->GetMarker_All_KindBC (iMarker) == markerType) {
497+ for (unsigned long iMarker = 0 ; iMarker < numberOfProfiles; iMarker++) {
459498
460499 /* --- Access the default data for this marker. ---*/
461-
462- string Marker_Tag = profileTags[iMarkerCounter];
500+ string Marker_Tag = profileTags[iMarker];
463501
464502 /* --- Header information for this marker. ---*/
465503
466504 node_file << " MARKER_TAG= " << Marker_Tag << endl;
467- node_file << " NROW=" << numberOfRowsInProfile[iMarkerCounter ] << endl;
505+ node_file << " NROW=" << numberOfRowsInProfile[iMarker ] << endl;
468506 node_file << " NCOL=" << nColumns << endl;
469507
508+
470509 /* --- header line (names of the columns) --- */
471- node_file << columnNames[iMarkerCounter ] << endl;
510+ node_file << totalColumnNames[iMarker ] << endl;
472511
473512 node_file << setprecision (15 );
474513 node_file << std::scientific;
475514
476515 /* --- Loop over the data structure and write the coords and vars. ---*/
477516
478- for (unsigned long iPoint = 0 ; iPoint < numberOfRowsInProfile[iMarkerCounter]; iPoint++) {
479-
517+ for (unsigned long iPoint = 0 ; iPoint < numberOfRowsInProfile[iMarker]; iPoint++) {
480518 for (unsigned short iDim = 0 ; iDim < dimension; iDim++) {
481- node_file << profileCoords[iMarkerCounter ][iDim][iPoint] << " \t " ;
519+ node_file << profileCoords[iMarker ][iDim][iPoint] << " \t " ;
482520 }
483521
484- node_file << columnValues[iMarkerCounter ] << endl;
522+ node_file << totalColumnValues[iMarker ] << endl;
485523
486524 }
487525
488- iMarkerCounter++;
489- }
526+
490527 } // iMarker
491528 node_file.close ();
492529
0 commit comments