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