[Trilinos-Users] [EXTERNAL] Amesos2 with Epetra

Rajamanickam, Sivasankaran srajama at sandia.gov
Tue Nov 13 14:12:35 EST 2018


Daniel

  We didn't plan support for the FECrsMatrix and this seems to be the root cause of the problem.


  If converting it to CrsMatrix is an ok solution, please go ahead.


Thanks

Siva


________________________________
From: Trilinos-Users <trilinos-users-bounces at trilinos.org> on behalf of Daniel Santos <dsantosolivan at gmail.com>
Sent: Tuesday, November 13, 2018 10:55 AM
To: Gates, Jason Matthew
Cc: Bartlett, Roscoe A; trilinos-users at trilinos.org
Subject: Re: [Trilinos-Users] [EXTERNAL] Amesos2 with Epetra

Hello,

Thank you for the reference, Roscoe.  I have checked it many times and has been very useful but in this case, the problem had nothing to do with that.

Thank you again, Jason. I have changed to CrsMatrix and now it compiles perfectly but when it runs I get a SegFault. What I have really is a FeCrsMatrix and it is what I am passing to the creator, could be this the problem? I have redone the mentioned example with CrsMatrix and that works perfectly. I will try in my code to copy the FECrsMatrix into a CrsMatrix to check if it is that the problem.

Thanks again,
Daniel.



On Tue, Nov 13, 2018 at 5:47 PM Gates, Jason Matthew <jmgate at sandia.gov<mailto:jmgate at sandia.gov>> wrote:
Perhaps try switching Epetra_RowMatrix to Epetra_CrsMatrix for the first template parameter to the Amesos2::create call?

On Nov 13, 2018, at 9:37 AM, Bartlett, Roscoe A <rabartl at sandia.gov<mailto:rabartl at sandia.gov>> wrote:

Hello Daniel,

To learn how to use memory in C++ using smart pointers like RCP, please see the document:

   https://bartlettroscoe.github.io/RefCountPtrBeginnersGuideSAND.pdf

Cheers,

-Ross

Dr. Roscoe A. Bartlett, PhD
http://www.cs.sandia.gov/cr-rabartl
Sandia National Laboratories

From: Trilinos-Users [mailto:trilinos-users-bounces at trilinos.org] On Behalf Of Daniel Santos
Sent: Tuesday, November 13, 2018 11:25 AM
To: Gates, Jason Matthew <jmgate at sandia.gov<mailto:jmgate at sandia.gov>>
Cc: trilinos-users at trilinos.org<mailto:trilinos-users at trilinos.org>
Subject: Re: [Trilinos-Users] [EXTERNAL] Amesos2 with Epetra

Hello Jason,

Thank you very much for your answer. I tried something like this but I thought it was returning an RCP pointer as in the example.
I don't think it has something to do with that because I have tried to catch the return with auto / auto* as:
auto sp =  Amesos2::create<Epetra_RowMatrix, Epetra_MultiVector>("Superlu", linearProblem->GetMatrix(), linearProblem->GetLHS(), linearProblem->GetRHS()));

In the example, with Tpetra it works perfectly but here I still get the errors about the adapter:

