Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Common/include/linear_algebra/CSysSolve.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ class CSysSolve {
mutable VectorType p; /*!< \brief Direction in CG and BCGSTAB. */
mutable VectorType z; /*!< \brief Preconditioned residual/direction in CG/BCGSTAB. */

mutable VectorType r_0; /*!< \brief The "arbitrary" vector in BCGSTAB. */
mutable VectorType v; /*!< \brief BCGSTAB "v" vector (v = A * M^-1 * p). */
mutable VectorType r_0; /*!< \brief The "arbitrary" vector in BCGSTAB. */
mutable VectorType v; /*!< \brief BCGSTAB "v" vector (v = A * M^-1 * p). */
mutable VectorType x_best; /*!< \brief BCGSTAB iterate with the smallest residual. */

mutable bool ritz_failed = false;
mutable unsigned long k = 0, k_new = 0;
Expand Down
14 changes: 14 additions & 0 deletions Common/src/linear_algebra/CSysSolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,7 @@ unsigned long CSysSolve<ScalarType>::BCGSTAB_LinSolver(const CSysVector<ScalarTy
p.Initialize(nBlk, nBlkDomain, nVar, nullptr);
v.Initialize(nBlk, nBlkDomain, nVar, nullptr);
z.Initialize(nBlk, nBlkDomain, nVar, nullptr);
if (config->GetComm_Level() == COMM_FULL) x_best.Initialize(nBlk, nBlkDomain, nVar, nullptr);

bcg_ready = true;
}
Expand Down Expand Up @@ -1135,6 +1136,8 @@ unsigned long CSysSolve<ScalarType>::BCGSTAB_LinSolver(const CSysVector<ScalarTy
/*--- Initialization ---*/

ScalarType alpha = 1.0, omega = 1.0, rho = 1.0, rho_prime = 1.0;
ScalarType norm_best = norm_r;
if (config->GetComm_Level() == COMM_FULL) x_best = x;
p = ScalarType(0.0);
v = ScalarType(0.0);
r_0 = r;
Expand Down Expand Up @@ -1195,6 +1198,10 @@ unsigned long CSysSolve<ScalarType>::BCGSTAB_LinSolver(const CSysVector<ScalarTy
/*--- Check if solution has converged, else output the relative residual if necessary ---*/

norm_r = r.norm();
if (norm_r < norm_best) {
norm_best = norm_r;
x_best = x;
}
if (norm_r < tol * norm0) break;
if (((monitoring) && (masterRank)) && ((i + 1) % monitorFreq == 0)) {
SU2_OMP_MASTER
Expand All @@ -1204,6 +1211,13 @@ unsigned long CSysSolve<ScalarType>::BCGSTAB_LinSolver(const CSysVector<ScalarTy
}
}

/*--- BCGSTAB does not reduce the residual monotonically, return the best iterate. ---*/

if ((config->GetComm_Level() == COMM_FULL) && (norm_r > norm_best)) {
x = x_best;
norm_r = norm_best;
}

/*--- Recalculate final residual (this should be optional) ---*/

if ((monitoring) && (config->GetComm_Level() == COMM_FULL)) {
Expand Down
6 changes: 3 additions & 3 deletions TestCases/hybrid_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def main():
wedge.cfg_dir = "euler/wedge"
wedge.cfg_file = "inv_wedge_HLLC.cfg"
wedge.test_iter = 20
wedge.test_vals = [-0.480786, 5.329367, -0.244869, 0.043126]
wedge.test_vals = [ 0.036140, 6.976887, -0.219795, 0.055341]
test_list.append(wedge)

# ONERA M6 Wing
Expand Down Expand Up @@ -170,7 +170,7 @@ def main():
rae2822_sa.cfg_dir = "rans/rae2822"
rae2822_sa.cfg_file = "turb_SA_RAE2822.cfg"
rae2822_sa.test_iter = 20
rae2822_sa.test_vals = [-2.639525, -4.027096, 0.792680, 0.020549, 1000.000000]
rae2822_sa.test_vals = [-2.913915, -5.160924, 0.801922, 0.019587, 1000.000000]
test_list.append(rae2822_sa)

# RAE2822 SST
Expand Down Expand Up @@ -452,7 +452,7 @@ def main():
inc_turb_naca0012.cfg_dir = "incomp_rans/naca0012"
inc_turb_naca0012.cfg_file = "naca0012.cfg"
inc_turb_naca0012.test_iter = 20
inc_turb_naca0012.test_vals = [-4.758114, -10.974548, -0.000004, -0.028637, 5.000000, -4.081478, 2.000000, -4.490126]
inc_turb_naca0012.test_vals = [-4.758114, -10.974548, -0.000006, -0.028637, 4.000000, -4.016988, 2.000000, -4.487046]
test_list.append(inc_turb_naca0012)

# NACA0012, SST_SUST
Expand Down
16 changes: 8 additions & 8 deletions TestCases/parallel_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def main():
invwedge_roe.cfg_dir = "nonequilibrium/invwedge"
invwedge_roe.cfg_file = "invwedge_roe.cfg"
invwedge_roe.test_iter = 10
invwedge_roe.test_vals = [-1.158437, -1.683200, -17.734417, -18.064156, -18.007526, 2.157771, 1.789407, 5.196450, 0.767270]
invwedge_roe.test_vals = [-0.856717, -1.381479, -16.733080, -17.063919, -17.006196, 2.492274, 1.625077, 5.504576, 1.052309]
invwedge_roe.test_vals_aarch64 = [-1.156325, -1.681088, -17.726749, -18.056513, -17.999860, 2.159488, 1.793498, 5.198638, 0.769831]
test_list.append(invwedge_roe)

Expand Down Expand Up @@ -463,7 +463,7 @@ def main():
rae2822_sa.cfg_dir = "rans/rae2822"
rae2822_sa.cfg_file = "turb_SA_RAE2822.cfg"
rae2822_sa.test_iter = 20
rae2822_sa.test_vals = [-2.888183, -5.136146, 0.788144, 0.019032, 1000.000000]
rae2822_sa.test_vals = [-3.032297, -5.144001, 0.789972, 0.019664, 1000.000000]
test_list.append(rae2822_sa)

# RAE2822 SST
Expand Down Expand Up @@ -949,15 +949,15 @@ def main():
turbmod_sa_bsl_rae2822.cfg_dir = "turbulence_models/sa/rae2822"
turbmod_sa_bsl_rae2822.cfg_file = "turb_SA_BSL_RAE2822.cfg"
turbmod_sa_bsl_rae2822.test_iter = 20
turbmod_sa_bsl_rae2822.test_vals = [-3.182935, -0.447793, -0.875861, -3.286652, 0.769925, 0.017709]
turbmod_sa_bsl_rae2822.test_vals = [-3.066175, -0.410328, -0.836186, -5.131450, 0.790218, 0.018113]
test_list.append(turbmod_sa_bsl_rae2822)

# SA Negative
turbmod_sa_neg_rae2822 = TestCase('turbmod_sa_neg_rae2822')
turbmod_sa_neg_rae2822.cfg_dir = "turbulence_models/sa/rae2822"
turbmod_sa_neg_rae2822.cfg_file = "turb_SA_NEG_RAE2822.cfg"
turbmod_sa_neg_rae2822.test_iter = 10
turbmod_sa_neg_rae2822.test_vals = [1.570952, 1.355242, -0.869320, 1.244343, 0.452923, 0.000000]
turbmod_sa_neg_rae2822.test_vals = [1.462498, 1.294317, -1.866969, 1.240402, 0.461990, 0.000000]
turbmod_sa_neg_rae2822.test_vals_aarch64 = [-1.345593, 1.448310, 1.208721, -0.846597, 1.248410, 0.489117, 0.000000]
test_list.append(turbmod_sa_neg_rae2822)

Expand All @@ -966,31 +966,31 @@ def main():
turbmod_sa_comp_rae2822.cfg_dir = "turbulence_models/sa/rae2822"
turbmod_sa_comp_rae2822.cfg_file = "turb_SA_COMP_RAE2822.cfg"
turbmod_sa_comp_rae2822.test_iter = 20
turbmod_sa_comp_rae2822.test_vals = [-3.192776, -0.471890, -0.893254, -5.190537, 0.777261, 0.017904]
turbmod_sa_comp_rae2822.test_vals = [-3.067270, -0.409333, -0.836419, -5.163006, 0.790775, 0.018091]
test_list.append(turbmod_sa_comp_rae2822)

# SA Edwards
turbmod_sa_edw_rae2822 = TestCase('turbmod_sa_edw_rae2822')
turbmod_sa_edw_rae2822.cfg_dir = "turbulence_models/sa/rae2822"
turbmod_sa_edw_rae2822.cfg_file = "turb_SA_EDW_RAE2822.cfg"
turbmod_sa_edw_rae2822.test_iter = 20
turbmod_sa_edw_rae2822.test_vals = [-3.198033, -0.439446, -0.883563, -3.899428, 0.786167, 0.017883]
turbmod_sa_edw_rae2822.test_vals = [-3.074021, -0.406573, -0.837105, -5.186866, 0.794308, 0.017860]
test_list.append(turbmod_sa_edw_rae2822)

# SA Compressibility and Edwards
turbmod_sa_comp_edw_rae2822 = TestCase('turbmod_sa_comp_edw_rae2822')
turbmod_sa_comp_edw_rae2822.cfg_dir = "turbulence_models/sa/rae2822"
turbmod_sa_comp_edw_rae2822.cfg_file = "turb_SA_COMP_EDW_RAE2822.cfg"
turbmod_sa_comp_edw_rae2822.test_iter = 20
turbmod_sa_comp_edw_rae2822.test_vals = [-2.943295, -0.168387, -0.632480, -5.127730, 0.802507, 0.020196]
turbmod_sa_comp_edw_rae2822.test_vals = [-3.070896, -0.339529, -0.812604, -5.279982, 0.809740, 0.019809]
test_list.append(turbmod_sa_comp_edw_rae2822)

# SA QCR
turbmod_sa_qcr_rae2822 = TestCase('turbmod_sa_qcr_rae2822')
turbmod_sa_qcr_rae2822.cfg_dir = "turbulence_models/sa/rae2822"
turbmod_sa_qcr_rae2822.cfg_file = "turb_SA_QCR_RAE2822.cfg"
turbmod_sa_qcr_rae2822.test_iter = 20
turbmod_sa_qcr_rae2822.test_vals = [-3.056565, -0.419621, -0.805532, -3.857890, 0.760796, 0.016908]
turbmod_sa_qcr_rae2822.test_vals = [-3.030070, -0.419207, -0.799348, -5.089007, 0.761556, 0.016831]
test_list.append(turbmod_sa_qcr_rae2822)

############################
Expand Down
4 changes: 2 additions & 2 deletions TestCases/serial_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def main():
rae2822_sa.cfg_dir = "rans/rae2822"
rae2822_sa.cfg_file = "turb_SA_RAE2822.cfg"
rae2822_sa.test_iter = 20
rae2822_sa.test_vals = [-3.131221, -5.161756, 0.778275, 0.019566, 1000.000000]
rae2822_sa.test_vals = [-3.119066, -5.151318, 0.777084, 0.019422, 1000.000000]
test_list.append(rae2822_sa)

# RAE2822 SST
Expand Down Expand Up @@ -508,7 +508,7 @@ def main():
inc_turb_naca0012.cfg_dir = "incomp_rans/naca0012"
inc_turb_naca0012.cfg_file = "naca0012.cfg"
inc_turb_naca0012.test_iter = 20
inc_turb_naca0012.test_vals = [-4.758064, -10.974498, -0.000003, -0.028654, 4, -6.049653, 2, -4.951206]
inc_turb_naca0012.test_vals = [-4.758064, -10.974498, -0.000003, -0.028654, 3.000000, -4.499423, 2.000000, -4.951202]
test_list.append(inc_turb_naca0012)

# NACA0012, SST_SUST
Expand Down
Loading