Stratimikos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ThyraTsqrAdaptorTester.cpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Stratimikos: Thyra-based strategies for linear solvers
5 // Copyright (2006) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 //
43 // This test exercises Thyra's TSQR adapter.
44 //
45 
46 #include "Epetra_Map.h"
47 #include "Epetra_MultiVector.h"
48 
49 #include "Epetra_Comm.h"
50 #include "Epetra_SerialComm.h"
51 #ifdef HAVE_MPI
52 # include "mpi.h"
53 # include "Epetra_MpiComm.h"
54 #endif
55 
56 #include "BelosConfigDefs.hpp"
57 #include "BelosMVOPTester.hpp"
58 #include "BelosEpetraAdapter.hpp"
59 
60 #ifdef HAVE_EPETRA_THYRA
61 # include "Thyra_TsqrAdaptor.hpp"
63 # include "Thyra_EpetraLinearOp.hpp"
64 #endif // HAVE_EPETRA_THYRA
65 
66 int
67 main (int argc, char *argv[])
68 {
69  using Teuchos::RCP;
70  using Teuchos::rcp;
71  using Teuchos::rcp_implicit_cast;
72  bool success = true;
73 
74 #ifdef HAVE_MPI
75  // Initialize MPI and setup an Epetra communicator
76  MPI_Init (&argc, &argv);
77  Epetra_MpiComm comm (MPI_COMM_WORLD);
78 #else // NOT HAVE_MPI
79  // If we aren't using MPI, then setup a serial communicator.
80  Epetra_SerialComm comm;
81 #endif // HAVE_MPI
82  const int myRank = comm.MyPID ();
83 
84  // Number of global elements
85  const int globalNumRows = 100;
86  const int blockSize = 3;
87  const int indexBase = 0;
88 
89  RCP<const Epetra_Map> range_epetra (new Epetra_Map (globalNumRows, indexBase, comm));
90  RCP<Epetra_MultiVector> X_epetra (new Epetra_MultiVector (*range_epetra, blockSize));
91 
92  // // Get update list and number of local equations from newly created Map.
93  // int NumMyElements = Map.NumMyElements();
94  // std::vector<int> MyGlobalElements(NumMyElements);
95  // Map->MyGlobalElements(&MyGlobalElements[0]);
96 
97 #ifdef HAVE_EPETRA_THYRA
98  // Create a Thyra vector space.
99  RCP<const Thyra::VectorSpaceBase<double> > range_thyra =
100  Thyra::create_VectorSpace (range_epetra);
101  // Create a multivector from the Epetra_MultiVector.
102  RCP<Thyra::MultiVectorBase<double> > X_thyra =
103  Thyra::create_MultiVector (rcp_implicit_cast<Epetra_MultiVector> (X_epetra), range_thyra);
104 
105  (void) range_thyra;
106  (void) X_thyra;
107 
108  typedef Thyra::TsqrAdaptor<double> tsqr_adapter_type;
109 
110 #endif // HAVE_EPETRA_THYRA
111 
112 #ifdef HAVE_MPI
113  MPI_Finalize();
114 #endif
115 
116  if (success) {
117  if (myRank == 0) {
118  std::cout << "End Result: TEST PASSED" << std::endl;
119  }
120  return EXIT_SUCCESS;
121  }
122  else {
123  if (myRank == 0) {
124  std::cout << "End Result: TEST FAILED" << std::endl;
125  }
126  return EXIT_FAILURE;
127  }
128 }
int main(int argc, char *argv[])
RCP< const VectorSpaceBase< double > > create_VectorSpace(const RCP< const Epetra_Map > &epetra_map)
Stub adaptor from Thyra::MultiVectorBase to TSQR.
RCP< MultiVectorBase< double > > create_MultiVector(const RCP< Epetra_MultiVector > &epetra_mv, const RCP< const VectorSpaceBase< double > > &range=Teuchos::null, const RCP< const VectorSpaceBase< double > > &domain=Teuchos::null)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)