[Trilinos-Users] Const-correctness and MueLu interface

Christopher Thiele ct37 at rice.edu
Tue Nov 26 17:26:45 EST 2019


Hi everyone,

I am currently integrating MueLu into an existing simulator code. I got 
it to work both as a solver and as a preconditioner, but I had to use 
some "hacks" regarding the interface. In my code, MueLu is a 
specialization of an abstract solver base class with the following 
interface:

MySolver::set_operator(const Matrix &A);
MySolver::solve(const Vector &b, Vector &x);

Unfortunately, MueLu's interface does not seem to allow the construction 
of a multigrid hierarchy from a constant matrix, since both

hierarchy->GetLevel(0)->Set("A", /* ... */);

and

MueLu::CreateTpetraPreconditioner(/* ... */);

require (pointers to) non-const matrices. Furthermore, the helper 
functions MueLu::TpetraCrs_To_XpetraMatrix and 
MueLu::TpetraMultiVector_To_XpetraMultiVector do not seem to accept 
(pointers to) non-const objects either.

Everything seems to work fine if I simply use const_cast with the above 
functions, but of course I would like to avoid this hack. Is there a 
reason why these functions do not accept constant matrices and vectors, 
i.e., do I have to copy the entire matrix before constructing the 
multigrid solver?

Best regards,
Christopher


More information about the Trilinos-Users mailing list