Thyra Package Browser (Single Doxygen Collection) Version of the Day
DefaultBlockedTriangularLinearOpWithSolve_UnitTests.cpp
Go to the documentation of this file.
00001 
00002 #include "Thyra_DefaultBlockedTriangularLinearOpWithSolve.hpp"
00003 #include "Thyra_DefaultSerialDenseLinearOpWithSolveFactory.hpp"
00004 #include "Thyra_LinearOpWithSolveFactoryHelpers.hpp"
00005 #include "Thyra_DefaultSpmdVectorSpace.hpp"
00006 #include "Thyra_DefaultLinearOpSource.hpp"
00007 #include "Thyra_MultiVectorStdOps.hpp"
00008 #include "Thyra_LinearOpTester.hpp"
00009 #include "Thyra_LinearOpWithSolveTester.hpp"
00010 
00011 #include "OperatorSolveHelpers.hpp"
00012 
00013 #include "Teuchos_UnitTestHarness.hpp"
00014 #include "Thyra_UnitTestHelpers.hpp"
00015 
00016 
00017 namespace Thyra {
00018 
00019 
00020 //
00021 // Helper code and declarations
00022 //
00023 
00024 
00025 using Teuchos::as;
00026 using Teuchos::null;
00027 using Teuchos::inOutArg;
00028 
00029 
00030 //
00031 // Unit Tests
00032 //
00033 
00034 
00035 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( DefaultBlockedTriangularLinearOpWithSolve,
00036   defaultConstruct, Scalar )
00037 {
00038   const RCP<DefaultBlockedTriangularLinearOpWithSolve<Scalar> > dbtlows =
00039     defaultBlockedTriangularLinearOpWithSolve<Scalar>();
00040   TEST_ASSERT(nonnull(dbtlows));
00041   TEST_EQUALITY_CONST(dbtlows->range(), null);
00042   TEST_EQUALITY_CONST(dbtlows->domain(), null);
00043   out << "dbtlows = " << *dbtlows;
00044 }
00045 THYRA_UNIT_TEST_TEMPLATE_1_INSTANT_SCALAR_TYPES( DefaultBlockedTriangularLinearOpWithSolve,
00046   defaultConstruct )
00047 
00048 
00049 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( DefaultBlockedTriangularLinearOpWithSolve,
00050   basic, Scalar )
00051 {
00052 
00053   typedef Teuchos::ScalarTraits<Scalar> ST;
00054 
00055   const Ordinal dim = 4;
00056 
00057   const RCP<const VectorSpaceBase<Scalar> > vs =
00058     defaultSpmdVectorSpace<Scalar>(dim);
00059 
00060   const RCP<const MultiVectorBase<Scalar> > M =
00061     createNonsingularMultiVector(vs);
00062 
00063   const RCP<const LinearOpWithSolveBase<Scalar> > lows =
00064     linearOpWithSolve<Scalar>(
00065       *defaultSerialDenseLinearOpWithSolveFactory<Scalar>(), M );
00066 
00067   const int numBlocks = 3;
00068 
00069   const RCP<DefaultBlockedTriangularLinearOpWithSolve<Scalar> > dbtlows =
00070     defaultBlockedTriangularLinearOpWithSolve<Scalar>();
00071   dbtlows->beginBlockFill(numBlocks, numBlocks);
00072 
00073   for (int block_i = 0; block_i < numBlocks; ++block_i) {
00074     dbtlows->setLOWSBlock(block_i, block_i, lows);
00075   }
00076 
00077   dbtlows->endBlockFill();
00078 
00079   out << "dbtlows = " << *dbtlows;
00080 
00081   Thyra::LinearOpTester<Scalar> linearOpTester;
00082   const bool checkOpResult = linearOpTester.check(*dbtlows, inOutArg(out));
00083   TEST_ASSERT(checkOpResult);
00084 
00085   Thyra::LinearOpWithSolveTester<Scalar> linearOpWithSolveTester;
00086   linearOpWithSolveTester.turn_off_all_tests();
00087   linearOpWithSolveTester.check_forward_default(true);
00088   linearOpWithSolveTester.check_adjoint_default(true);
00089   const bool checkSolveResult = linearOpWithSolveTester.check(*dbtlows, &out);
00090   TEST_ASSERT(checkSolveResult);
00091 
00092 }
00093 THYRA_UNIT_TEST_TEMPLATE_1_INSTANT_SCALAR_TYPES( DefaultBlockedTriangularLinearOpWithSolve,
00094   basic )
00095 
00096 
00097 } // namespace Thyra
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines