Thyra Version of the Day
Loading...
Searching...
No Matches
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
55namespace Thyra {
56
57
58template<class Scalar> class DefaultProductVectorSpace;
59
60
86template<class Scalar>
88 : virtual public PhysicallyBlockedLinearOpBase<Scalar>
89 , virtual public RowStatLinearOpBase<Scalar>
90 , virtual public ScaledLinearOpBase<Scalar>
91{
92public:
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,
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
193protected:
194
197
201 bool opSupportedImpl(EOpTransp M_trans) const;
202
204 void applyImpl(
205 const EOpTransp M_trans,
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
250private:
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
313template<class Scalar>
315
316
321template<class Scalar>
324 const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
325 const std::string &label = ""
326 );
327
328
333template<class Scalar>
336 const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
337 const Teuchos::RCP<const LinearOpBase<Scalar> > &A01,
338 const std::string &label = ""
339 );
340
341
346template<class Scalar>
349 const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
350 const Teuchos::RCP<const LinearOpBase<Scalar> > &A10,
351 const std::string &label = ""
352 );
353
354
359template<class Scalar>
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
374template<class Scalar>
378 const std::string &label = ""
379 );
380
381
386template<class Scalar>
391 const std::string &label = ""
392 );
393
394
399template<class Scalar>
404 const std::string &label = ""
405 );
406
407
412template<class Scalar>
419 const std::string &label = ""
420 );
421
422
423} // namespace Thyra
424
425
426#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. `*.