Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_ProductEpetraMultiVector.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
11 #include "EpetraExt_BlockUtility.h"
12 #include "Epetra_Map.h"
13 
17 {
18 }
19 
23 {
24 }
25 
28  const Teuchos::RCP<const Epetra_BlockMap>& block_map,
29  const Teuchos::RCP<const Epetra_BlockMap>& coeff_map_,
30  const Teuchos::RCP<const EpetraExt::MultiComm>& product_comm_,
31  int num_vectors) :
33  coeff_map(coeff_map_),
34  product_comm(product_comm_),
35  product_map(Teuchos::rcp(EpetraExt::BlockUtility::GenerateBlockMap(*coeff_map,*block_map, *product_comm))),
36  bv(Teuchos::rcp(new EpetraExt::BlockMultiVector(*coeff_map, *product_map,
37  num_vectors)))
38 {
39  for (int i=0; i<this->size(); i++)
40  this->setCoeffPtr(i, bv->GetBlock(i));
41 }
42 
45  const Teuchos::RCP<const Epetra_BlockMap>& block_map,
46  const Teuchos::RCP<const Epetra_BlockMap>& coeff_map_,
47  const Teuchos::RCP<const Epetra_BlockMap>& product_map_,
48  const Teuchos::RCP<const EpetraExt::MultiComm>& product_comm_,
49  int num_vectors) :
51  coeff_map(coeff_map_),
52  product_comm(product_comm_),
53  product_map(product_map_),
54  bv(Teuchos::rcp(new EpetraExt::BlockMultiVector(*coeff_map, *product_map,
55  num_vectors)))
56 {
57  for (int i=0; i<this->size(); i++)
58  this->setCoeffPtr(i, bv->GetBlock(i));
59 }
60 
63  const Teuchos::RCP<const Epetra_BlockMap>& block_map,
64  const Teuchos::RCP<const Epetra_BlockMap>& coeff_map_,
65  const Teuchos::RCP<const Epetra_BlockMap>& product_map_,
66  const Teuchos::RCP<const EpetraExt::MultiComm>& product_comm_,
68  const Epetra_MultiVector& block_vector) :
70  coeff_map(coeff_map_),
71  product_comm(product_comm_),
72  product_map(product_map_),
73  bv(Teuchos::rcp(new EpetraExt::BlockMultiVector(CV, *coeff_map,
74  block_vector)))
75 {
76  for (int i=0; i<this->size(); i++)
77  this->setCoeffPtr(i, bv->GetBlock(i));
78 }
79 
83  coeff_map(v.coeff_map),
84  product_comm(v.product_comm),
85  product_map(v.product_map),
86  bv(v.bv)
87 {
88 }
89 
92 
97  coeff_map = v.coeff_map;
98  product_comm = v.product_comm;
99  product_map = v.product_map;
100  bv = v.bv; // Note this is a shallow copy, which is consistent with above
101  return *this;
102 }
103 
107  if (this->size() > 0) {
108  if (bv != Teuchos::null)
109  bv->Update(1.0, v, 0.0);
110  else {
111  EpetraExt::BlockMultiVector block_v(View, *coeff_map, v);
112  for (int i=0; i<this->size(); i++)
113  *(coeff_[i]) = *(block_v.GetBlock(i));
114  }
115  }
116  return *this;
117 }
118 
119 void
122 {
123  if (this->size() > 0) {
124  if (bv != Teuchos::null)
125  v.Update(1.0, *bv, 0.0);
126  else {
127  EpetraExt::BlockMultiVector block_v(View, *coeff_map, v);
128  for (int i=0; i<this->size(); i++)
129  *(block_v.GetBlock(i)) = *(coeff_[i]);
130  }
131  }
132 }
133 
134 void
137 {
138  if (this->size() > 0) {
139  if (bv != Teuchos::null)
140  bv->Update(1.0, v, 0.0);
141  else {
142  EpetraExt::BlockMultiVector block_v(View, *coeff_map, v);
143  for (int i=0; i<this->size(); i++)
144  *(coeff_[i]) = *(block_v.GetBlock(i));
145  }
146  }
147 }
148 
151 coefficientMap() const {
152  return coeff_map;
153 }
154 
157 productMap() const {
158  return product_map;
159 }
160 
163 productComm() const {
164  return product_comm;
165 }
166 
167 int
169 numVectors() const {
170  if (bv != Teuchos::null)
171  return bv->NumVectors();
172  else if (this->size() > 0 && this->coeff_[0] != Teuchos::null)
173  return this->coeff_[0]->NumVectors();
174  return -1;
175 }
176 
177 void
180  const Teuchos::RCP<const Epetra_BlockMap>& coeff_map_,
181  const Teuchos::RCP<const EpetraExt::MultiComm>& product_comm_,
182  int num_vectors)
183 {
185  coeff_map = coeff_map_;
186  product_comm = product_comm_;
187  product_map =
188  Teuchos::rcp(EpetraExt::BlockUtility::GenerateBlockMap(*coeff_map,
189  *block_map,
190  *product_comm));
191  bv = Teuchos::rcp(new EpetraExt::BlockMultiVector(*coeff_map, *product_map,
192  num_vectors));
193  for (int i=0; i<this->size(); i++)
194  this->setCoeffPtr(i, bv->GetBlock(i));
195 }
196 
197 void
200  const Teuchos::RCP<const Epetra_BlockMap>& coeff_map_,
201  const Teuchos::RCP<const Epetra_BlockMap>& product_map_,
202  const Teuchos::RCP<const EpetraExt::MultiComm>& product_comm_,
203  int num_vectors)
204 {
206  coeff_map = coeff_map_;
207  product_comm = product_comm_;
208  product_map = product_map_;
209  bv = Teuchos::rcp(new EpetraExt::BlockMultiVector(*coeff_map, *product_map,
210  num_vectors));
211  for (int i=0; i<this->size(); i++)
212  this->setCoeffPtr(i, bv->GetBlock(i));
213 }
214 
215 void
218  const Epetra_MultiVector& block_vector)
219 {
220  bv =
221  Teuchos::rcp(new EpetraExt::BlockMultiVector(CV, *coeff_map, block_vector));
222  for (int i=0; i<this->size(); i++)
223  this->setCoeffPtr(i, bv->GetBlock(i));
224 }
225 
229 {
230  return bv;
231 }
232 
236 {
237  return bv;
238 }
239 
240 void
243 {
244  bv = block_vec;
245  for (int i=0; i<this->size(); i++)
246  this->setCoeffPtr(i, bv->GetBlock(i));
247 }
void setCoeffPtr(ordinal_type i, const Teuchos::RCP< Epetra_MultiVector > &c)
Set coefficient i to c.
Teuchos::RCP< const EpetraExt::MultiComm > product_comm
Product multi-level communicator.
int numVectors() const
Get number of vectors.
ProductContainer & operator=(const ProductContainer &)
Assignment.
void assignToBlockMultiVector(Epetra_MultiVector &v) const
Assignment.
Teuchos::RCP< EpetraExt::BlockMultiVector > bv
Block vector storing coefficients.
ProductEpetraMultiVector & operator=(const ProductEpetraMultiVector &v)
Assignment.
Teuchos::RCP< const EpetraExt::MultiComm > productComm() const
Get product comm.
void reset(const Teuchos::RCP< const Epetra_BlockMap > &map)
Resize to new map map.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< const Epetra_BlockMap > coefficientMap() const
Get coefficient map.
void reset(const Teuchos::RCP< const Epetra_BlockMap > &block_map, const Teuchos::RCP< const Epetra_BlockMap > &coeff_map, const Teuchos::RCP< const EpetraExt::MultiComm > &product_comm, int num_vectors)
Reset to a new size.
A container class storing products of Epetra_MultiVector&#39;s.
Teuchos::RCP< EpetraExt::BlockMultiVector > getBlockMultiVector()
Get block vector.
A product (in the mathematical sense) container class whose coefficients are vectors, operators, or in general any type that would have an expensive copy constructor.
Teuchos::RCP< const Epetra_BlockMap > productMap() const
Get product map.
Teuchos::RCP< const Epetra_BlockMap > coeff_map
Product map of block vector.
void setBlockMultiVector(const Teuchos::RCP< EpetraExt::BlockMultiVector > &block_vec)
Set block vector.
void resetCoefficients(Epetra_DataAccess CV, const Epetra_MultiVector &block_vector)
Reset vector cofficients.
Teuchos::RCP< const Epetra_BlockMap > product_map
Product map of block vector.
void assignFromBlockMultiVector(const Epetra_MultiVector &v)
Assignment.
Epetra_DataAccess
ordinal_type size() const
Return size.