]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Fix SolverSelector when using a custom SolverControl. It got copied into a member...
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 12 Oct 2010 19:05:40 +0000 (19:05 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 12 Oct 2010 19:05:40 +0000 (19:05 +0000)
git-svn-id: https://svn.dealii.org/trunk@22316 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/solver_selector.h

index cb5ad94fb30155e3b591178f14ce7d18087ca230..fa602b32b09cee7fb652d6830409d882b4effe51 100644 (file)
@@ -140,6 +140,12 @@ class SolverSelector : public Subscriptor
                                      * 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
@@ -189,27 +195,17 @@ class SolverSelector : public Subscriptor
                    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.
                                      */
@@ -255,7 +251,7 @@ template <class VECTOR>
 SolverSelector<VECTOR>::SolverSelector(const std::string    &solver_name,
                                       SolverControl        &control,
                                       VectorMemory<VECTOR> &) :
-               control(control),
+               control(&control),
                solver_name(solver_name)
 {}
 
@@ -273,7 +269,6 @@ SolverSelector<VECTOR>::select(const std::string& name)
 }
 
 
-
 template <class VECTOR>
 template<class Matrix, class Preconditioner>
 void
@@ -286,31 +281,31 @@ SolverSelector<VECTOR>::solve(const Matrix &A,
   
   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);
     }
@@ -319,6 +314,14 @@ SolverSelector<VECTOR>::solve(const Matrix &A,
 }
 
 
+template <class VECTOR>
+void SolverSelector<VECTOR>::set_control(
+  SolverControl & ctrl)
+{
+  control=&ctrl;
+}
+
+
 template <class VECTOR>
 std::string SolverSelector<VECTOR>::get_solver_names()
 {

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.