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 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
4 //
5 // Copyright 2004 NTESS and the Thyra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef THYRA_DEFAULT_BLOCKED_LINEAR_OP_DECL_HPP
11 #define THYRA_DEFAULT_BLOCKED_LINEAR_OP_DECL_HPP
12 
13 
14 #include "Thyra_PhysicallyBlockedLinearOpBase.hpp"
15 #include "Thyra_ProductVectorSpaceBase.hpp"
16 #include "Thyra_RowStatLinearOpBase.hpp"
17 #include "Thyra_ScaledLinearOpBase.hpp"
18 #include "Teuchos_ConstNonconstObjectContainer.hpp"
19 
20 
21 
22 namespace Thyra {
23 
24 
25 template<class Scalar> class DefaultProductVectorSpace;
26 
27 
53 template<class Scalar>
55  : virtual public PhysicallyBlockedLinearOpBase<Scalar>
56  , virtual public RowStatLinearOpBase<Scalar>
57  , virtual public ScaledLinearOpBase<Scalar>
58 {
59 public:
60 
63 
66 
68 
71 
73  void beginBlockFill();
75  void beginBlockFill(
76  const int numRowBlocks, const int numColBlocks
77  );
79  void beginBlockFill(
82  );
84  bool blockFillIsActive() const;
86  bool acceptsBlock(const int i, const int j) const;
88  void setNonconstBlock(
89  const int i, const int j,
90  const Teuchos::RCP<LinearOpBase<Scalar> > &block
91  );
93  void setBlock(
94  const int i, const int j
95  ,const Teuchos::RCP<const LinearOpBase<Scalar> > &block
96  );
98  void endBlockFill();
100  void uninitialize();
101 
103 
106 
109  productRange() const;
112  productDomain() const;
114  bool blockExists(const int i, const int j) const;
116  bool blockIsConst(const int i, const int j) const;
119  getNonconstBlock(const int i, const int j);
122  getBlock(const int i, const int j) const;
123 
125 
128 
135 
137 
140 
144  std::string description() const;
145 
153  void describe(
155  const Teuchos::EVerbosityLevel verbLevel
156  ) const;
157 
159 
160 protected:
161 
164 
168  bool opSupportedImpl(EOpTransp M_trans) const;
169 
171  void applyImpl(
172  const EOpTransp M_trans,
173  const MultiVectorBase<Scalar> &X,
174  const Ptr<MultiVectorBase<Scalar> > &Y,
175  const Scalar alpha,
176  const Scalar beta
177  ) const;
178 
180 
183 
185  virtual bool rowStatIsSupportedImpl(
186  const RowStatLinearOpBaseUtils::ERowStat rowStat) const;
187 
189  virtual void getRowStatImpl(
190  const RowStatLinearOpBaseUtils::ERowStat rowStat,
191  const Teuchos::Ptr<VectorBase< Scalar> > &rowStatVec) const;
192 
194 
197 
199  virtual bool supportsScaleLeftImpl() const;
200 
202  virtual bool supportsScaleRightImpl() const;
203 
205  virtual void scaleLeftImpl(
206  const VectorBase< Scalar > &row_scaling
207  );
208 
210  virtual void scaleRightImpl(
211  const VectorBase< Scalar > &col_scaling
212  );
213 
215 
216 
217 private:
218 
219  // ///////////////////
220  // Private types
221 
224 
225  template<class Scalar2>
226  struct BlockEntry {
227  BlockEntry() : i(-1), j(-1) {}
228  BlockEntry( const int i_in, const int j_in, const CNCLO &block_in )
229  :i(i_in),j(j_in),block(block_in)
230  {}
231  int i;
232  int j;
233  CNCLO block;
234  };
235 
236  // /////////////////////////
237  // Private data members
238 
243  int numRowBlocks_; // M
244  int numColBlocks_; // N
245 
246  std::vector<CNCLO> Ops_; // Final M x N storage
247 
248  vec_array_t rangeBlocks_;
249  vec_array_t domainBlocks_;
250  std::vector<BlockEntry<Scalar> > Ops_stack_; // Temp stack of ops begin filled (if Ops_.size()==0).
251  bool blockFillIsActive_;
252 
253  // ///////////////////////////
254  // Private member functions
255 
256  void resetStorage( const int numRowBlocks, const int numColBlocks );
257  void assertBlockFillIsActive(bool) const;
258  void assertBlockRowCol(const int i, const int j) const;
259  void setBlockSpaces(
260  const int i, const int j, const LinearOpBase<Scalar> &block
261  );
262  template<class LinearOpType>
263  void setBlockImpl(
264  const int i, const int j,
265  const Teuchos::RCP<LinearOpType> &block
266  );
267  void adjustBlockSpaces();
268 
269  // Not defined and not to be called
272 
273 };
274 
275 
280 template<class Scalar>
281 RCP<DefaultBlockedLinearOp<Scalar> > defaultBlockedLinearOp();
282 
283 
288 template<class Scalar>
290 block1x1(
291  const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
292  const std::string &label = ""
293  );
294 
295 
300 template<class Scalar>
302 block1x2(
303  const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
304  const Teuchos::RCP<const LinearOpBase<Scalar> > &A01,
305  const std::string &label = ""
306  );
307 
308 
313 template<class Scalar>
315 block2x1(
316  const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
317  const Teuchos::RCP<const LinearOpBase<Scalar> > &A10,
318  const std::string &label = ""
319  );
320 
321 
326 template<class Scalar>
328 block2x2(
329  const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
330  const Teuchos::RCP<const LinearOpBase<Scalar> > &A01,
331  const Teuchos::RCP<const LinearOpBase<Scalar> > &A10,
332  const Teuchos::RCP<const LinearOpBase<Scalar> > &A11,
333  const std::string &label = ""
334  );
335 
336 
341 template<class Scalar>
343 nonconstBlock1x1(
344  const Teuchos::RCP<LinearOpBase<Scalar> > &A00,
345  const std::string &label = ""
346  );
347 
348 
353 template<class Scalar>
355 nonconstBlock1x2(
356  const Teuchos::RCP<LinearOpBase<Scalar> > &A00,
357  const Teuchos::RCP<LinearOpBase<Scalar> > &A01,
358  const std::string &label = ""
359  );
360 
361 
366 template<class Scalar>
368 nonconstBlock2x1(
369  const Teuchos::RCP<LinearOpBase<Scalar> > &A00,
370  const Teuchos::RCP<LinearOpBase<Scalar> > &A10,
371  const std::string &label = ""
372  );
373 
374 
379 template<class Scalar>
381 nonconstBlock2x2(
382  const Teuchos::RCP<LinearOpBase<Scalar> > &A00,
383  const Teuchos::RCP<LinearOpBase<Scalar> > &A01,
384  const Teuchos::RCP<LinearOpBase<Scalar> > &A10,
385  const Teuchos::RCP<LinearOpBase<Scalar> > &A11,
386  const std::string &label = ""
387  );
388 
389 
390 } // namespace Thyra
391 
392 
393 #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