mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-12-18 21:43:27 -06:00
Moved ISTL right and left hand side construction for ISTL to solveSystem
cherry-picked from add-scalarproduct and ported.
This commit is contained in:
parent
bdc4573e2a
commit
3115b7868f
@ -154,24 +154,6 @@ namespace Opm
|
||||
A[ri][ja[i]] = sa[i];
|
||||
}
|
||||
}
|
||||
// System RHS
|
||||
Vector b(size);
|
||||
std::copy(rhs, rhs + size, b.begin());
|
||||
// System solution
|
||||
Vector x(size);
|
||||
x = 0.0;
|
||||
|
||||
if (linsolver_save_system_)
|
||||
{
|
||||
// Save system to files.
|
||||
writeMatrixToMatlab(A, linsolver_save_filename_ + "-mat");
|
||||
std::string rhsfile(linsolver_save_filename_ + "-rhs");
|
||||
std::ofstream rhsf(rhsfile.c_str());
|
||||
rhsf.precision(15);
|
||||
rhsf.setf(std::ios::scientific | std::ios::showpos);
|
||||
std::copy(b.begin(), b.end(),
|
||||
std::ostream_iterator<VectorBlockType>(rhsf, "\n"));
|
||||
}
|
||||
|
||||
int maxit = linsolver_max_iterations_;
|
||||
if (maxit == 0) {
|
||||
@ -187,7 +169,7 @@ namespace Opm
|
||||
Dune::OverlappingSchwarzOperator<Mat,Vector,Vector, Comm>
|
||||
opA(A, istlComm);
|
||||
Dune::OverlappingSchwarzScalarProduct<Vector,Comm> sp(istlComm);
|
||||
return solveSystem(opA, x, solution, b, sp, istlComm, maxit);
|
||||
return solveSystem(opA, solution, rhs, sp, istlComm, maxit);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@ -195,15 +177,34 @@ namespace Opm
|
||||
Dune::SeqScalarProduct<Vector> sp;
|
||||
Dune::Amg::SequentialInformation comm;
|
||||
Operator opA(A);
|
||||
return solveSystem(opA, x, solution, b, sp, comm, maxit);
|
||||
return solveSystem(opA, solution, rhs, sp, comm, maxit);
|
||||
}
|
||||
}
|
||||
|
||||
template<class O, class V, class S, class C>
|
||||
template<class O, class S, class C>
|
||||
LinearSolverInterface::LinearSolverReport
|
||||
LinearSolverIstl::solveSystem (O& opA, V& x, double* solution, V& b,
|
||||
LinearSolverIstl::solveSystem (O& opA, double* solution, const double* rhs,
|
||||
S& sp, const C& comm, int maxit) const
|
||||
{
|
||||
// System RHS
|
||||
Vector b(opA.getmat().N());
|
||||
std::copy(rhs, rhs + size, b.begin());
|
||||
// System solution
|
||||
Vector x(opA.getmat().M());
|
||||
x = 0.0;
|
||||
|
||||
if (linsolver_save_system_)
|
||||
{
|
||||
// Save system to files.
|
||||
writeMatrixToMatlab(opA.getmat(), linsolver_save_filename_ + "-mat");
|
||||
std::string rhsfile(linsolver_save_filename_ + "-rhs");
|
||||
std::ofstream rhsf(rhsfile.c_str());
|
||||
rhsf.precision(15);
|
||||
rhsf.setf(std::ios::scientific | std::ios::showpos);
|
||||
std::copy(b.begin(), b.end(),
|
||||
std::ostream_iterator<VectorBlockType>(rhsf, "\n"));
|
||||
}
|
||||
|
||||
LinearSolverReport res;
|
||||
switch (linsolver_type_) {
|
||||
case CG_ILU0:
|
||||
|
@ -88,16 +88,14 @@ namespace Opm
|
||||
private:
|
||||
/// \brief Solve the linear system using ISTL
|
||||
/// \param[in] opA The linear operator of the system to solve.
|
||||
/// \param[in,out] x The vector with the initial guess that will store
|
||||
/// the computed solution
|
||||
/// \param[out] solution C array for storing the solution vector.
|
||||
/// \param[in] b The vector containing the right hand side of the system.
|
||||
/// \param[in] rhs C array containing the right hand side.
|
||||
/// \param[in] sp The scalar product to use.
|
||||
/// \param[in] comm The information about the parallel domain decomposition.
|
||||
/// \param[in] maxit The maximum number of iterations allowed.
|
||||
template<class O, class V, class S, class C>
|
||||
LinearSolverReport solveSystem(O& opA, V& x, double* solution,
|
||||
V& b, S& sp, const C& comm, int maxit) const;
|
||||
template<class O, class S, class C>
|
||||
LinearSolverReport solveSystem(O& opA, double* solution, const double *rhs,
|
||||
S& sp, const C& comm, int maxit) const;
|
||||
|
||||
double linsolver_residual_tolerance_;
|
||||
int linsolver_verbosity_;
|
||||
|
Loading…
Reference in New Issue
Block a user