Thyra Package Browser (Single Doxygen Collection) Version of the Day
EpetraLinearOpParallel_UnitTests.cpp
Go to the documentation of this file.
00001 #include "Thyra_EpetraLinearOp.hpp"
00002 #include "Thyra_LinearOpTester.hpp"
00003 #include "Thyra_DefaultBlockedLinearOp.hpp"
00004 #include "Thyra_MultiVectorBase.hpp"
00005 #include "Thyra_MultiVectorStdOps.hpp"
00006 #include "EpetraThyraAdaptersTestHelpers.hpp"
00007 
00008 #include "Teuchos_UnitTestHarness.hpp"
00009 
00010 
00011 namespace {
00012 
00013 
00014 //
00015 // Unit Tests
00016 //
00017 
00018 
00019 TEUCHOS_UNIT_TEST( EpetraLinearOpParallel, blocked_op )
00020 {
00021 
00022   using Teuchos::describe;
00023   using Thyra::block2x2;
00024   using Thyra::block2x1;
00025   using Thyra::block1x2;
00026   using Thyra::LinearOpBase;
00027   using Thyra::MultiVectorBase;
00028   using Thyra::createMembers;
00029 
00030   int scale=30;
00031   
00032   // build sub operators
00033   RCP<const Thyra::LinearOpBase<double> > A00 = Thyra::epetraLinearOp(getEpetraMatrix(scale*4,scale*4,0));
00034   RCP<const Thyra::LinearOpBase<double> > A01 = Thyra::epetraLinearOp(getEpetraMatrix(scale*4,scale*3,1));
00035   RCP<const Thyra::LinearOpBase<double> > A02 = Thyra::epetraLinearOp(getEpetraMatrix(scale*4,scale*2,2));
00036   RCP<const Thyra::LinearOpBase<double> > A10 = Thyra::epetraLinearOp(getEpetraMatrix(scale*3,scale*4,3));
00037   RCP<const Thyra::LinearOpBase<double> > A11 = Thyra::epetraLinearOp(getEpetraMatrix(scale*3,scale*3,4));
00038   RCP<const Thyra::LinearOpBase<double> > A12 = Thyra::epetraLinearOp(getEpetraMatrix(scale*3,scale*2,5));
00039   RCP<const Thyra::LinearOpBase<double> > A20 = Thyra::epetraLinearOp(getEpetraMatrix(scale*2,scale*4,6));
00040   RCP<const Thyra::LinearOpBase<double> > A21 = Thyra::epetraLinearOp(getEpetraMatrix(scale*2,scale*3,8));
00041   RCP<const Thyra::LinearOpBase<double> > A22 = Thyra::epetraLinearOp(getEpetraMatrix(scale*2,scale*2,8));
00042   
00043   out << "Sub operators built" << std::endl;
00044 
00045   typedef double S;
00046   const RCP<Thyra::PhysicallyBlockedLinearOpBase<S> > M00 = rcp(new Thyra::DefaultBlockedLinearOp<S>());
00047   M00->beginBlockFill(2,2);
00048   M00->setBlock(0,0,A00);
00049   M00->setBlock(0,1,A02);
00050   M00->setBlock(1,0,A20);
00051   M00->setBlock(1,1,A22);
00052   M00->endBlockFill();
00053 
00054   out << "Built M00" << std::endl;
00055 
00056   const RCP<Thyra::PhysicallyBlockedLinearOpBase<S> > M10 = rcp(new Thyra::DefaultBlockedLinearOp<S>());
00057   M10->beginBlockFill(2,1);
00058   M10->setBlock(0,0,A01);
00059   M10->setBlock(1,0,A21);
00060   M10->endBlockFill();
00061 
00062   out << "Built M10" << std::endl;
00063 
00064   const RCP<Thyra::PhysicallyBlockedLinearOpBase<S> > M01 = rcp(new Thyra::DefaultBlockedLinearOp<S>());
00065   M01->beginBlockFill(1,2);
00066   M01->setBlock(0,0,A10);
00067   M01->setBlock(0,1,A12);
00068   M01->endBlockFill();
00069 
00070   out << "Built M01" << std::endl;
00071 
00072   const RCP<Thyra::PhysicallyBlockedLinearOpBase<S> > M = rcp(new Thyra::DefaultBlockedLinearOp<S>());
00073   M->beginBlockFill(2,2);
00074   M->setBlock(0,0,A11);
00075   M->setBlock(0,1,M01);
00076   M->setBlock(1,0,M10);
00077   M->setBlock(1,1,M00);
00078   M->endBlockFill();
00079 
00080   out << "Built M" << std::endl;
00081 
00082   out << "M = " << describe(*M, Teuchos::VERB_MEDIUM);
00083   out << "M->range() = " << describe(*M->range(), Teuchos::VERB_MEDIUM);
00084   out << "M->domain() = " << describe(*M->range(), Teuchos::VERB_MEDIUM);
00085 
00086   out << "Test complete" << std::endl;
00087 
00088 }
00089 
00090 
00091 } // namespace
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines