Stokhos Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
src
epetra
Stokhos_VectorOrthogPolyImp.hpp
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_ProductBasis.hpp
"
43
44
template
<
typename
coeff_type>
45
Stokhos::VectorOrthogPoly<coeff_type>::
46
VectorOrthogPoly
() :
47
ProductContainer
<coeff_type>(),
48
basis_
()
49
{
50
}
51
52
template
<
typename
coeff_type>
53
Stokhos::VectorOrthogPoly<coeff_type>::
54
VectorOrthogPoly
(
55
const
Teuchos::RCP<
const
Stokhos::OrthogPolyBasis<ordinal_type, value_type>
>& theBasis,
56
const
Teuchos::RCP<const Epetra_BlockMap>& theMap) :
57
ProductContainer
<coeff_type>(theMap),
58
basis_
(theBasis)
59
{
60
}
61
62
template
<
typename
coeff_type>
63
Stokhos::VectorOrthogPoly<coeff_type>::
64
VectorOrthogPoly
(
65
const
Teuchos::RCP<
const
Stokhos::OrthogPolyBasis<ordinal_type, value_type>
>& theBasis,
66
const
Teuchos::RCP<const Epetra_BlockMap>& theMap,
67
const
typename
traits_type::cloner_type& cloner)
68
:
ProductContainer
<coeff_type>(theMap, cloner),
69
basis_
(theBasis)
70
{
71
}
72
73
template
<
typename
coeff_type>
74
Stokhos::VectorOrthogPoly<coeff_type>::
75
VectorOrthogPoly
(
const
Stokhos::VectorOrthogPoly<coeff_type>
& v) :
76
ProductContainer
<coeff_type>(v),
77
basis_
(v.
basis_
)
78
{
79
}
80
81
template
<
typename
coeff_type>
82
Stokhos::VectorOrthogPoly<coeff_type>::
83
~VectorOrthogPoly
()
84
{
85
}
86
87
template
<
typename
coeff_type>
88
Stokhos::VectorOrthogPoly<coeff_type>
&
89
Stokhos::VectorOrthogPoly<coeff_type>::
90
operator=
(
const
Stokhos::VectorOrthogPoly<coeff_type>
& v)
91
{
92
if
(
this
!= &v) {
93
ProductContainer<coeff_type>::operator=
(v);
94
basis_
= v.
basis_
;
95
}
96
return
*
this
;
97
}
98
99
template
<
typename
coeff_type>
100
void
101
Stokhos::VectorOrthogPoly<coeff_type>::
102
reset
(
103
const
Teuchos::RCP<
const
Stokhos::OrthogPolyBasis<ordinal_type, value_type>
>& new_basis,
104
const
Teuchos::RCP<const Epetra_BlockMap>& new_map,
105
const
typename
traits_type::cloner_type& cloner)
106
{
107
basis_
= new_basis;
108
ProductContainer<coeff_type>::reset
(new_map, cloner);
109
}
110
111
template
<
typename
coeff_type>
112
Teuchos::RCP<const Stokhos::OrthogPolyBasis<typename Stokhos::VectorOrthogPoly<coeff_type>::ordinal_type,
typename
Stokhos::VectorOrthogPoly<coeff_type>::value_type
> >
113
Stokhos::VectorOrthogPoly<coeff_type>::
114
basis
()
const
115
{
116
return
basis_
;
117
}
118
119
120
template
<
typename
coeff_type>
121
coeff_type&
122
Stokhos::VectorOrthogPoly<coeff_type>::
123
term
(
ordinal_type
dimension,
ordinal_type
order)
124
{
125
Teuchos::RCP< const Stokhos::ProductBasis<ordinal_type, value_type> >
126
product_basis = Teuchos::rcp_dynamic_cast< const Stokhos::ProductBasis<ordinal_type, value_type> >(
basis_
,
true
);
127
ordinal_type
d = product_basis->dimension();
128
MultiIndex<ordinal_type>
theTerm(d);
129
theTerm[dimension] = order;
130
ordinal_type
index
= product_basis->index(theTerm);
131
return
*(this->
coeff_
[this->
map_
->LID(
index
)]);
132
}
133
134
template
<
typename
coeff_type>
135
const
coeff_type&
136
Stokhos::VectorOrthogPoly<coeff_type>::
137
term
(
ordinal_type
dimension,
ordinal_type
order)
const
138
{
139
Teuchos::RCP< const Stokhos::ProductBasis<ordinal_type, value_type> >
140
product_basis = Teuchos::rcp_dynamic_cast< const Stokhos::ProductBasis<ordinal_type, value_type> >(
basis_
,
true
);
141
ordinal_type
d = product_basis->dimension();
142
MultiIndex<ordinal_type>
theTerm(d);
143
theTerm[dimension] = order;
144
ordinal_type
index
= product_basis->index(theTerm);
145
return
*(this->
coeff_
[this->
map_
->LID(
index
)]);
146
}
147
148
template
<
typename
coeff_type>
149
void
150
Stokhos::VectorOrthogPoly<coeff_type>::
151
evaluate
(
const
Teuchos::Array<value_type>& basis_values, coeff_type& result)
const
152
{
153
traits_type::init(result,
value_type
(0));
154
ordinal_type
sz = this->
coeff_
.size();
155
for
(
ordinal_type
i=0; i<sz; i++)
156
traits_type::update(result, basis_values[i], *(this->
coeff_
[i]));
157
}
158
159
template
<
typename
coeff_type>
160
void
161
Stokhos::VectorOrthogPoly<coeff_type>::
162
sumIntoAllTerms
(
const
value_type
& weight,
163
const
Teuchos::Array<value_type>& basis_values,
164
const
Teuchos::Array<value_type>& basis_norms,
165
const
coeff_type& vec)
166
{
167
ordinal_type
sz = this->
coeff_
.size();
168
int
i_gid;
169
for
(
ordinal_type
i=0; i<sz; i++) {
170
i_gid = this->
map_
->GID(i);
171
traits_type::update(*(this->
coeff_
[i]),
172
weight*basis_values[i_gid]/basis_norms[i_gid],
173
vec);
174
}
175
}
176
177
template
<
typename
coeff_type>
178
std::ostream&
179
Stokhos::VectorOrthogPoly<coeff_type>::
180
print
(std::ostream& os)
const
181
{
182
ordinal_type
sz = this->
coeff_
.size();
183
os <<
"Stokhos::VectorOrthogPoly of global size "
184
<< this->
map_
->NumGlobalElements() <<
", local size "
<< sz <<
" in basis "
185
<<
"\n"
<<
basis_
->getName() <<
":"
<< std::endl;
186
187
Teuchos::RCP< const Stokhos::ProductBasis<ordinal_type, value_type> >
188
product_basis = Teuchos::rcp_dynamic_cast< const Stokhos::ProductBasis<ordinal_type, value_type> >(
basis_
);
189
190
if
(product_basis != Teuchos::null) {
191
for
(
ordinal_type
i=0; i<sz; i++) {
192
const
MultiIndex<ordinal_type>
& trm = product_basis->term(i);
193
os <<
"Term "
<< i <<
" ("
;
194
for
(
ordinal_type
j
=0;
j<static_cast<ordinal_type>
(trm.
size
())-1;
j
++)
195
os << trm[
j
] <<
", "
;
196
os << trm[trm.
size
()-1] <<
"):"
<< std::endl;
197
traits_type::print(os, *(this->
coeff_
[this->
map_
->LID(i)]));
198
}
199
}
200
else
{
201
for
(
ordinal_type
i=0; i<sz; i++) {
202
os <<
"Term "
<< this->
map_
->GID(i) <<
":"
<< std::endl;
203
traits_type::print(os, *(this->
coeff_
[i]));
204
}
205
}
206
207
return
os;
208
}
j
j
Definition
Sacado_Fad_Exp_MP_Vector.hpp:527
Stokhos_ProductBasis.hpp
Stokhos::MultiIndex
A multidimensional index.
Definition
Stokhos_ProductBasisUtils.hpp:79
Stokhos::MultiIndex::size
ordinal_type size() const
Size.
Definition
Stokhos_ProductBasisUtils.hpp:99
Stokhos::OrthogPolyBasis
Abstract base class for multivariate orthogonal polynomials.
Definition
Stokhos_OrthogPolyBasis.hpp:74
Stokhos::ProductContainer::ProductContainer
ProductContainer()
Default constructor.
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 >::map_
Teuchos::RCP< const Epetra_BlockMap > map_
Definition
Stokhos_ProductContainer.hpp:176
Stokhos::Sparse3Tensor::index
SparseArrayIterator< index_iterator, value_iterator >::value_type index(const SparseArrayIterator< index_iterator, value_iterator > &it)
Definition
Stokhos_Sparse3Tensor.hpp:295
Stokhos::VectorOrthogPoly
A container class storing an orthogonal polynomial whose coefficients are vectors,...
Definition
Stokhos_VectorOrthogPoly.hpp:58
Stokhos::VectorOrthogPoly::basis
Teuchos::RCP< const Stokhos::OrthogPolyBasis< ordinal_type, value_type > > basis() const
Get basis.
Definition
Stokhos_VectorOrthogPolyImp.hpp:114
Stokhos::VectorOrthogPoly::operator=
VectorOrthogPoly & operator=(const VectorOrthogPoly &)
Assignment.
Definition
Stokhos_VectorOrthogPolyImp.hpp:90
Stokhos::VectorOrthogPoly::sumIntoAllTerms
void sumIntoAllTerms(const value_type &weight, const Teuchos::Array< value_type > &basis_values, const Teuchos::Array< value_type > &basis_norms, const coeff_type &vec)
Evaluate polynomial at supplied basis values.
Definition
Stokhos_VectorOrthogPolyImp.hpp:162
Stokhos::VectorOrthogPoly::ordinal_type
ProductContainer< coeff_type >::ordinal_type ordinal_type
Typename of ordinals.
Definition
Stokhos_VectorOrthogPoly.hpp:68
Stokhos::VectorOrthogPoly::~VectorOrthogPoly
virtual ~VectorOrthogPoly()
Destructor.
Definition
Stokhos_VectorOrthogPolyImp.hpp:83
Stokhos::VectorOrthogPoly::print
std::ostream & print(std::ostream &os) const
Print polynomial.
Definition
Stokhos_VectorOrthogPolyImp.hpp:180
Stokhos::VectorOrthogPoly::reset
void reset(const Teuchos::RCP< const Stokhos::OrthogPolyBasis< ordinal_type, value_type > > &new_basis, const Teuchos::RCP< const Epetra_BlockMap > &new_map, const typename traits_type::cloner_type &cloner)
Reset to a new basis.
Definition
Stokhos_VectorOrthogPolyImp.hpp:102
Stokhos::VectorOrthogPoly::value_type
ProductContainer< coeff_type >::value_type value_type
Typename of values.
Definition
Stokhos_VectorOrthogPoly.hpp:65
Stokhos::VectorOrthogPoly::basis_
Teuchos::RCP< const Stokhos::OrthogPolyBasis< ordinal_type, value_type > > basis_
Basis.
Definition
Stokhos_VectorOrthogPoly.hpp:148
Stokhos::VectorOrthogPoly::VectorOrthogPoly
VectorOrthogPoly()
Constructor with no basis.
Definition
Stokhos_VectorOrthogPolyImp.hpp:46
Stokhos::VectorOrthogPoly::evaluate
void evaluate(const Teuchos::Array< value_type > &basis_values, coeff_type &result) const
Evaluate polynomial at supplied basis values.
Definition
Stokhos_VectorOrthogPolyImp.hpp:151
Stokhos::VectorOrthogPoly::term
coeff_type & term(ordinal_type dimension, ordinal_type order)
Get term for dimension dimension and order order.
Definition
Stokhos_VectorOrthogPolyImp.hpp:123
Generated by
1.17.0