00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "Teuchos_GlobalMPISession.hpp"
00030 #include "Teuchos_DefaultComm.hpp"
00031 #include "Thyra_VectorImpl.hpp"
00032 #include "Thyra_VectorSpaceImpl.hpp"
00033 #include "Thyra_LinearCombinationTester.hpp"
00034 #include "Thyra_DefaultSpmdVectorSpace.hpp"
00035 #include "Teuchos_CommandLineProcessor.hpp"
00036 #include "Teuchos_ScalarTraits.hpp"
00037 #include "Teuchos_StandardCatchMacros.hpp"
00038 #include "Teuchos_VerboseObject.hpp"
00039
00040 using namespace Teuchos;
00041 using namespace Thyra;
00042
00043
00044 #define SKIP_BLOCK_TESTS
00045
00046 #define TEST_FLOATS
00047 #define TEST_COMPLEX
00048
00049 template <class Scalar> inline
00050 bool runTests(int n, Teuchos::RefCountPtr<Teuchos::FancyOStream>& out)
00051 {
00052 typedef typename Teuchos::ScalarTraits<Scalar> ST;
00053 typedef typename ST::magnitudeType Mag;
00054
00055 Mag epsErr = n * 1.0e2 * ST::prec();
00056 Mag epsWarn = 1.0e2 * epsErr;
00057
00058
00059
00060 *out << "======= Testing on a monolithic vector space ======" << std::endl;
00061 VectorSpace<Scalar> space
00062 = new DefaultSpmdVectorSpace<Scalar>(DefaultComm<Index>::getComm(),n,-1);
00063
00064 TestSpecifier<Scalar> spec(true, epsErr, epsWarn);
00065
00066 LinearCombinationTester<Scalar> tester(DefaultComm<Index>::getComm(),
00067 space, out, spec);
00068
00069 return tester.runAllTests();
00070 }
00071
00072 int main( int argc, char *argv[] )
00073 {
00074 bool success = false;
00075
00076 GlobalMPISession mpiSession(&argc, &argv);
00077
00078
00079 Teuchos::RefCountPtr<Teuchos::FancyOStream>
00080 out = Teuchos::VerboseObjectBase::getDefaultOStream();
00081
00082 try {
00083
00084 int n = 20;
00085 CommandLineProcessor clp;
00086 clp.throwExceptions(false);
00087 bool verbose = false;
00088 clp.addOutputSetupOptions(true);
00089 clp.setOption( "verbose", "quiet", &verbose, "Determines if any output is printed or not." );
00090 clp.setOption( "local-dim", &n, "Local number of elements in each constituent vector." );
00091 CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
00092 if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL ) return parse_return;
00093
00094 if (!verbose) out = rcp(new FancyOStream(rcp(new oblackholestream())));
00095
00096 success = runTests<double>(n, out) ;
00097
00098 success = runTests<float>(n, out) && success;
00099
00100 #if defined(HAVE_COMPLEX) && defined(HAVE_TEUCHOS_COMPLEX)
00101 success = runTests<std::complex<double> >(n, out) && success;
00102 #endif
00103 }
00104
00105 TEUCHOS_STANDARD_CATCH_STATEMENTS(true,out.get()?*out:std::cerr,success)
00106
00107 if (success)
00108 {
00109 *out << "all tests PASSED!" << std::endl;
00110 return 0;
00111 }
00112 else
00113 {
00114 *out << "at least one test FAILED!" << std::endl;
00115 return 1;
00116 }
00117 }
00118