Skip to content
Snippets Groups Projects
Commit 86c9cdef authored by Christian Engwer's avatar Christian Engwer
Browse files

[solvers] store reduction as a scalar real value

parent d628dfb1
No related branches found
No related tags found
1 merge request!87[multirhstest] Check with AlignedNumber.
......@@ -98,6 +98,9 @@ namespace Dune
//! \brief The real type of the field type (is the same if using real numbers, but differs for std::complex)
typedef typename FieldTraits<field_type>::real_type real_type;
//! \brief scalar type underlying the field_type
typedef SimdScalar<real_type> scalar_real_type;
/**
\brief Apply inverse operator,
......@@ -191,6 +194,7 @@ namespace Dune
using typename InverseOperator<X,Y>::range_type;
using typename InverseOperator<X,Y>::field_type;
using typename InverseOperator<X,Y>::real_type;
using typename InverseOperator<X,Y>::scalar_real_type;
/*!
\brief General constructor to initialize an iterative solver.
......@@ -211,7 +215,7 @@ namespace Dune
<li> 2 : print line for each iteration </li>
</ul>
*/
IterativeSolver (LinearOperator<X,Y>& op, Preconditioner<X,Y>& prec, real_type reduction, int maxit, int verbose) :
IterativeSolver (LinearOperator<X,Y>& op, Preconditioner<X,Y>& prec, scalar_real_type reduction, int maxit, int verbose) :
_op(stackobject_to_shared_ptr(op)),
_prec(stackobject_to_shared_ptr(prec)),
_sp(new SeqScalarProduct<X>),
......@@ -244,7 +248,7 @@ namespace Dune
</ul>
*/
IterativeSolver (LinearOperator<X,Y>& op, ScalarProduct<X>& sp, Preconditioner<X,Y>& prec,
real_type reduction, int maxit, int verbose) :
scalar_real_type reduction, int maxit, int verbose) :
_op(stackobject_to_shared_ptr(op)),
_prec(stackobject_to_shared_ptr(prec)),
_sp(stackobject_to_shared_ptr(sp)),
......@@ -270,7 +274,7 @@ namespace Dune
*/
virtual void apply (X& x, X& b, double reduction, InverseOperatorResult& res)
{
real_type saved_reduction = _reduction;
scalar_real_type saved_reduction = _reduction;
_reduction = reduction;
static_cast<InverseOperator<X,Y>*>(this)->apply(x,b,res);
_reduction = saved_reduction;
......@@ -286,7 +290,7 @@ namespace Dune
std::shared_ptr<LinearOperator<X,Y>> _op;
std::shared_ptr<Preconditioner<X,Y>> _prec;
std::shared_ptr<ScalarProduct<X>> _sp;
real_type _reduction;
scalar_real_type _reduction;
int _maxit;
int _verbose;
SolverCategory::Category _category;
......
......@@ -904,6 +904,8 @@ namespace Dune {
using typename IterativeSolver<X,Y>::real_type;
private:
using typename IterativeSolver<X,X>::scalar_real_type;
//! \bief field_type Allocator retrieved from domain type
using fAlloc =
typename X::allocator_type::template rebind<field_type>::other;
......@@ -919,7 +921,7 @@ namespace Dune {
\copydoc LoopSolver::LoopSolver(L&,P&,double,int,int)
\param restart number of GMRes cycles before restart
*/
RestartedGMResSolver (LinearOperator<X,Y>& op, Preconditioner<X,Y>& prec, real_type reduction, int restart, int maxit, int verbose) :
RestartedGMResSolver (LinearOperator<X,Y>& op, Preconditioner<X,Y>& prec, scalar_real_type reduction, int restart, int maxit, int verbose) :
IterativeSolver<X,Y>::IterativeSolver(op,prec,reduction,maxit,verbose),
_restart(restart)
{}
......@@ -930,7 +932,7 @@ namespace Dune {
\copydoc LoopSolver::LoopSolver(L&,S&,P&,double,int,int)
\param restart number of GMRes cycles before restart
*/
RestartedGMResSolver (LinearOperator<X,Y>& op, ScalarProduct<X>& sp, Preconditioner<X,Y>& prec, real_type reduction, int restart, int maxit, int verbose) :
RestartedGMResSolver (LinearOperator<X,Y>& op, ScalarProduct<X>& sp, Preconditioner<X,Y>& prec, scalar_real_type reduction, int restart, int maxit, int verbose) :
IterativeSolver<X,Y>::IterativeSolver(op,sp,prec,reduction,maxit,verbose),
_restart(restart)
{}
......@@ -1230,6 +1232,8 @@ namespace Dune {
using typename IterativeSolver<X,X>::real_type;
private:
using typename IterativeSolver<X,X>::scalar_real_type;
//! \bief field_type Allocator retrieved from domain type
typedef typename X::allocator_type::template rebind<field_type>::other fAlloc;
public:
......@@ -1240,7 +1244,7 @@ namespace Dune {
\copydoc LoopSolver::LoopSolver(L&,P&,double,int,int)
\param restart number of GMRes cycles before restart
*/
GeneralizedPCGSolver (LinearOperator<X,X>& op, Preconditioner<X,X>& prec, real_type reduction, int maxit, int verbose, int restart = 10) :
GeneralizedPCGSolver (LinearOperator<X,X>& op, Preconditioner<X,X>& prec, scalar_real_type reduction, int maxit, int verbose, int restart = 10) :
IterativeSolver<X,X>::IterativeSolver(op,prec,reduction,maxit,verbose),
_restart(restart)
{}
......@@ -1252,7 +1256,7 @@ namespace Dune {
\param restart When to restart the construction of
the Krylov search space.
*/
GeneralizedPCGSolver (LinearOperator<X,X>& op, ScalarProduct<X>& sp, Preconditioner<X,X>& prec, real_type reduction, int maxit, int verbose, int restart = 10) :
GeneralizedPCGSolver (LinearOperator<X,X>& op, ScalarProduct<X>& sp, Preconditioner<X,X>& prec, scalar_real_type reduction, int maxit, int verbose, int restart = 10) :
IterativeSolver<X,X>::IterativeSolver(op,sp,prec,reduction,maxit,verbose),
_restart(restart)
{}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment