Thyra Package Browser (Single Doxygen Collection)  Version of the Day
EpetraThyraWrappers_UnitTests.cpp
Go to the documentation of this file.
1 /*
2 // @HEADER
3 // ***********************************************************************
4 //
5 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
6 // Copyright (2004) Sandia Corporation
7 //
8 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9 // license for use of this work by or on behalf of the U.S. Government.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov)
39 //
40 // ***********************************************************************
41 // @HEADER
42 */
43 
45 #include "Thyra_DefaultProductVectorSpace.hpp"
46 #include "Thyra_VectorStdOps.hpp"
47 #include "Thyra_MultiVectorStdOps.hpp"
48 #include "Thyra_TestingTools.hpp"
50 
52 
53 
54 namespace {
55 
56 
57 //
58 // Unit Tests
59 //
60 
61 
62 TEUCHOS_UNIT_TEST( get_Epetra_MultiVector, singleBlockProductVector )
63 {
64  using Teuchos::Comm;
65  typedef Teuchos_Ordinal Ordinal;
66  using Thyra::VectorSpaceBase;
67  using Thyra::MultiVectorBase;
68 
69  const RCP<const Epetra_Comm> epetra_comm = getEpetraComm();
70  const RCP<const Comm<Ordinal> > comm = Thyra::create_Comm(epetra_comm);
71 
72  const RCP<const Epetra_Map> epetra_map = rcp(new Epetra_Map(g_localDim, 0, *epetra_comm));
73  const RCP<const VectorSpaceBase<double> > vs = Thyra::create_VectorSpace(epetra_map);
74 
75  const RCP<const VectorSpaceBase<double> > pvs = Thyra::productVectorSpace(vs, 1);
76 
77  const RCP<MultiVectorBase<double> > pmv = Thyra::createMembers(pvs, 1);
78 
79  const double alpha = 3.5;
80  Thyra::assign<double>( pmv.ptr(), alpha );
81 
82  const RCP<Epetra_MultiVector> epetra_mv =
83  Thyra::get_Epetra_MultiVector(*epetra_map, pmv);
84 
85  const RCP<MultiVectorBase<double> > mv2 =
86  Thyra::create_MultiVector(epetra_mv, pvs);
87 
88  Thyra::testRelNormDiffErr<double>(
89  "*pmv->col(0)", *pmv->col(0),
90  "*mv2->col(0)", *mv2->col(0),
91  "max-error", 0.0,
92  "max-warning", 0.0,
93  &out
94  );
95 
96 }
97 
98 
99 } // namespace
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...
RCP< const VectorSpaceBase< double > > create_VectorSpace(const RCP< const Epetra_Map > &epetra_map)
Create an VectorSpaceBase object given an Epetra_Map object.
RCP< MultiVectorBase< double > > create_MultiVector(const RCP< Epetra_MultiVector > &epetra_mv, const RCP< const VectorSpaceBase< double > > &range, const RCP< const VectorSpaceBase< double > > &domain=Teuchos::null)
Create a non-const MultiVectorBase object from a non-const Epetra_MultiVector object.
TEUCHOS_UNIT_TEST(EpetraOperatorWrapper, basic)
TEUCHOS_ORDINAL_TYPE Teuchos_Ordinal
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos_Ordinal Ordinal
RCP< const Teuchos::Comm< Ordinal > > create_Comm(const RCP< const Epetra_Comm > &epetraComm)
Given an Epetra_Comm object, return an equivalent Teuchos::Comm object.