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");
146 linearSolverBuilder.setParameterList(paramList);
150 RCP<Thyra::LinearOpWithSolveFactoryBase<double> > lowsFactory =
151 linearSolverBuilder.createLinearSolveStrategy(
"");
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");
215 linearSolverBuilder.setParameterList(paramList);
219 RCP<Thyra::LinearOpWithSolveFactoryBase<double> > lowsFactory =
220 linearSolverBuilder.createLinearSolveStrategy(
"");
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());