[Trilinos-Users] Thyra Operator from Tpetra MultiVector

Bartlett, Roscoe A. bartlettra at ornl.gov
Mon Jul 29 09:34:29 MDT 2013


You are likely getting bit by C++ template implicit (non) conversion problems.  The issue and workarounds are described in detail in Section 5.7.3 in:


If one of those approaches does not fix you problem, let me know.


From: trilinos-users-bounces at software.sandia.gov [mailto:trilinos-users-bounces at software.sandia.gov] On Behalf Of Einar Otnes
Sent: Monday, July 22, 2013 1:00 PM
To: trilinos-users at software.sandia.gov
Subject: [Trilinos-Users] Thyra Operator from Tpetra MultiVector

Dear experts,

I'm currently trying to learn how to use the Thyra-Tpetra adapters such that I can use the Thyra framework with Tpetra distributed vectors.

I have been able to use Tpetra vectors, but I'm still struggling with obtaining  a Thyra Linear operator  from Tpetra MultiVector. The code snippet below will not compile due to the last statement where I try to create a Thyra Linear operator from Tpetra multiVector. What am I doing wrong?

Thank you so much for your help.

Best regards,

Einar Otnes


#include <Teuchos_Comm.hpp>

#include <Tpetra_DefaultPlatform.hpp>
#include <Tpetra_Vector.hpp>
#include <Tpetra_MultiVector.hpp>
#include <Tpetra_Map.hpp>

#include "Thyra_TpetraThyraWrappers.hpp"

#include "Thyra_VectorBase.hpp"
#include "Thyra_MultiVectorBase.hpp"
#include "Thyra_LinearOpBase.hpp"
#include "Thyra_OperatorVectorClientSupport.hpp"

int main(int argc, char* argv[]) {

      using Teuchos::RCP;

      typedef int     LO;
      typedef long    GO;
      typedef double  ST;

      typedef Kokkos::DefaultNode::DefaultNodeType             node_type;
      typedef Tpetra::Map<LO, GO, node_type>                   map_type;
      typedef Thyra::TpetraVectorSpace<ST,LO,GO,node_type >    VSpace;
      typedef Thyra::VectorSpaceBase<ST>                       VSB;
      typedef Thyra::TpetraVector<ST, LO, GO, node_type>       V;
      typedef Tpetra::MultiVector<ST, LO, GO, node_type>       MV;
      typedef Thyra::VectorBase<ST>                            VB;
      typedef Thyra::MultiVectorBase<ST>                       MVB;
      typedef Thyra::LinearOpBase<ST>                          LOP;

      Teuchos::oblackholestream blackHole;
      Teuchos::GlobalMPISession mpiSession (&argc, &argv, &blackHole);

      RCP<const Teuchos::Comm<int> > comm = Tpetra::DefaultPlatform::getDefaultPlatform().getComm();
      RCP<node_type> node                 = Kokkos::DefaultNode::getDefaultNode ();

      // Set problem size
      size_t m =  12;
      size_t n =  12;

      RCP<const map_type> rngMap = rcp (new map_type (m, 0, comm, Tpetra::GloballyDistributed, node));
      RCP<const map_type> domMap = rcp (new map_type (n, 0, comm, Tpetra::GloballyDistributed, node));

      RCP<VSpace> domSp = Thyra::tpetraVectorSpace<ST,LO,GO,node_type>(domMap);
      RCP<VSpace> rngSp = Thyra::tpetraVectorSpace<ST,LO,GO,node_type>(rngMap);

      RCP<VB> x =Thyra::tpetraVector<ST,LO,GO,node_type>(
                    domSp, rcp(new Tpetra::Vector<ST, LO, GO, node_type>(domMap))

      RCP<VB> b =Thyra::tpetraVector<ST,LO,GO,node_type>(
                    rngSp, rcp(new Tpetra::Vector<ST, LO, GO, node_type>(rngMap))

      // !!!!!!!!!!!! Here is my problem.

      // How do I define a Thyra operator from a Tpetra multiVector?
      // I want this operator to be able to operate on "x" to create "b", i.e. b=Ax.
      // My suggestion below doesn't compile, but I cannot figure out how to make this work...

//    RCP<LOP> A = Thyra::tpetraMultiVector(rngSp,
//                  rcp(new Thyra::tpetraVectorSpace<ST,LO,GO,node_type>(domMap)),
//                  rcp(new Tpetra::MultiVector<ST,LO,GO,node_type>(rngMap,domMap->getGlobalNumElements()))
//    );

      return EXIT_SUCCESS;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://software.sandia.gov/pipermail/trilinos-users/attachments/20130729/509ebe82/attachment.html 

More information about the Trilinos-Users mailing list