46#include "Thyra_DefaultScaledAdjointLinearOp.hpp"
47#include "Thyra_DefaultMultipliedLinearOp.hpp"
48#include "Thyra_DefaultDiagonalLinearOp.hpp"
49#include "Thyra_VectorStdOps.hpp"
50#include "Thyra_TestingTools.hpp"
51#include "Thyra_LinearOpTester.hpp"
54#include "EpetraExt_readEpetraLinearSystem.h"
62# include "Epetra_MpiComm.h"
64# include "Epetra_SerialComm.h"
77using Thyra::VectorBase;
78using Thyra::LinearOpBase;
79using Thyra::createMember;
80using Thyra::LinearOpTester;
86std::string matrixFile =
"";
87std::string matrixFile2 =
"";
93 "matrix-file", &matrixFile,
94 "Defines the Epetra_CrsMatrix to read in." );
96 "matrix-file-2", &matrixFile2,
97 "Defines the second Epetra_CrsMatrix to read in." );
102buildBDGOperator(
int scenario,
const Teuchos::RCP<
const Thyra::LinearOpBase<double> > &
B,
103 const Teuchos::RCP<
const Thyra::LinearOpBase<double> > & G,
104 const double vecScale, std::ostream & out)
114 d = createMember(
B->domain(),
"d");
116 d = createMember(
B->range(),
"d");
117 V_S( d.
ptr(), vecScale );
123 M = multiply( scale(scalea,
B), diagonal(d), scale(scaleb,G),
"M" );
124 out <<
" Testing B*D*G" << std::endl;
127 M = multiply( scale(scalea,
B), diagonal(d), adjoint(G),
"M" );
128 out <<
" Testing B*D*adj(G)" << std::endl;
131 M = multiply( adjoint(
B), diagonal(d), scale(scaleb,G),
"M" );
132 out <<
" Testing adj(B)*D*G" << std::endl;
135 M = multiply( adjoint(
B), diagonal(d), adjoint(G),
"M" );
136 out <<
" Testing adj(B)*D*adj(G)" << std::endl;
139 M = multiply(
B, scale(scaled,diagonal(d)), G,
"M" );
140 out <<
" Testing B*(52.0*D)*G" << std::endl;
146 out <<
"\nM = " << *M;
153buildBGOperator(
int scenario,
const Teuchos::RCP<
const Thyra::LinearOpBase<double> > &
B,
154 const Teuchos::RCP<
const Thyra::LinearOpBase<double> > & G,
166 M = multiply( scale(scalea,
B), scale(scaleb,G),
"M" );
167 out <<
" Testing B*G" << std::endl;
170 M = multiply( scale(scalea,
B), adjoint(G),
"M" );
171 out <<
" Testing B*adj(G)" << std::endl;
174 M = multiply( adjoint(
B), scale(scaleb,G),
"M" );
175 out <<
" Testing adj(B)*G" << std::endl;
178 M = multiply( adjoint(
B), adjoint(G),
"M" );
179 out <<
" Testing adj(B)*adj(G)" << std::endl;
185 out <<
"\nM = " << *M;
191buildBDBOperator(
int scenario,
const Teuchos::RCP<
const Thyra::LinearOpBase<double> > &
B,
192 const double vecScale, std::ostream & out)
194 return buildBDGOperator(scenario,
B,
B,vecScale,out);
206 out <<
"\nReading linear system in Epetra format from the file \'"<<matrixFile<<
"\' ...\n";
209 Epetra_MpiComm comm(MPI_COMM_WORLD);
211 Epetra_SerialComm comm;
214 EpetraExt::readEpetraLinearSystem( matrixFile, comm, &epetra_B, NULL, NULL, NULL );
229 for(
int scenario=1;scenario<=5;scenario++) {
243 BtDB_transformer->transform( *M, M_explicit.
ptr() );
245 out <<
"\nM_explicit = " << *M_explicit;
251 LinearOpTester<double> M_explicit_tester;
252 M_explicit_tester.show_all_tests(
true);;
254 const bool result = M_explicit_tester.compare( *M, *M_explicit, Teuchos::inoutArg(out) );
255 if (!result) success =
false;
267 out <<
"\nReading linear system in Epetra format from the file \'"<<matrixFile<<
"\'";
268 out <<
" and from the file \'"<<matrixFile2<<
"\' ...\n";
271 Epetra_MpiComm comm(MPI_COMM_WORLD);
273 Epetra_SerialComm comm;
277 EpetraExt::readEpetraLinearSystem( matrixFile, comm, &epetra_B, NULL, NULL, NULL );
278 EpetraExt::readEpetraLinearSystem( matrixFile, comm, &epetra_G, NULL, NULL, NULL );
292 for(
int scenario=1;scenario<=3;scenario++) {
294 if(scenario==1 || scenario==3)
295 M = buildBDGOperator(scenario,
B,G,4.5,out);
297 M = buildBDGOperator(scenario,G,
B,4.5,out);
310 BtDB_transformer->transform( *M, M_explicit.
ptr() );
312 out <<
"\nM_explicit = " << *M_explicit;
318 LinearOpTester<double> M_explicit_tester;
319 M_explicit_tester.show_all_tests(
true);;
321 const bool result = M_explicit_tester.compare( *M, *M_explicit, Teuchos::inoutArg(out) );
322 if (!result) success =
false;
334 out <<
"\nReading linear system in Epetra format from the file \'"<<matrixFile2<<
"\' ...\n";
337 Epetra_MpiComm comm(MPI_COMM_WORLD);
339 Epetra_SerialComm comm;
342 EpetraExt::readEpetraLinearSystem( matrixFile, comm, &epetra_G, NULL, NULL, NULL );
355 int scenes[] = {1,4};
356 for(
int i=0;i<2;i++) {
357 int scenario = scenes[i];
371 BtDB_transformer->transform( *M, M_explicit.
ptr() );
373 out <<
"\nM_explicit = " << *M_explicit;
379 LinearOpTester<double> M_explicit_tester;
380 M_explicit_tester.show_all_tests(
true);;
382 const bool result = M_explicit_tester.compare( *M, *M_explicit, Teuchos::inoutArg(out) );
383 if (!result) success =
false;
395 out <<
"\nReading linear system in Epetra format from the file \'"<<matrixFile<<
"\'";
396 out <<
" and from the file \'"<<matrixFile2<<
"\' ...\n";
399 Epetra_MpiComm comm(MPI_COMM_WORLD);
401 Epetra_SerialComm comm;
405 EpetraExt::readEpetraLinearSystem( matrixFile, comm, &epetra_B, NULL, NULL, NULL );
406 EpetraExt::readEpetraLinearSystem( matrixFile, comm, &epetra_G, NULL, NULL, NULL );
420 for(
int scenario=1;scenario<=4;scenario++) {
422 if(scenario==1 || scenario==3)
423 M = buildBGOperator(scenario,
B,G,out);
425 M = buildBGOperator(scenario,G,
B,out);
427 M = buildBGOperator(scenario,G,G,out);
440 BtDB_transformer->transform( *M, M_explicit.
ptr() );
442 out <<
"\nM_explicit = " << *M_explicit;
448 LinearOpTester<double> M_explicit_tester;
449 M_explicit_tester.show_all_tests(
true);;
451 const bool result = M_explicit_tester.compare( *M, *M_explicit, Teuchos::inoutArg(out) );
452 if (!result) success =
false;
TEUCHOS_UNIT_TEST(Comm, Issue1029)
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
static CommandLineProcessor & getCLP()
RCP< const EpetraLinearOp > epetraLinearOp(const RCP< const Epetra_Operator > &op, EOpTransp opTrans=NOTRANS, EApplyEpetraOpAs applyAs=EPETRA_OP_APPLY_APPLY, EAdjointEpetraOp adjointSupport=EPETRA_OP_ADJOINT_SUPPORTED, const RCP< const VectorSpaceBase< double > > &range=Teuchos::null, const RCP< const VectorSpaceBase< double > > &domain=Teuchos::null)
Dynamically allocate a nonconst EpetraLinearOp to wrap a const Epetra_Operator object.
#define TEUCHOS_ASSERT(assertion_test)