Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_DefaultBlockedLinearOp_decl.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 
43 #ifndef THYRA_DEFAULT_BLOCKED_LINEAR_OP_DECL_HPP
44 #define THYRA_DEFAULT_BLOCKED_LINEAR_OP_DECL_HPP
45 
46 
47 #include "Thyra_PhysicallyBlockedLinearOpBase.hpp"
48 #include "Thyra_ProductVectorSpaceBase.hpp"
49 #include "Thyra_RowStatLinearOpBase.hpp"
50 #include "Thyra_ScaledLinearOpBase.hpp"
51 #include "Teuchos_ConstNonconstObjectContainer.hpp"
52 
53 
54 
55 namespace Thyra {
56 
57 
58 template<class Scalar> class DefaultProductVectorSpace;
59 
60 
86 template<class Scalar>
88  : virtual public PhysicallyBlockedLinearOpBase<Scalar>
89  , virtual public RowStatLinearOpBase<Scalar>
90  , virtual public ScaledLinearOpBase<Scalar>
91 {
92 public:
93 
96 
99 
101 
104 
106  void beginBlockFill();
108  void beginBlockFill(
109  const int numRowBlocks, const int numColBlocks
110  );
112  void beginBlockFill(
115  );
117  bool blockFillIsActive() const;
119  bool acceptsBlock(const int i, const int j) const;
121  void setNonconstBlock(
122  const int i, const int j,
123  const Teuchos::RCP<LinearOpBase<Scalar> > &block
124  );
126  void setBlock(
127  const int i, const int j
128  ,const Teuchos::RCP<const LinearOpBase<Scalar> > &block
129  );
131  void endBlockFill();
133  void uninitialize();
134 
136 
139 
142  productRange() const;
145  productDomain() const;
147  bool blockExists(const int i, const int j) const;
149  bool blockIsConst(const int i, const int j) const;
152  getNonconstBlock(const int i, const int j);
155  getBlock(const int i, const int j) const;
156 
158 
161 
168 
170 
173 
177  std::string description() const;
178 
186  void describe(
188  const Teuchos::EVerbosityLevel verbLevel
189  ) const;
190 
192 
193 protected:
194 
197 
201  bool opSupportedImpl(EOpTransp M_trans) const;
202 
204  void applyImpl(
205  const EOpTransp M_trans,
206  const MultiVectorBase<Scalar> &X,
207  const Ptr<MultiVectorBase<Scalar> > &Y,
208  const Scalar alpha,
209  const Scalar beta
210  ) const;
211 
213 
216 
218  virtual bool rowStatIsSupportedImpl(
219  const RowStatLinearOpBaseUtils::ERowStat rowStat) const;
220 
222  virtual void getRowStatImpl(
223  const RowStatLinearOpBaseUtils::ERowStat rowStat,
224  const Teuchos::Ptr<VectorBase< Scalar> > &rowStatVec) const;
225 
227 
230 
232  virtual bool supportsScaleLeftImpl() const;
233 
235  virtual bool supportsScaleRightImpl() const;
236 
238  virtual void scaleLeftImpl(
239  const VectorBase< Scalar > &row_scaling
240  );
241 
243  virtual void scaleRightImpl(
244  const VectorBase< Scalar > &col_scaling
245  );
246 
248 
249 
250 private:
251 
252  // ///////////////////
253  // Private types
254 
257 
258  template<class Scalar2>
259  struct BlockEntry {
260  BlockEntry() : i(-1), j(-1) {}
261  BlockEntry( const int i_in, const int j_in, const CNCLO &block_in )
262  :i(i_in),j(j_in),block(block_in)
263  {}
264  int i;
265  int j;
266  CNCLO block;
267  };
268 
269  // /////////////////////////
270  // Private data members
271 
276  int numRowBlocks_; // M
277  int numColBlocks_; // N
278 
279  std::vector<CNCLO> Ops_; // Final M x N storage
280 
281  vec_array_t rangeBlocks_;
282  vec_array_t domainBlocks_;
283  std::vector<BlockEntry<Scalar> > Ops_stack_; // Temp stack of ops begin filled (if Ops_.size()==0).
284  bool blockFillIsActive_;
285 
286  // ///////////////////////////
287  // Private member functions
288 
289  void resetStorage( const int numRowBlocks, const int numColBlocks );
290  void assertBlockFillIsActive(bool) const;
291  void assertBlockRowCol(const int i, const int j) const;
292  void setBlockSpaces(
293  const int i, const int j, const LinearOpBase<Scalar> &block
294  );
295  template<class LinearOpType>
296  void setBlockImpl(
297  const int i, const int j,
298  const Teuchos::RCP<LinearOpType> &block
299  );
300  void adjustBlockSpaces();
301 
302  // Not defined and not to be called
305 
306 };
307 
308 
313 template<class Scalar>
314 RCP<DefaultBlockedLinearOp<Scalar> > defaultBlockedLinearOp();
315 
316 
321 template<class Scalar>
323 block1x1(
324  const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
325  const std::string &label = ""
326  );
327 
328 
333 template<class Scalar>
335 block1x2(
336  const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
337  const Teuchos::RCP<const LinearOpBase<Scalar> > &A01,
338  const std::string &label = ""
339  );
340 
341 
346 template<class Scalar>
348 block2x1(
349  const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
350  const Teuchos::RCP<const LinearOpBase<Scalar> > &A10,
351  const std::string &label = ""
352  );
353 
354 
359 template<class Scalar>
361 block2x2(
362  const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
363  const Teuchos::RCP<const LinearOpBase<Scalar> > &A01,
364  const Teuchos::RCP<const LinearOpBase<Scalar> > &A10,
365  const Teuchos::RCP<const LinearOpBase<Scalar> > &A11,
366  const std::string &label = ""
367  );
368 
369 
374 template<class Scalar>
376 nonconstBlock1x1(
377  const Teuchos::RCP<LinearOpBase<Scalar> > &A00,
378  const std::string &label = ""
379  );
380 
381 
386 template<class Scalar>
388 nonconstBlock1x2(
389  const Teuchos::RCP<LinearOpBase<Scalar> > &A00,
390  const Teuchos::RCP<LinearOpBase<Scalar> > &A01,
391  const std::string &label = ""
392  );
393 
394 
399 template<class Scalar>
401 nonconstBlock2x1(
402  const Teuchos::RCP<LinearOpBase<Scalar> > &A00,
403  const Teuchos::RCP<LinearOpBase<Scalar> > &A10,
404  const std::string &label = ""
405  );
406 
407 
412 template<class Scalar>
414 nonconstBlock2x2(
415  const Teuchos::RCP<LinearOpBase<Scalar> > &A00,
416  const Teuchos::RCP<LinearOpBase<Scalar> > &A01,
417  const Teuchos::RCP<LinearOpBase<Scalar> > &A10,
418  const Teuchos::RCP<LinearOpBase<Scalar> > &A11,
419  const std::string &label = ""
420  );
421 
422 
423 } // namespace Thyra
424 
425 
426 #endif // THYRA_DEFAULT_BLOCKED_LINEAR_OP_DECL_HPP
bool blockExists(const int i, const int j) const
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
Teuchos::RCP< const ProductVectorSpaceBase< Scalar > > productRange() const
bool acceptsBlock(const int i, const int j) const
void applyImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha, const Scalar beta) const
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Prints the details about the constituent linear operators.
virtual void getRowStatImpl(const RowStatLinearOpBaseUtils::ERowStat rowStat, const Teuchos::Ptr< VectorBase< Scalar > > &rowStatVec) const
bool blockIsConst(const int i, const int j) const
void setNonconstBlock(const int i, const int j, const Teuchos::RCP< LinearOpBase< Scalar > > &block)
Interface for a collection of column vectors called a multi-vector.
std::string description() const
Prints just the name DefaultBlockedLinearOp along with the overall dimensions and the number of const...
Base interface for physically blocked linear operators.
Abstract interface for finite-dimensional dense vectors.
Teuchos::RCP< const LinearOpBase< Scalar > > clone() const
Teuchos::RCP< const VectorSpaceBase< Scalar > > domain() const
Base class for all linear operators.
Applies left or right sclaing to the linear operator.
Teuchos::RCP< const ProductVectorSpaceBase< Scalar > > productDomain() const
Teuchos::RCP< const VectorSpaceBase< Scalar > > range() const
virtual void scaleLeftImpl(const VectorBase< Scalar > &row_scaling)
virtual void scaleRightImpl(const VectorBase< Scalar > &col_scaling)
bool opSupportedImpl(EOpTransp M_trans) const
Returns true only if all constituent operators support M_trans.
Interface for exxtracting row statistics as a VectorBase from a supporting LinearOpBase object...
virtual bool rowStatIsSupportedImpl(const RowStatLinearOpBaseUtils::ERowStat rowStat) const
Teuchos::RCP< LinearOpBase< Scalar > > getNonconstBlock(const int i, const int j)
void setBlock(const int i, const int j, const Teuchos::RCP< const LinearOpBase< Scalar > > &block)
Concrete composite LinearOpBase subclass that creates single linear operator object out of a set of c...
Teuchos::RCP< const LinearOpBase< Scalar > > getBlock(const int i, const int j) const