Teko  Version of the Day
 All Classes Files Functions Variables Pages
Teko_BlockedReordering.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Teko: A package for block and physics based preconditioning
4 //
5 // Copyright 2010 NTESS and the Teko contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef __Teko_BlockedReordering_hpp__
11 #define __Teko_BlockedReordering_hpp__
12 
13 #include <string>
14 #include <vector>
15 
16 #include "Teuchos_RCP.hpp"
17 
18 #include "Thyra_LinearOpBase.hpp"
19 #include "Thyra_LinearOpDefaultBase.hpp"
20 #include "Thyra_BlockedLinearOpBase.hpp"
21 #include "Thyra_ProductMultiVectorBase.hpp"
22 
23 namespace Teko {
24 
73  public:
75 
76 
79 
81  BlockReorderManager(int sz) : children_(sz, Teuchos::null) {}
82 
85  for (unsigned int i = 0; i < children_.size(); i++) children_[i] = bmm.children_[i]->Copy();
86  }
87 
89  virtual ~BlockReorderManager() {}
90 
92 
94  virtual Teuchos::RCP<BlockReorderManager> Copy() const {
95  return Teuchos::rcp(new BlockReorderManager(*this));
96  }
97 
99  virtual void SetNumBlocks(int sz) {
100  children_.clear();
101  children_.resize(sz);
102  }
103 
105  virtual int GetNumBlocks() const { return children_.size(); }
106 
115  virtual void SetBlock(int blockIndex, int reorder);
116 
129  virtual void SetBlock(int blockIndex, const Teuchos::RCP<BlockReorderManager>& reorder);
130 
146  virtual const Teuchos::RCP<BlockReorderManager> GetBlock(int blockIndex);
147 
162  virtual const Teuchos::RCP<const BlockReorderManager> GetBlock(int blockIndex) const;
163 
165  virtual std::string toString() const;
166 
168  virtual int LargestIndex() const;
169 
170  protected:
172  std::vector<Teuchos::RCP<BlockReorderManager> > children_;
173 };
174 
180  public:
182 
183 
185  BlockReorderLeaf(int ind) : value_(ind) {}
186 
190 
192  virtual Teuchos::RCP<BlockReorderManager> Copy() const {
193  return Teuchos::rcp(new BlockReorderLeaf(*this));
194  }
195 
197  virtual int GetNumBlocks() const { return 0; }
198 
200  virtual void SetNumBlocks(int /* sz */) {}
201 
203  virtual void SetBlock(int /* blockIndex */, int /* reorder */) {}
204 
206  virtual const Teuchos::RCP<BlockReorderManager> GetBlock(int /* blockIndex */) {
207  return Teuchos::null;
208  }
209 
211  virtual const Teuchos::RCP<const BlockReorderManager> GetBlock(int /* blockIndex */) const {
212  return Teuchos::null;
213  }
214 
216  int GetIndex() const { return value_; }
217 
219  virtual std::string toString() const {
220  std::stringstream ss;
221  ss << value_;
222  return ss.str();
223  }
224 
226  virtual int LargestIndex() const { return value_; }
227 
228  protected:
230 
232  int value_;
233 
234  private:
235  BlockReorderLeaf(); // hidden from users
236 };
237 
260 Teuchos::RCP<const Thyra::LinearOpBase<double> > buildReorderedLinearOp(
261  const BlockReorderManager& bmm,
262  const Teuchos::RCP<const Thyra::BlockedLinearOpBase<double> >& blkOp);
263 
287 Teuchos::RCP<const Thyra::LinearOpBase<double> > buildReorderedLinearOp(
288  const BlockReorderManager& rowMgr, const BlockReorderManager& colMgr,
289  const Teuchos::RCP<const Thyra::BlockedLinearOpBase<double> >& blkOp);
290 
312 Teuchos::RCP<const Thyra::VectorSpaceBase<double> > buildReorderedVectorSpace(
313  const BlockReorderManager& mgr,
314  const Teuchos::RCP<const Thyra::ProductVectorSpaceBase<double> >& blkSpc);
315 
327 Teuchos::RCP<Thyra::MultiVectorBase<double> > buildReorderedMultiVector(
328  const BlockReorderManager& mgr,
329  const Teuchos::RCP<Thyra::ProductMultiVectorBase<double> >& blkVec);
330 
342 Teuchos::RCP<const Thyra::MultiVectorBase<double> > buildReorderedMultiVector(
343  const BlockReorderManager& mgr,
344  const Teuchos::RCP<const Thyra::ProductMultiVectorBase<double> >& blkVec);
345 
358 Teuchos::RCP<Thyra::MultiVectorBase<double> > buildFlatMultiVector(
359  const BlockReorderManager& mgr,
360  const Teuchos::RCP<Thyra::ProductMultiVectorBase<double> >& blkVec);
361 
374 Teuchos::RCP<const Thyra::MultiVectorBase<double> > buildFlatMultiVector(
375  const BlockReorderManager& mgr,
376  const Teuchos::RCP<const Thyra::ProductMultiVectorBase<double> >& blkVec);
377 
380 Teuchos::RCP<const Thyra::VectorSpaceBase<double> > buildFlatVectorSpace(
381  const BlockReorderManager& mgr,
382  const Teuchos::RCP<const Thyra::VectorSpaceBase<double> >& blkSpc);
383 
397 Teuchos::RCP<const BlockReorderManager> blockedReorderFromString(std::string& reorder);
398 
399 } // end namespace Teko
400 
401 #endif
int GetIndex() const
Get the the index that is stored in this block.
int value_
The value of the index for this leaf.
virtual std::string toString() const
Return a string description of this leaf class.
virtual const Teuchos::RCP< const BlockReorderManager > GetBlock(int) const
Get a particular subblock...this returns null.
virtual const Teuchos::RCP< BlockReorderManager > GetBlock(int)
Get a particular subblock...this returns null.
BlockReorderManager(const BlockReorderManager &bmm)
Copy constructor.
std::vector< Teuchos::RCP< BlockReorderManager > > children_
Definitions of the subblocks.
Class that describes how a flat blocked operator should be reordered.
virtual int GetNumBlocks() const
Gets the number of subblocks.
virtual int LargestIndex() const
Largest index in this manager.
virtual const Teuchos::RCP< BlockReorderManager > GetBlock(int blockIndex)
Get a particular block. If there is no block at this index location return a new one.
virtual ~BlockReorderManager()
Do nothing destructor.
virtual Teuchos::RCP< BlockReorderManager > Copy() const
Make a copy of this object.
virtual void SetNumBlocks(int sz)
Sets the number of subblocks.
Teuchos::RCP< Thyra::MultiVectorBase< double > > buildReorderedMultiVector(const BlockReorderManager &mgr, const Teuchos::RCP< Thyra::ProductMultiVectorBase< double > > &blkVec)
Convert a flat multi vector into a reordered multivector.
virtual int LargestIndex() const
Largest index in this manager.
BlockReorderLeaf(int ind)
Simple constructor that sets the index.
BlockReorderManager(int sz)
Set this level to have size sz.
virtual Teuchos::RCP< BlockReorderManager > Copy() const
Returns a copy of this object.
BlockReorderLeaf(const BlockReorderLeaf &brl)
Copy constructor.
virtual std::string toString() const
For sanities sake, print a readable string.
virtual void SetBlock(int, int)
Set the sub block, this does nothing b/c its a leaf.
virtual int GetNumBlocks() const
Get the number of subblocks (this one returns 0 b/c its a leaf)
virtual void SetNumBlocks(int)
Set the number of subblocks (this one does nothing b/c its a leaf)
BlockReorderManager()
Basic empty constructor.
Teuchos::RCP< const BlockReorderManager > blockedReorderFromString(std::string &reorder)
Convert a string to a block reorder manager object.
virtual void SetBlock(int blockIndex, int reorder)
Sets the sublock to a specific index value.