Skip to content

Commit 9effc40

Browse files
committed
Merge branch 'develop' into feature_clang-tidy
2 parents e303ace + 0829072 commit 9effc40

3 files changed

Lines changed: 69 additions & 30 deletions

File tree

Common/include/option_structure.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const unsigned int EXIT_DIVERGENCE = 2; /*!< \brief Exit code (divergence). */
7474

7575
const unsigned int MAX_PARAMETERS = 10; /*!< \brief Maximum number of parameters for a design variable definition. */
7676
const unsigned int MAX_NUMBER_PERIODIC = 10; /*!< \brief Maximum number of periodic boundary conditions. */
77-
const unsigned int MAX_STRING_SIZE = 200; /*!< \brief Maximum number of domains. */
77+
const unsigned int MAX_STRING_SIZE = 400; /*!< \brief Maximum size of a generic string. */
7878
const unsigned int MAX_NUMBER_FFD = 15; /*!< \brief Maximum number of FFDBoxes for the FFD. */
7979
enum: unsigned int{MAX_SOLS = 13}; /*!< \brief Maximum number of solutions at the same time (dimension of solution container array). */
8080
const unsigned int MAX_TERMS = 7; /*!< \brief Maximum number of terms in the numerical equations (dimension of solver container array). */

SU2_CFD/include/CMarkerProfileReaderFVM.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ class CMarkerProfileReaderFVM {
7171

7272
vector<unsigned long> numberOfRowsInProfile; /*!< \brief Auxiliary structure for holding the number of rows for a particular marker in a profile file. */
7373
vector<unsigned long> numberOfColumnsInProfile; /*!< \brief Auxiliary structure for holding the number of columns for a particular marker in a profile file. */
74+
vector<string> totalColumnNames; /*!< \brief Names of the columns for the profile, one for each inlet marker. */
75+
vector<string> totalColumnValues; /*!< \brief Initial values for the profile, constructed from MARKER_INLET. */
7476

7577
vector<vector<passivedouble> > profileData; /*!< \brief Auxiliary structure for holding the data values from a profile file. */
7678
vector<vector<vector<su2double> > > profileCoords; /*!< \brief Data structure for holding the merged inlet boundary coordinates from all ranks. */

SU2_CFD/src/CMarkerProfileReaderFVM.cpp

Lines changed: 66 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -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

438480
void 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

Comments
 (0)