4 #include "Epetra_MpiComm.h"
5 #include "Epetra_Map.h"
6 #include "Thyra_VectorSpaceFactoryBase.hpp"
8 #include "Thyra_DefaultSpmdVectorSpace_decl.hpp"
9 #include "Thyra_DefaultSpmdVector_decl.hpp"
10 #include "Thyra_MultiVectorBase_decl.hpp"
11 #include "Thyra_ScalarProdVectorSpaceBase_decl.hpp"
12 #include "Thyra_DefaultSpmdMultiVector_decl.hpp"
25 using Teuchos::outArg;
28 using Teuchos::rcp_dynamic_cast;
30 using Teuchos::reduceAll;
38 (void) MPI_Comm_rank (MPI_COMM_WORLD, &myRank);
39 (void) MPI_Comm_size (MPI_COMM_WORLD, &numProcs);
44 std::ostringstream os;
45 os <<
"(Process " << myRank <<
") ";
50 std::ostringstream os;
51 os << prefix <<
"Creating Epetra_Comm" << endl;
55 const Epetra_MpiComm epetra_comm (MPI_COMM_WORLD);
57 const Epetra_SerialComm epetra_comm ();
60 std::ostringstream os;
61 os << prefix <<
"Creating Teuchos::Comm" << endl;
64 RCP<const Teuchos::Comm<Teuchos_Ordinal> > comm =
68 lclSuccess = success ? 1 : 0;
69 reduceAll (*comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
71 if (gblSuccess != 1) {
72 out <<
"FAILED; some process(es) have a null Teuchos::Comm" << endl;
77 const int localDim = myRank % 2;
78 const int globalDim = numProcs / 2;
79 RCP<const Epetra_Map> epetra_map;
81 std::ostringstream os;
82 os << prefix <<
"Creating Epetra_Map: localDim=" << localDim <<
", globalDim=" << globalDim << endl;
85 epetra_map =
rcp (
new Epetra_Map (globalDim, localDim, 0, epetra_comm));
88 lclSuccess = success ? 1 : 0;
89 reduceAll (*comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
91 if (gblSuccess != 1) {
92 out <<
"FAILED; some process(es) have a null Epetra_Map" << endl;
97 std::ostringstream os;
98 os << prefix <<
"Creating Thyra::DefaultSpmdVectorSpace" << endl;
101 RCP<Thyra::DefaultSpmdVectorSpace<double> > SPMD =
102 Thyra::DefaultSpmdVectorSpace<double>::create();
106 lclSuccess = success ? 1 : 0;
107 reduceAll (*comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
109 if (gblSuccess != 1) {
110 out <<
"FAILED; some process(es) have a null SPMD" << endl;
114 SPMD->initialize(comm, localDim, globalDim);
117 std::ostringstream os;
118 os << prefix <<
"Creating Thyra::MultiVectorBase" << endl;
121 RCP<const Thyra::MultiVectorBase<double> > spmd =
122 rcp (
new Thyra::DefaultSpmdMultiVector<double> (
124 rcp_dynamic_cast<
const Thyra::ScalarProdVectorSpaceBase<double> > (
125 SPMD->smallVecSpcFcty()->createVecSpc(1),
true)
130 lclSuccess = success ? 1 : 0;
131 reduceAll (*comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
133 if (gblSuccess != 1) {
134 out <<
"FAILED; some process(es) have a null Thyra::MultiVectorBase"
140 std::ostringstream os;
141 os << prefix <<
"Calling Thyra::get_Epetra_MultiVector "
142 "(const overload; see #1941)" << endl;
146 RCP<const Epetra_MultiVector> mv_c =
148 const_cast<const Thyra::MultiVectorBase<double>&
> (*spmd));
151 lclSuccess = success ? 1 : 0;
152 reduceAll (*comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
154 if (gblSuccess != 1) {
155 out <<
"FAILED; some process(es) have a null const Epetra_MultiVector"
161 std::ostringstream os;
162 os << prefix <<
"Calling Thyra::get_Epetra_MultiVector "
163 "(nonconst overload; see #2061)" << endl;
167 RCP<Epetra_MultiVector> mv_nc =
169 const_cast<Thyra::MultiVectorBase<double>&
> (*spmd));
172 lclSuccess = success ? 1 : 0;
173 reduceAll (*comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
175 if (gblSuccess != 1) {
176 out <<
"FAILED; some process(es) have a null nonconst Epetra_MultiVector"
182 std::ostringstream os;
183 os << prefix <<
"Done with test on this process" << endl;
RCP< Epetra_MultiVector > get_Epetra_MultiVector(const Epetra_Map &map, const RCP< MultiVectorBase< double > > &mv)
Get a non-const Epetra_MultiVector view from a non-const MultiVectorBase object if possible...
static Teuchos::RCP< const Comm< OrdinalType > > getComm()
TEUCHOS_UNIT_TEST(EpetraOperatorWrapper, basic)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
#define TEST_EQUALITY(v1, v2)