Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_ProductVectorSpaceBase.hpp
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
5 // Copyright (2004) 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 (bartlettra@ornl.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef THYRA_PRODUCT_VECTOR_SPACE_BASE_HPP
43 #define THYRA_PRODUCT_VECTOR_SPACE_BASE_HPP
44 
45 
46 #include "Thyra_VectorSpaceBase.hpp"
47 #include "Teuchos_ExpandScalarTypeMacros.hpp"
48 
49 
50 namespace Thyra {
51 
52 
94 template<class Scalar>
95 class ProductVectorSpaceBase : virtual public VectorSpaceBase<Scalar> {
96 public:
97 
104  virtual int numBlocks() const = 0;
105 
112  virtual Teuchos::RCP<const VectorSpaceBase<Scalar> > getBlock(const int k) const = 0;
113 
114 #ifdef DOXYGEN_COMPILE
115 private:
116  const VectorSpaceBase<Scalar> *spaces;
117 #endif
118 
119 private:
120 
121  // Not defined and not to be called
122  ProductVectorSpaceBase<Scalar>&
123  operator=(const ProductVectorSpaceBase<Scalar>&);
124 
125 };
126 
127 
133 template<class Scalar>
134 inline
135 RCP<ProductVectorSpaceBase<Scalar> >
137  const RCP<VectorSpaceBase<Scalar> > &v,
138  const bool forceSuccess = true
139  )
140 {
141  return Teuchos::rcp_dynamic_cast<ProductVectorSpaceBase<Scalar> >(
142  v, forceSuccess);
143 }
144 
145 
151 template<class Scalar>
152 inline
155  const RCP<const VectorSpaceBase<Scalar> > &v,
156  const bool forceSuccess = true
157  )
158 {
159  return Teuchos::rcp_dynamic_cast<const ProductVectorSpaceBase<Scalar> >(
160  v, forceSuccess);
161 }
162 
163 
169 inline
172  const RCP<VectorSpaceBase<double> > &vs,
173  const bool forceSuccess = true
174  )
175 {
176  return nonconstProductVectorSpaceBase<double>(vs, forceSuccess);
177 }
178 
179 
184 inline
187  const RCP<const VectorSpaceBase<double> > &vs,
188  const bool forceSuccess = true
189  )
190 {
191  return productVectorSpaceBase<double>(vs, forceSuccess);
192 }
193 
194 
195 } // namespace Thyra
196 
197 #endif // THYRA_PRODUCT_VECTOR_SPACE_BASE_HPP
virtual Teuchos::RCP< const VectorSpaceBase< Scalar > > getBlock(const int k) const =0
Returns a vector space for the kth (zero-based) block.
RCP< ProductVectorSpaceBase< double > > nonconstProductVectorSpaceBase(const RCP< VectorSpaceBase< double > > &vs, const bool forceSuccess=true)
Inline overload of nonconstProductVectorSpaceBase&lt;Scalar&gt;(..) for double.
virtual int numBlocks() const =0
Returns the number of blocks that make up this product space.
Abstract interface for objects that represent a space for vectors.
RCP< const ProductVectorSpaceBase< double > > productVectorSpaceBase(const RCP< const VectorSpaceBase< double > > &vs, const bool forceSuccess=true)
Inline overload of productVectorSpaceBase&lt;Scalar&gt;(..) for double.
RCP< const ProductVectorSpaceBase< Scalar > > productVectorSpaceBase(const RCP< const VectorSpaceBase< Scalar > > &v, const bool forceSuccess=true)
Dynamic cast from a const VectorSpaceBase to a const ProductVectorSpaceBase object and thow exception...
RCP< ProductVectorSpaceBase< Scalar > > nonconstProductVectorSpaceBase(const RCP< VectorSpaceBase< Scalar > > &v, const bool forceSuccess=true)
Dynamic cast from a VectorSpaceBase to a ProductVectorSpaceBase object and thow exception if this fai...