00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef THYRA_DEFAULT_BLOCKED_LINEAR_OP_DECL_HPP
00030 #define THYRA_DEFAULT_BLOCKED_LINEAR_OP_DECL_HPP
00031
00032 #include "Thyra_PhysicallyBlockedLinearOpBase.hpp"
00033 #include "Thyra_SingleScalarLinearOpBase.hpp"
00034 #include "Thyra_ProductVectorSpaceBase.hpp"
00035 #include "Teuchos_ConstNonconstObjectContainer.hpp"
00036 #include "Teuchos_Array.hpp"
00037 #include "Teuchos_Handleable.hpp"
00038 #include "Teuchos_arrayArg.hpp"
00039
00040 namespace Thyra {
00041
00067 template<class Scalar>
00068 class DefaultBlockedLinearOp
00069 : virtual public PhysicallyBlockedLinearOpBase<Scalar>
00070 , virtual protected SingleScalarLinearOpBase<Scalar>
00071 , virtual public Teuchos::Handleable<LinearOpBase<Scalar, Scalar> >
00072 {
00073 public:
00074
00075 TEUCHOS_GET_RCP(LinearOpBase<Scalar>);
00076
00078 using SingleScalarLinearOpBase<Scalar>::apply;
00079
00082
00084 DefaultBlockedLinearOp();
00085
00087
00090
00092 void beginBlockFill();
00094 void beginBlockFill(
00095 const int numRowBlocks, const int numColBlocks
00096 );
00098 void beginBlockFill(
00099 const Teuchos::RCP<const ProductVectorSpaceBase<Scalar> > &productRange
00100 ,const Teuchos::RCP<const ProductVectorSpaceBase<Scalar> > &productDomain
00101 );
00103 bool blockFillIsActive() const;
00105 bool acceptsBlock(const int i, const int j) const;
00107 void setNonconstBlock(
00108 const int i, const int j
00109 ,const Teuchos::RCP<LinearOpBase<Scalar> > &block
00110 );
00112 void setBlock(
00113 const int i, const int j
00114 ,const Teuchos::RCP<const LinearOpBase<Scalar> > &block
00115 );
00117 void endBlockFill();
00119 void uninitialize();
00120
00122
00125
00127 Teuchos::RCP<const ProductVectorSpaceBase<Scalar> >
00128 productRange() const;
00130 Teuchos::RCP<const ProductVectorSpaceBase<Scalar> >
00131 productDomain() const;
00133 bool blockExists(const int i, const int j) const;
00135 bool blockIsConst(const int i, const int j) const;
00137 Teuchos::RCP<LinearOpBase<Scalar> >
00138 getNonconstBlock(const int i, const int j);
00140 Teuchos::RCP<const LinearOpBase<Scalar> >
00141 getBlock(const int i, const int j) const;
00142
00144
00147
00149 Teuchos::RCP< const VectorSpaceBase<Scalar> > range() const;
00151 Teuchos::RCP< const VectorSpaceBase<Scalar> > domain() const;
00153 Teuchos::RCP<const LinearOpBase<Scalar> > clone() const;
00154
00156
00157
00160
00164 std::string description() const;
00165
00173 void describe(
00174 Teuchos::FancyOStream &out
00175 ,const Teuchos::EVerbosityLevel verbLevel
00176 ) const;
00177
00179
00180 protected:
00181
00184
00188 bool opSupported(ETransp M_trans) const;
00189
00191 void apply(
00192 const ETransp M_trans
00193 ,const MultiVectorBase<Scalar> &X
00194 ,MultiVectorBase<Scalar> *Y
00195 ,const Scalar alpha
00196 ,const Scalar beta
00197 ) const;
00198
00200
00201 private:
00202
00203
00204
00205
00206 typedef Teuchos::ConstNonconstObjectContainer<LinearOpBase<Scalar> > CNCLO;
00207 typedef Teuchos::Array<Teuchos::RCP<const VectorSpaceBase<Scalar> > > vec_array_t;
00208
00209 template<class Scalar2>
00210 struct BlockEntry {
00211 BlockEntry() : i(-1), j(-1) {}
00212 BlockEntry( const int i_in, const int j_in, const CNCLO &block_in )
00213 :i(i_in),j(j_in),block(block_in)
00214 {}
00215 int i;
00216 int j;
00217 CNCLO block;
00218 };
00219
00220
00221
00222
00223 Teuchos::RCP<const ProductVectorSpaceBase<Scalar> > productRange_;
00224 Teuchos::RCP<const ProductVectorSpaceBase<Scalar> > productDomain_;
00225 int numRowBlocks_;
00226 int numColBlocks_;
00227
00228 std::vector<CNCLO> Ops_;
00229
00230 vec_array_t rangeBlocks_;
00231 vec_array_t domainBlocks_;
00232 std::vector<BlockEntry<Scalar> > Ops_stack_;
00233 bool blockFillIsActive_;
00234
00235
00236
00237
00238 void resetStorage( const int numRowBlocks, const int numColBlocks );
00239 void assertBlockFillIsActive(bool) const;
00240 void assertBlockRowCol(const int i, const int j) const;
00241 void setBlockSpaces(
00242 const int i, const int j, const LinearOpBase<Scalar> &block
00243 );
00244 template<class LinearOpType>
00245 void setBlockImpl(
00246 const int i, const int j
00247 ,const Teuchos::RCP<LinearOpType> &block
00248 );
00249
00250
00251 DefaultBlockedLinearOp(const DefaultBlockedLinearOp&);
00252 DefaultBlockedLinearOp& operator=(const DefaultBlockedLinearOp&);
00253
00254 };
00255
00260 template<class Scalar>
00261 Teuchos::RCP<const LinearOpBase<Scalar> >
00262 block2x2(
00263 const Teuchos::RCP<const LinearOpBase<Scalar> > &A00
00264 ,const Teuchos::RCP<const LinearOpBase<Scalar> > &A01
00265 ,const Teuchos::RCP<const LinearOpBase<Scalar> > &A10
00266 ,const Teuchos::RCP<const LinearOpBase<Scalar> > &A11
00267 );
00268
00273 template<class Scalar>
00274 Teuchos::RCP<const LinearOpBase<Scalar> >
00275 block2x1(
00276 const Teuchos::RCP<const LinearOpBase<Scalar> > &A00
00277 ,const Teuchos::RCP<const LinearOpBase<Scalar> > &A10
00278 );
00279
00284 template<class Scalar>
00285 Teuchos::RCP<const LinearOpBase<Scalar> >
00286 block1x2(
00287 const Teuchos::RCP<const LinearOpBase<Scalar> > &A00
00288 ,const Teuchos::RCP<const LinearOpBase<Scalar> > &A01
00289 );
00290
00295 template<class Scalar>
00296 Teuchos::RCP<LinearOpBase<Scalar> >
00297 nonconstBlock2x2(
00298 const Teuchos::RCP<LinearOpBase<Scalar> > &A00
00299 ,const Teuchos::RCP<LinearOpBase<Scalar> > &A01
00300 ,const Teuchos::RCP<LinearOpBase<Scalar> > &A10
00301 ,const Teuchos::RCP<LinearOpBase<Scalar> > &A11
00302 );
00303
00308 template<class Scalar>
00309 Teuchos::RCP<LinearOpBase<Scalar> >
00310 nonconstBlock2x1(
00311 const Teuchos::RCP<LinearOpBase<Scalar> > &A00
00312 ,const Teuchos::RCP<LinearOpBase<Scalar> > &A10
00313 );
00314
00319 template<class Scalar>
00320 Teuchos::RCP<LinearOpBase<Scalar> >
00321 nonconstBlock1x2(
00322 const Teuchos::RCP<LinearOpBase<Scalar> > &A00
00323 ,const Teuchos::RCP<LinearOpBase<Scalar> > &A01
00324 );
00325
00326 }
00327
00328 #endif // THYRA_DEFAULT_BLOCKED_LINEAR_OP_DECL_HPP