Panzer
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
disc-fe
src
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData_impl.hpp
Go to the documentation of this file.
1
// @HEADER
2
// ***********************************************************************
3
//
4
// Panzer: A partial differential equation assembly
5
// engine for strongly coupled complex multiphysics systems
6
// Copyright (2011) Sandia Corporation
7
//
8
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9
// the U.S. Government retains certain rights in this software.
10
//
11
// Redistribution and use in source and binary forms, with or without
12
// modification, are permitted provided that the following conditions are
13
// met:
14
//
15
// 1. Redistributions of source code must retain the above copyright
16
// notice, this list of conditions and the following disclaimer.
17
//
18
// 2. Redistributions in binary form must reproduce the above copyright
19
// notice, this list of conditions and the following disclaimer in the
20
// documentation and/or other materials provided with the distribution.
21
//
22
// 3. Neither the name of the Corporation nor the names of the
23
// contributors may be used to endorse or promote products derived from
24
// this software without specific prior written permission.
25
//
26
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
//
38
// Questions? Contact Roger P. Pawlowski (rppawlo@sandia.gov) and
39
// Eric C. Cyr (eccyr@sandia.gov)
40
// ***********************************************************************
41
// @HEADER
42
43
#ifndef __Panzer_TpetraVector_ReadOnly_GlobalEvaluationData_impl_hpp__
44
#define __Panzer_TpetraVector_ReadOnly_GlobalEvaluationData_impl_hpp__
45
46
#include "Thyra_TpetraThyraWrappers.hpp"
47
48
namespace
panzer
{
49
50
using
Teuchos::RCP;
51
52
template
<
typename
ScalarT,
typename
LocalOrdinalT,
typename
GlobalOrdinalT,
typename
NodeT>
53
void
54
TpetraVector_ReadOnly_GlobalEvaluationData<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT>::
55
useConstantValues
(
const
std::vector<GlobalOrdinalT> & indices,
double
value)
56
{
57
TEUCHOS_TEST_FOR_EXCEPTION(
isInitialized_
,std::logic_error,
58
"TpetraVector_ReadOnly_GED has been initialized, cannot call \"useConstantValues\"!"
);
59
60
// add this specification to the filtered pairs vector
61
FilteredGlobalPair
pair;
62
pair.first = indices;
63
pair.second = value;
64
globalFilteredPairs_
.push_back(pair);
65
}
66
67
template
<
typename
ScalarT,
typename
LocalOrdinalT,
typename
GlobalOrdinalT,
typename
NodeT>
68
void
69
TpetraVector_ReadOnly_GlobalEvaluationData<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT>::
70
initialize
(
const
RCP<const ImportType>& importer,
71
const
RCP<const MapType>& ghostedMap,
72
const
RCP<const MapType>& ownedMap)
73
{
74
importer_
= importer;
75
ghostedMap_
= ghostedMap;
76
ownedMap_
= ownedMap;
77
78
// allocate the ghosted vector
79
ghostedVector_
= Teuchos::rcp(
new
VectorType
(
ghostedMap_
));
80
81
// build up the thyra conversion data structures
82
ghostedSpace_
= Thyra::tpetraVectorSpace<ScalarT, LocalOrdinalT,
83
GlobalOrdinalT, NodeT>(
ghostedMap_
);
84
ownedSpace_
= Thyra::tpetraVectorSpace<ScalarT, LocalOrdinalT,
85
GlobalOrdinalT, NodeT>(
ownedMap_
);
86
87
88
// translate filtered pair GIDs to LIDs
89
// initialize some ghosted values to the user specified values
90
filteredPairs_
.resize(
globalFilteredPairs_
.size());
91
for
(std::size_t i=0;i<
globalFilteredPairs_
.size();i++) {
92
std::vector<LocalOrdinalT> lids;
93
const
std::vector<GlobalOrdinalT> & gids =
globalFilteredPairs_
[i].first;
94
for
(std::size_t j=0;j<gids.size();j++) {
95
LocalOrdinalT lid = ghostedMap->getLocalElement(gids[j]);
96
97
// add legit LIDs to list
98
if
(lid>=0)
99
lids.push_back(lid);
100
}
101
102
// convert original GID vector to LID vector, store value as well
103
filteredPairs_
[i].first = lids;
104
filteredPairs_
[i].second =
globalFilteredPairs_
[i].second;
105
}
106
107
isInitialized_
=
true
;
108
}
109
110
template
<
typename
ScalarT,
typename
LocalOrdinalT,
typename
GlobalOrdinalT,
typename
NodeT>
111
void
112
TpetraVector_ReadOnly_GlobalEvaluationData<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT>::
113
globalToGhost
(
int
/* mem */
)
114
{
115
TEUCHOS_TEST_FOR_EXCEPTION(
ownedVector_
== Teuchos::null, std::logic_error,
116
"Owned vector has not been set, can't perform the halo exchange!"
);
117
118
// Initialize the ghosted data, zeroing out things, and filling in specified
119
// constants.
120
initializeData
();
121
122
// Do the global distribution.
123
ghostedVector_
->doImport(*
ownedVector_
, *
importer_
, Tpetra::INSERT);
124
PHX::ExecSpace().fence();
125
}
126
127
template
<
typename
ScalarT,
typename
LocalOrdinalT,
typename
GlobalOrdinalT,
typename
NodeT>
128
void
129
TpetraVector_ReadOnly_GlobalEvaluationData<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT>::
130
initializeData
()
131
{
132
TEUCHOS_TEST_FOR_EXCEPTION(!
isInitialized_
,std::logic_error,
133
"TpetraVector_ReadOnly_GED has not been initialized, cannot call \"initializeData\"!"
);
134
135
ghostedVector_
->putScalar(0.0);
136
PHX::ExecSpace().fence();
137
138
typedef
typename
VectorType::dual_view_type::t_dev::memory_space DMS;
139
auto
values =
ghostedVector_
->getLocalViewHost(Tpetra::Access::OverwriteAll);
140
141
// initialize some ghosted values to the user specified values
142
for
(std::size_t i=0;i<
filteredPairs_
.size();i++) {
143
const
std::vector<int> & lids =
filteredPairs_
[i].first;
144
double
value =
filteredPairs_
[i].second;
145
for
(std::size_t j=0;j<lids.size();j++)
146
values(lids[j], 0) = value;
147
}
148
}
149
150
template
<
typename
ScalarT,
typename
LocalOrdinalT,
typename
GlobalOrdinalT,
typename
NodeT>
151
void
152
TpetraVector_ReadOnly_GlobalEvaluationData<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT>::
153
setOwnedVector_Tpetra
(
const
Teuchos::RCP<const VectorType>& ownedVector)
154
{
155
TEUCHOS_ASSERT(
isInitialized_
);
156
ownedVector_
= ownedVector;
157
}
158
159
template
<
typename
ScalarT,
typename
LocalOrdinalT,
typename
GlobalOrdinalT,
typename
NodeT>
160
Teuchos::RCP<const typename TpetraVector_ReadOnly_GlobalEvaluationData<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT>::VectorType>
161
TpetraVector_ReadOnly_GlobalEvaluationData<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT>::
162
getOwnedVector_Tpetra
()
const
163
{
164
TEUCHOS_ASSERT(
isInitialized_
);
165
return
ownedVector_
;
166
}
167
168
template
<
typename
ScalarT,
typename
LocalOrdinalT,
typename
GlobalOrdinalT,
typename
NodeT>
169
Teuchos::RCP<typename TpetraVector_ReadOnly_GlobalEvaluationData<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT>::VectorType>
170
TpetraVector_ReadOnly_GlobalEvaluationData<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT>::
171
getGhostedVector_Tpetra
()
const
172
{
173
TEUCHOS_ASSERT(
isInitialized_
);
174
TEUCHOS_ASSERT(
ghostedVector_
!=Teuchos::null);
175
176
return
ghostedVector_
;
177
}
178
179
template
<
typename
ScalarT,
typename
LocalOrdinalT,
typename
GlobalOrdinalT,
typename
NodeT>
180
void
181
TpetraVector_ReadOnly_GlobalEvaluationData<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT>::
182
setOwnedVector
(
const
Teuchos::RCP<
const
Thyra::VectorBase<double>
>&
183
ownedVector)
184
{
185
typedef
Thyra::TpetraOperatorVectorExtraction<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT> TOE;
186
TEUCHOS_ASSERT(
isInitialized_
);
187
ownedVector_
= TOE::getConstTpetraVector(ownedVector);
188
}
189
190
template
<
typename
ScalarT,
typename
LocalOrdinalT,
typename
GlobalOrdinalT,
typename
NodeT>
191
Teuchos::RCP<const Thyra::VectorBase<double> >
192
TpetraVector_ReadOnly_GlobalEvaluationData<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT>::
193
getOwnedVector
()
const
194
{
195
TEUCHOS_ASSERT(
isInitialized_
);
196
return
(
ownedVector_
== Teuchos::null) ? Teuchos::null :
197
Thyra::createConstVector(
ownedVector_
,
ownedSpace_
);
198
}
199
200
template
<
typename
ScalarT,
typename
LocalOrdinalT,
typename
GlobalOrdinalT,
typename
NodeT>
201
Teuchos::RCP<Thyra::VectorBase<double> >
202
TpetraVector_ReadOnly_GlobalEvaluationData<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT>::
203
getGhostedVector
()
const
204
{
205
TEUCHOS_ASSERT(
isInitialized_
);
206
TEUCHOS_ASSERT(
ghostedVector_
!=Teuchos::null);
207
208
return
Thyra::createVector(
ghostedVector_
,
ghostedSpace_
);
209
}
210
211
template
<
typename
ScalarT,
typename
LocalOrdinalT,
typename
GlobalOrdinalT,
typename
NodeT>
212
void
213
TpetraVector_ReadOnly_GlobalEvaluationData<ScalarT,LocalOrdinalT,GlobalOrdinalT,NodeT>::
214
print
(std::ostream & os)
const
215
{
216
const
std::string tab =
" "
;
217
os <<
"\n"
;
218
os << tab <<
"TpetraVector_ReadOnly_GlobalEvaluationData\n"
219
<< tab <<
" init = "
<<
isInitialized_
<<
"\n"
220
<< tab <<
" owned = "
<<
ownedVector_
<<
"\n"
221
<< tab <<
" ghosted = "
<<
ghostedVector_
<<
"\n"
;
222
}
223
224
225
}
226
227
#endif
Thyra::VectorBase
panzer::TpetraVector_ReadOnly_GlobalEvaluationData::getOwnedVector_Tpetra
Teuchos::RCP< const VectorType > getOwnedVector_Tpetra() const
Get the owned vector (Tpetra version).
Definition
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData_impl.hpp:162
panzer::TpetraVector_ReadOnly_GlobalEvaluationData::useConstantValues
void useConstantValues(const std::vector< GlobalOrdinalT > &indices, double value)
Definition
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData_impl.hpp:55
panzer::TpetraVector_ReadOnly_GlobalEvaluationData::getGhostedVector
Teuchos::RCP< Thyra::VectorBase< double > > getGhostedVector() const
Get the ghosted vector (Thyra version).
Definition
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData_impl.hpp:203
panzer::TpetraVector_ReadOnly_GlobalEvaluationData::globalFilteredPairs_
std::vector< FilteredGlobalPair > globalFilteredPairs_
Definition
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData.hpp:165
panzer::TpetraVector_ReadOnly_GlobalEvaluationData::ownedMap_
Teuchos::RCP< const MapType > ownedMap_
Definition
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData.hpp:154
panzer::TpetraVector_ReadOnly_GlobalEvaluationData::ghostedSpace_
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > ghostedSpace_
Definition
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData.hpp:156
panzer::TpetraVector_ReadOnly_GlobalEvaluationData::filteredPairs_
std::vector< FilteredLocalPair > filteredPairs_
Definition
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData.hpp:166
panzer::TpetraVector_ReadOnly_GlobalEvaluationData::globalToGhost
virtual void globalToGhost(int mem)
Definition
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData_impl.hpp:113
panzer::TpetraVector_ReadOnly_GlobalEvaluationData::getGhostedVector_Tpetra
Teuchos::RCP< VectorType > getGhostedVector_Tpetra() const
Get the ghosted vector (Tpetra version).
Definition
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData_impl.hpp:171
panzer::TpetraVector_ReadOnly_GlobalEvaluationData::ownedVector_
Teuchos::RCP< const VectorType > ownedVector_
Definition
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData.hpp:161
panzer::TpetraVector_ReadOnly_GlobalEvaluationData::isInitialized_
bool isInitialized_
Definition
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData.hpp:151
panzer::TpetraVector_ReadOnly_GlobalEvaluationData::ownedSpace_
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > ownedSpace_
Definition
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData.hpp:157
panzer::TpetraVector_ReadOnly_GlobalEvaluationData::print
void print(std::ostream &os) const
Diagnostic function.
Definition
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData_impl.hpp:214
panzer::TpetraVector_ReadOnly_GlobalEvaluationData::initializeData
virtual void initializeData()
Clear out the ghosted vector.
Definition
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData_impl.hpp:130
panzer::TpetraVector_ReadOnly_GlobalEvaluationData::setOwnedVector
void setOwnedVector(const Teuchos::RCP< const Thyra::VectorBase< double > > &ownedVector)
Set the owned vector (Thyra version).
Definition
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData_impl.hpp:182
panzer::TpetraVector_ReadOnly_GlobalEvaluationData::setOwnedVector_Tpetra
void setOwnedVector_Tpetra(const Teuchos::RCP< const VectorType > &ownedVector)
Set the owned vector (Tpetra version).
Definition
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData_impl.hpp:153
panzer::TpetraVector_ReadOnly_GlobalEvaluationData::FilteredGlobalPair
std::pair< std::vector< GlobalOrdinalT >, double > FilteredGlobalPair
Definition
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData.hpp:163
panzer::TpetraVector_ReadOnly_GlobalEvaluationData::VectorType
Tpetra::Vector< ScalarT, LocalOrdinalT, GlobalOrdinalT, NodeT > VectorType
Definition
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData.hpp:67
panzer::TpetraVector_ReadOnly_GlobalEvaluationData::ghostedVector_
Teuchos::RCP< VectorType > ghostedVector_
Definition
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData.hpp:160
panzer::TpetraVector_ReadOnly_GlobalEvaluationData::initialize
void initialize(const Teuchos::RCP< const ImportType > &importer, const Teuchos::RCP< const MapType > &ghostedMap, const Teuchos::RCP< const MapType > &ownedMap)
Definition
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData_impl.hpp:70
panzer::TpetraVector_ReadOnly_GlobalEvaluationData::getOwnedVector
Teuchos::RCP< const Thyra::VectorBase< double > > getOwnedVector() const
Get the owned vector (Thyra version).
Definition
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData_impl.hpp:193
panzer::TpetraVector_ReadOnly_GlobalEvaluationData::ghostedMap_
Teuchos::RCP< const MapType > ghostedMap_
Definition
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData.hpp:153
panzer::TpetraVector_ReadOnly_GlobalEvaluationData::importer_
Teuchos::RCP< const ImportType > importer_
Definition
Panzer_TpetraVector_ReadOnly_GlobalEvaluationData.hpp:159
panzer
Computes .
Definition
Panzer_BasisValues_Evaluator_decl.hpp:54
Generated by
1.17.0