44#include <Teuchos_ConfigDefs.hpp>
45#include <Teuchos_UnitTestHarness.hpp>
46#include <Teuchos_RCP.hpp>
47#include <Teuchos_ParameterList.hpp>
48#include "Teuchos_XMLParameterListHelpers.hpp"
54 #include "Epetra_MpiComm.h"
56 #include "Epetra_SerialComm.h"
59#include "Epetra_Map.h"
60#include "Epetra_CrsMatrix.h"
61#include "Epetra_Vector.h"
64#include "Thyra_LinearOpBase.hpp"
65#include "Thyra_VectorBase.hpp"
66#include "Thyra_EpetraThyraWrappers.hpp"
67#include "Thyra_EpetraLinearOp.hpp"
68#include "Thyra_LinearOpWithSolveFactoryHelpers.hpp"
69#include "Thyra_LinearOpWithSolveHelpers.hpp"
70#include "Thyra_DefaultZeroLinearOp.hpp"
71#include "Thyra_DefaultProductVector.hpp"
72#include "Thyra_DefaultProductVectorSpace.hpp"
73#include "Thyra_MultiVectorStdOps.hpp"
74#include "Thyra_VectorStdOps.hpp"
75#include "Thyra_DefaultBlockedLinearOp.hpp"
82Teuchos::RCP<Epetra_CrsMatrix>
buildMatrix(
int nx, Epetra_Comm & comm)
84 Epetra_Map map(nx*comm.NumProc(),0,comm);
85 Teuchos::RCP<Epetra_CrsMatrix> mat = Teuchos::rcp(
new Epetra_CrsMatrix(Copy,map,3));
87 int offsets[3] = {-1, 0, 1 };
88 double values[3] = { -1, 2, -1};
89 int maxGid = map.MaxAllGID();
90 for(
int lid=0;lid<nx;lid++) {
91 int gid = mat->GRID(lid);
92 int numEntries = 3, offset = 0;
93 int indices[3] = { gid+offsets[0],
104 mat->InsertGlobalValues(gid,numEntries,values+offset,indices+offset);
115 Epetra_MpiComm Comm(MPI_COMM_WORLD);
117 Epetra_SerialComm Comm;
121 Teuchos::RCP<Epetra_CrsMatrix> mat =
buildMatrix(100,Comm);
122 Teuchos::RCP<Epetra_Vector> x0 = rcp(
new Epetra_Vector(mat->OperatorDomainMap()));
123 Teuchos::RCP<Epetra_Vector> x1 = rcp(
new Epetra_Vector(mat->OperatorDomainMap()));
124 Teuchos::RCP<Epetra_Vector> b = rcp(
new Epetra_Vector(mat->OperatorRangeMap()));
134 RCP<const Thyra::LinearOpBase<double> >
135 tA = Thyra::epetraLinearOp( mat );
136 RCP<Thyra::VectorBase<double> >
137 tx0 = Thyra::create_Vector( x0, tA->domain() );
138 RCP<Thyra::VectorBase<double> >
139 tx1 = Thyra::create_Vector( x1, tA->domain() );
140 RCP<const Thyra::VectorBase<double> >
141 tb = Thyra::create_Vector( b, tA->range() );
144 RCP<Teuchos::ParameterList> paramList = Teuchos::getParametersFromXmlFile(
"BelosGCRODRTest.xml");
150 RCP<Thyra::LinearOpWithSolveFactoryBase<double> > lowsFactory =
154 RCP<Thyra::LinearOpWithSolveBase<double> > lows =
155 Thyra::linearOpWithSolve(*lowsFactory, tA);
158 Thyra::SolveStatus<double> status;
159 status = Thyra::solve<double>(*lows, Thyra::NOTRANS, *tb, tx0.ptr());
160 status = Thyra::solve<double>(*lows, Thyra::NOTRANS, *tb, tx1.ptr());
167 Epetra_MpiComm Comm(MPI_COMM_WORLD);
169 Epetra_SerialComm Comm;
173 Teuchos::RCP<Epetra_CrsMatrix> mat =
buildMatrix(100,Comm);
174 Teuchos::RCP<Epetra_Vector> b = rcp(
new Epetra_Vector(mat->OperatorRangeMap()));
182 RCP<const Thyra::LinearOpBase<double> > tA;
183 RCP<const Thyra::VectorBase<double> > tb;
186 RCP<const Thyra::LinearOpBase<double> > tA_sub
187 = Thyra::epetraLinearOp( mat );
188 RCP<const Thyra::LinearOpBase<double> > zero
189 = Thyra::zero(tA_sub->range(),tA_sub->domain());
191 tA = Thyra::block2x2(tA_sub,zero,zero,tA_sub);
194 RCP<const Thyra::VectorBase<double> > tb_sub
195 = Thyra::create_Vector( b, tA_sub->range() );
197 RCP<Thyra::VectorBase<double> > tb_m = Thyra::createMember(tA->range());
198 Thyra::randomize(-1.0,1.0,tb_m.ptr());
202 RCP<Thyra::VectorBase<double> > tx0;
203 RCP<Thyra::VectorBase<double> > tx1;
205 tx0 = Thyra::createMember(tA->domain());
206 tx1 = Thyra::createMember(tA->domain());
208 Thyra::randomize(-1.0,1.0,tx0.ptr());
209 Thyra::randomize(-1.0,1.0,tx1.ptr());
213 RCP<Teuchos::ParameterList> paramList = Teuchos::getParametersFromXmlFile(
"BelosGCRODRTest.xml");
219 RCP<Thyra::LinearOpWithSolveFactoryBase<double> > lowsFactory =
223 RCP<Thyra::LinearOpWithSolveBase<double> > lows =
224 Thyra::linearOpWithSolve(*lowsFactory, tA);
227 Thyra::SolveStatus<double> status;
228 status = Thyra::solve<double>(*lows, Thyra::NOTRANS, *tb, tx0.ptr());
229 status = Thyra::solve<double>(*lows, Thyra::NOTRANS, *tb, tx1.ptr());
Concrete subclass of Thyra::LinearSolverBuilderBase for creating LinearOpWithSolveFactoryBase objects...
RCP< Thyra::LinearOpWithSolveFactoryBase< Scalar > > createLinearSolveStrategy(const std::string &linearSolveStrategyName) const
void setParameterList(RCP< ParameterList > const ¶mList)
TEUCHOS_UNIT_TEST(belos_gcrodr, multiple_solves)
Teuchos::RCP< Epetra_CrsMatrix > buildMatrix(int nx, Epetra_Comm &comm)