]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Enable Trilinos direct solvers with LA::distributed::Vector.
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Fri, 10 Nov 2017 13:50:09 +0000 (14:50 +0100)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Fri, 10 Nov 2017 14:47:41 +0000 (15:47 +0100)
include/deal.II/lac/trilinos_solver.h
source/lac/trilinos_solver.cc

index 17e672d3429edf6229d656025917bd81be1402b5..38d63ac5defcb6931dadb0fe26cecdd98882f784 100644 (file)
@@ -645,6 +645,15 @@ namespace TrilinosWrappers
      */
     void solve (MPI::Vector &x, const MPI::Vector &b);
 
+    /**
+     * Solve the linear system <tt>Ax=b</tt> based on the package set in
+     * intialize() for deal.II's own parallel vectors. Note the matrix is not
+     * refactorized during this call.
+     */
+    void
+    solve (dealii::LinearAlgebra::distributed::Vector<double>       &x,
+           const dealii::LinearAlgebra::distributed::Vector<double> &b);
+
     /**
      * Solve the linear system <tt>Ax=b</tt>. Creates a factorization of the
      * matrix with the package chosen from the additional data structure and
index 2839e10dc26ef83187f60072a8fc5a0dc9c8c101..79c19a658eabe7255dc46c95f1e277cca933e988 100644 (file)
@@ -780,17 +780,45 @@ namespace TrilinosWrappers
     // Assign the RHS vector to the Epetra_LinearProblem object
     linear_problem->SetRHS(const_cast<Epetra_MultiVector *>(&b.trilinos_vector()));
 
+    // First set whether we want to print the solver information to screen or
+    // not.
+    ConditionalOStream verbose_cout (std::cout,
+                                     additional_data.output_solver_details);
+
+
+    verbose_cout << "Starting solve" << std::endl;
+
     // Fetch return value of Amesos Solver functions
-    int ierr;
+    int ierr = solver->Solve ();
+    AssertThrow (ierr == 0, ExcTrilinosError (ierr));
+
+    // Finally, force the SolverControl object to report convergence
+    solver_control.check (0, 0);
+  }
+
+
+
+  void SolverDirect::solve (dealii::LinearAlgebra::distributed::Vector<double>       &x,
+                            const dealii::LinearAlgebra::distributed::Vector<double> &b)
+  {
+    Epetra_Vector ep_x (View, linear_problem->GetOperator()->OperatorDomainMap(), x.begin());
+    Epetra_Vector ep_b (View, linear_problem->GetOperator()->OperatorRangeMap(), const_cast<double *>(b.begin()));
+
+    // Assign the empty LHS vector to the Epetra_LinearProblem object
+    linear_problem->SetLHS(&ep_x);
+
+    // Assign the RHS vector to the Epetra_LinearProblem object
+    linear_problem->SetRHS(&ep_b);
 
     // First set whether we want to print the solver information to screen or
     // not.
     ConditionalOStream verbose_cout (std::cout,
                                      additional_data.output_solver_details);
 
-
     verbose_cout << "Starting solve" << std::endl;
-    ierr = solver->Solve ();
+
+    // Fetch return value of Amesos Solver functions
+    int ierr = solver->Solve ();
     AssertThrow (ierr == 0, ExcTrilinosError (ierr));
 
     // Finally, force the SolverControl object to report convergence
@@ -917,7 +945,6 @@ namespace TrilinosWrappers
 
     do_solve();
   }
-
 }
 
 

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.