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 // Stratimikos: Thyra-based strategies for linear solvers
4 //
5 // Copyright 2006 NTESS and the Stratimikos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 //
11 // This test exercises Thyra's TSQR adapter.
12 //
13 
14 #include "Epetra_Map.h"
15 #include "Epetra_MultiVector.h"
16 
17 #include "Epetra_Comm.h"
18 #include "Epetra_SerialComm.h"
19 #ifdef HAVE_MPI
20 # include "mpi.h"
21 # include "Epetra_MpiComm.h"
22 #endif
23 
24 #include "BelosConfigDefs.hpp"
25 #include "BelosMVOPTester.hpp"
26 #include "BelosEpetraAdapter.hpp"
27 
28 #ifdef HAVE_EPETRA_THYRA
29 # include "Thyra_TsqrAdaptor.hpp"
31 # include "Thyra_EpetraLinearOp.hpp"
32 #endif // HAVE_EPETRA_THYRA
33 
34 int
35 main (int argc, char *argv[])
36 {
37  using Teuchos::RCP;
38  using Teuchos::rcp;
39  using Teuchos::rcp_implicit_cast;
40  bool success = true;
41 
42 #ifdef HAVE_MPI
43  // Initialize MPI and setup an Epetra communicator
44  MPI_Init (&argc, &argv);
45  Epetra_MpiComm comm (MPI_COMM_WORLD);
46 #else // NOT HAVE_MPI
47  // If we aren't using MPI, then setup a serial communicator.
48  Epetra_SerialComm comm;
49 #endif // HAVE_MPI
50  const int myRank = comm.MyPID ();
51 
52  // Number of global elements
53  const int globalNumRows = 100;
54  const int blockSize = 3;
55  const int indexBase = 0;
56 
57  RCP<const Epetra_Map> range_epetra (new Epetra_Map (globalNumRows, indexBase, comm));
58  RCP<Epetra_MultiVector> X_epetra (new Epetra_MultiVector (*range_epetra, blockSize));
59 
60  // // Get update list and number of local equations from newly created Map.
61  // int NumMyElements = Map.NumMyElements();
62  // std::vector<int> MyGlobalElements(NumMyElements);
63  // Map->MyGlobalElements(&MyGlobalElements[0]);
64 
65 #ifdef HAVE_EPETRA_THYRA
66  // Create a Thyra vector space.
67  RCP<const Thyra::VectorSpaceBase<double> > range_thyra =
68  Thyra::create_VectorSpace (range_epetra);
69  // Create a multivector from the Epetra_MultiVector.
70  RCP<Thyra::MultiVectorBase<double> > X_thyra =
71  Thyra::create_MultiVector (rcp_implicit_cast<Epetra_MultiVector> (X_epetra), range_thyra);
72 
73  (void) range_thyra;
74  (void) X_thyra;
75 
76  typedef Thyra::TsqrAdaptor<double> tsqr_adapter_type;
77 
78 #endif // HAVE_EPETRA_THYRA
79 
80 #ifdef HAVE_MPI
81  MPI_Finalize();
82 #endif
83 
84  if (success) {
85  if (myRank == 0) {
86  std::cout << "End Result: TEST PASSED" << std::endl;
87  }
88  return EXIT_SUCCESS;
89  }
90  else {
91  if (myRank == 0) {
92  std::cout << "End Result: TEST FAILED" << std::endl;
93  }
94  return EXIT_FAILURE;
95  }
96 }
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)