Thyra Version of the Day
Loading...
Searching...
No Matches
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
22namespace Thyra {
23
24
25template<class Scalar> class DefaultProductVectorSpace;
26
27
53template<class Scalar>
55 : virtual public PhysicallyBlockedLinearOpBase<Scalar>
56 , virtual public RowStatLinearOpBase<Scalar>
57 , virtual public ScaledLinearOpBase<Scalar>
58{
59public:
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;
89 const int i, const int j,
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
160protected:
161
164
168 bool opSupportedImpl(EOpTransp M_trans) const;
169
171 void applyImpl(
172 const EOpTransp M_trans,
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
217private:
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
280template<class Scalar>
282
283
288template<class Scalar>
291 const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
292 const std::string &label = ""
293 );
294
295
300template<class Scalar>
303 const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
304 const Teuchos::RCP<const LinearOpBase<Scalar> > &A01,
305 const std::string &label = ""
306 );
307
308
313template<class Scalar>
316 const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
317 const Teuchos::RCP<const LinearOpBase<Scalar> > &A10,
318 const std::string &label = ""
319 );
320
321
326template<class Scalar>
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
341template<class Scalar>
345 const std::string &label = ""
346 );
347
348
353template<class Scalar>
358 const std::string &label = ""
359 );
360
361
366template<class Scalar>
371 const std::string &label = ""
372 );
373
374
379template<class Scalar>
386 const std::string &label = ""
387 );
388
389
390} // namespace Thyra
391
392
393#endif // THYRA_DEFAULT_BLOCKED_LINEAR_OP_DECL_HPP
Concrete composite LinearOpBase subclass that creates single linear operator object out of a set of c...
Teuchos::RCP< const VectorSpaceBase< Scalar > > domain() const
bool blockIsConst(const int i, const int j) const
virtual void scaleRightImpl(const VectorBase< Scalar > &col_scaling)
void applyImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha, const Scalar beta) const
Teuchos::RCP< LinearOpBase< Scalar > > nonconstBlock2x2(const Teuchos::RCP< LinearOpBase< Scalar > > &A00, const Teuchos::RCP< LinearOpBase< Scalar > > &A01, const Teuchos::RCP< LinearOpBase< Scalar > > &A10, const Teuchos::RCP< LinearOpBase< Scalar > > &A11, const std::string &label="")
Form an implicit block 2x2 linear operator [ A00, A01; A10, A11 ].
bool acceptsBlock(const int i, const int j) const
Teuchos::RCP< const VectorSpaceBase< Scalar > > range() const
virtual bool rowStatIsSupportedImpl(const RowStatLinearOpBaseUtils::ERowStat rowStat) const
Teuchos::RCP< LinearOpBase< Scalar > > getNonconstBlock(const int i, const int j)
Teuchos::RCP< const LinearOpBase< Scalar > > getBlock(const int i, const int j) const
bool blockExists(const int i, const int j) const
Teuchos::RCP< const LinearOpBase< Scalar > > block2x1(const Teuchos::RCP< const LinearOpBase< Scalar > > &A00, const Teuchos::RCP< const LinearOpBase< Scalar > > &A10, const std::string &label="")
Form an implicit block 2x1 linear operator [ A00; A10 ].
virtual void scaleLeftImpl(const VectorBase< Scalar > &row_scaling)
void setNonconstBlock(const int i, const int j, const Teuchos::RCP< LinearOpBase< Scalar > > &block)
Teuchos::RCP< LinearOpBase< Scalar > > nonconstBlock1x2(const Teuchos::RCP< LinearOpBase< Scalar > > &A00, const Teuchos::RCP< LinearOpBase< Scalar > > &A01, const std::string &label="")
Form an implicit block 1x2 linear operator [ A00, A01 ].
Teuchos::RCP< const ProductVectorSpaceBase< Scalar > > productDomain() const
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Prints the details about the constituent linear operators.
RCP< DefaultBlockedLinearOp< Scalar > > defaultBlockedLinearOp()
Nonmember default constructor.
Teuchos::RCP< const ProductVectorSpaceBase< Scalar > > productRange() const
virtual void getRowStatImpl(const RowStatLinearOpBaseUtils::ERowStat rowStat, const Teuchos::Ptr< VectorBase< Scalar > > &rowStatVec) const
void setBlock(const int i, const int j, const Teuchos::RCP< const LinearOpBase< Scalar > > &block)
std::string description() const
Prints just the name DefaultBlockedLinearOp along with the overall dimensions and the number of const...
Teuchos::RCP< const LinearOpBase< Scalar > > block1x2(const Teuchos::RCP< const LinearOpBase< Scalar > > &A00, const Teuchos::RCP< const LinearOpBase< Scalar > > &A01, const std::string &label="")
Form an implicit block 1x2 linear operator [ A00, A01 ].
Teuchos::RCP< LinearOpBase< Scalar > > nonconstBlock2x1(const Teuchos::RCP< LinearOpBase< Scalar > > &A00, const Teuchos::RCP< LinearOpBase< Scalar > > &A10, const std::string &label="")
Form an implicit block 2x1 linear operator [ A00; A10 ].
Teuchos::RCP< const LinearOpBase< Scalar > > block2x2(const Teuchos::RCP< const LinearOpBase< Scalar > > &A00, const Teuchos::RCP< const LinearOpBase< Scalar > > &A01, const Teuchos::RCP< const LinearOpBase< Scalar > > &A10, const Teuchos::RCP< const LinearOpBase< Scalar > > &A11, const std::string &label="")
Form an implicit block 2x2 linear operator [ A00, A01; A10, A11 ].
Teuchos::RCP< const LinearOpBase< Scalar > > clone() const
bool opSupportedImpl(EOpTransp M_trans) const
Returns true only if all constituent operators support M_trans.
Teuchos::RCP< const LinearOpBase< Scalar > > block1x1(const Teuchos::RCP< const LinearOpBase< Scalar > > &A00, const std::string &label="")
Form an implicit block 1x1 linear operator [ A00 ].
Teuchos::RCP< LinearOpBase< Scalar > > nonconstBlock1x1(const Teuchos::RCP< LinearOpBase< Scalar > > &A00, const std::string &label="")
Form an implicit block 1x1 linear operator [ A00 ].
Base class for all linear operators.
Interface for a collection of column vectors called a multi-vector.
Base interface for physically blocked linear operators.
Interface for exxtracting row statistics as a VectorBase from a supporting LinearOpBase object.
Applies left or right sclaing to the linear operator.
Abstract interface for finite-dimensional dense vectors.
EOpTransp
Enumeration for determining how a linear operator is applied. `*.