Panzer
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
disc-fe
src
evaluators
Panzer_GatherTangent_BlockedEpetra_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_GatherTangent_BlockedEpetra_impl_hpp__
44
#define __Panzer_GatherTangent_BlockedEpetra_impl_hpp__
45
47
//
48
// Include Files
49
//
51
52
// Epetra
53
#include "Epetra_Map.h"
54
55
// Panzer
56
#include "
Panzer_BlockedVector_ReadOnly_GlobalEvaluationData.hpp
"
57
#include "
Panzer_GlobalEvaluationData.hpp
"
58
#include "
Panzer_GlobalEvaluationDataContainer.hpp
"
59
#include "
Panzer_PureBasis.hpp
"
60
#include "
Panzer_GlobalIndexer.hpp
"
61
#include "
Panzer_GlobalIndexer_Utilities.hpp
"
62
63
// Phalanx
64
#include "Phalanx_DataLayout.hpp"
65
66
// Teuchos
67
#include "Teuchos_Assert.hpp"
68
#include "Teuchos_FancyOStream.hpp"
69
70
// Thyra
71
#include "Thyra_ProductVectorBase.hpp"
72
#include "Thyra_SpmdVectorBase.hpp"
73
75
//
76
// Initializing Constructor
77
//
79
template
<
typename
EvalT,
typename
TRAITS,
typename
LO,
typename
GO>
80
panzer::GatherTangent_BlockedEpetra<EvalT, TRAITS, LO, GO>::
81
GatherTangent_BlockedEpetra
(
82
const
std::vector<Teuchos::RCP<const GlobalIndexer>>&
83
indexers,
84
const
Teuchos::ParameterList& p)
85
:
86
indexers_
(indexers),
87
useTimeDerivativeSolutionVector_
(false),
88
globalDataKey_
(
"Tangent Gather Container"
)
89
{
90
using
panzer::PureBasis
;
91
using
PHX::MDField;
92
using
PHX::print;
93
using
std::size_t;
94
using
std::string;
95
using
std::vector;
96
using
Teuchos::RCP;
97
98
// Get the necessary information from the ParameterList.
99
const
vector<string>& names = *(p.get<RCP<vector<string>>>(
"DOF Names"
));
100
indexerNames_
= p.get<RCP<vector<string>>>(
"Indexer Names"
);
101
RCP<PureBasis> basis = p.get<RCP<PureBasis>>(
"Basis"
);
102
if
(p.isType<
bool
>(
"Use Time Derivative Solution Vector"
))
103
useTimeDerivativeSolutionVector_
=
104
p.get<
bool
>(
"Use Time Derivative Solution Vector"
);
105
if (p.isType<
string
>(
"Global Data Key"
))
106
globalDataKey_
= p.get<
string
>(
"Global Data Key"
);
107
108
// Allocate the fields.
109
int
numFields(names.size());
110
gatherFields_
.resize(numFields);
111
for (
int
fd(0); fd < numFields; ++fd)
112
{
113
gatherFields_
[fd] =
114
MDField<ScalarT, Cell, NODE>(names[fd], basis->functional);
115
this->addEvaluatedField(
gatherFields_
[fd]);
116
}
// end loop over names
117
118
// Figure out what the first active name is.
119
string
firstName(
"<none>"
);
120
if
(numFields > 0)
121
firstName = names[0];
122
string
n(
"GatherTangent (Blocked Epetra): "
+ firstName +
" ("
+
123
print<EvalT>() +
")"
);
124
this->setName(n);
125
}
// end of Initializing Constructor
126
128
//
129
// postRegistrationSetup()
130
//
132
template
<
typename
EvalT,
typename
TRAITS,
typename
LO,
typename
GO>
133
void
134
panzer::GatherTangent_BlockedEpetra<EvalT, TRAITS, LO, GO>::
135
postRegistrationSetup
(
136
typename
TRAITS::SetupData
/* d */
,
137
PHX::FieldManager<TRAITS>
&
/* fm */
)
138
{
139
using
std::size_t;
140
using
std::string;
141
using
Teuchos::null;
142
TEUCHOS_ASSERT(
gatherFields_
.size() ==
indexerNames_
->size());
143
int
numFields(
gatherFields_
.size());
144
indexerIds_
.resize(numFields);
145
subFieldIds_
.resize(numFields);
146
for
(
int
fd(0); fd < numFields; ++fd)
147
{
148
// Get the field ID from the DOF manager.
149
const
string
& fieldName((*
indexerNames_
)[fd]);
150
indexerIds_
[fd] =
getFieldBlock
(fieldName,
indexers_
);
151
subFieldIds_
[fd] =
indexers_
[
indexerIds_
[fd]]->getFieldNum(fieldName);
152
TEUCHOS_ASSERT(
indexerIds_
[fd] >= 0);
153
}
// end loop over gatherFields_
154
indexerNames_
= null;
155
}
// end of postRegistrationSetup()
156
158
//
159
// preEvaluate()
160
//
162
template
<
typename
EvalT,
typename
TRAITS,
typename
LO,
typename
GO>
163
void
164
panzer::GatherTangent_BlockedEpetra<EvalT, TRAITS, LO, GO>::
165
preEvaluate
(
166
typename
TRAITS::PreEvalData d)
167
{
168
using
std::logic_error;
169
using
Teuchos::RCP;
170
using
Teuchos::rcp_dynamic_cast;
171
using
Teuchos::typeName;
172
using
Thyra::ProductVectorBase
;
173
using
BVROGED =
BlockedVector_ReadOnly_GlobalEvaluationData
;
174
using
GED =
GlobalEvaluationData
;
175
if
(d.gedc->containsDataObject(
globalDataKey_
))
176
{
177
RCP<GED> ged = d.gedc->getDataObject(
globalDataKey_
);
178
xBvRoGed_
= rcp_dynamic_cast<BVROGED>(ged,
true
);
179
}
// end if (d.gedc.containsDataObject(globalDataKey_))
180
}
// end of preEvaluate()
181
183
//
184
// evaluateFields()
185
//
187
template
<
typename
EvalT,
typename
TRAITS,
typename
LO,
typename
GO>
188
void
189
panzer::GatherTangent_BlockedEpetra<EvalT, TRAITS, LO, GO>::
190
evaluateFields
(
191
typename
TRAITS::EvalData workset)
192
{
193
using
PHX::MDField;
194
using
std::size_t;
195
using
std::string;
196
using
std::vector;
197
using
Teuchos::ArrayRCP;
198
using
Teuchos::ptrFromRef;
199
using
Teuchos::RCP;
200
using
Teuchos::rcp_dynamic_cast;
201
using
Thyra::VectorBase
;
202
using
Thyra::SpmdVectorBase;
203
204
// If no global evaluation data container was set, then this evaluator
205
// becomes a no-op.
206
if
(
xBvRoGed_
.is_null())
207
return
;
208
209
// For convenience, pull out some objects from the workset.
210
string
blockId(this->
wda
(workset).block_id);
211
const
vector<size_t>& localCellIds = this->
wda
(workset).cell_local_ids;
212
int
numFields(
gatherFields_
.size()), numCells(localCellIds.size());
213
214
// Loop over the fields to be gathered.
215
for
(
int
fieldIndex(0); fieldIndex < numFields; ++fieldIndex)
216
{
217
MDField<ScalarT, Cell, NODE>& field =
gatherFields_
[fieldIndex];
218
int
indexerId(
indexerIds_
[fieldIndex]),
219
subFieldNum(
subFieldIds_
[fieldIndex]);
220
221
// Grab the local data for inputing.
222
auto
xEvRoGed =
xBvRoGed_
->getGEDBlock(indexerId);
223
auto
subRowIndexer =
indexers_
[indexerId];
224
const
vector<int>& elmtOffset =
225
subRowIndexer->getGIDFieldOffsets(blockId, subFieldNum);
226
int
numBases(elmtOffset.size());
227
228
// Gather operation for each cell in the workset.
229
for
(
int
cell(0); cell < numCells; ++cell)
230
{
231
LO cellLocalId = localCellIds[cell];
232
auto
LIDs = subRowIndexer->getElementLIDs(cellLocalId);
233
234
// Loop over the basis functions and fill the fields.
235
for
(
int
basis(0); basis < numBases; ++basis)
236
{
237
int
offset(elmtOffset[basis]), lid(LIDs[offset]);
238
field(cell, basis) = (*xEvRoGed)[lid];
239
}
// end loop over the basis functions
240
}
// end loop over localCellIds
241
}
// end loop over the fields to be gathered
242
}
// end of evaluateFields()
243
244
#endif
// __Panzer_GatherTangent_BlockedEpetra_impl_hpp__
Panzer_BlockedVector_ReadOnly_GlobalEvaluationData.hpp
Panzer_GlobalEvaluationDataContainer.hpp
Panzer_GlobalEvaluationData.hpp
Panzer_GlobalIndexer.hpp
Panzer_GlobalIndexer_Utilities.hpp
Panzer_PureBasis.hpp
PHX::FieldManager
Definition
Panzer_BCStrategy_Base.hpp:53
Thyra::ProductVectorBase
Definition
Panzer_GatherSolution_BlockedEpetra_decl.hpp:80
Thyra::VectorBase
panzer::BlockedVector_ReadOnly_GlobalEvaluationData
This class encapsulates the needs of a gather operation to do a halo exchange for blocked vectors.
Definition
Panzer_BlockedVector_ReadOnly_GlobalEvaluationData.hpp:75
panzer::EvaluatorWithBaseImpl::wda
WorksetDetailsAccessor wda
Definition
Panzer_Evaluator_WithBaseImpl.hpp:63
panzer::GatherTangent_BlockedEpetra::indexers_
std::vector< Teuchos::RCP< const GlobalIndexer > > indexers_
These map the local (field, element, basis) triplet to a global ID for scattering.
Definition
Panzer_GatherTangent_BlockedEpetra_decl.hpp:207
panzer::GatherTangent_BlockedEpetra::indexerNames_
Teuchos::RCP< std::vector< std::string > > indexerNames_
A list of the names of the fields to be gathered.
Definition
Panzer_GatherTangent_BlockedEpetra_decl.hpp:227
panzer::GatherTangent_BlockedEpetra::xBvRoGed_
Teuchos::RCP< panzer::BlockedVector_ReadOnly_GlobalEvaluationData > xBvRoGed_
The GlobalEvaluationData containing both the owned and ghosted tangent vectors.
Definition
Panzer_GatherTangent_BlockedEpetra_decl.hpp:245
panzer::GatherTangent_BlockedEpetra::preEvaluate
void preEvaluate(typename TRAITS::PreEvalData d)
Pre-Evaluate: Sets the tangent vector.
Definition
Panzer_GatherTangent_BlockedEpetra_impl.hpp:165
panzer::GatherTangent_BlockedEpetra::useTimeDerivativeSolutionVector_
bool useTimeDerivativeSolutionVector_
A flag indicating whether we're to be working with or .
Definition
Panzer_GatherTangent_BlockedEpetra_decl.hpp:233
panzer::GatherTangent_BlockedEpetra::indexerIds_
std::vector< int > indexerIds_
The block index into indexers_.
Definition
Panzer_GatherTangent_BlockedEpetra_decl.hpp:212
panzer::GatherTangent_BlockedEpetra::gatherFields_
std::vector< PHX::MDField< ScalarT, Cell, NODE > > gatherFields_
The fields to be gathered.
Definition
Panzer_GatherTangent_BlockedEpetra_decl.hpp:222
panzer::GatherTangent_BlockedEpetra::GatherTangent_BlockedEpetra
GatherTangent_BlockedEpetra()
Default Constructor (disabled).
panzer::GatherTangent_BlockedEpetra::globalDataKey_
std::string globalDataKey_
The key identifying the GlobalEvaluationData.
Definition
Panzer_GatherTangent_BlockedEpetra_decl.hpp:238
panzer::GatherTangent_BlockedEpetra::postRegistrationSetup
void postRegistrationSetup(typename TRAITS::SetupData d, PHX::FieldManager< TRAITS > &vm)
Post-Registration Setup.
Definition
Panzer_GatherTangent_BlockedEpetra_impl.hpp:135
panzer::GatherTangent_BlockedEpetra::evaluateFields
void evaluateFields(typename TRAITS::EvalData d)
Evaluate Fields: Gather operation.
Definition
Panzer_GatherTangent_BlockedEpetra_impl.hpp:190
panzer::GatherTangent_BlockedEpetra::subFieldIds_
std::vector< int > subFieldIds_
Sub-field IDs, which need to be mapped.
Definition
Panzer_GatherTangent_BlockedEpetra_decl.hpp:217
panzer::GlobalEvaluationData
Definition
Panzer_GlobalEvaluationData.hpp:57
panzer::PureBasis
Description and data layouts associated with a particular basis.
Definition
Panzer_PureBasis.hpp:61
panzer::getFieldBlock
int getFieldBlock(const std::string &fieldName, const std::vector< Teuchos::RCP< const GlobalIndexer > > &ugis)
Definition
Panzer_GlobalIndexer_Utilities.cpp:60
Generated by
1.17.0