44 #include "Thyra_DefaultProductVectorSpace.hpp"
45 #include "Thyra_VectorStdOps.hpp"
46 #include "Thyra_MultiVectorStdOps.hpp"
47 #include "Thyra_SpmdVectorSpaceBase.hpp"
48 #include "Thyra_VectorSpaceTester.hpp"
49 #include "Thyra_TestingTools.hpp"
50 #include "Epetra_Vector.h"
61 using Teuchos::ptrFromRef;
63 using Teuchos::rcp_dynamic_cast;
67 void createEpetraVsAndMap(
const Thyra::Ordinal localDim_in,
68 const Ptr<RCP<
const Thyra::VectorSpaceBase<double> > > &vs,
69 const Ptr<RCP<const Epetra_Map> > &epetra_map,
70 const int emptyProcRootRank = -1
73 const RCP<const Epetra_Comm> epetra_comm = getEpetraComm();
74 const int procRank = epetra_comm->MyPID();
75 const Thyra::Ordinal localDim = (procRank == emptyProcRootRank ? 0 : localDim_in);
76 *epetra_map =
rcp(
new Epetra_Map(-1, as<int>(localDim), 0, *epetra_comm));
81 void runVectorSpaceTesterTest(
const int emptyProc,
84 using Thyra::VectorSpaceBase;
85 using Thyra::SpmdVectorSpaceBase;
86 using Thyra::MultiVectorBase;
88 RCP<const VectorSpaceBase<double> > vs;
89 RCP<const Epetra_Map> epetra_map;
90 createEpetraVsAndMap(
g_localDim, outArg(vs), outArg(epetra_map), emptyProc);
91 const int numProcs = epetra_map->Comm().NumProc();
93 if (emptyProc >= numProcs) {
94 out <<
"emptyProc = " << emptyProc <<
" >= numProcs = " << numProcs
95 <<
": Skipping this test case!\n";
99 const Ordinal dimMultiplier = (emptyProc < 0 ? numProcs : numProcs-1);
103 const RCP<const SpmdVectorSpaceBase<double> > spmd_vs =
104 rcp_dynamic_cast<
const SpmdVectorSpaceBase<double> >(vs,
true);
106 TEST_EQUALITY(spmd_vs->localSubDim(), as<int>(epetra_map->NumMyElements()));
108 Thyra::VectorSpaceTester<double> vectorSpaceTester;
110 vectorSpaceTester.warning_tol((0.1)*tol);
111 vectorSpaceTester.error_tol(tol);
112 vectorSpaceTester.show_all_tests(g_show_all_tests);
113 vectorSpaceTester.dump_all(g_dumpAll);
118 void runCreateVectorUnitTest(
const int emptyProc,
121 using Thyra::VectorBase;
122 using Thyra::VectorSpaceBase;
123 using Thyra::MultiVectorBase;
125 RCP<const VectorSpaceBase<double> > vs;
126 RCP<const Epetra_Map> epetra_map;
127 createEpetraVsAndMap(
g_localDim, outArg(vs), outArg(epetra_map), emptyProc);
128 const int numProcs = epetra_map->Comm().NumProc();
130 if (emptyProc >= numProcs) {
131 out <<
"emptyProc = " << emptyProc <<
" >= numProcs = " << numProcs
132 <<
": Skipping this test case!\n";
136 const RCP<Epetra_Vector> epetra_vec =
rcp(
new Epetra_Vector(*epetra_map));
138 const RCP<Epetra_Vector> epetra_vec2 =
142 const RCP<const Epetra_Vector> const_epetra_vec2 =
157 const RCP<const Epetra_Comm> epetra_comm = getEpetraComm();
171 runVectorSpaceTesterTest(-1, out, success);
177 runVectorSpaceTesterTest(0, out, success);
183 runVectorSpaceTesterTest(1, out, success);
195 runCreateVectorUnitTest(0, out, success);
201 runCreateVectorUnitTest(1, out, success);
214 TEUCHOS_UNIT_TEST( EpetraThyraWrappers, get_Epetra_MultiVector_singleBlockProductVector )
216 using Thyra::VectorSpaceBase;
217 using Thyra::MultiVectorBase;
219 RCP<const VectorSpaceBase<double> > vs;
220 RCP<const Epetra_Map> epetra_map;
221 createEpetraVsAndMap(
g_localDim, outArg(vs), outArg(epetra_map));
223 const RCP<const VectorSpaceBase<double> > pvs = Thyra::productVectorSpace(vs, 1);
225 const RCP<MultiVectorBase<double> > pmv = Thyra::createMembers(pvs, 1);
227 const double alpha = 3.5;
228 Thyra::assign<double>( pmv.ptr(), alpha );
230 const RCP<Epetra_MultiVector> epetra_mv =
233 const RCP<MultiVectorBase<double> > mv2 =
236 Thyra::testRelNormDiffErr<double>(
237 "*pmv->col(0)", *pmv->col(0),
238 "*mv2->col(0)", *mv2->col(0),
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 magnitudeType eps()
RCP< const VectorSpaceBase< double > > create_VectorSpace(const RCP< const Epetra_Map > &epetra_map)
Create an VectorSpaceBase object given an Epetra_Map object.
TEUCHOS_UNIT_TEST(EpetraOperatorWrapper, basic)
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)
Create a non-const MultiVectorBase object from a non-const Epetra_MultiVector object.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
RCP< VectorBase< double > > create_Vector(const RCP< Epetra_Vector > &epetra_v, const RCP< const VectorSpaceBase< double > > &space=Teuchos::null)
Create a non-const VectorBase object from a non-const Epetra_Vector object.
RCP< Epetra_Vector > get_Epetra_Vector(const Epetra_Map &map, const RCP< VectorBase< double > > &v)
Get a non-const Epetra_Vector view from a non-const VectorBase object if possible.
RCP< const Epetra_Comm > get_Epetra_Comm(const Teuchos::Comm< Ordinal > &comm)
Get (or create) and Epetra_Comm given a Teuchos::Comm object.
#define TEST_EQUALITY(v1, v2)
RCP< const Teuchos::Comm< Ordinal > > create_Comm(const RCP< const Epetra_Comm > &epetraComm)
Given an Epetra_Comm object, return an equivalent Teuchos::Comm object.