[Trilinos-Users] Copying Amesos2 Solver and Tpetra MultiVectors

D H mrhyde at stanford.edu
Sat Jun 7 11:29:55 MDT 2014


Hi everyone,

I am new to working with Trilinos and have what is hopefully an easy C++/Trilinos question.

I'm working with Amesos2 to solve linear systems, and I have code that is structured like:

class A {
...
public B b_instance;
...
}

class B {
...
public Teuchos::RCP<Amesos2::Solver< Tpetra::CrsMatrix<double,int,int,Tpetra::DefaultPlatform::DefaultPlatformType::NodeType> , Tpetra::MultiVector<double,int,int,Tpetra::DefaultPlatform::DefaultPlatformType::NodeType> > > amesos2_solver;
public Teuchos::RCP< Tpetra::MultiVector<double,int,int,Tpetra::DefaultPlatform::DefaultPlatformType::NodeType> > amesos2_X;
public Teuchos::RCP< Tpetra::MultiVector<double,int,int,Tpetra::DefaultPlatform::DefaultPlatformType::NodeType> > amesos2_B;
...
}

In my program, I have several instances of class A.  For the first instance, I use its b_instance to compute the numeric (LU) factorization of a sparse matrix, which is another class variable of B.  At that point, amesos2_X and amesos2_B are just random Nx1 vectors, but they have been associated with amesos2_solver using "amesos2_solver = Amesos2::create<MAT,MV>(solver_name, my_matrix, amesos2_X, amesos2_B);".

So now, what I would like to do is to copy the amesos2_solver, amesos2_X, and amesos2_B variables into the b_instances of my other instances of class A.  I don't want to just create copies of pointers that are all pointing to the same place - I would like separate variables that contain the same information.  The motivation for this is so I can create several independent solvers with the same matrix but only have to compute the LU factorization once.

Can you recommend what is the best way to copy these variabes, or the underlying computed factorization, to other instances?  I'd be very grateful for any help you can provide - thanks very much!

Best regards,

David


More information about the Trilinos-Users mailing list