....../trilinos/include/Amesos2_MatrixAdapter_def.hpp: In instantiation of ‘Teuchos::RCP<const Amesos2::MatrixAdapter<Matrix> > Amesos2::createConstMatrixAdapter(Teuchos::RCP<const T>) [with Matrix = Epetra_RowMatrix]’:
....../trilinos/include/Amesos2_SolverCore_def.hpp:70:46:   required from ‘Amesos2::SolverCore<ConcreteSolver, Matrix, Vector>::SolverCore(Teuchos::RCP<const T2>, Teuchos::RCP<T>, Teuchos::RCP<const Serializer>) [with ConcreteSolver = Amesos2::KLU2; Matrix = Epetra_RowMatrix; Vector = Epetra_MultiVector]’
....../trilinos/include/Amesos2_KLU2_def.hpp:75:24:   required from ‘Amesos2::KLU2< <template-parameter-1-1>, <template-parameter-1-2> >::KLU2(Teuchos::RCP<const T>, Teuchos::RCP<T2>, Teuchos::RCP<const T2>) [with Matrix = Epetra_RowMatrix; Vector = Epetra_MultiVector]’
....../trilinos/include/Amesos2_Factory.hpp:361:19:   required from ‘static Teuchos::RCP<Amesos2::Solver<Matrix, Vector> > Amesos2::create_solver_with_supported_type<ConcreteSolver, Matrix, Vector>::apply(Teuchos::RCP<const T2>, Teuchos::RCP<T>, Teuchos::RCP<const Serializer>) [with ConcreteSolver = Amesos2::KLU2; Matrix = Epetra_RowMatrix; Vector = Epetra_MultiVector]’
....../trilinos/include/Amesos2_Factory.hpp:413:87:   required from ‘static Teuchos::RCP<Amesos2::Solver<Matrix, Vector> > Amesos2::handle_solver_type_support<ConcreteSolver, Matrix, Vector>::apply(Teuchos::RCP<const T2>, Teuchos::RCP<T>, Teuchos::RCP<const Serializer>) [with ConcreteSolver = Amesos2::KLU2; Matrix = Epetra_RowMatrix; Vector = Epetra_MultiVector]’
....../trilinos/include/Amesos2_Factory.hpp:552:67:   required from ‘Teuchos::RCP<Amesos2::Solver<Matrix, Vector> > Amesos2::create(std::__cxx11::string, Teuchos::RCP<const T>, Teuchos::RCP<T2>, Teuchos::RCP<const T2>) [with Matrix = Epetra_RowMatrix; Vector = Epetra_MultiVector; std::__cxx11::string = std::__cxx11::basic_string<char>]’
....../trilinos/include/Amesos2_Factory.hpp:476:19:   required from ‘Amesos2::Solver<Matrix, Vector>* Amesos2::create(const char*, const Matrix*, Vector*, const Vector*) [with Matrix = Epetra_RowMatrix; Vector = Epetra_MultiVector]’
.......Solvers_Direct_Amesos2.cpp:32:161:   required from here
....../trilinos/include/Amesos2_MatrixAdapter_def.hpp:578:17: error: no matching function for call to ‘Amesos2::ConcreteMatrixAdapter<Epetra_RowMatrix>::ConcreteMatrixAdapter(Teuchos::RCP<Epetra_RowMatrix>)’
     return( rcp(new ConcreteMatrixAdapter<Matrix>(rcp_const_cast<Matrix,const Matrix>(m))).getConst() );
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ....../trilinos/include/Amesos2_TpetraRowMatrix_AbstractMatrixAdapter_def.hpp:48,
                 from ....../trilinos/include/Amesos2_AbstractConcreteMatrixAdapter_def.hpp:47,
                 from ....../trilinos/include/Amesos2_ConcreteMatrixAdapter_def.hpp:48,
                 from ....../trilinos/include/Amesos2_MatrixAdapter_def.hpp:49,
                 from ....../trilinos/include/Amesos2_SolverCore_def.hpp:56,
                 from ....../trilinos/include/Amesos2_SolverCore.hpp:50,
                 from ....../trilinos/include/Amesos2_KLU2_decl.hpp:56,
                 from ....../trilinos/include/Amesos2_KLU2.hpp:47,
                 from ....../trilinos/include/Amesos2_Factory.hpp:104,
                 from ....../trilinos/include/Amesos2.hpp:45,
                 from .......Solvers_Direct_Amesos2.cpp:2:
....../trilinos/include/Amesos2_ConcreteMatrixAdapter_decl.hpp:51:9: note: candidate: ‘constexpr Amesos2::ConcreteMatrixAdapter<Epetra_RowMatrix>::ConcreteMatrixAdapter()’
   class ConcreteMatrixAdapter {};
         ^~~~~~~~~~~~~~~~~~~~~
