Stokhos Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
src
epetra
Stokhos_ProductEpetraMultiVector.cpp
Go to the documentation of this file.
1
// @HEADER
2
// ***********************************************************************
3
//
4
// Stokhos Package
5
// Copyright (2009) 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 Eric T. Phipps (etphipp@sandia.gov).
38
//
39
// ***********************************************************************
40
// @HEADER
41
42
#include "
Stokhos_ProductEpetraMultiVector.hpp
"
43
#include "EpetraExt_BlockUtility.h"
44
#include "
Epetra_Map.h
"
45
46
Stokhos::ProductEpetraMultiVector::
47
ProductEpetraMultiVector
() :
48
ProductContainer
<
Epetra_MultiVector
>()
49
{
50
}
51
52
Stokhos::ProductEpetraMultiVector::
53
ProductEpetraMultiVector
(
const
Teuchos::RCP<const Epetra_BlockMap>& block_map) :
54
ProductContainer
<
Epetra_MultiVector
>(block_map)
55
{
56
}
57
58
Stokhos::ProductEpetraMultiVector::
59
ProductEpetraMultiVector
(
60
const
Teuchos::RCP<const Epetra_BlockMap>& block_map,
61
const
Teuchos::RCP<const Epetra_BlockMap>& coeff_map_,
62
const
Teuchos::RCP<const EpetraExt::MultiComm>& product_comm_,
63
int
num_vectors) :
64
ProductContainer
<
Epetra_MultiVector
>(block_map),
65
coeff_map
(coeff_map_),
66
product_comm
(product_comm_),
67
product_map
(
Teuchos
::rcp(EpetraExt::BlockUtility::GenerateBlockMap(*
coeff_map
,*block_map, *
product_comm
))),
68
bv
(
Teuchos
::rcp(new EpetraExt::BlockMultiVector(*
coeff_map
, *
product_map
,
69
num_vectors)))
70
{
71
for
(
int
i=0; i<this->
size
(); i++)
72
this->
setCoeffPtr
(i,
bv
->GetBlock(i));
73
}
74
75
Stokhos::ProductEpetraMultiVector::
76
ProductEpetraMultiVector
(
77
const
Teuchos::RCP<const Epetra_BlockMap>& block_map,
78
const
Teuchos::RCP<const Epetra_BlockMap>& coeff_map_,
79
const
Teuchos::RCP<const Epetra_BlockMap>& product_map_,
80
const
Teuchos::RCP<const EpetraExt::MultiComm>& product_comm_,
81
int
num_vectors) :
82
ProductContainer
<
Epetra_MultiVector
>(block_map),
83
coeff_map
(coeff_map_),
84
product_comm
(product_comm_),
85
product_map
(product_map_),
86
bv
(
Teuchos
::rcp(new EpetraExt::BlockMultiVector(*
coeff_map
, *
product_map
,
87
num_vectors)))
88
{
89
for
(
int
i=0; i<this->
size
(); i++)
90
this->
setCoeffPtr
(i,
bv
->GetBlock(i));
91
}
92
93
Stokhos::ProductEpetraMultiVector::
94
ProductEpetraMultiVector
(
95
const
Teuchos::RCP<const Epetra_BlockMap>& block_map,
96
const
Teuchos::RCP<const Epetra_BlockMap>& coeff_map_,
97
const
Teuchos::RCP<const Epetra_BlockMap>& product_map_,
98
const
Teuchos::RCP<const EpetraExt::MultiComm>& product_comm_,
99
Epetra_DataAccess
CV,
100
const
Epetra_MultiVector
& block_vector) :
101
ProductContainer
<
Epetra_MultiVector
>(block_map),
102
coeff_map
(coeff_map_),
103
product_comm
(product_comm_),
104
product_map
(product_map_),
105
bv
(
Teuchos
::rcp(new EpetraExt::BlockMultiVector(CV, *
coeff_map
,
106
block_vector)))
107
{
108
for
(
int
i=0; i<this->
size
(); i++)
109
this->
setCoeffPtr
(i,
bv
->GetBlock(i));
110
}
111
112
Stokhos::ProductEpetraMultiVector::
113
ProductEpetraMultiVector
(
const
Stokhos::ProductEpetraMultiVector
& v) :
114
ProductContainer
<
Epetra_MultiVector
>(v),
115
coeff_map
(v.
coeff_map
),
116
product_comm
(v.
product_comm
),
117
product_map
(v.
product_map
),
118
bv
(v.
bv
)
119
{
120
}
121
122
Stokhos::ProductEpetraMultiVector::
123
~ProductEpetraMultiVector
() {}
124
125
Stokhos::ProductEpetraMultiVector
&
126
Stokhos::ProductEpetraMultiVector::
127
operator=
(
const
Stokhos::ProductEpetraMultiVector
& v) {
128
ProductContainer<Epetra_MultiVector>::operator=
(v);
129
coeff_map
= v.
coeff_map
;
130
product_comm
= v.
product_comm
;
131
product_map
= v.
product_map
;
132
bv
= v.
bv
;
// Note this is a shallow copy, which is consistent with above
133
return
*
this
;
134
}
135
136
Stokhos::ProductEpetraMultiVector
&
137
Stokhos::ProductEpetraMultiVector::
138
operator=
(
const
Epetra_MultiVector
& v) {
139
if
(this->
size
() > 0) {
140
if
(
bv
!= Teuchos::null)
141
bv
->Update(1.0, v, 0.0);
142
else
{
143
EpetraExt::BlockMultiVector block_v(
View
, *
coeff_map
, v);
144
for
(
int
i=0; i<this->
size
(); i++)
145
*(
coeff_
[i]) = *(block_v.GetBlock(i));
146
}
147
}
148
return
*
this
;
149
}
150
151
void
152
Stokhos::ProductEpetraMultiVector::
153
assignToBlockMultiVector
(
Epetra_MultiVector
& v)
const
154
{
155
if
(this->
size
() > 0) {
156
if
(
bv
!= Teuchos::null)
157
v.
Update
(1.0, *
bv
, 0.0);
158
else
{
159
EpetraExt::BlockMultiVector block_v(
View
, *
coeff_map
, v);
160
for
(
int
i=0; i<this->
size
(); i++)
161
*(block_v.GetBlock(i)) = *(
coeff_
[i]);
162
}
163
}
164
}
165
166
void
167
Stokhos::ProductEpetraMultiVector::
168
assignFromBlockMultiVector
(
const
Epetra_MultiVector
& v)
169
{
170
if
(this->
size
() > 0) {
171
if
(
bv
!= Teuchos::null)
172
bv
->Update(1.0, v, 0.0);
173
else
{
174
EpetraExt::BlockMultiVector block_v(
View
, *
coeff_map
, v);
175
for
(
int
i=0; i<this->
size
(); i++)
176
*(
coeff_
[i]) = *(block_v.GetBlock(i));
177
}
178
}
179
}
180
181
Teuchos::RCP<const Epetra_BlockMap>
182
Stokhos::ProductEpetraMultiVector::
183
coefficientMap
()
const
{
184
return
coeff_map
;
185
}
186
187
Teuchos::RCP<const Epetra_BlockMap>
188
Stokhos::ProductEpetraMultiVector::
189
productMap
()
const
{
190
return
product_map
;
191
}
192
193
Teuchos::RCP<const EpetraExt::MultiComm>
194
Stokhos::ProductEpetraMultiVector::
195
productComm
()
const
{
196
return
product_comm
;
197
}
198
199
int
200
Stokhos::ProductEpetraMultiVector::
201
numVectors
()
const
{
202
if
(
bv
!= Teuchos::null)
203
return
bv
->NumVectors();
204
else
if
(this->
size
() > 0 && this->
coeff_
[0] != Teuchos::null)
205
return
this->
coeff_
[0]->NumVectors();
206
return
-1;
207
}
208
209
void
210
Stokhos::ProductEpetraMultiVector::
211
reset
(
const
Teuchos::RCP<const Epetra_BlockMap>& block_map,
212
const
Teuchos::RCP<const Epetra_BlockMap>& coeff_map_,
213
const
Teuchos::RCP<const EpetraExt::MultiComm>& product_comm_,
214
int
num_vectors)
215
{
216
ProductContainer<Epetra_MultiVector>::reset
(block_map);
217
coeff_map
= coeff_map_;
218
product_comm
= product_comm_;
219
product_map
=
220
Teuchos::rcp(EpetraExt::BlockUtility::GenerateBlockMap(*
coeff_map
,
221
*block_map,
222
*
product_comm
));
223
bv
= Teuchos::rcp(
new
EpetraExt::BlockMultiVector(*
coeff_map
, *
product_map
,
224
num_vectors));
225
for
(
int
i=0; i<this->
size
(); i++)
226
this->
setCoeffPtr
(i,
bv
->GetBlock(i));
227
}
228
229
void
230
Stokhos::ProductEpetraMultiVector::
231
reset
(
const
Teuchos::RCP<const Epetra_BlockMap>& block_map,
232
const
Teuchos::RCP<const Epetra_BlockMap>& coeff_map_,
233
const
Teuchos::RCP<const Epetra_BlockMap>& product_map_,
234
const
Teuchos::RCP<const EpetraExt::MultiComm>& product_comm_,
235
int
num_vectors)
236
{
237
ProductContainer<Epetra_MultiVector>::reset
(block_map);
238
coeff_map
= coeff_map_;
239
product_comm
= product_comm_;
240
product_map
= product_map_;
241
bv
= Teuchos::rcp(
new
EpetraExt::BlockMultiVector(*
coeff_map
, *
product_map
,
242
num_vectors));
243
for
(
int
i=0; i<this->
size
(); i++)
244
this->
setCoeffPtr
(i,
bv
->GetBlock(i));
245
}
246
247
void
248
Stokhos::ProductEpetraMultiVector::
249
resetCoefficients
(
Epetra_DataAccess
CV,
250
const
Epetra_MultiVector
& block_vector)
251
{
252
bv
=
253
Teuchos::rcp(
new
EpetraExt::BlockMultiVector(CV, *
coeff_map
, block_vector));
254
for
(
int
i=0; i<this->
size
(); i++)
255
this->
setCoeffPtr
(i,
bv
->GetBlock(i));
256
}
257
258
Teuchos::RCP<EpetraExt::BlockMultiVector>
259
Stokhos::ProductEpetraMultiVector::
260
getBlockMultiVector
()
261
{
262
return
bv
;
263
}
264
265
Teuchos::RCP<const EpetraExt::BlockMultiVector>
266
Stokhos::ProductEpetraMultiVector::
267
getBlockMultiVector
()
const
268
{
269
return
bv
;
270
}
271
272
void
273
Stokhos::ProductEpetraMultiVector::
274
setBlockMultiVector
(
const
Teuchos::RCP<EpetraExt::BlockMultiVector>& block_vec)
275
{
276
bv
= block_vec;
277
for
(
int
i=0; i<this->
size
(); i++)
278
this->
setCoeffPtr
(i,
bv
->GetBlock(i));
279
}
Epetra_DataAccess
Epetra_DataAccess
View
View
Definition
Kokkos_View_MP_Vector_Interlaced.hpp:180
Epetra_Map.h
Stokhos_ProductEpetraMultiVector.hpp
Epetra_MultiVector
Epetra_MultiVector::Update
int Update(double ScalarA, const Epetra_MultiVector &A, double ScalarThis)
Stokhos::ProductContainer< Epetra_MultiVector >::ProductContainer
ProductContainer()
Definition
Stokhos_ProductContainerImp.hpp:44
Stokhos::ProductContainer< Epetra_MultiVector >::coeff_
Teuchos::Array< Teuchos::RCP< Epetra_MultiVector > > coeff_
Definition
Stokhos_ProductContainer.hpp:179
Stokhos::ProductContainer::reset
void reset(const Teuchos::RCP< const Epetra_BlockMap > &map)
Resize to new map map.
Definition
Stokhos_ProductContainerImp.hpp:99
Stokhos::ProductContainer::operator=
ProductContainer & operator=(const ProductContainer &)
Assignment.
Definition
Stokhos_ProductContainerImp.hpp:87
Stokhos::ProductContainer< Epetra_MultiVector >::size
ordinal_type size() const
Definition
Stokhos_ProductContainerImp.hpp:139
Stokhos::ProductContainer< Epetra_MultiVector >::setCoeffPtr
void setCoeffPtr(ordinal_type i, const Teuchos::RCP< Epetra_MultiVector > &c)
Definition
Stokhos_ProductContainerImp.hpp:187
Stokhos::ProductEpetraMultiVector
A container class storing products of Epetra_MultiVector's.
Definition
Stokhos_ProductEpetraMultiVector.hpp:57
Stokhos::ProductEpetraMultiVector::coeff_map
Teuchos::RCP< const Epetra_BlockMap > coeff_map
Product map of block vector.
Definition
Stokhos_ProductEpetraMultiVector.hpp:190
Stokhos::ProductEpetraMultiVector::product_map
Teuchos::RCP< const Epetra_BlockMap > product_map
Product map of block vector.
Definition
Stokhos_ProductEpetraMultiVector.hpp:196
Stokhos::ProductEpetraMultiVector::product_comm
Teuchos::RCP< const EpetraExt::MultiComm > product_comm
Product multi-level communicator.
Definition
Stokhos_ProductEpetraMultiVector.hpp:193
Stokhos::ProductEpetraMultiVector::numVectors
int numVectors() const
Get number of vectors.
Definition
Stokhos_ProductEpetraMultiVector.cpp:201
Stokhos::ProductEpetraMultiVector::bv
Teuchos::RCP< EpetraExt::BlockMultiVector > bv
Block vector storing coefficients.
Definition
Stokhos_ProductEpetraMultiVector.hpp:199
Stokhos::ProductEpetraMultiVector::assignFromBlockMultiVector
void assignFromBlockMultiVector(const Epetra_MultiVector &v)
Assignment.
Definition
Stokhos_ProductEpetraMultiVector.cpp:168
Stokhos::ProductEpetraMultiVector::~ProductEpetraMultiVector
virtual ~ProductEpetraMultiVector()
Destructor.
Definition
Stokhos_ProductEpetraMultiVector.cpp:123
Stokhos::ProductEpetraMultiVector::operator=
ProductEpetraMultiVector & operator=(const ProductEpetraMultiVector &v)
Assignment.
Definition
Stokhos_ProductEpetraMultiVector.cpp:127
Stokhos::ProductEpetraMultiVector::resetCoefficients
void resetCoefficients(Epetra_DataAccess CV, const Epetra_MultiVector &block_vector)
Reset vector cofficients.
Definition
Stokhos_ProductEpetraMultiVector.cpp:249
Stokhos::ProductEpetraMultiVector::setBlockMultiVector
void setBlockMultiVector(const Teuchos::RCP< EpetraExt::BlockMultiVector > &block_vec)
Set block vector.
Definition
Stokhos_ProductEpetraMultiVector.cpp:274
Stokhos::ProductEpetraMultiVector::productMap
Teuchos::RCP< const Epetra_BlockMap > productMap() const
Get product map.
Definition
Stokhos_ProductEpetraMultiVector.cpp:189
Stokhos::ProductEpetraMultiVector::getBlockMultiVector
Teuchos::RCP< EpetraExt::BlockMultiVector > getBlockMultiVector()
Get block vector.
Definition
Stokhos_ProductEpetraMultiVector.cpp:260
Stokhos::ProductEpetraMultiVector::assignToBlockMultiVector
void assignToBlockMultiVector(Epetra_MultiVector &v) const
Assignment.
Definition
Stokhos_ProductEpetraMultiVector.cpp:153
Stokhos::ProductEpetraMultiVector::reset
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.
Definition
Stokhos_ProductEpetraMultiVector.cpp:211
Stokhos::ProductEpetraMultiVector::ProductEpetraMultiVector
ProductEpetraMultiVector()
Default constructor.
Definition
Stokhos_ProductEpetraMultiVector.cpp:47
Stokhos::ProductEpetraMultiVector::productComm
Teuchos::RCP< const EpetraExt::MultiComm > productComm() const
Get product comm.
Definition
Stokhos_ProductEpetraMultiVector.cpp:195
Stokhos::ProductEpetraMultiVector::coefficientMap
Teuchos::RCP< const Epetra_BlockMap > coefficientMap() const
Get coefficient map.
Definition
Stokhos_ProductEpetraMultiVector.cpp:183
Teuchos
Definition
Sacado_UQ_PCE_Traits.hpp:136
Generated by
1.17.0