]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Reindent some files.
authorturcksin <turcksin@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 14 Jul 2014 15:15:42 +0000 (15:15 +0000)
committerturcksin <turcksin@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 14 Jul 2014 15:15:42 +0000 (15:15 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_paralution@33167 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/lac/paralution_precondition.h
deal.II/include/deal.II/lac/paralution_solver.h
deal.II/include/deal.II/lac/paralution_vector.h
deal.II/source/lac/paralution_precondition.cc
deal.II/source/lac/paralution_solver.cc
deal.II/source/lac/paralution_vector.cc

index 4e94a075cc069047ea1fb740776431a8a3739e07..d7c45ef4f1f115f77c9c623ca89a80a28076757c 100644 (file)
@@ -48,7 +48,8 @@ namespace ParalutionWrappers
    * Preconditioner for the smoother of the multigrid.
    */
   enum mg_preconditioner {jacobi, sgs, multicolored_sgs, multicolored_sor, ilu,
-      ilut, multicolored_ilu};
+                          ilut, multicolored_ilu
+                         };
 
   /**
    * Solver used as smoother and to solve the coarse system of the multigrid.
index 9b3a738cdb3f3de4b98c10ebb639c3a580d23797..9d798085788fc949e9518d4759461a6ce75d26cd 100644 (file)
@@ -36,7 +36,7 @@ DEAL_II_NAMESPACE_OPEN
 namespace ParalutionWrappers
 {
   /**
-   * Base class for solver classes using the Paralution solvers except AMG which 
+   * Base class for solver classes using the Paralution solvers except AMG which
    * is not derived from this class.
    *
    * @ingroup ParalutionWrappers
@@ -71,7 +71,7 @@ namespace ParalutionWrappers
     /**
      * Reference to the object that controls convergence of the iterative
      * solver. In fact, for these Paralution wrappers, Paralution does so
-     * itself, but we copy the data from this object before starting solution 
+     * itself, but we copy the data from this object before starting solution
      * process, and copy the data back into it afterwards.
      */
     SolverControl &solver_control;
@@ -514,7 +514,7 @@ namespace ParalutionWrappers
    * @ingroup ParalutionWrappers
    * @author Bruno Turcksin, 2014
    */
-  class SolverAMG 
+  class SolverAMG
   {
   public:
     /**
@@ -597,7 +597,7 @@ namespace ParalutionWrappers
      * flags for tuning this particular solver.
      */
     SolverAMG (SolverControl        &cn,
-              const AdditionalData &data = AdditionalData());
+               const AdditionalData &data = AdditionalData());
 
     /**
      * Solve the linear system <tt>Ax=b</tt> using the AMG solver of
@@ -621,7 +621,7 @@ namespace ParalutionWrappers
     /**
      * Reference to the object that controls convergence of the iterative
      * solver. In fact, for these Paralution wrappers, Paralution does so
-     * itself, but we copy the data from this object before starting solution 
+     * itself, but we copy the data from this object before starting solution
      * process, and copy the data back into it afterwards.
      */
     SolverControl &solver_control;
index 2d857a849c09dc9365523f9ff5694ffae8985baa..8793763b3a0c2c158ad87ede07a97efaa6d4087d 100644 (file)
@@ -65,8 +65,11 @@ namespace ParalutionWrappers
      */
     typedef dealii::types::global_dof_index size_type;
     typedef Number                          value_type;
+    typedef Number                          real_type;
     typedef Number                         *iterator;
     typedef const Number                   *const_iterator;
+    typedef value_type                     &reference;
+    typedef const value_type               &const_reference;
 
     /**
      * A variable that indicates whether this vector supports distributed data
@@ -450,9 +453,9 @@ namespace ParalutionWrappers
      * printed in a line, while if @p false then the elements are printed on a
      * separate line each.
      */
