Stokhos Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
src
epetra
Stokhos_EpetraVectorOrthogPoly.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_EpetraVectorOrthogPoly.hpp
"
43
44
Stokhos::EpetraVectorOrthogPoly::
45
EpetraVectorOrthogPoly
() :
46
ProductContainer
<
Epetra_Vector
>(),
47
VectorOrthogPoly
<
Epetra_Vector
>(),
48
ProductEpetraVector
()
49
{
50
}
51
52
Stokhos::EpetraVectorOrthogPoly::
53
EpetraVectorOrthogPoly
(
54
const
Teuchos::RCP<
const
Stokhos::OrthogPolyBasis<int, double>
>&
basis
,
55
const
Teuchos::RCP<const Epetra_BlockMap>& block_map) :
56
ProductContainer
<
Epetra_Vector
>(block_map),
57
VectorOrthogPoly
<
Epetra_Vector
>(
basis
, block_map),
58
ProductEpetraVector
(block_map)
59
{
60
}
61
62
Stokhos::EpetraVectorOrthogPoly::
63
EpetraVectorOrthogPoly
(
64
const
Teuchos::RCP<
const
Stokhos::OrthogPolyBasis<int, double>
>&
basis
,
65
const
Teuchos::RCP<const Epetra_BlockMap>& block_map,
66
const
Teuchos::RCP<const Epetra_BlockMap>&
coeff_map
,
67
const
Teuchos::RCP<const EpetraExt::MultiComm>&
product_comm
) :
68
ProductContainer
<
Epetra_Vector
>(block_map),
69
VectorOrthogPoly
<
Epetra_Vector
>(
basis
, block_map),
70
ProductEpetraVector
(block_map,
coeff_map
,
product_comm
)
71
{
72
}
73
74
Stokhos::EpetraVectorOrthogPoly::
75
EpetraVectorOrthogPoly
(
76
const
Teuchos::RCP<
const
Stokhos::OrthogPolyBasis<int, double>
>&
basis
,
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
ProductContainer
<
Epetra_Vector
>(block_map),
82
VectorOrthogPoly
<
Epetra_Vector
>(
basis
, block_map),
83
ProductEpetraVector
(block_map,
coeff_map
,
product_map
,
product_comm
)
84
{
85
}
86
87
Stokhos::EpetraVectorOrthogPoly::
88
EpetraVectorOrthogPoly
(
89
const
Teuchos::RCP<
const
Stokhos::OrthogPolyBasis<int, double>
>&
basis
,
90
const
Teuchos::RCP<const Epetra_BlockMap>& block_map,
91
const
Teuchos::RCP<const Epetra_BlockMap>&
coeff_map
,
92
const
Teuchos::RCP<const Epetra_BlockMap>&
product_map
,
93
const
Teuchos::RCP<const EpetraExt::MultiComm>&
product_comm
,
94
Epetra_DataAccess
CV,
95
const
Epetra_Vector
& block_vector) :
96
ProductContainer
<
Epetra_Vector
>(block_map),
97
VectorOrthogPoly
<
Epetra_Vector
>(
basis
, block_map),
98
ProductEpetraVector
(block_map,
coeff_map
,
product_map
,
product_comm
, CV,
99
block_vector)
100
{
101
}
102
103
Stokhos::EpetraVectorOrthogPoly::
104
EpetraVectorOrthogPoly
(
const
Stokhos::EpetraVectorOrthogPoly
& v) :
105
ProductContainer
<
Epetra_Vector
>(v),
106
VectorOrthogPoly
<
Epetra_Vector
>(v),
107
ProductEpetraVector
(v)
108
{
109
}
110
111
Stokhos::EpetraVectorOrthogPoly::
112
~EpetraVectorOrthogPoly
() {}
113
114
Stokhos::EpetraVectorOrthogPoly
&
115
Stokhos::EpetraVectorOrthogPoly::
116
operator=
(
const
Stokhos::EpetraVectorOrthogPoly
& v) {
117
ProductEpetraVector::operator=
(v);
118
this->
basis_
= v.
basis_
;
119
return
*
this
;
120
}
121
122
void
123
Stokhos::EpetraVectorOrthogPoly::
124
reset
(
125
const
Teuchos::RCP<
const
Stokhos::OrthogPolyBasis<int, double>
>& new_basis,
126
const
Teuchos::RCP<const Epetra_BlockMap>& block_map,
127
const
Teuchos::RCP<const Epetra_BlockMap>&
coeff_map
,
128
const
Teuchos::RCP<const EpetraExt::MultiComm>&
product_comm
)
129
{
130
ProductEpetraVector::reset
(block_map,
coeff_map
,
product_comm
);
131
this->
basis_
= new_basis;
132
}
133
134
void
135
Stokhos::EpetraVectorOrthogPoly::
136
reset
(
137
const
Teuchos::RCP<
const
Stokhos::OrthogPolyBasis<int, double>
>& new_basis,
138
const
Teuchos::RCP<const Epetra_BlockMap>& block_map,
139
const
Teuchos::RCP<const Epetra_BlockMap>&
coeff_map
,
140
const
Teuchos::RCP<const Epetra_BlockMap>&
product_map
,
141
const
Teuchos::RCP<const EpetraExt::MultiComm>&
product_comm
)
142
{
143
ProductEpetraVector::reset
(block_map,
coeff_map
,
product_map
,
product_comm
);
144
this->
basis_
= new_basis;
145
}
146
147
void
148
Stokhos::EpetraVectorOrthogPoly::
149
computeMean
(
Epetra_Vector
& v)
const
150
{
151
if
(this->
map_
->Comm().NumProc() == 1 || !this->map_->DistributedGlobal()) {
152
v.
Scale
(1.0, *(this->
coeff_
[0]));
153
return
;
154
}
155
156
int
root = -1;
157
int
gid = 0;
158
int
lid = -1;
159
this->
map_
->RemoteIDList(1, &gid, &root, &lid);
160
if
(this->
map_
->Comm().MyPID() == root) {
161
v.
Scale
(1.0, *(this->
coeff_
[lid]));
162
}
163
this->
map_
->Comm().Broadcast(v.
Values
(), v.
MyLength
(), root);
164
}
165
166
void
167
Stokhos::EpetraVectorOrthogPoly::
168
computeVariance
(
Epetra_Vector
& v)
const
169
{
170
Epetra_Vector
*v_local = NULL;
171
bool
is_parallel = (this->
map_
->Comm().NumProc() > 1) &&
172
this->
map_
->DistributedGlobal();
173
if
(is_parallel)
174
v_local =
new
Epetra_Vector
(v.
Map
());
175
else
176
v_local = &v;
177
178
// Compute partial variance with terms on this processor
179
const
Teuchos::Array<double>& nrm2 = this->
basis_
->norm_squared();
180
v_local->
PutScalar
(0.0);
181
int
i_gid;
182
for
(
int
i=0; i<this->
size
(); i++) {
183
i_gid = this->
map_
->GID(i);
184
if
(i_gid != 0)
185
v_local->
Multiply
(nrm2[i_gid], *(this->
coeff_
[i]), *(this->
coeff_
[i]),
186
1.0);
187
}
188
189
// Compute total variance by summing across all processors
190
if
(is_parallel)
191
this->
map_
->Comm().SumAll(v_local->
Values
(), v.
Values
(), v.
MyLength
());
192
}
193
194
void
195
Stokhos::EpetraVectorOrthogPoly::
196
computeStandardDeviation
(
Epetra_Vector
& v)
const
197
{
198
// Compute variance
199
computeVariance
(v);
200
201
// Compute standard deviation
202
for
(
int
i=0; i<v.
MyLength
(); i++)
203
v[i] = std::sqrt(v[i]);
204
}
Epetra_DataAccess
Epetra_DataAccess
Stokhos_EpetraVectorOrthogPoly.hpp
Epetra_DistObject::Map
const Epetra_BlockMap & Map() const
Epetra_MultiVector::Scale
int Scale(double ScalarValue)
Epetra_MultiVector::MyLength
int MyLength() const
Epetra_MultiVector::Values
double * Values() const
Epetra_MultiVector::Multiply
int Multiply(char TransA, char TransB, double ScalarAB, const Epetra_MultiVector &A, const Epetra_MultiVector &B, double ScalarThis)
Epetra_MultiVector::PutScalar
int PutScalar(double ScalarConstant)
Epetra_Vector
Stokhos::EpetraVectorOrthogPoly
A container class storing an orthogonal polynomial whose coefficients are vectors,...
Definition
Stokhos_EpetraVectorOrthogPoly.hpp:57
Stokhos::EpetraVectorOrthogPoly::reset
void reset(const Teuchos::RCP< const Stokhos::OrthogPolyBasis< int, double > > &basis, 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 basis.
Definition
Stokhos_EpetraVectorOrthogPoly.cpp:124
Stokhos::EpetraVectorOrthogPoly::operator=
EpetraVectorOrthogPoly & operator=(const EpetraVectorOrthogPoly &v)
Assignment.
Definition
Stokhos_EpetraVectorOrthogPoly.cpp:116
Stokhos::EpetraVectorOrthogPoly::EpetraVectorOrthogPoly
EpetraVectorOrthogPoly()
Constructor with no basis.
Definition
Stokhos_EpetraVectorOrthogPoly.cpp:45
Stokhos::EpetraVectorOrthogPoly::computeMean
void computeMean(Epetra_Vector &v) const
Compute mean.
Definition
Stokhos_EpetraVectorOrthogPoly.cpp:149
Stokhos::EpetraVectorOrthogPoly::computeVariance
void computeVariance(Epetra_Vector &v) const
Compute variance.
Definition
Stokhos_EpetraVectorOrthogPoly.cpp:168
Stokhos::EpetraVectorOrthogPoly::computeStandardDeviation
void computeStandardDeviation(Epetra_Vector &v) const
Compute standard deviation.
Definition
Stokhos_EpetraVectorOrthogPoly.cpp:196
Stokhos::EpetraVectorOrthogPoly::~EpetraVectorOrthogPoly
virtual ~EpetraVectorOrthogPoly()
Destructor.
Definition
Stokhos_EpetraVectorOrthogPoly.cpp:112
Stokhos::OrthogPolyBasis
Abstract base class for multivariate orthogonal polynomials.
Definition
Stokhos_OrthogPolyBasis.hpp:74
Stokhos::ProductContainer
A product (in the mathematical sense) container class whose coefficients are vectors,...
Definition
Stokhos_ProductContainer.hpp:61
Stokhos::ProductContainer< Epetra_Vector >::coeff_
Teuchos::Array< Teuchos::RCP< Epetra_Vector > > coeff_
Definition
Stokhos_ProductContainer.hpp:179
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::ProductEpetraVector::product_comm
Teuchos::RCP< const EpetraExt::MultiComm > product_comm
Product multi-level communicator.
Definition
Stokhos_ProductEpetraVector.hpp:189
Stokhos::ProductEpetraVector::product_map
Teuchos::RCP< const Epetra_BlockMap > product_map
Product map of block vector.
Definition
Stokhos_ProductEpetraVector.hpp:192
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::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::operator=
ProductEpetraVector & operator=(const ProductEpetraVector &v)
Assignment.
Definition
Stokhos_ProductEpetraVector.cpp:122
Stokhos::VectorOrthogPoly< Epetra_Vector >::basis
Teuchos::RCP< const Stokhos::OrthogPolyBasis< ordinal_type, value_type > > basis() const
Definition
Stokhos_VectorOrthogPolyImp.hpp:114
Stokhos::VectorOrthogPoly< Epetra_Vector >::basis_
Teuchos::RCP< const Stokhos::OrthogPolyBasis< ordinal_type, value_type > > basis_
Definition
Stokhos_VectorOrthogPoly.hpp:148
Stokhos::VectorOrthogPoly< Epetra_Vector >::VectorOrthogPoly
VectorOrthogPoly()
Definition
Stokhos_VectorOrthogPolyImp.hpp:46
Generated by
1.17.0