Skip to content

Commit 9e7dc31

Browse files
authored
Merge branch 'develop' into feature_NEMO_newton
2 parents c2e6445 + 2ce680a commit 9e7dc31

10 files changed

Lines changed: 288 additions & 276 deletions

File tree

.github/workflows/release-management.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- os_bin: macos64-mpi
2424
flags: '-Dcustom-mpi=true --cross-file=/hostfiles/hostfile_darwin_mpi'
2525
- os_bin: linux64
26-
flags: '-Dwith-mpi=disabled --cross-file=/hostfiles/hostfile_linux'
26+
flags: '-Dwith-mpi=disabled -Dstatic-cgns-deps=true --cross-file=/hostfiles/hostfile_linux'
2727
- os_bin: linux64-mpi
2828
flags: '-Dcustom-mpi=true --cross-file=/hostfiles/hostfile_linux_mpi'
2929
runs-on: ubuntu-latest

Common/src/geometry/CGeometry.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3510,14 +3510,16 @@ void CGeometry::SetRotationalVelocity(const CConfig *config, bool print) {
35103510
unsigned long iPoint;
35113511
unsigned short iDim;
35123512

3513-
su2double RotVel[3] = {0.0,0.0,0.0}, Distance[3] = {0.0,0.0,0.0},
3514-
Center[3] = {0.0,0.0,0.0}, Omega[3] = {0.0,0.0,0.0};
3513+
su2double GridVel[3] = {0.0,0.0,0.0}, Distance[3] = {0.0,0.0,0.0},
3514+
Center[3] = {0.0,0.0,0.0}, Omega[3] = {0.0,0.0,0.0},
3515+
xDot[3] = {0.0,0.0,0.0};
35153516

35163517
/*--- Center of rotation & angular velocity vector from config ---*/
35173518

35183519
for (iDim = 0; iDim < 3; iDim++) {
35193520
Center[iDim] = config->GetMotion_Origin(iDim);
35203521
Omega[iDim] = config->GetRotation_Rate(iDim)/config->GetOmega_Ref();
3522+
xDot[iDim] = config->GetTranslation_Rate(iDim)/config->GetVelocity_Ref();
35213523
}
35223524

35233525
su2double L_Ref = config->GetLength_Ref();
@@ -3529,9 +3531,11 @@ void CGeometry::SetRotationalVelocity(const CConfig *config, bool print) {
35293531
cout << ", " << Center[2] << " )\n";
35303532
cout << " Angular velocity about x, y, z axes: ( " << Omega[0] << ", ";
35313533
cout << Omega[1] << ", " << Omega[2] << " ) rad/s" << endl;
3534+
cout << " Translational velocity in x, y, z direction: ("
3535+
<< xDot[0] << ", " << xDot[1] << ", " << xDot[2] << ")." << endl;
35323536
}
35333537

3534-
/*--- Loop over all nodes and set the rotational velocity ---*/
3538+
/*--- Loop over all nodes and set the rotational and translational velocity ---*/
35353539

35363540
for (iPoint = 0; iPoint < nPoint; iPoint++) {
35373541

@@ -3544,15 +3548,15 @@ void CGeometry::SetRotationalVelocity(const CConfig *config, bool print) {
35443548
for (iDim = 0; iDim < nDim; iDim++)
35453549
Distance[iDim] = (Coord[iDim]-Center[iDim])/L_Ref;
35463550

3547-
/*--- Calculate the angular velocity as omega X r ---*/
3551+
/*--- Calculate the angular velocity as omega X r and add translational velocity ---*/
35483552

3549-
RotVel[0] = Omega[1]*(Distance[2]) - Omega[2]*(Distance[1]);
3550-
RotVel[1] = Omega[2]*(Distance[0]) - Omega[0]*(Distance[2]);
3551-
RotVel[2] = Omega[0]*(Distance[1]) - Omega[1]*(Distance[0]);
3553+
GridVel[0] = Omega[1]*(Distance[2]) - Omega[2]*(Distance[1]) + xDot[0];
3554+
GridVel[1] = Omega[2]*(Distance[0]) - Omega[0]*(Distance[2]) + xDot[1];
3555+
GridVel[2] = Omega[0]*(Distance[1]) - Omega[1]*(Distance[0]) + xDot[2];
35523556

35533557
/*--- Store the grid velocity at this node ---*/
35543558

3555-
nodes->SetGridVel(iPoint, RotVel);
3559+
nodes->SetGridVel(iPoint, GridVel);
35563560

35573561
}
35583562

SU2_CFD/src/output/COutput.cpp

Lines changed: 53 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -924,16 +924,16 @@ bool COutput::GetCauchyCorrectedTimeConvergence(const CConfig *config){
924924
}
925925

926926
bool COutput::SetResult_Files(CGeometry *geometry, CConfig *config, CSolver** solver_container,
927-
unsigned long iter, bool force_writing){
927+
unsigned long iter, bool force_writing) {
928928

929-
bool isFileWrite=false;
930-
unsigned short nVolumeFiles = config->GetnVolumeOutputFiles();
931-
auto VolumeFiles = config->GetVolumeOutputFiles();
929+
bool isFileWrite = false;
930+
const auto nVolumeFiles = config->GetnVolumeOutputFiles();
931+
const auto* VolumeFiles = config->GetVolumeOutputFiles();
932932

933933
/*--- Check if the data sorters are allocated, if not, allocate them. --- */
934934
AllocateDataSorters(config, geometry);
935935

936-
for (unsigned short iFile = 0; iFile < nVolumeFiles; iFile++){
936+
for (unsigned short iFile = 0; iFile < nVolumeFiles; iFile++) {
937937

938938
/*--- Collect the volume data from the solvers.
939939
* If time-domain is enabled, we also load the data although we don't output it,
@@ -947,7 +947,7 @@ bool COutput::SetResult_Files(CGeometry *geometry, CConfig *config, CSolver** so
947947

948948
volumeDataSorter->SortOutputData();
949949

950-
if (rank == MASTER_NODE && !isFileWrite){
950+
if (rank == MASTER_NODE && !isFileWrite) {
951951
fileWritingTable->SetAlign(PrintingToolbox::CTablePrinter::CENTER);
952952
fileWritingTable->PrintHeader();
953953
fileWritingTable->SetAlign(PrintingToolbox::CTablePrinter::LEFT);
@@ -958,18 +958,18 @@ bool COutput::SetResult_Files(CGeometry *geometry, CConfig *config, CSolver** so
958958

959959
WriteToFile(config, geometry, VolumeFiles[iFile]);
960960

961-
if (rank == MASTER_NODE && !isFileWrite){
962-
fileWritingTable->PrintFooter();
963-
headerNeeded = true;
964-
}
965-
966961
/*--- Write any additonal files defined in the child class ----*/
967962

968963
WriteAdditionalFiles(config, geometry, solver_container);
969964

970965
isFileWrite = true;
971966
}
972967

968+
if (rank == MASTER_NODE && isFileWrite) {
969+
fileWritingTable->PrintFooter();
970+
headerNeeded = true;
971+
}
972+
973973
return isFileWrite;
974974
}
975975

@@ -1006,90 +1006,83 @@ void COutput::PrintConvergenceSummary(){
10061006

10071007
bool COutput::Convergence_Monitoring(CConfig *config, unsigned long Iteration) {
10081008

1009-
unsigned short iCounter;
1010-
10111009
convergence = true;
10121010

1013-
for (unsigned short iField_Conv = 0; iField_Conv < convFields.size(); iField_Conv++){
1011+
for (auto iField_Conv = 0ul; iField_Conv < convFields.size(); iField_Conv++) {
10141012

1015-
bool fieldConverged = false;
1013+
const auto& convField = convFields[iField_Conv];
1014+
const auto it = historyOutput_Map.find(convField);
10161015

1017-
const string &convField = convFields[iField_Conv];
1018-
if (historyOutput_Map.count(convField) > 0){
1019-
su2double monitor = historyOutput_Map.at(convField).value;
1016+
if (it == historyOutput_Map.end()) continue;
10201017

1021-
/*--- Stop the simulation in case a nan appears, do not save the solution ---*/
1022-
if (std::isnan(SU2_TYPE::GetValue(monitor))) {
1023-
SU2_MPI::Error("SU2 has diverged (NaN detected).", CURRENT_FUNCTION);
1024-
}
1018+
const auto& field = it->second;
1019+
const su2double monitor = field.value;
10251020

1026-
/*--- Cauchy based convergence criteria ---*/
1021+
/*--- Stop the simulation in case a nan appears, do not save the solution. ---*/
1022+
if (std::isnan(SU2_TYPE::GetValue(monitor))) {
1023+
SU2_MPI::Error("SU2 has diverged (NaN detected).", CURRENT_FUNCTION);
1024+
}
10271025

1028-
if (historyOutput_Map.at(convField).fieldType == HistoryFieldType::COEFFICIENT) {
1026+
bool fieldConverged = false;
1027+
1028+
switch (field.fieldType) {
1029+
1030+
/*--- Cauchy based convergence criteria ---*/
1031+
case HistoryFieldType::COEFFICIENT: {
10291032

1030-
if (Iteration == 0){
1031-
for (iCounter = 0; iCounter < nCauchy_Elems; iCounter++){
1033+
if (Iteration == 0) {
1034+
for (auto iCounter = 0ul; iCounter < nCauchy_Elems; iCounter++) {
10321035
cauchySerie[iField_Conv][iCounter] = 0.0;
10331036
}
10341037
newFunc[iField_Conv] = monitor;
10351038
}
10361039

10371040
oldFunc[iField_Conv] = newFunc[iField_Conv];
10381041
newFunc[iField_Conv] = monitor;
1039-
cauchyFunc = fabs(newFunc[iField_Conv] - oldFunc[iField_Conv])/fabs(monitor);
1042+
/*--- Automatically modify the scaling factor of relative Cauchy convergence for
1043+
* coefficients that are close to zero. Example: For the clean aircraft, the rolling
1044+
* moment coefficient MOMENT_X is close to zero and thus will never reach a relative
1045+
* cauchy convergence ->> dividing tiny numbers is not a good idea. Using absolute
1046+
* cauchy convergence is more robust in this case. ---*/
1047+
cauchyFunc = fabs(newFunc[iField_Conv] - oldFunc[iField_Conv]) / fmax(fabs(monitor), 0.1);
10401048

10411049
cauchySerie[iField_Conv][Iteration % nCauchy_Elems] = cauchyFunc;
10421050
cauchyValue = 0.0;
1043-
for (iCounter = 0; iCounter < nCauchy_Elems; iCounter++)
1051+
for (auto iCounter = 0ul; iCounter < nCauchy_Elems; iCounter++)
10441052
cauchyValue += cauchySerie[iField_Conv][iCounter];
10451053

10461054
cauchyValue /= nCauchy_Elems;
10471055

1048-
if (cauchyValue >= cauchyEps) { fieldConverged = false;}
1049-
else { fieldConverged = true;}
1050-
10511056
/*--- Start monitoring only if the current iteration
1052-
* is larger than the number of cauchy elements and
1053-
* the number of start-up iterations --- */
1054-
1055-
if (Iteration < max(config->GetStartConv_Iter(), nCauchy_Elems)){
1056-
fieldConverged = false;
1057-
}
1057+
* is larger than the number of cauchy elements. --- */
1058+
fieldConverged = (cauchyValue < cauchyEps) && (Iteration >= nCauchy_Elems);
10581059

1060+
if (Iteration == 0) cauchyValue = 1.0;
10591061
SetHistoryOutputValue("CAUCHY_" + convField, cauchyValue);
10601062

1061-
if(Iteration == 0){
1062-
SetHistoryOutputValue("CAUCHY_" + convField, 1.0);
1063-
}
1064-
}
1063+
} break;
10651064

10661065

10671066
/*--- Residual based convergence criteria ---*/
1067+
case HistoryFieldType::RESIDUAL:
1068+
case HistoryFieldType::AUTO_RESIDUAL:
10681069

1069-
if (historyOutput_Map.at(convField).fieldType == HistoryFieldType::RESIDUAL ||
1070-
historyOutput_Map.at(convField).fieldType == HistoryFieldType::AUTO_RESIDUAL) {
1071-
1072-
/*--- Check the convergence ---*/
1073-
1074-
if (Iteration != 0 && (monitor <= minLogResidual)) { fieldConverged = true; }
1075-
else { fieldConverged = false; }
1076-
1077-
}
1078-
1079-
/*--- Do not apply any convergence criteria of the number
1080-
of iterations is less than a particular value ---*/
1081-
1082-
if (Iteration < config->GetStartConv_Iter()) {
1083-
fieldConverged = false;
1084-
}
1070+
fieldConverged = (Iteration != 0) && (monitor <= minLogResidual);
1071+
break;
10851072

1086-
convergence = fieldConverged && convergence;
1073+
default:
1074+
break;
10871075
}
1076+
1077+
convergence = fieldConverged && convergence;
10881078
}
10891079

1090-
if (convFields.empty()) convergence = false;
1080+
/*--- Do not apply any convergence criteria if the number
1081+
* of iterations is less than a particular value. ---*/
1082+
1083+
if (convFields.empty() || Iteration < config->GetStartConv_Iter()) convergence = false;
10911084

1092-
/*--- Apply the same convergence criteria to all the processors ---*/
1085+
/*--- Apply the same convergence criteria to all processors. ---*/
10931086

10941087
unsigned short local = convergence, global = 0;
10951088
SU2_MPI::Allreduce(&local, &global, 1, MPI_UNSIGNED_SHORT, MPI_MAX, SU2_MPI::GetComm());

TestCases/py_wrapper/translating_NACA0012/config.cfg

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ RESTART_SOL= NO
88
% FREE-STREAM DEFINITION
99
%
1010
% We are translating the domain instead of having farfield velocity.
11-
GRID_MOVEMENT= STEADY_TRANSLATION
12-
MOTION_ORIGIN= ( 0.0, 0.0, 0.0 )
13-
TRANSLATION_RATE= ( -264.994, -5.78219, 0.0 )
11+
% Note: The rotating frame is intended for 3D cases. To use the feature in a 2D case,
12+
% care must be taken with respect to the axes, e.g. to obtain a pitching motion, a
13+
% rotation about the z-axis can be used.
14+
GRID_MOVEMENT= ROTATING_FRAME
15+
MOTION_ORIGIN= 0.0, 0.0, 0.0
16+
ROTATION_RATE= 0.0, 0.0, 0.5
17+
TRANSLATION_RATE= -264.994, -5.78219, 0.0
1418
MACH_NUMBER= 0.0
1519
FREESTREAM_PRESSURE= 101325.0
1620
FREESTREAM_TEMPERATURE= 273.15
@@ -68,6 +72,6 @@ CONV_RESIDUAL_MINVAL= -9
6872
%
6973
MESH_FILENAME= ../../euler/naca0012/mesh_NACA0012_inv.su2
7074
MESH_FORMAT= SU2
71-
SCREEN_OUTPUT= (INNER_ITER, RMS_RES, LIFT, DRAG)
75+
SCREEN_OUTPUT= (INNER_ITER, RMS_RES, LIFT, DRAG, MOMENT_X, MOMENT_Y, MOMENT_Z)
7276
HISTORY_OUTPUT= (INNER_ITER, RMS_RES, AERO_COEFF)
7377

0 commit comments

Comments
 (0)