Stratimikos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ThyraTsqrAdaptorTester.cpp
Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 //
00004 //         Stratimikos: Thyra-based strategies for linear solvers
00005 //                Copyright (2006) Sandia Corporation
00006 //
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
00038 //
00039 // ***********************************************************************
00040 // @HEADER
00041 
00042 //
00043 //  This test exercises Thyra's TSQR adapter.
00044 //
00045 
00046 #include "Epetra_Map.h"
00047 #include "Epetra_MultiVector.h"
00048 
00049 #include "Epetra_Comm.h"
00050 #include "Epetra_SerialComm.h"
00051 #ifdef HAVE_MPI
00052 #  include "mpi.h"
00053 #  include "Epetra_MpiComm.h"
00054 #endif
00055 
00056 #include "BelosConfigDefs.hpp"
00057 #include "BelosMVOPTester.hpp"
00058 #include "BelosEpetraAdapter.hpp"
00059 
00060 #ifdef HAVE_EPETRA_THYRA
00061 #  include "Thyra_TsqrAdaptor.hpp"
00062 #  include "Thyra_EpetraThyraWrappers.hpp"
00063 #  include "Thyra_EpetraLinearOp.hpp"
00064 #endif // HAVE_EPETRA_THYRA
00065 
00066 int
00067 main (int argc, char *argv[])
00068 {
00069   using Teuchos::RCP;
00070   using Teuchos::rcp;
00071   using Teuchos::rcp_implicit_cast;
00072   bool success = true;
00073 
00074 #ifdef HAVE_MPI
00075   // Initialize MPI and setup an Epetra communicator
00076   MPI_Init (&argc, &argv);
00077   Epetra_MpiComm comm (MPI_COMM_WORLD);
00078 #else // NOT HAVE_MPI
00079   // If we aren't using MPI, then setup a serial communicator.
00080   Epetra_SerialComm comm;
00081 #endif // HAVE_MPI
00082   const int myRank = comm.MyPID ();
00083 
00084   // Number of global elements
00085   const int globalNumRows = 100;
00086   const int blockSize = 3;
00087   const int indexBase = 0;
00088 
00089   RCP<const Epetra_Map> range_epetra (new Epetra_Map (globalNumRows, indexBase, comm));
00090   RCP<Epetra_MultiVector> X_epetra (new Epetra_MultiVector (*range_epetra, blockSize));
00091 
00092   // // Get update list and number of local equations from newly created Map.
00093   // int NumMyElements = Map.NumMyElements();
00094   // std::vector<int> MyGlobalElements(NumMyElements);
00095   // Map->MyGlobalElements(&MyGlobalElements[0]);
00096 
00097 #ifdef HAVE_EPETRA_THYRA
00098   // Create a Thyra vector space.
00099   RCP<const Thyra::VectorSpaceBase<double> > range_thyra =
00100     Thyra::create_VectorSpace (range_epetra);
00101   // Create a multivector from the Epetra_MultiVector.
00102   RCP<Thyra::MultiVectorBase<double> > X_thyra =
00103     Thyra::create_MultiVector (rcp_implicit_cast<Epetra_MultiVector> (X_epetra), range_thyra);
00104 
00105   (void) range_thyra;
00106   (void) X_thyra;
00107 
00108   typedef Thyra::TsqrAdaptor<double> tsqr_adapter_type;
00109 
00110 #endif // HAVE_EPETRA_THYRA
00111 
00112 #ifdef HAVE_MPI
00113   MPI_Finalize();
00114 #endif
00115 
00116   if (success) {
00117     if (myRank == 0) {
00118       std::cout << "End Result: TEST PASSED" << std::endl;
00119     }
00120     return EXIT_SUCCESS;
00121   }
00122   else {
00123     if (myRank == 0) {
00124       std::cout << "End Result: TEST FAILED" << std::endl;
00125     }
00126     return EXIT_FAILURE;
00127   }
00128 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines