Skip to content
Open
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
12 changes: 6 additions & 6 deletions Code/Source/linear_solver/bicgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void bicgsv (fsi_linear_solver::FSILS_lhsType& lhs, fsi_linear_solver::FSILS_sub
S(dof,nNo), T(dof,nNo);

ls.callD = fsi_linear_solver::fsils_cpu_t();
ls.suc = false;
ls.success = false;
double err = norm::fsi_ls_normv(dof, mynNo, lhs.commu, R);
double errO = err;
ls.iNorm = err;
Expand All @@ -67,8 +67,8 @@ void bicgsv (fsi_linear_solver::FSILS_lhsType& lhs, fsi_linear_solver::FSILS_sub
dmsg << "err: " << err;
dmsg << "eps: " << eps;
#endif
if (err < eps) {
ls.suc = true;
if (err < eps) {
ls.success = true;
break;
}

Expand Down Expand Up @@ -142,7 +142,7 @@ void bicgss(fsi_linear_solver::FSILS_lhsType& lhs, fsi_linear_solver::FSILS_subL
Vector<double> P(nNo), Rh(nNo), X(nNo), V(nNo), S(nNo), T(nNo);

ls.callD = fsi_linear_solver::fsils_cpu_t();
ls.suc = false;
ls.success = false;
double err = norm::fsi_ls_norms(mynNo, lhs.commu, R);
double errO = err;
ls.iNorm = err;
Expand All @@ -166,8 +166,8 @@ void bicgss(fsi_linear_solver::FSILS_lhsType& lhs, fsi_linear_solver::FSILS_subL
dmsg << "err: " << err;
dmsg << "eps: " << eps;
#endif
if (err < eps) {
ls.suc = true;
if (err < eps) {
ls.success = true;
break;
}

Expand Down
12 changes: 6 additions & 6 deletions Code/Source/linear_solver/cgrad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void schur(FSILS_lhsType& lhs, FSILS_subLsType& ls, const int dof, const Array<d
Array<double> GP(dof,nNo), unCondU(dof,nNo);

double time = fsi_linear_solver::fsils_cpu_t();
ls.suc = false;
ls.success = false;
ls.iNorm = norm::fsi_ls_norms(mynNo, lhs.commu, R);
double eps = pow(std::max(ls.absTol,ls.relTol*ls.iNorm),2.0);
double errO = ls.iNorm*ls.iNorm;
Expand Down Expand Up @@ -64,7 +64,7 @@ void schur(FSILS_lhsType& lhs, FSILS_subLsType& ls, const int dof, const Array<d
last_i = i;

if (err < eps) {
ls.suc = true;
ls.success = true;
break;
}

Expand Down Expand Up @@ -156,7 +156,7 @@ void cgrad_v(FSILS_lhsType& lhs, FSILS_subLsType& ls, const int dof, const Array
Array<double> P(dof,nNo), KP(dof,nNo), X(dof,nNo);

ls.callD = fsi_linear_solver::fsils_cpu_t();
ls.suc = false;
ls.success = false;
ls.iNorm = norm::fsi_ls_normv(dof, mynNo, lhs.commu, R);
double eps = pow(std::max(ls.absTol, ls.relTol* ls.iNorm), 2.0);

Expand All @@ -181,7 +181,7 @@ void cgrad_v(FSILS_lhsType& lhs, FSILS_subLsType& ls, const int dof, const Array
last_i = i;

if (err < eps) {
ls.suc = true;
ls.success = true;
break;
}

Expand Down Expand Up @@ -242,7 +242,7 @@ void cgrad_s(FSILS_lhsType& lhs, FSILS_subLsType& ls, const Vector<double>& K, V
Vector<double> P(nNo), KP(nNo), X(nNo);

ls.callD = fsi_linear_solver::fsils_cpu_t();
ls.suc = false;
ls.success = false;
ls.iNorm = norm::fsi_ls_norms(mynNo, lhs.commu, R);
double eps = pow(std::max(ls.absTol, ls.relTol* ls.iNorm), 2.0);
double errO = ls.iNorm * ls.iNorm;
Expand All @@ -266,7 +266,7 @@ void cgrad_s(FSILS_lhsType& lhs, FSILS_subLsType& ls, const Vector<double>& K, V
last_i = i;

if (err < eps) {
ls.suc = true;
ls.success = true;
break;
}

Expand Down
4 changes: 1 addition & 3 deletions Code/Source/linear_solver/fils_struct.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,7 @@ class FSILS_subLsType
{
public:
/// Successful solving (OUT)
bool suc;

//int suc; // Successful solving (OUT)
bool success;

/// Maximum iteration (IN)
int mItr;
Expand Down
22 changes: 12 additions & 10 deletions Code/Source/linear_solver/gmres.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ void gmres(fsi_linear_solver::FSILS_lhsType& lhs, fsi_linear_solver::FSILS_subLs
Array<double> unCondU(dof,nNo);
Vector<double> y(ls.sD), c(ls.sD), s(ls.sD), err(ls.sD+1);

double time = fsi_linear_solver::fsils_cpu_t();
ls.suc = false;
double time = fsi_linear_solver::fsils_cpu_t();
ls.success = false;
double eps = 0.0;
int last_i = 0;
X = 0.0;
Expand Down Expand Up @@ -210,7 +210,7 @@ void gmres(fsi_linear_solver::FSILS_lhsType& lhs, fsi_linear_solver::FSILS_subLs
#endif

if (fabs(err(i+1)) < eps) {
ls.suc = true;
ls.success = true;
break;
}
} // for int i = 0; i < ls.sD
Expand All @@ -235,7 +235,7 @@ void gmres(fsi_linear_solver::FSILS_lhsType& lhs, fsi_linear_solver::FSILS_subLs
}

ls.fNorm = fabs(err(last_i+1));
if (ls.suc) {
if (ls.success) {
break;
}

Expand Down Expand Up @@ -283,7 +283,7 @@ void gmres_s(fsi_linear_solver::FSILS_lhsType& lhs, fsi_linear_solver::FSILS_sub
Vector<double> X(nNo), y(ls.sD), c(ls.sD), s(ls.sD), err(ls.sD+1);

ls.callD = fsi_linear_solver::fsils_cpu_t();
ls.suc = false;
ls.success = false;
double eps = norm::fsi_ls_norms(mynNo, lhs.commu, R);
ls.iNorm = eps;
ls.fNorm = eps;
Expand All @@ -298,6 +298,7 @@ void gmres_s(fsi_linear_solver::FSILS_lhsType& lhs, fsi_linear_solver::FSILS_sub
if (ls.iNorm <= ls.absTol) {
ls.callD = std::numeric_limits<double>::epsilon();
ls.dB = 0.0;
ls.success = true;
return;
}

Expand Down Expand Up @@ -375,7 +376,7 @@ void gmres_s(fsi_linear_solver::FSILS_lhsType& lhs, fsi_linear_solver::FSILS_sub
#endif

if (fabs(err(i+1)) < eps) {
ls.suc = true;
ls.success = true;
break;
}
} // for int i = 0; i < ls.sD
Expand All @@ -400,7 +401,7 @@ void gmres_s(fsi_linear_solver::FSILS_lhsType& lhs, fsi_linear_solver::FSILS_sub
}

ls.fNorm = fabs(err(last_i+1));
if (ls.suc) {
if (ls.success) {
break;
}
}
Expand Down Expand Up @@ -452,7 +453,7 @@ void gmres_v(fsi_linear_solver::FSILS_lhsType& lhs, fsi_linear_solver::FSILS_sub
Vector<double> y(ls.sD), c(ls.sD), s(ls.sD), err(ls.sD+1);

ls.callD = fsi_linear_solver::fsils_cpu_t();
ls.suc = false;
ls.success = false;
double eps = norm::fsi_ls_normv(dof, mynNo, lhs.commu, R);
ls.iNorm = eps;
ls.fNorm = eps;
Expand All @@ -469,6 +470,7 @@ void gmres_v(fsi_linear_solver::FSILS_lhsType& lhs, fsi_linear_solver::FSILS_sub
if (ls.iNorm <= ls.absTol) {
ls.callD = std::numeric_limits<double>::epsilon();
ls.dB = 0.0;
ls.success = true;
return;
}

Expand Down Expand Up @@ -565,7 +567,7 @@ void gmres_v(fsi_linear_solver::FSILS_lhsType& lhs, fsi_linear_solver::FSILS_sub
#endif

if (fabs(err(i+1)) < eps) {
ls.suc = true;
ls.success = true;
break;
}
} // for int i = 0; i < ls.sD
Expand All @@ -590,7 +592,7 @@ void gmres_v(fsi_linear_solver::FSILS_lhsType& lhs, fsi_linear_solver::FSILS_sub
}

ls.fNorm = fabs(err(last_i+1));
if (ls.suc) {
if (ls.success) {
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Code/Source/linear_solver/ns_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void ns_solver(fsi_linear_solver::FSILS_lhsType& lhs, fsi_linear_solver::FSILS_l

ls.CG.itr = 0;
ls.GM.itr = 0;
ls.RI.suc = false;
ls.RI.success = false;
eps = std::max(ls.RI.absTol, ls.RI.relTol*eps);
#ifdef debug_ns_solver
dmsg << "eps: " << eps;
Expand Down Expand Up @@ -385,7 +385,7 @@ void ns_solver(fsi_linear_solver::FSILS_lhsType& lhs, fsi_linear_solver::FSILS_l
#endif

if (ls.RI.fNorm < eps*eps) {
ls.RI.suc = true;
ls.RI.success = true;
break;
}

Expand Down
14 changes: 7 additions & 7 deletions Code/Source/solver/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ void output_result(Simulation* simulation, std::array<double,3>& timeP, const i

// Add a warning if the solution to the linear system did not converge.
std::string convergence_msg;
if (eq.FSILS.RI.suc) {
c1 = "[";
c2 = "]";
if (eq.FSILS.RI.success) {
c1 = "[";
c2 = "]";
} else {
c1 = "!";
c2 = "!";
convergence_msg = " WARNING: The linear system solution has not converged";
c1 = "!";
c2 = "!";
convergence_msg = " WARNING: The linear system solution has not converged";
}

// NS 1-2 3.82E1 [ -62 7.92E-4 7.92E-4 3.60E-4] [ 5 -15 23]
Expand All @@ -147,7 +147,7 @@ void output_result(Simulation* simulation, std::array<double,3>& timeP, const i
if (eq.itr > eq.maxItr) {
auto msg = "[svMultiPhysics] WARNING: The number of nonlinear iterations (" + std::to_string(eq.itr) +
") has exceeded the maximum number set by the value of the Add_equation/Max_iterations parameter in the svMultiPhysics solver input file.";
if (!eq.FSILS.RI.suc) {
if (!eq.FSILS.RI.success) {
msg += " This may be due to the failure of the linear system solution to converge.";
}
msg += "\n";
Expand Down
6 changes: 3 additions & 3 deletions Code/Source/solver/petsc_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1073,8 +1073,8 @@ void PetscLinearAlgebra::PetscImpl::solve(ComMod& com_mod, eqType& lEq, const Ve

petsc_set_values(com_mod.dof, com_mod.cEq, com_mod.R.data(), com_mod.Val.data(), W_.data(), V_.data());

petsc_solve(&lEq.FSILS.RI.fNorm, &lEq.FSILS.RI.iNorm, &lEq.FSILS.RI.dB, &lEq.FSILS.RI.callD,
&lEq.FSILS.RI.suc, &lEq.FSILS.RI.itr, com_mod.R.data(), lEq.FSILS.RI.mItr, com_mod.dof, com_mod.cEq);

petsc_solve(&lEq.FSILS.RI.fNorm, &lEq.FSILS.RI.iNorm, &lEq.FSILS.RI.dB,
&lEq.FSILS.RI.callD, &lEq.FSILS.RI.success, &lEq.FSILS.RI.itr,
com_mod.R.data(), lEq.FSILS.RI.mItr, com_mod.dof, com_mod.cEq);
}

22 changes: 13 additions & 9 deletions Code/Source/solver/trilinos_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1252,9 +1252,11 @@ void TrilinosLinearAlgebra::TrilinosImpl::solve(ComMod& com_mod, eqType& lEq, co
throw std::runtime_error("[TrilinosLinearAlgebra::solve] ERROR: '" + prec_name + "' is not a valid Trilinos preconditioner.");
}

trilinos_global_solve_(trilinos_, Val.data(), R.data(), R_.data(), W_.data(), lEq.FSILS.RI.fNorm,
lEq.FSILS.RI.iNorm, lEq.FSILS.RI.itr, lEq.FSILS.RI.callD, lEq.FSILS.RI.dB, lEq.FSILS.RI.suc,
solver_type, lEq.FSILS.RI.relTol, lEq.FSILS.RI.mItr, lEq.FSILS.RI.sD, prec_type);
trilinos_global_solve_(trilinos_, Val.data(), R.data(), R_.data(), W_.data(),
lEq.FSILS.RI.fNorm, lEq.FSILS.RI.iNorm,
lEq.FSILS.RI.itr, lEq.FSILS.RI.callD, lEq.FSILS.RI.dB,
lEq.FSILS.RI.success, solver_type, lEq.FSILS.RI.relTol,
lEq.FSILS.RI.mItr, lEq.FSILS.RI.sD, prec_type);

for (int a = 0; a < com_mod.tnNo; a++) {
for (int i = 0; i < com_mod.R.nrows(); i++) {
Expand All @@ -1266,7 +1268,7 @@ void TrilinosLinearAlgebra::TrilinosImpl::solve(ComMod& com_mod, eqType& lEq, co
/// @brief Solve a system of linear equations assembled by Trilinos.
void TrilinosLinearAlgebra::TrilinosImpl::solve_assembled(ComMod& com_mod, eqType& lEq, const Vector<int>& incL, const Vector<double>& res)
{
lEq.FSILS.RI.suc = false;
lEq.FSILS.RI.success = false;
int solver_type = static_cast<int>(lEq.ls.LS_type);
int prec_type = static_cast<int>(preconditioner_);
bool assembled = true;
Expand All @@ -1278,7 +1280,8 @@ void TrilinosLinearAlgebra::TrilinosImpl::solve_assembled(ComMod& com_mod, eqTyp
std::cout << "[TrilinosImpl::solve_assembled] prec_type: " << prec_name << std::endl;
std::cout << "[TrilinosImpl::solve_assembled] R_.size(): " << R_.size() << std::endl;
std::cout << "[TrilinosImpl::solve_assembled] W_.size(): " << W_.size() << std::endl;
std::cout << "[TrilinosImpl::solve_assembled] lEq.FSILS.RI.suc: " << lEq.FSILS.RI.suc << std::endl;
std::cout << "[TrilinosImpl::solve_assembled] lEq.FSILS.RI.success: "
<< lEq.FSILS.RI.success << std::endl;
#endif

if (consts::trilinos_preconditioners.count(preconditioner_) == 0) {
Expand All @@ -1288,10 +1291,11 @@ void TrilinosLinearAlgebra::TrilinosImpl::solve_assembled(ComMod& com_mod, eqTyp

init_dir_and_coup_neu(com_mod, incL, res);

trilinos_solve_(trilinos_, R_.data(), W_.data(), lEq.FSILS.RI.fNorm, lEq.FSILS.RI.iNorm,
lEq.FSILS.RI.itr, lEq.FSILS.RI.callD, lEq.FSILS.RI.dB, lEq.FSILS.RI.suc,
solver_type, lEq.FSILS.RI.relTol, lEq.FSILS.RI.mItr, lEq.FSILS.RI.sD,
prec_type, assembled);
trilinos_solve_(trilinos_, R_.data(), W_.data(), lEq.FSILS.RI.fNorm,
lEq.FSILS.RI.iNorm, lEq.FSILS.RI.itr, lEq.FSILS.RI.callD,
lEq.FSILS.RI.dB, lEq.FSILS.RI.success, solver_type,
lEq.FSILS.RI.relTol, lEq.FSILS.RI.mItr, lEq.FSILS.RI.sD,
prec_type, assembled);

for (int a = 0; a < com_mod.tnNo; a++) {
for (int i = 0; i < com_mod.R.nrows(); i++) {
Expand Down
Loading