-    void print (std::ostream      &out,         
-                const unsigned int precision,   
-                const bool         scientific,  
+    void print (std::ostream      &out,
+                const unsigned int precision,
+                const bool         scientific,
                 const bool         across) const;
 
     /**
@@ -461,6 +464,16 @@ namespace ParalutionWrappers
      */
     void sync();
 
+    /**
+     * Swap the contents of this vector and the other vector @p v. One could
+     * do this operation with a temporary variable and copying over the data
+     * elements, but this function is significantly more efficient since it
+     * only swaps the pointers to the data of the two vectors and therefore
+     * does not need to allocate temporary storage and move data around. Note
+     * that the vectors need to be of the same size and base on the same map.
+     */
+    void swap (Vector<Number> &v);
+
     /**
      * Determine an estimate for the memory consumption (in bytes) of this
      * object.
index 2919a9c9c86c11d118a997bcab619fb187e0f395..2577987c8267aa3b5671c82d9e56b08dd92bae9d 100644 (file)
@@ -224,11 +224,11 @@ namespace ParalutionWrappers
                                                           const mg_solver coarse_solver,
                                                           const unsigned int n_unknowns_coarse_level,
                                                           const unsigned int max_iter,
-                                                          const mg_cycle cycle,                           
+                                                          const mg_cycle cycle,
                                                           const mg_interpolation interpolation,
                                                           const double coupling_strength,
                                                           const double relaxation_parameter,
-                                                          const double over_interpolation)                     
+                                                          const double over_interpolation)
     :
     verbose(verbose),
     coarse_solver(coarse_solver),
@@ -269,8 +269,8 @@ namespace ParalutionWrappers
   {
     // Downcast the preconditioner pointer
     paralution::AMG<paralution::LocalMatrix<Number>,paralution::LocalVector<Number>,
-      Number>* downcasted_ptr = static_cast<paralution::AMG<paralution::
-        LocalMatrix<Number>,paralution::LocalVector<Number>,Number>* >(this->preconditioner.get());
+               Number>* downcasted_ptr = static_cast<paralution::AMG<paralution::
+                                         LocalMatrix<Number>,paralution::LocalVector<Number>,Number>* >(this->preconditioner.get());
 
     // Set the maximum number of iterations.
     downcasted_ptr->InitMaxIter(additional_data.max_iter);
@@ -286,55 +286,55 @@ namespace ParalutionWrappers
 
     // Set the interpolation type.
     switch (additional_data.interpolation)
-    {
+      {
       case aggregation :
-        {
-          downcasted_ptr->SetInterpolation(paralution::Aggregation);
-          downcasted_ptr->SetOverInterp(additional_data.over_interpolation);
-          break;
-        }
+      {
+        downcasted_ptr->SetInterpolation(paralution::Aggregation);
+        downcasted_ptr->SetOverInterp(additional_data.over_interpolation);
+        break;
+      }
       case smoothed_aggregation :
-        {
-          downcasted_ptr->SetInterpolation(paralution::SmoothedAggregation);
-          downcasted_ptr->SetInterpRelax(additional_data.relaxation_parameter);
-          break;
-        }
+      {
+        downcasted_ptr->SetInterpolation(paralution::SmoothedAggregation);
+        downcasted_ptr->SetInterpRelax(additional_data.relaxation_parameter);
+        break;
+      }
       default :
-        {
-          AssertThrow(false,ExcMessage("Unknown interpolation type for PreconditionAMG."));
-        }
-    }
+      {
+        AssertThrow(false,ExcMessage("Unknown interpolation type for PreconditionAMG."));
+      }
+      }
 
     // Set the coupling strength
     downcasted_ptr->SetCouplingStrength(additional_data.coupling_strength);
 
     // Set the type of cycle
     switch (additional_data.cycle)
-    {
+      {
       case V_cycle :
-        {
-          downcasted_ptr->SetCycle(paralution::Vcycle);
-          break;
-        }
+      {
+        downcasted_ptr->SetCycle(paralution::Vcycle);
+        break;
+      }
       case  W_cycle :
-        {
-          downcasted_ptr->SetCycle(paralution::Wcycle);
-          break;
-        }
+      {
+        downcasted_ptr->SetCycle(paralution::Wcycle);
+        break;
+      }
       case K_cycle :
-        {
-          downcasted_ptr->SetCycle(paralution::Kcycle);
-          break;
-        }
+      {
+        downcasted_ptr->SetCycle(paralution::Kcycle);
+        break;
+      }
       case F_cycle :
-        {
-          downcasted_ptr->SetCycle(paralution::Fcycle);
-        }
+      {
+        downcasted_ptr->SetCycle(paralution::Fcycle);
+      }
       default :
-        {
-          AssertThrow(false,ExcMessage("Unknown cycle type for PreconditionAMG."));
-        }
-    }
+      {
+        AssertThrow(false,ExcMessage("Unknown cycle type for PreconditionAMG."));
+      }
+      }
 
     // Use manual coarse grid solver.
     downcasted_ptr->SetManualSolver(true);
@@ -342,60 +342,60 @@ namespace ParalutionWrappers
 
     // Coarse solver
     switch (additional_data.coarse_solver)
-    {
+      {
       case richardson :
-        {
-          paralution::FixedPoint<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
-            Number> *cs = new paralution::FixedPoint<paralution::LocalMatrix<Number>,
-            paralution::LocalVector<Number>, Number>;
-          coarse_solver = cs;
-          break;
-        }
+      {
+        paralution::FixedPoint<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
+                   Number> *cs = new paralution::FixedPoint<paralution::LocalMatrix<Number>,
+        paralution::LocalVector<Number>, Number>;
+        coarse_solver = cs;
+        break;
+      }
       case cg :
-        {
-          paralution::CG<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
-            Number> *cs = new paralution::CG<paralution::LocalMatrix<Number>,
-            paralution::LocalVector<Number>, Number>;
-          coarse_solver = cs;
-          break;
-        }
+      {
+        paralution::CG<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
+                   Number> *cs = new paralution::CG<paralution::LocalMatrix<Number>,
+        paralution::LocalVector<Number>, Number>;
+        coarse_solver = cs;
+        break;
+      }
       case cr :
-        {
-          paralution::CR<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
-            Number> *cs = new paralution::CR<paralution::LocalMatrix<Number>,
-            paralution::LocalVector<Number>, Number>;
-          coarse_solver = cs;
-          break;
-        }
+      {
+        paralution::CR<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
+                   Number> *cs = new paralution::CR<paralution::LocalMatrix<Number>,
+        paralution::LocalVector<Number>, Number>;
+        coarse_solver = cs;
+        break;
+      }
       case bicgstab :
-        {
-          paralution::BiCGStab<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
-            Number> *cs =  new paralution::BiCGStab<paralution::LocalMatrix<Number>,
-            paralution::LocalVector<Number>, Number>;
-          coarse_solver = cs;
-          break;
-        }
+      {
+        paralution::BiCGStab<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
+                   Number> *cs =  new paralution::BiCGStab<paralution::LocalMatrix<Number>,
+        paralution::LocalVector<Number>, Number>;
+        coarse_solver = cs;
+        break;
+      }
       case gmres :
-        {
-          paralution::GMRES<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
-            Number> *cs = new paralution::GMRES<paralution::LocalMatrix<Number>,
-            paralution::LocalVector<Number>, Number>;
-          coarse_solver = cs;
-          break;
-        }
+      {
+        paralution::GMRES<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
+                   Number> *cs = new paralution::GMRES<paralution::LocalMatrix<Number>,
+        paralution::LocalVector<Number>, Number>;
+        coarse_solver = cs;
+        break;
+      }
       case fgmres :
-        {
-          paralution::FGMRES<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
-            Number> *cs = new paralution::FGMRES<paralution::LocalMatrix<Number>,
-            paralution::LocalVector<Number>, Number>;
-          coarse_solver = cs;
-          break;
-        }
+      {
+        paralution::FGMRES<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
+                   Number> *cs = new paralution::FGMRES<paralution::LocalMatrix<Number>,
+        paralution::LocalVector<Number>, Number>;
+        coarse_solver = cs;
+        break;
+      }
       default :
-        {
-          AssertThrow(false,ExcMessage("Unknown coarse solver for PreconditionAMG."));
-        }
-    }
+      {
+        AssertThrow(false,ExcMessage("Unknown coarse solver for PreconditionAMG."));
+      }
+      }
 
     // Set the coarse solver and the verbosity of the coarse solver.
     coarse_solver->Verbose(additional_data.verbose);
index aadf732b87e747d34bfb3381c679cae1b5b7a0fc..8c202d9ff21f27276c75be12393eca389a964d92 100644 (file)
@@ -29,7 +29,7 @@ namespace ParalutionWrappers
 
 
 
-  SolverControlSolverBase::control() const
+  SolverControl &SolverBase::control() const
   {
     return solver_control;
   }
@@ -73,7 +73,7 @@ namespace ParalutionWrappers
     // Let the deal.II SolverControl object know what has happened. If the solve
     // succeeded, the status of the solver control will turn into
     // SolverControl::success. solver_control only exists on the host so the solver
-    // needs to be on the most. 
+    // needs to be on the most.
     solver->MoveToHost();
 
     solver_control.check (solver->GetIterationCount(), solver->GetCurrentResidual());
@@ -407,71 +407,71 @@ namespace ParalutionWrappers
     // Set the system to solve.
     solver.SetOperator(A.paralution_matrix());
     solver.SetOperatorFormat(CSR);
-    
+
     // Set the verbosity of the multigrid.
     solver.Verbose(additional_data.verbose);
-    
+
     // Set number of unknowns on coarsest level.
     solver.SetCoarsestLevel(additional_data.n_unknowns_coarse_level);
 
     // Set the interpolation type.
     switch (additional_data.interpolation)
-    {
+      {
       case aggregation :
-        {
-          solver.SetInterpolation(paralution::Aggregation);
-          solver.SetOverInterp(additional_data.over_interpolation);
-          break;
-        }
+      {
+        solver.SetInterpolation(paralution::Aggregation);
+        solver.SetOverInterp(additional_data.over_interpolation);
+        break;
+      }
       case smoothed_aggregation :
-        {
-          solver.SetInterpolation(paralution::SmoothedAggregation);
-          solver.SetInterpRelax(additional_data.relaxation_parameter);
-          break;
-        }
+      {
+        solver.SetInterpolation(paralution::SmoothedAggregation);
+        solver.SetInterpRelax(additional_data.relaxation_parameter);
+        break;
+      }
       default :
-        {
-          AssertThrow(false,ExcMessage("Unknown interpolation type for PreconditionAMG."));
-        }
-    }
+      {
+        AssertThrow(false,ExcMessage("Unknown interpolation type for PreconditionAMG."));
+      }
+      }
 
     // Set the coupling strength.
     solver.SetCouplingStrength(additional_data.coupling_strength);
 
     // Set the type of cycle
     switch (additional_data.cycle)
-    {
+      {
       case V_cycle :
-        {
-          solver.SetCycle(paralution::Vcycle);
-          break;
-        }
+      {
+        solver.SetCycle(paralution::Vcycle);
+        break;
+      }
       case  W_cycle :
-        {
-          solver.SetCycle(paralution::Wcycle);
-          break;
-        }
+      {
+        solver.SetCycle(paralution::Wcycle);
+        break;
+      }
       case K_cycle :
-        {
-          solver.SetCycle(paralution::Kcycle);
-          break;
-        }
+      {
+        solver.SetCycle(paralution::Kcycle);
+        break;
+      }
       case F_cycle :
-        {
-          solver.SetCycle(paralution::Fcycle);
-        }
+      {
+        solver.SetCycle(paralution::Fcycle);
+      }
       default :
-        {
-          AssertThrow(false,ExcMessage("Unknown cycle type for PreconditionAMG."));
-        }
-    }
-    
+      {
+        AssertThrow(false,ExcMessage("Unknown cycle type for PreconditionAMG."));
+      }
+      }
+
     // Manual smoothers
     solver.SetManualSmoothers(true);
-    
+
     // Manual course grid solver
     solver.SetManualSolver(true);
-    
+
     // Set grid transfer scaling
     solver.SetScaling(true);
 
@@ -482,222 +482,222 @@ namespace ParalutionWrappers
 
     // Smoother for each level
     paralution::IterativeLinearSolver<paralution::LocalMatrix<Number>,
-      paralution::LocalVector<Number>,Number> **smoothers = NULL;
+               paralution::LocalVector<Number>,Number> **smoothers = NULL;
     smoothers = new paralution::IterativeLinearSolver<paralution::LocalMatrix<Number>,
-              paralution::LocalVector<Number>,Number>* [n_levels-1];
+    paralution::LocalVector<Number>,Number>* [n_levels-1];
 
     // Preconditioner for each smoother
     paralution::Preconditioner<paralution::LocalMatrix<Number>,
-      paralution::LocalVector<Number>,Number> **preconds = NULL;
+               paralution::LocalVector<Number>,Number> **preconds = NULL;
     preconds = new paralution::Preconditioner<paralution::LocalMatrix<Number>,
-             paralution::LocalVector<Number>,Number>* [n_levels-1];
+    paralution::LocalVector<Number>,Number>* [n_levels-1];
 
     // Coarse Grid Solver
     paralution::IterativeLinearSolver<paralution::LocalMatrix<Number>,
-      paralution::LocalVector<Number>,Number> *coarse_solver;
+               paralution::LocalVector<Number>,Number> *coarse_solver;
 
     // Smoother
     switch (additional_data.smoother)
-    {
+      {
       case richardson :
-        {
-          for (unsigned int i=0; i<n_levels-1; ++i)
+      {
+        for (unsigned int i=0; i<n_levels-1; ++i)
           {
             paralution::FixedPoint<paralution::LocalMatrix<Number>,
-              paralution::LocalVector<Number>,Number> *richardson = NULL;
+                       paralution::LocalVector<Number>,Number> *richardson = NULL;
             richardson = new paralution::FixedPoint<paralution::LocalMatrix<Number>,
-                       paralution::LocalVector<Number>,Number>;
+            paralution::LocalVector<Number>,Number>;
             smoothers[i] = richardson;
             smoothers[i]->Verbose(additional_data.verbose);
           }
 
-          break;
-        }
+        break;
+      }
       case cg :
-        {
-          for (unsigned int i=0; i<n_levels-1; ++i)
+      {
+        for (unsigned int i=0; i<n_levels-1; ++i)
           {
             paralution::CG<paralution::LocalMatrix<Number>,paralution::LocalVector<Number>,
-              Number> *cg = NULL;
+                       Number> *cg = NULL;
             cg = new paralution::CG<paralution::LocalMatrix<Number>,paralution::LocalVector<Number>,
-               Number>;
+            Number>;
             smoothers[i] = cg;
             smoothers[i]->Verbose(additional_data.verbose);
           }
 
-          break;
-        }
+        break;
+      }
       case cr :
-        {
-          for (unsigned int i=0; i<n_levels-1; ++i)
+      {
+        for (unsigned int i=0; i<n_levels-1; ++i)
           {
             paralution::CR<paralution::LocalMatrix<Number>,paralution::LocalVector<Number>,
-              Number> *cr = NULL;
+                       Number> *cr = NULL;
             cr = new paralution::CR<paralution::LocalMatrix<Number>,paralution::LocalVector<Number>,
-               Number>;
+            Number>;
             smoothers[i] = cr;
             smoothers[i]->Verbose(additional_data.verbose);
           }
 
-          break;
-        }
+        break;
+      }
       case bicgstab :
-        {
-          for (unsigned int i=0; i<n_levels-1; ++i)
+      {
+        for (unsigned int i=0; i<n_levels-1; ++i)
           {
             paralution::BiCGStab<paralution::LocalMatrix<Number>,paralution::LocalVector<Number>,
-              Number> *bicgstab = NULL;
+                       Number> *bicgstab = NULL;
             bicgstab = new paralution::BiCGStab<paralution::LocalMatrix<Number>,
-                     paralution::LocalVector<Number>,Number>;
+            paralution::LocalVector<Number>,Number>;
             smoothers[i] = bicgstab;
             smoothers[i]->Verbose(additional_data.verbose);
           }
 
-          break;
-        }
+        break;
+      }
       case gmres :
-        {
-          for (unsigned int i=0; i<n_levels-1; ++i)
+      {
+        for (unsigned int i=0; i<n_levels-1; ++i)
           {
             paralution::GMRES<paralution::LocalMatrix<Number>,paralution::LocalVector<Number>,
-              Number> *gmres = NULL;
+                       Number> *gmres = NULL;
             gmres = new paralution::GMRES<paralution::LocalMatrix<Number>,
-                  paralution::LocalVector<Number>,Number>;
+            paralution::LocalVector<Number>,Number>;
             smoothers[i] = gmres;
             smoothers[i]->Verbose(additional_data.verbose);
           }
 
-          break;
-        }
+        break;
+      }
       case fgmres :
-        {
-          for (unsigned int i=0; i<n_levels-1; ++i)
+      {
+        for (unsigned int i=0; i<n_levels-1; ++i)
           {
             paralution::FGMRES<paralution::LocalMatrix<Number>,paralution::LocalVector<Number>,
-              Number> *fgmres = NULL;
+                       Number> *fgmres = NULL;
             fgmres = new paralution::FGMRES<paralution::LocalMatrix<Number>,
-                  paralution::LocalVector<Number>,Number>;
+            paralution::LocalVector<Number>,Number>;
             smoothers[i] = fgmres;
             smoothers[i]->Verbose(additional_data.verbose);
           }
 
-          break;
-        }
+        break;
+      }
       default :
-        {
-          AssertThrow(false,ExcMessage("Unknown smoother for AMG."));
-        }
-    }
+      {
+        AssertThrow(false,ExcMessage("Unknown smoother for AMG."));
+      }
+      }
 
     // Preconditioner
     switch (additional_data.preconditioner)
-    {
+      {
       case jacobi :
-        {
-          for (unsigned int i=0; i<n_levels-1; ++i)
+      {
+        for (unsigned int i=0; i<n_levels-1; ++i)
           {
             paralution::Jacobi<paralution::LocalMatrix<Number>,paralution::LocalVector<Number>,
-              Number> *jacobi = NULL;
+                       Number> *jacobi = NULL;
             jacobi = new paralution::Jacobi<paralution::LocalMatrix<Number>,
-                   paralution::LocalVector<Number>,Number>;
+            paralution::LocalVector<Number>,Number>;
             preconds[i] = jacobi;
             smoothers[i]->SetPreconditioner(*preconds[i]);
           }
 
-          break;
-        }
+        break;
+      }
       case sgs :
-        {
-          for (unsigned int i=0; i<n_levels-1; ++i)
+      {
+        for (unsigned int i=0; i<n_levels-1; ++i)
           {
             paralution::SGS<paralution::LocalMatrix<Number>,paralution::LocalVector<Number>,
-              Number> *sgs = NULL;
+                       Number> *sgs = NULL;
             sgs = new paralution::SGS<paralution::LocalMatrix<Number>,paralution::LocalVector<Number>,
-                Number>;
+            Number>;
             preconds[i] = sgs;
             smoothers[i]->SetPreconditioner(*preconds[i]);
           }
 
-          break;
-        }
+        break;
+      }
       case multicolored_sgs :
-        {
-          for (unsigned int i=0; i<n_levels-1; ++i)
+      {
+        for (unsigned int i=0; i<n_levels-1; ++i)
           {
             paralution::MultiColoredSGS<paralution::LocalMatrix<Number>,paralution::LocalVector<Number>,
-              Number> *multicolored_sgs = NULL;
+                       Number> *multicolored_sgs = NULL;
             multicolored_sgs = new paralution::MultiColoredSGS<paralution::LocalMatrix<Number>,
-                             paralution::LocalVector<Number>,Number>;
+            paralution::LocalVector<Number>,Number>;
             multicolored_sgs->SetPrecondMatrixFormat(ELL);
             preconds[i] = multicolored_sgs;
             smoothers[i]->SetPreconditioner(*preconds[i]);
           }
 
-          break;
-        }
+        break;
+      }
       case multicolored_sor :
-        {
-          for (unsigned int i=0; i<n_levels-1; ++i)
+      {
+        for (unsigned int i=0; i<n_levels-1; ++i)
           {
             paralution::MultiColoredGS<paralution::LocalMatrix<Number>,paralution::LocalVector<Number>,
-              Number> *multicolored_sor = NULL;
+                       Number> *multicolored_sor = NULL;
             multicolored_sor = new paralution::MultiColoredGS<paralution::LocalMatrix<Number>,
-                     paralution::LocalVector<Number>,Number>;
+            paralution::LocalVector<Number>,Number>;
             multicolored_sor->SetPrecondMatrixFormat(ELL);
             preconds[i] = multicolored_sor;
             smoothers[i]->SetPreconditioner(*preconds[i]);
           }
 
-          break;
-        }
+        break;
+      }
       case ilu :
-        {
-          for (unsigned int i=0; i<n_levels-1; ++i)
+      {
+        for (unsigned int i=0; i<n_levels-1; ++i)
           {
             paralution::ILU<paralution::LocalMatrix<Number>,paralution::LocalVector<Number>,
-              Number> *ilu = NULL;
+                       Number> *ilu = NULL;
             ilu = new paralution::ILU<paralution::LocalMatrix<Number>,paralution::LocalVector<Number>,
-                Number>;
+            Number>;
             preconds[i] = ilu;
             smoothers[i]->SetPreconditioner(*preconds[i]);
           }
 
-          break;
-        }
+        break;
+      }
       case ilut :
-        {
-          for (unsigned int i=0; i<n_levels-1; ++i)
+      {
+        for (unsigned int i=0; i<n_levels-1; ++i)
           {
             paralution::ILUT<paralution::LocalMatrix<Number>,paralution::LocalVector<Number>,
-              Number> *ilut = NULL;
+                       Number> *ilut = NULL;
             ilut = new paralution::ILUT<paralution::LocalMatrix<Number>,
-                  paralution::LocalVector<Number>,Number>;
+            paralution::LocalVector<Number>,Number>;
             preconds[i] = ilut;
             smoothers[i]->SetPreconditioner(*preconds[i]);
           }
 
-          break;
-        }
+        break;
+      }
       case multicolored_ilu :
-        {
-          for (unsigned int i=0; i<n_levels-1; ++i)
+      {
+        for (unsigned int i=0; i<n_levels-1; ++i)
           {
             paralution::MultiColoredILU<paralution::LocalMatrix<Number>,paralution::LocalVector<Number>,
-              Number> *multicolored_ilu = NULL;
+                       Number> *multicolored_ilu = NULL;
             multicolored_ilu = new paralution::MultiColoredILU<paralution::LocalMatrix<Number>,
-                     paralution::LocalVector<Number>,Number>;
+            paralution::LocalVector<Number>,Number>;
             multicolored_ilu->SetPrecondMatrixFormat(ELL);
             preconds[i] = multicolored_ilu;
             smoothers[i]->SetPreconditioner(*preconds[i]);
           }
 
-          break;
-        }
+        break;
+      }
       default :
-        {
-          AssertThrow(false,ExcMessage("Unknown preconditioner for the smoother for AMG."));
-        }
-    }
+      {
+        AssertThrow(false,ExcMessage("Unknown preconditioner for the smoother for AMG."));
+      }
+      }
 
     // Set the smoothers.
     solver.SetSmoother(smoothers);
@@ -706,60 +706,60 @@ namespace ParalutionWrappers
 
     // Coarse solver
     switch (additional_data.coarse_solver)
-    {
+      {
       case richardson :
-        {
-          paralution::FixedPoint<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
-            Number> *cs = new paralution::FixedPoint<paralution::LocalMatrix<Number>,
-            paralution::LocalVector<Number>, Number>;
-          coarse_solver = cs;
-          break;
-        }
+      {
+        paralution::FixedPoint<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
+                   Number> *cs = new paralution::FixedPoint<paralution::LocalMatrix<Number>,
+        paralution::LocalVector<Number>, Number>;
+        coarse_solver = cs;
+        break;
+      }
       case cg :
-        {
-          paralution::CG<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
-            Number> *cs = new paralution::CG<paralution::LocalMatrix<Number>,
-            paralution::LocalVector<Number>, Number>;
-          coarse_solver = cs;
-          break;
-        }
+      {
+        paralution::CG<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
+                   Number> *cs = new paralution::CG<paralution::LocalMatrix<Number>,
+        paralution::LocalVector<Number>, Number>;
+        coarse_solver = cs;
+        break;
+      }
       case cr :
-        {
-          paralution::CR<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
-            Number> *cs = new paralution::CR<paralution::LocalMatrix<Number>,
-            paralution::LocalVector<Number>, Number>;
-          coarse_solver = cs;
-          break;
-        }
+      {
+        paralution::CR<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
+                   Number> *cs = new paralution::CR<paralution::LocalMatrix<Number>,
+        paralution::LocalVector<Number>, Number>;
+        coarse_solver = cs;
+        break;
+      }
       case bicgstab :
-        {
-          paralution::BiCGStab<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
-            Number> *cs =  new paralution::BiCGStab<paralution::LocalMatrix<Number>,
-            paralution::LocalVector<Number>, Number>;
-          coarse_solver = cs;
-          break;
-        }
+      {
+        paralution::BiCGStab<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
+                   Number> *cs =  new paralution::BiCGStab<paralution::LocalMatrix<Number>,
+        paralution::LocalVector<Number>, Number>;
+        coarse_solver = cs;
+        break;
+      }
       case gmres :
-        {
-          paralution::GMRES<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
-            Number> *cs = new paralution::GMRES<paralution::LocalMatrix<Number>,
-            paralution::LocalVector<Number>, Number>;
-          coarse_solver = cs;
-          break;
-        }
+      {
+        paralution::GMRES<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
+                   Number> *cs = new paralution::GMRES<paralution::LocalMatrix<Number>,
+        paralution::LocalVector<Number>, Number>;
+        coarse_solver = cs;
+        break;
+      }
       case fgmres :
-        {
-          paralution::FGMRES<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
-            Number> *cs = new paralution::FGMRES<paralution::LocalMatrix<Number>,
-            paralution::LocalVector<Number>, Number>;
-          coarse_solver = cs;
-          break;
-        }
+      {
+        paralution::FGMRES<paralution::LocalMatrix<Number>, paralution::LocalVector<Number>,
+                   Number> *cs = new paralution::FGMRES<paralution::LocalMatrix<Number>,
+        paralution::LocalVector<Number>, Number>;
+        coarse_solver = cs;
+        break;
+      }
       default :
-        {
-          AssertThrow(false,ExcMessage("Unknown coarse solver for PreconditionAMG."));
-        }
-    }
+      {
+        AssertThrow(false,ExcMessage("Unknown coarse solver for PreconditionAMG."));
+      }
+      }
     solver.SetSolver(*coarse_solver);
 
     // Set absolute tolerance, relative tolerance, divergence tolerance,
@@ -782,7 +782,7 @@ namespace ParalutionWrappers
     // Let the deal.II SolverControl object know what has happened. If the solve
     // succeeded, the status of the solver control will turn into
     // SolverControl::success. solver_control only exists on the host so the solver
-    // needs to be on the most. 
+    // needs to be on the most.
     solver.MoveToHost();
 
     solver_control.check (solver.GetIterationCount(), solver.GetCurrentResidual());
@@ -793,29 +793,29 @@ namespace ParalutionWrappers
 
     // Free the coarse solver, the preconditioners and the smoothers.
     if (coarse_solver!=NULL)
-    {
-      delete coarse_solver;
-      coarse_solver = NULL;
-    }
+      {
+        delete coarse_solver;
+        coarse_solver = NULL;
+      }
     if (preconds!=NULL)
-    {
-      for (unsigned int i=0; i<n_levels-1; ++i)
-        delete [] preconds[i];
-      delete [] preconds;
-      preconds = NULL;
-    }
+      {
+        for (unsigned int i=0; i<n_levels-1; ++i)
+          delete [] preconds[i];
+        delete [] preconds;
+        preconds = NULL;
+      }
     if (smoothers!=NULL)
-    {
-      for (unsigned int i=0; i<n_levels-1; ++i)
-        delete [] smoothers[i];
-      delete [] smoothers;
-      smoothers = NULL;
-    }
+      {
+        for (unsigned int i=0; i<n_levels-1; ++i)
+          delete [] smoothers[i];
+        delete [] smoothers;
+        smoothers = NULL;
+      }
   }
 
 
 
-  SolverControlSolverAMG::control() const
+  SolverControl &SolverAMG::control() const
   {
     return solver_control;
   }
index bd14accea92f6651d98d7c0004fe386b0ad17dc8..cdea0085593bb383a7821b057249a26819525e79 100644 (file)
@@ -18,6 +18,8 @@
 
 #ifdef DEAL_II_WITH_PARALUTION
 
+#include <algorithm>
+
 DEAL_II_NAMESPACE_OPEN
 
 namespace ParalutionWrappers
@@ -251,7 +253,7 @@ namespace ParalutionWrappers
   {
     AssertThrow (out, ExcIO());
 
-    // get a representation of the vector and loop over all the elements 
+    // get a representation of the vector and loop over all the elements
     out.precision (precision);
     if (scientific)
       out.setf (std::ios::scientific, std::ios::floatfield);
@@ -270,6 +272,13 @@ namespace ParalutionWrappers
     // of the vector
     AssertThrow (out, ExcIO());
   }
+
+
+  template <typename Number>
+  void Vector<Number>::swap(Vector<Number> &v)
+  {
+    std::swap(&local_vector, &(v.paralution_vector()));
+  }
 }
 
 // Explicit instantiations

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.