+ /**
+ * An implementation of the solver interface using the Paralution Richardson solver
+ * (paralution::fixed_point_iteration).
+ *
+ * @ingroup ParalutionWrappers
+ * @author Bruno Turcksin, 2014
+ */
+ class SolverRichardson : public SolverBase
+ {
+ public:
+ /**
+ * Standardized data struct to pipe additional data to the solver.
+ */
+ struct AdditionalData
+ {
+ /**
+ * Constructor. By default, set the verbosity of the solver to zero and
+ * the relaxation parameter to one.
+ */
+ AdditionalData (const unsigned int verbose = 0,
+ const double relaxation_parameter = 1.);
+
+ /**
+ * Verbosity of the solver: 0 = no output, 1 = print information at the
+ * start and at the end, 3 = print residual at each iteration.
+ */
+ unsigned int verbose;
+
+ /**
+ * Relaxation parameter.
+ */
+ double relaxation_parameter;
+ };
+
+ /**
+ * Constructor. AdditionalData is a structure that contains additional
+ * flags for tuning this particular solver.
+ */
+ SolverRichardson (SolverControl &cn,
+ const AdditionalData &data = AdditionalData());
+
+ /**
+ * Solve the linear system <tt>Ax=b</tt> using the CG solver of
+ * Paralution. If the flag @p move_to_accelerator is set to true, the
+ * solver is built on the accelerator.
+ */
+ template <typename Number>
+ void solve (const SparseMatrix<Number> &A,
+ Vector<Number> &x,
+ const Vector<Number> &b,
+ const PreconditionBase<Number> &preconditioner,
+ bool move_to_accelerator=false);
+
+ private:
+ /**
+ * store a copy of the flags for this solver.
+ */
+ const AdditionalData additional_data;
+ };
+
+
+
/**
* An implementation of the solver interface using the Paralution CG solver.
*
{
public:
/**
- * Constructor.
+ * Standardized data struct to pipe additional data to the solver.
+ */
+ struct AdditionalData
+ {
+ /**
+ * Constructor. By default, set the verbosity of the solver to zero.
+ */
+ AdditionalData (const unsigned int verbose = 0);
+
+ /**
+ * Verbosity of the solver: 0 = no output, 1 = print information at the
+ * start and at the end, 3 = print residual at each iteration.
+ */
+ unsigned int verbose;
+
+ /**
+ * Relaxation parameter.
+ */
+ double relaxation_parameter;
+ };
+
+ /**
+ * Constructor. AdditionalData is a structure that contains additional
+ * flags for tuning this particular solver.
*/
- SolverCG (SolverControl &cn);
+ SolverCG (SolverControl &cn,
+ const AdditionalData &data = AdditionalData());
/**
* Solve the linear system <tt>Ax=b</tt> using the CG solver of
const Vector<Number> &b,
const PreconditionBase<Number> &preconditioner,
bool move_to_accelerator=false);
+
+ private:
+ /**
+ * store a copy of the flags for this solver.
+ */
+ const AdditionalData additional_data;
+ };
+
+
+
+ /**
+ * An implementation of the solver interface using the Paralution CR solver.
+ *
+ * @ingroup ParalutionWrappers
+ * @author Bruno Turcksin, 2014
+ */
+ class SolverCR : public SolverBase
+ {
+ public:
+ /**
+ * Standardized data struct to pipe additional data to the solver.
+ */
+ struct AdditionalData
+ {
+ /**
+ * Constructor. By default, set the verbosity of the solver to zero.
+ */
+ AdditionalData (const unsigned int verbose = 0);
+
+ /**
+ * Verbosity of the solver: 0 = no output, 1 = print information at the
+ * start and at the end, 3 = print residual at each iteration.
+ */
+ unsigned int verbose;
+ };
+
+ /**
+ * Constructor. AdditionalData is a structure that contains additional
+ * flags for tuning this particular solver.
+ */
+ SolverCR (SolverControl &cn,
+ const AdditionalData &data = AdditionalData());
+
+ /**
+ * Solve the linear system <tt>Ax=b</tt> using the CR solver of
+ * Paralution. If the flag @p move_to_accelerator is set to true, the
+ * solver is built on the accelerator.
+ */
+ template <typename Number>
+ void solve (const SparseMatrix<Number> &A,
+ Vector<Number> &x,
+ const Vector<Number> &b,
+ const PreconditionBase<Number> &preconditioner,
+ bool move_to_accelerator=false);
+
+ private:
+ /**
+ * store a copy of the flags for this solver.
+ */
+ const AdditionalData additional_data;
+ };
+
+
+
+ /**
+ * An implementation of the solver interface using the Paralution DPCG solver.
+ * DPCG stands for Deflated Preconditioned Conjugate Gradient. It is a
+ * two-level preconditioned CG algorithm to iteratively solve and
+ * ill-conditioned linear system. Deflation tries to remove the bad
+ * eigenvalues from the spectrum of the preconditioned system.
+ *
+ * @ingroup ParalutionWrappers
+ * @author Bruno Turcksin, 2014
+ */
+ class SolverDPCG : public SolverBase
+ {
+ public:
+ /**
+ * Standardized data struct to pipe additional data to the solver.
+ */
+ struct AdditionalData
+ {
+ /**
+ * Constructor. By default, set the verbosity of the solver to zero and
+ * set the number of deflated vectors to two.
+ */
+ AdditionalData (const unsigned int verbose = 0,
+ const unsigned int n_deflated_vectors = 2);
+
+ /**
+ * Verbosity of the solver: 0 = no output, 1 = print information at the
+ * start and at the end, 3 = print residual at each iteration.
+ */
+ unsigned int verbose;
+
+ /**
+ * Number of deflated vectors.
+ */
+ unsigned int n_deflated_vectors;
+ };
+
+ /**
+ * Constructor. AdditionalData is a structure that contains additional
+ * flags for tuning this particular solver.
+ */
+ SolverDPCG (SolverControl &cn,
+ const AdditionalData &data = AdditionalData());
+
+ /**
+ * Solve the linear system <tt>Ax=b</tt> using the DPCG solver of
+ * Paralution. If the flag @p move_to_accelerator is set to true, the
+ * solver is built on the accelerator.
+ */
+ template <typename Number>
+ void solve (const SparseMatrix<Number> &A,
+ Vector<Number> &x,
+ const Vector<Number> &b,
+ const PreconditionBase<Number> &preconditioner,
+ bool move_to_accelerator=false);
+
+ private:
+ /**
+ * store a copy of the flags for this solver.
+ */
+ const AdditionalData additional_data;
};
/**
* An implementation of the solver interface using the Paralution BiCGStab
* solver.
+ *
+ * @ingroup ParalutionWrappers
+ * @author Bruno Turcksin, 2013
*/
class SolverBicgstab : public SolverBase
{
public:
/**
- * Constructor.
+ * Standardized data struct to pipe additional data to the solver.
+ */
+ struct AdditionalData
+ {
+ /**
+ * Constructor. By default, set the verbosity of the solver to zero.
+ */
+ AdditionalData (const unsigned int verbose = 0);
+
+ /**
+ * Verbosity of the solver: 0 = no output, 1 = print information at the
+ * start and at the end, 3 = print residual at each iteration.
+ */
+ unsigned int verbose;
+ };
+
+ /**
+ * Constructor. AdditionalData is a structure that contains additional
+ * flags for tuning this particular solver.
*/
- SolverBicgstab (SolverControl &cn);
+ SolverBicgstab (SolverControl &cn,
+ const AdditionalData &data = AdditionalData());
/**
* Solve the linear system <tt>Ax=b</tt> using the BiCGStab solver of
const Vector<Number> &b,
const PreconditionBase<Number> &preconditioner,
bool move_to_accelerator=false);
+
+ private:
+ /**
+ * store a copy of the flags for this solver.
+ */
+ const AdditionalData additional_data;
};
/**
* An implementation of the solver interface using the Paralution GMRES
* solver.
+ *
+ * @ingroup ParalutionWrappers
+ * @author Bruno Turcksin, 2013
*/
class SolverGMRES : public SolverBase
{
struct AdditionalData
{
/**
- * Constructor. By default, set the size of the Krylov space to 30,
- * i.e. do a restart every 30 iterations.
+ * Constructor. By default, set the verbosity of the solver to zero and
+ * set the size of the Krylov space to 30, i.e. do a restart every 30
+ * iterations.
+ */
+ AdditionalData (const unsigned int verbose = 0,
+ const unsigned int restart_parameter = 30);
+
+ /**
+ * Verbosity of the solver: 0 = no output, 1 = print information at the
+ * start and at the end, 3 = print residual at each iteration.
*/
- AdditionalData (const unsigned int restart_parameter = 30);
+ unsigned int verbose;
/**
* Size of the Krylov space.
/**
* Constructor. AdditionalData is a structure that contains additional
- * flags for tuning this particulat solver.
+ * flags for tuning this particular solver.
*/
- SolverGMRES (SolverControl &cn,
+ SolverGMRES (SolverControl &cn,
const AdditionalData &data = AdditionalData());
/**
private:
/**
- * Store a copy of the flags for this solver.
+ * store a copy of the flags for this solver.
+ */
+ const AdditionalData additional_data;
+ };
+
+
+
+ /**
+ * An implementation of the solver interface using the Paralution GMRES
+ * solver.
+ *
+ * @ingroup ParalutionWrappers
+ * @author Bruno Turcksin, 2014
+ */
+ class SolverFGMRES : public SolverBase
+ {
+ public:
+ /**
+ * Standardized data struct to pipe additional data to the solver.
+ */
+ struct AdditionalData
+ {
+ /**
+ * Constructor. By default, set the verbosity of the solver to zero and
+ * set the size of the Krylov space to 30, i.e. do a restart every 30
+ * iterations.
+ */
+ AdditionalData (const unsigned int verbose = 0,
+ const unsigned int restart_parameter = 30);
+
+ /**
+ * Verbosity of the solver: 0 = no output, 1 = print information at the
+ * start and at the end, 3 = print residual at each iteration.
+ */
+ unsigned int verbose;
+
+ /**
+ * Size of the Krylov space.
+ */
+ unsigned int restart_parameter;
+ };
+
+ /**
+ * Constructor. AdditionalData is a structure that contains additional
+ * flags for tuning this particular solver.
+ */
+ SolverFGMRES (SolverControl &cn,
+ const AdditionalData &data = AdditionalData());
+
+ /**
+ * Solve the linear system <tt>Ax=b</tt> using the GMRES solver of
+ * Paralution. If the flag @p move_to_accelerator is set to true, the
+ * solver is built on the accelerator.
+ */
+ template <typename Number>
+ void solve (const SparseMatrix<Number> &A,
+ Vector<Number> &x,
+ const Vector<Number> &b,
+ const PreconditionBase<Number> &preconditioner,
+ bool move_to_accelerator=false);
+
+ private:
+ /**
+ * store a copy of the flags for this solver.
*/
const AdditionalData additional_data;
};
return solver_control;
}
+
+
template <typename Number>
void SolverBase::execute_solve(std_cxx1x::shared_ptr<paralution::IterativeLinearSolver<paralution::
LocalMatrix<Number>,paralution::LocalVector<Number>,Number> > solver,
- /* ---------------------- SolverCG ------------------------ */
+ /* --------------------- SolverRichardson----------------- */
+
+ SolverRichardson::AdditionalData::AdditionalData(const unsigned int verbose,
+ const double relaxation_parameter)
+ :
+ verbose(verbose),
+ relaxation_parameter(relaxation_parameter)
+ {}
+
+
+
+ SolverRichardson::SolverRichardson (SolverControl &cn,
+ const AdditionalData &data)
+ :
+ SolverBase (cn),
+ additional_data (data)
+ {}
+
+
+
+ template <typename Number>
+ void SolverRichardson::solve(const SparseMatrix<Number> &A,
+ Vector<Number> &x,
+ const Vector<Number> &b,
+ const PreconditionBase<Number> &preconditioner,
+ bool move_to_accelerator)
+ {
+ std_cxx1x::shared_ptr<paralution::FixedPoint<paralution::LocalMatrix<Number>,
+ paralution::LocalVector<Number>,Number> > solver(new paralution::
+ FixedPoint<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,Number>);
+
+ // Set the verbosity of the solver.
+ solver->Verbose(additional_data.verbose);
+
+ // Set the relaxation parameter.
+ solver->SetRelaxation(additional_data.relaxation_parameter);
+
+ this->execute_solve<Number>(solver,A,x,b,preconditioner,move_to_accelerator);
+ }
+
+
+
+ /* ---------------------- SolverCG ------------------------- */
- SolverCG::SolverCG (SolverControl &cn)
+ SolverCG::AdditionalData::AdditionalData(const unsigned int verbose)
:
- SolverBase (cn)
+ verbose(verbose)
+ {}
+
+
+
+ SolverCG::SolverCG (SolverControl &cn, const AdditionalData &data)
+ :
+ SolverBase (cn),
+ additional_data (data)
{}
paralution::LocalVector<Number>,Number> > solver(new paralution::
CG<paralution::LocalMatrix<Number>,paralution::LocalVector<Number>,Number>);
+ // Set the verbosity of the solver.
+ solver->Verbose(additional_data.verbose);
+
+ this->execute_solve<Number>(solver,A,x,b,preconditioner,move_to_accelerator);
+ }
+
+
+
+ /* ---------------------- SolverCR ------------------------- */
+
+ SolverCR::AdditionalData::AdditionalData(const unsigned int verbose)
+ :
+ verbose(verbose)
+ {}
+
+
+
+ SolverCR::SolverCR (SolverControl &cn, const AdditionalData &data)
+ :
+ SolverBase (cn),
+ additional_data (data)
+ {}
+
+
+
+ template <typename Number>
+ void SolverCR::solve(const SparseMatrix<Number> &A,
+ Vector<Number> &x,
+ const Vector<Number> &b,
+ const PreconditionBase<Number> &preconditioner,
+ bool move_to_accelerator)
+ {
+ std_cxx1x::shared_ptr<paralution::CR<paralution::LocalMatrix<Number>,
+ paralution::LocalVector<Number>,Number> > solver(new paralution::
+ CR<paralution::LocalMatrix<Number>,paralution::LocalVector<Number>,Number>);
+
+ // Set the verbosity of the solver.
+ solver->Verbose(additional_data.verbose);
+
+ this->execute_solve<Number>(solver,A,x,b,preconditioner,move_to_accelerator);
+ }
+
+
+
+ /* ---------------------- SolverDPCG ----------------------- */
+
+ SolverDPCG::AdditionalData::AdditionalData(const unsigned int verbose,
+ const const unsigned int n_deflated_vectors)
+ :
+ verbose (verbose),
+ n_deflated_vectors(n_deflated_vectors)
+ {}
+
+
+
+ SolverDPCG::SolverDPCG (SolverControl &cn, const AdditionalData &data)
+ :
+ SolverBase (cn),
+ additional_data (data)
+ {}
+
+
+
+ template <typename Number>
+ void SolverDPCG::solve(const SparseMatrix<Number> &A,
+ Vector<Number> &x,
+ const Vector<Number> &b,
+ const PreconditionBase<Number> &preconditioner,
+ bool move_to_accelerator)
+ {
+ std_cxx1x::shared_ptr<paralution::DPCG<paralution::LocalMatrix<Number>,
+ paralution::LocalVector<Number>,Number> > solver(new paralution::
+ DPCG<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,Number>);
+
+ // Set the verbosity of the solver.
+ solver->Verbose(additional_data.verbose);
+
+ // Set the number of deflated vectors.
+ solver->SetNVectors(additional_data.n_deflated_vectors);
+
this->execute_solve<Number>(solver,A,x,b,preconditioner,move_to_accelerator);
}
/* -------------------- SolverBicgstab --------------------- */
- SolverBicgstab::SolverBicgstab (SolverControl &cn)
+ SolverBicgstab::AdditionalData::AdditionalData(const unsigned int verbose)
:
- SolverBase (cn)
+ verbose(verbose)
+ {}
+
+
+
+ SolverBicgstab::SolverBicgstab (SolverControl &cn, const AdditionalData &data)
+ :
+ SolverBase (cn),
+ additional_data (data)
{}
paralution::LocalVector<Number>,Number> > solver(new paralution::
BiCGStab<paralution::LocalMatrix<Number>,paralution::LocalVector<Number>,Number>);
+ // Set the verbosity of the solver.
+ solver->Verbose(additional_data.verbose);
+
this->execute_solve<Number>(solver,A,x,b,preconditioner,move_to_accelerator);
}
/* --------------------- SolverGMRES ----------------------- */
- SolverGMRES::AdditionalData::AdditionalData(const unsigned int restart_parameter)
+ SolverGMRES::AdditionalData::AdditionalData(const unsigned int verbose,
+ const unsigned int restart_parameter)
:
+ verbose(verbose),
restart_parameter(restart_parameter)
{}
-
SolverGMRES::SolverGMRES (SolverControl &cn,
const AdditionalData &data)
:
paralution::LocalVector<Number>,Number> > solver(new paralution::
GMRES<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,Number>);
+ // Set the verbosity of the solver.
+ solver->Verbose(additional_data.verbose);
+
+ // Set the restart parameter.
+ solver->SetBasisSize(additional_data.restart_parameter);
+
+ this->execute_solve<Number>(solver,A,x,b,preconditioner,move_to_accelerator);
+ }
+
+
+
+ /* --------------------- SolverFGMRES ---------------------- */
+
+ SolverFGMRES::AdditionalData::AdditionalData(const unsigned int verbose,
+ const unsigned int restart_parameter)
+ :
+ verbose(verbose),
+ restart_parameter(restart_parameter)
+ {}
+
+
+
+ SolverFGMRES::SolverFGMRES (SolverControl &cn,
+ const AdditionalData &data)
+ :
+ SolverBase (cn),
+ additional_data (data)
+ {}
+
+
+
+ template <typename Number>
+ void SolverFGMRES::solve(const SparseMatrix<Number> &A,
+ Vector<Number> &x,
+ const Vector<Number> &b,
+ const PreconditionBase<Number> &preconditioner,
+ bool move_to_accelerator)
+ {
+ std_cxx1x::shared_ptr<paralution::FGMRES<paralution::LocalMatrix<Number>,
+ paralution::LocalVector<Number>,Number> > solver(new paralution::
+ FGMRES<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,Number>);
+
+ // Set the verbosity of the solver.
+ solver->Verbose(additional_data.verbose);
+
// Set the restart parameter.
solver->SetBasisSize(additional_data.restart_parameter);
const PreconditionBase<double> &preconditioner,
bool move_to_accelerator);
+ template void SolverCR::solve<float>(const SparseMatrix<float> &A,
+ Vector<float> &x,
+ const Vector<float> &b,
+ const PreconditionBase<float> &preconditioner,
+ bool move_to_accelerator);
+
+ template void SolverCR::solve<double>(const SparseMatrix<double> &A,
+ Vector<double> &x,
+ const Vector<double> &b,
+ const PreconditionBase<double> &preconditioner,
+ bool move_to_accelerator);
+
+ template void SolverDPCG::solve<float>(const SparseMatrix<float> &A,
+ Vector<float> &x,
+ const Vector<float> &b,
+ const PreconditionBase<float> &preconditioner,
+ bool move_to_accelerator);
+
+ template void SolverDPCG::solve<double>(const SparseMatrix<double> &A,
+ Vector<double> &x,
+ const Vector<double> &b,
+ const PreconditionBase<double> &preconditioner,
+ bool move_to_accelerator);
+
template void SolverBicgstab::solve<float>(const SparseMatrix<float> &A,
Vector<float> &x,
const Vector<float> &b,
const Vector<double> &b,
const PreconditionBase<double> &preconditioner,
bool move_to_accelerator);
+
+ template void SolverFGMRES::solve<float>(const SparseMatrix<float> &A,
+ Vector<float> &x,
+ const Vector<float> &b,
+ const PreconditionBase<float> &preconditioner,
+ bool move_to_accelerator);
+
+ template void SolverFGMRES::solve<double>(const SparseMatrix<double> &A,
+ Vector<double> &x,
+ const Vector<double> &b,
+ const PreconditionBase<double> &preconditioner,
+ bool move_to_accelerator);
}
DEAL_II_NAMESPACE_CLOSE