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
00030 #ifndef THYRA_DEFAULT_BLOCKED_LINEAR_OP_DECL_HPP
00031 #define THYRA_DEFAULT_BLOCKED_LINEAR_OP_DECL_HPP
00032
00033
00034 #include "Thyra_PhysicallyBlockedLinearOpBase.hpp"
00035 #include "Thyra_SingleScalarLinearOpBase.hpp"
00036 #include "Thyra_ProductVectorSpaceBase.hpp"
00037 #include "Teuchos_ConstNonconstObjectContainer.hpp"
00038 #include "Teuchos_Array.hpp"
00039 #include "Teuchos_Handleable.hpp"
00040 #include "Teuchos_arrayArg.hpp"
00041
00042
00043 namespace Thyra {
00044
00045
00046 template<class Scalar> class DefaultProductVectorSpace;
00047
00048
00074 template<class Scalar>
00075 class DefaultBlockedLinearOp
00076 : virtual public PhysicallyBlockedLinearOpBase<Scalar>
00077 , virtual protected SingleScalarLinearOpBase<Scalar>
00078 , virtual public Teuchos::Handleable<LinearOpBase<Scalar, Scalar> >
00079 {
00080 public:
00081
00082 #ifdef THYRA_INJECT_USING_DECLARATIONS
00083 using SingleScalarLinearOpBase<Scalar>::apply;
00084 #endif
00085
00086
00087 TEUCHOS_GET_RCP(LinearOpBase<Scalar>);
00088
00091
00093 DefaultBlockedLinearOp();
00094
00096
00099
00101 void beginBlockFill();
00103 void beginBlockFill(
00104 const int numRowBlocks, const int numColBlocks
00105 );
00107 void beginBlockFill(
00108 const Teuchos::RCP<const ProductVectorSpaceBase<Scalar> > &productRange,
00109 const Teuchos::RCP<const ProductVectorSpaceBase<Scalar> > &productDomain
00110 );
00112 bool blockFillIsActive() const;
00114 bool acceptsBlock(const int i, const int j) const;
00116 void setNonconstBlock(
00117 const int i, const int j,
00118 const Teuchos::RCP<LinearOpBase<Scalar> > &block
00119 );
00121 void setBlock(
00122 const int i, const int j
00123 ,const Teuchos::RCP<const LinearOpBase<Scalar> > &block
00124 );
00126 void endBlockFill();
00128 void uninitialize();
00129
00131
00134
00136 Teuchos::RCP<const ProductVectorSpaceBase<Scalar> >
00137 productRange() const;
00139 Teuchos::RCP<const ProductVectorSpaceBase<Scalar> >
00140 productDomain() const;
00142 bool blockExists(const int i, const int j) const;
00144 bool blockIsConst(const int i, const int j) const;
00146 Teuchos::RCP<LinearOpBase<Scalar> >
00147 getNonconstBlock(const int i, const int j);
00149 Teuchos::RCP<const LinearOpBase<Scalar> >
00150 getBlock(const int i, const int j) const;
00151
00153
00156
00158 Teuchos::RCP< const VectorSpaceBase<Scalar> > range() const;
00160 Teuchos::RCP< const VectorSpaceBase<Scalar> > domain() const;
00162 Teuchos::RCP<const LinearOpBase<Scalar> > clone() const;
00163
00165
00168
00172 std::string description() const;
00173
00181 void describe(
00182 Teuchos::FancyOStream &out,
00183 const Teuchos::EVerbosityLevel verbLevel
00184 ) const;
00185
00187
00188 protected:
00189
00192
00196 bool opSupported(EOpTransp M_trans) const;
00197
00199 void apply(
00200 const EOpTransp M_trans,
00201 const MultiVectorBase<Scalar> &X,
00202 MultiVectorBase<Scalar> *Y,
00203 const Scalar alpha,
00204 const Scalar beta
00205 ) const;
00206
00208
00209 private:
00210
00211
00212
00213
00214 typedef Teuchos::ConstNonconstObjectContainer<LinearOpBase<Scalar> > CNCLO;
00215 typedef Teuchos::Array<Teuchos::RCP<const VectorSpaceBase<Scalar> > > vec_array_t;
00216
00217 template<class Scalar2>
00218 struct BlockEntry {
00219 BlockEntry() : i(-1), j(-1) {}
00220 BlockEntry( const int i_in, const int j_in, const CNCLO &block_in )
00221 :i(i_in),j(j_in),block(block_in)
00222 {}
00223 int i;
00224 int j;
00225 CNCLO block;
00226 };
00227
00228
00229
00230
00231 Teuchos::RCP<const ProductVectorSpaceBase<Scalar> > productRange_;
00232 Teuchos::RCP<const ProductVectorSpaceBase<Scalar> > productDomain_;
00233 Teuchos::RCP<const DefaultProductVectorSpace<Scalar> > defaultProductRange_;
00234 Teuchos::RCP<const DefaultProductVectorSpace<Scalar> > defaultProductDomain_;
00235 int numRowBlocks_;
00236 int numColBlocks_;
00237
00238 std::vector<CNCLO> Ops_;
00239
00240 vec_array_t rangeBlocks_;
00241 vec_array_t domainBlocks_;
00242 std::vector<BlockEntry<Scalar> > Ops_stack_;
00243 bool blockFillIsActive_;
00244
00245
00246
00247
00248 void resetStorage( const int numRowBlocks, const int numColBlocks );
00249 void assertBlockFillIsActive(bool) const;
00250 void assertBlockRowCol(const int i, const int j) const;
00251 void setBlockSpaces(
00252 const int i, const int j, const LinearOpBase<Scalar> &block
00253 );
00254 template<class LinearOpType>
00255 void setBlockImpl(
00256 const int i, const int j,
00257 const Teuchos::RCP<LinearOpType> &block
00258 );
00259 void adjustBlockSpaces();
00260
00261
00262 DefaultBlockedLinearOp(const DefaultBlockedLinearOp&);
00263 DefaultBlockedLinearOp& operator=(const DefaultBlockedLinearOp&);
00264
00265 };
00266
00267
00272 template<class Scalar>
00273 RCP<DefaultBlockedLinearOp<Scalar> > defaultBlockedLinearOp();
00274
00275
00280 template<class Scalar>
00281 Teuchos::RCP<const LinearOpBase<Scalar> >
00282 block1x1(
00283 const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
00284 const std::string &label = ""
00285 );
00286
00287
00292 template<class Scalar>
00293 Teuchos::RCP<const LinearOpBase<Scalar> >
00294 block1x2(
00295 const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
00296 const Teuchos::RCP<const LinearOpBase<Scalar> > &A01,
00297 const std::string &label = ""
00298 );
00299
00300
00305 template<class Scalar>
00306 Teuchos::RCP<const LinearOpBase<Scalar> >
00307 block2x1(
00308 const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
00309 const Teuchos::RCP<const LinearOpBase<Scalar> > &A10,
00310 const std::string &label = ""
00311 );
00312
00313
00318 template<class Scalar>
00319 Teuchos::RCP<const LinearOpBase<Scalar> >
00320 block2x2(
00321 const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
00322 const Teuchos::RCP<const LinearOpBase<Scalar> > &A01,
00323 const Teuchos::RCP<const LinearOpBase<Scalar> > &A10,
00324 const Teuchos::RCP<const LinearOpBase<Scalar> > &A11,
00325 const std::string &label = ""
00326 );
00327
00328
00333 template<class Scalar>
00334 Teuchos::RCP<LinearOpBase<Scalar> >
00335 nonconstBlock1x1(
00336 const Teuchos::RCP<LinearOpBase<Scalar> > &A00,
00337 const std::string &label = ""
00338 );
00339
00340
00345 template<class Scalar>
00346 Teuchos::RCP<LinearOpBase<Scalar> >
00347 nonconstBlock1x2(
00348 const Teuchos::RCP<LinearOpBase<Scalar> > &A00,
00349 const Teuchos::RCP<LinearOpBase<Scalar> > &A01,
00350 const std::string &label = ""
00351 );
00352
00353
00358 template<class Scalar>
00359 Teuchos::RCP<LinearOpBase<Scalar> >
00360 nonconstBlock2x1(
00361 const Teuchos::RCP<LinearOpBase<Scalar> > &A00,
00362 const Teuchos::RCP<LinearOpBase<Scalar> > &A10,
00363 const std::string &label = ""
00364 );
00365
00366
00371 template<class Scalar>
00372 Teuchos::RCP<LinearOpBase<Scalar> >
00373 nonconstBlock2x2(
00374 const Teuchos::RCP<LinearOpBase<Scalar> > &A00,
00375 const Teuchos::RCP<LinearOpBase<Scalar> > &A01,
00376 const Teuchos::RCP<LinearOpBase<Scalar> > &A10,
00377 const Teuchos::RCP<LinearOpBase<Scalar> > &A11,
00378 const std::string &label = ""
00379 );
00380
00381
00382 }
00383
00384
00385 #endif // THYRA_DEFAULT_BLOCKED_LINEAR_OP_DECL_HPP