....../trilinos/include/Amesos2_ConcreteMatrixAdapter_decl.hpp:51:9: note:   candidate expects 0 arguments, 1 provided
....../trilinos/include/Amesos2_ConcreteMatrixAdapter_decl.hpp:51:9: note: candidate: ‘constexpr Amesos2::ConcreteMatrixAdapter<Epetra_RowMatrix>::ConcreteMatrixAdapter(const Amesos2::ConcreteMatrixAdapter<Epetra_RowMatrix>&)’
....../trilinos/include/Amesos2_ConcreteMatrixAdapter_decl.hpp:51:9: note:   no known conversion for argument 1 from ‘Teuchos::RCP<Epetra_RowMatrix>’ to ‘const Amesos2::ConcreteMatrixAdapter<Epetra_RowMatrix>&’
....../trilinos/include/Amesos2_ConcreteMatrixAdapter_decl.hpp:51:9: note: candidate: ‘constexpr Amesos2::ConcreteMatrixAdapter<Epetra_RowMatrix>::ConcreteMatrixAdapter(Amesos2::ConcreteMatrixAdapter<Epetra_RowMatrix>&&)’
....../trilinos/include/Amesos2_ConcreteMatrixAdapter_decl.hpp:51:9: note:   no known conversion for argument 1 from ‘Teuchos::RCP<Epetra_RowMatrix>’ to ‘Amesos2::ConcreteMatrixAdapter<Epetra_RowMatrix>&&’
In file included from ....../trilinos/include/Amesos2_SolverCore_def.hpp:56,
                 from ....../trilinos/include/Amesos2_SolverCore.hpp:50,
                 from ....../trilinos/include/Amesos2_KLU2_decl.hpp:56,
                 from ....../trilinos/include/Amesos2_KLU2.hpp:47,
                 from ....../trilinos/include/Amesos2_Factory.hpp:104,
                 from ....../trilinos/include/Amesos2.hpp:45,
                 from .......Solvers_Direct_Amesos2.cpp:2:
....../trilinos/include/Amesos2_MatrixAdapter_def.hpp: In instantiation of ‘Amesos2::MatrixAdapter<Matrix>::global_size_t Amesos2::MatrixAdapter<Matrix>::getGlobalNumRows() const [with Matrix = Epetra_RowMatrix; Amesos2::MatrixAdapter<Matrix>::global_size_t = long unsigned int]’:
....../trilinos/include/Amesos2_SolverCore_def.hpp:80:44:   required from ‘Amesos2::SolverCore<ConcreteSolver, Matrix, Vector>::SolverCore(Teuchos::RCP<const T2>, Teuchos::RCP<T>, Teuchos::RCP<const Serializer>) [with ConcreteSolver = Amesos2::KLU2; Matrix = Epetra_RowMatrix; Vector = Epetra_MultiVector]’
....../trilinos/include/Amesos2_KLU2_def.hpp:75:24:   required from ‘Amesos2::KLU2< <template-parameter-1-1>, <template-parameter-1-2> >::KLU2(Teuchos::RCP<const T>, Teuchos::RCP<T2>, Teuchos::RCP<const T2>) [with Matrix = Epetra_RowMatrix; Vector = Epetra_MultiVector]’
....../trilinos/include/Amesos2_Factory.hpp:361:19:   required from ‘static Teuchos::RCP<Amesos2::Solver<Matrix, Vector> > Amesos2::create_solver_with_supported_type<ConcreteSolver, Matrix, Vector>::apply(Teuchos::RCP<const T2>, Teuchos::RCP<T>, Teuchos::RCP<const Serializer>) [with ConcreteSolver = Amesos2::KLU2; Matrix = Epetra_RowMatrix; Vector = Epetra_MultiVector]’
....../trilinos/include/Amesos2_Factory.hpp:413:87:   required from ‘static Teuchos::RCP<Amesos2::Solver<Matrix, Vector> > Amesos2::handle_solver_type_support<ConcreteSolver, Matrix, Vector>::apply(Teuchos::RCP<const T2>, Teuchos::RCP<T>, Teuchos::RCP<const Serializer>) [with ConcreteSolver = Amesos2::KLU2; Matrix = Epetra_RowMatrix; Vector = Epetra_MultiVector]’
....../trilinos/include/Amesos2_Factory.hpp:552:67:   required from ‘Teuchos::RCP<Amesos2::Solver<Matrix, Vector> > Amesos2::create(std::__cxx11::string, Teuchos::RCP<const T>, Teuchos::RCP<T2>, Teuchos::RCP<const T2>) [with Matrix = Epetra_RowMatrix; Vector = Epetra_MultiVector; std::__cxx11::string = std::__cxx11::basic_string<char>]’
....../trilinos/include/Amesos2_Factory.hpp:476:19:   required from ‘Amesos2::Solver<Matrix, Vector>* Amesos2::create(const char*, const Matrix*, Vector*, const Vector*) [with Matrix = Epetra_RowMatrix; Vector = Epetra_MultiVector]’
.......Solvers_Direct_Amesos2.cpp:32:161:   required from here
....../trilinos/include/Amesos2_MatrixAdapter_def.hpp:131:12: error: invalid static_cast from type ‘const Amesos2::MatrixAdapter<Epetra_RowMatrix>*’ to type ‘const adapter_t*’ {aka ‘const Amesos2::ConcreteMatrixAdapter<Epetra_RowMatrix>*’}
     return static_cast<const adapter_t*>(this)->getGlobalNumRows_impl();

