[Trilinos-Users] [EXTERNAL] How to create a new operator from Belos:Operator

Thornquist, Heidi K hkthorn at sandia.gov
Thu Mar 29 12:53:18 EDT 2018


Hi Hui,

It looks like there is an issue with how the templates are being instantiated in the code that creates the Belos solver.  An example of how you can interact with the Belos CG solvers, given a specialized operator, is in:

Trilinos/packages/belos/test/BlockCG/test_bl_cg_complex_hb.cpp

From the error, I see that the instantiation of the linear problem object is being done with a mixed template, where the multi-vector is an Epetra_MultiVector and the operator is a Belos::Operator<double>.
The multi-vector and operator template need to be compatible, so either they are both Epetra objects or they are both Belos::MultiVec<double>/Belos::Operator<double> objects.

Is your specialized operator written to apply to Epetra_MultiVector objects?  If so, then the Belos::EpetraMultiVec class is written to inherit from both the Epetra_MultiVector and the Belos::MultiVec<double> classes.
That would be your best path forward.

Let me know if you have any other questions.

Thanks,
Heidi

--

Heidi K. Thornquist
Electrical Models & Simulation
Sandia National Laboratories




From: Trilinos-Users <trilinos-users-bounces at trilinos.org> on behalf of "Wu, Hui" <wu40 at llnl.gov>
Date: Thursday, March 29, 2018 at 10:39 AM
To: "trilinos-users at trilinos.org" <trilinos-users at trilinos.org>
Subject: [EXTERNAL] [Trilinos-Users] How to create a new operator from Belos:Operator


I am trying to solve a problem Ax = b using Belos::BlockCGSolMgr where A is a dense matrix and I don't want to calculate and store A. Therefore I cannot use Epetra_Operator as OP in Belos::LinearProblem<ScalarType, MV, OP>. I need to create a new operator to do Ax. I considered the example mentioned here: https://github.com/trilinos/Trilinos/blob/master/packages/belos/test/MVOPTester/MyBetterOperator.hpp



In the new operator, I write a function Apply to do Ax.



However, the following compiling error shows up:


BelosOperatorTraits.hpp(71): error: class "Belos::Operator<double>" has no member "this_type_is_missing_a_specialization"
        OP::this_type_is_missing_a_specialization();
            ^
          detected during:
            instantiation of "void Belos::UndefinedOperatorTraits<ScalarType, MV, OP>::notDefined() [with ScalarType=double, MV=Epetra_MultiVector, OP=Belos::Operator<double>]" at line 131
            instantiation of "void Belos::OperatorTraits<ScalarType, MV, OP>::Apply(const OP &, const MV &, MV &, Belos::ETrans) [with ScalarType=double, MV=Epetra_MultiVector, OP=Belos::Operator<double>]" at line 1130 of "BelosLinearProblem.hpp"
            instantiation of "void Belos::LinearProblem<ScalarType, MV, OP>::computeCurrResVec(MV *, const MV *, const MV *) const [with ScalarType=double, MV=Epetra_MultiVector, OP=Belos::Operator<double>]" at line 867 of "BelosLinearProblem.hpp"
            instantiation of "bool Belos::LinearProblem<ScalarType, MV, OP>::setProblem(const Teuchos::RCP<MV> &, const Teuchos::RCP<const MV> &) [with ScalarType=double, MV=Epetra_MultiVector, OP=Belos::Operator<double>]"


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


More information about the Trilinos-Users mailing list