On 7/15/22 07:35, 沈键 wrote:
**

  In step58, it suggested to use iterative solver to improve performance. And I tried gmres, but program threw error: "solver_gmres.h:676:13: error: cannot convert ‘std::complex<double>’ to ‘double’ in assignment". My code is as follows:

void TEST_Solver_Complex::solve() {
   LogStream::Prefix p("Solve");
   deallog << "Solving linear system..." << std::endl;

   // SparseDirectUMFPACK direct_solver;
   // solution = system_rhs;
   // direct_solver.solve(system_matrix, solution);
   SolverControl   solver_control(std::max<std::size_t>(1000,
                                                        system_rhs.size() / 10),
                                  1e-10 * system_rhs.l2_norm());
   SolverGMRES<Vector<std::complex<double>>> solver(solver_control);
   PreconditionJacobi<SparseMatrix<std::complex<double>>> preconditioner;
   preconditioner.initialize(system_matrix, 1.0);
   solver.solve(system_matrix, solution, system_rhs, preconditioner);

   deallog << "Done." << std::endl;
}

Can anyone point out what's wrong with this code snip snippet? Thanks for your help.

I don't think you're doing anything wrong. SolverGMRES is simply not implemented for complex-valued linear systems.

If you wanted to go this route, you'd need to find the right papers that describe how to implement GMRES for complex arithmetic, and then implement that (or modify the existing GMRES implementation). Or you treat the linear system as a 2x2 block system in real/non-complex variables (like in step-29) for which one could come up with block preconditioners and then apply the existing GMRES implementation.

Best
 W.

--
------------------------------------------------------------------------
Wolfgang Bangerth          email:                 [email protected]
                           www: http://www.math.colostate.edu/~bangerth/

--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/9f477616-0edb-f063-2ae8-6602afadb983%40colostate.edu.

Reply via email to