On Tue, Nov 13, 2018 at 4:49 PM Gates, Jason Matthew <jmgate at sandia.gov<mailto:jmgate at sandia.gov>> wrote:
A Teuchos expert might want to chime in to confirm this, but I suspect you could either:

  *   Remove the Teuchos::RCP<…> that’s wrapping the type on the left hand side for your solver variable, or
  *   Use something along the lines of Teuchos::rcpFromRef(…) to wrap the right hand side.

It looks like the problem is the left hand side is currently a pointer type, while the right hand side isn’t.

Hope this helps,

Jason M. Gates


On Nov 13, 2018, at 2:56 AM, Daniel Santos <dsantosolivan at gmail.com<mailto:dsantosolivan at gmail.com>> wrote:

Good morning,

I am trying to use the Amesos2 package with Epetra matrices/vectors. The problem is that I have not found any tutorial for doing that.

I have started with the tutorial: SimpleSolve (https://trilinos.org/docs/dev/packages/amesos2/doc/html/SimpleSolve_8cpp-example.html) and that one compiles and run without a problem (with Klu solver).
Then I try to use the same in my code:
Teuchos::RCP<Amesos2::Solver<Epetra_RowMatrix, Epetra_MultiVector>> solver = Amesos2::create<Epetra_RowMatrix, Epetra_MultiVector>("Superlu", linearProblem->GetMatrix(), linearProblem->GetLHS(), linearProblem->GetRHS());
where linearProblem is a Epetra_LinearProblem.
In that case, I get a lot of errors about the Adapters of Epetra like these:
/......cpp:32:139: error: conversion from ‘Amesos2::Solver<Epetra_RowMatrix, Epetra_MultiVector>*’ to non-scalar type ‘Teuchos::RCP<Amesos2::Solver<Epetra_RowMatrix, Epetra_MultiVector> >’ requested
         Teuchos::RCP<Amesos2::Solver<Epetra_RowMatrix, Epetra_MultiVector>> solver = Amesos2::create<Epetra_RowMatrix, Epetra_MultiVector>("Superlu", linearProblem->GetMatrix(), linearProblem->GetLHS(), linearProblem->GetRHS());
/...../trilinos/include/Amesos2_MatrixAdapter_def.hpp:578:17: error: no matching function for call to ‘Amesos2::ConcreteMatrixAdapter<Epetra_RowMatrix>::ConcreteMatrixAdapter(Teuchos::RCP<Epetra_RowMatrix>)’
     return( rcp(new ConcreteMatrixAdapter<Matrix>(rcp_const_cast<Matrix,const Matrix>(m))).getConst() );
How should I correctly use this?
Thank you very much,
Daniel Santos-Oliván.
_______________________________________________
Trilinos-Users mailing list
Trilinos-Users at trilinos.org<mailto:Trilinos-Users at trilinos.org>
https://trilinos.org/mailman/listinfo/trilinos-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://trilinos.org/pipermail/trilinos-users/attachments/20181113/a293972e/attachment.html>


More information about the Trilinos-Users mailing list