* class are all lower case.
*/
void select(const std::string& name);
+
+ /**
+ * Set a new SolverControl. This needs to
+ * be set before solving.
+ */
+ void set_control(SolverControl & ctrl);
/**
* Set the additional data. For more
std::string, << "Solver " << arg1 << " does not exist. Use one of "
<< std::endl << get_solver_names());
+
+
+ protected:
/**
- * Stores the @p ReductionControl that
- * is needed in the constructor of
- * each @p Solver class. This
- * data member is public, so that
- * it can easily be changed from
- * its default values. If you
- * create a SolverControl or
- * ReductionControl object with
- * the values needed, you can
- * simply use <tt>solver.control
- * = my_control</tt> to set the
- * values here.
- *
- * This object is updated in
- * solve(), thus declared mutable
- * here.
+ * Stores the @p SolverControl that is
+ * needed in the constructor of each @p
+ * Solver class. This can be changed with
+ * @p set_control().
*/
- mutable ReductionControl control;
+ SmartPointer< SolverControl, SolverSelector< VECTOR > > control;
- protected:
/**
* Stores the name of the solver.
*/
SolverSelector<VECTOR>::SolverSelector(const std::string &solver_name,
SolverControl &control,
VectorMemory<VECTOR> &) :
- control(control),
+ control(&control),
solver_name(solver_name)
{}
}
-
template <class VECTOR>
template<class Matrix, class Preconditioner>
void
if (solver_name=="richardson")
{
- SolverRichardson<VECTOR> solver(control,vector_memory,
+ SolverRichardson<VECTOR> solver(*control, vector_memory,
richardson_data);
solver.solve(A,x,b,precond);
}
else if (solver_name=="cg")
{
- SolverCG<VECTOR> solver(control,vector_memory,
+ SolverCG<VECTOR> solver(*control, vector_memory,
cg_data);
solver.solve(A,x,b,precond);
}
else if (solver_name=="bicgstab")
{
- SolverBicgstab<VECTOR> solver(control,vector_memory,
+ SolverBicgstab<VECTOR> solver(*control, vector_memory,
bicgstab_data);
solver.solve(A,x,b,precond);
}
else if (solver_name=="gmres")
{
- SolverGMRES<VECTOR> solver(control,vector_memory,
+ SolverGMRES<VECTOR> solver(*control,vector_memory,
gmres_data);
solver.solve(A,x,b,precond);
}
else if (solver_name=="fgmres")
{
- SolverFGMRES<VECTOR> solver(control,vector_memory,
+ SolverFGMRES<VECTOR> solver(*control,vector_memory,
fgmres_data);
solver.solve(A,x,b,precond);
}
}
+template <class VECTOR>
+void SolverSelector<VECTOR>::set_control(
+ SolverControl & ctrl)
+{
+ control=&ctrl;
+}
+
+
template <class VECTOR>
std::string SolverSelector<VECTOR>::get_solver_names()
{