11#ifndef __Panzer_GatherTangent_BlockedEpetra_impl_hpp__
12#define __Panzer_GatherTangent_BlockedEpetra_impl_hpp__
21#include "Epetra_Map.h"
32#include "Phalanx_DataLayout.hpp"
35#include "Teuchos_Assert.hpp"
36#include "Teuchos_FancyOStream.hpp"
39#include "Thyra_ProductVectorBase.hpp"
40#include "Thyra_SpmdVectorBase.hpp"
47template<
typename EvalT,
typename TRAITS,
typename LO,
typename GO>
50 const std::vector<Teuchos::RCP<const GlobalIndexer>>&
52 const Teuchos::ParameterList& p)
67 const vector<string>& names = *(p.get<RCP<vector<string>>>(
"DOF Names"));
69 RCP<PureBasis> basis = p.get<RCP<PureBasis>>(
"Basis");
70 if (p.isType<
bool>(
"Use Time Derivative Solution Vector"))
72 p.get<
bool>(
"Use Time Derivative Solution Vector");
73 if (p.isType<
string>(
"Global Data Key"))
77 int numFields(names.size());
79 for (
int fd(0); fd < numFields; ++fd)
82 MDField<ScalarT, Cell, NODE>(names[fd], basis->functional);
87 string firstName(
"<none>");
90 string n(
"GatherTangent (Blocked Epetra): " + firstName +
" (" +
91 print<EvalT>() +
")");
100template<
typename EvalT,
typename TRAITS,
typename LO,
typename GO>
104 typename TRAITS::SetupData ,
114 for (
int fd(0); fd < numFields; ++fd)
130template<
typename EvalT,
typename TRAITS,
typename LO,
typename GO>
134 typename TRAITS::PreEvalData d)
136 using std::logic_error;
138 using Teuchos::rcp_dynamic_cast;
139 using Teuchos::typeName;
146 xBvRoGed_ = rcp_dynamic_cast<BVROGED>(ged,
true);
155template<
typename EvalT,
typename TRAITS,
typename LO,
typename GO>
159 typename TRAITS::EvalData workset)
165 using Teuchos::ArrayRCP;
166 using Teuchos::ptrFromRef;
168 using Teuchos::rcp_dynamic_cast;
170 using Thyra::SpmdVectorBase;
178 string blockId(this->
wda(workset).block_id);
179 const vector<size_t>& localCellIds = this->
wda(workset).cell_local_ids;
180 int numFields(
gatherFields_.size()), numCells(localCellIds.size());
183 for (
int fieldIndex(0); fieldIndex < numFields; ++fieldIndex)
185 MDField<ScalarT, Cell, NODE>& field =
gatherFields_[fieldIndex];
190 auto xEvRoGed =
xBvRoGed_->getGEDBlock(indexerId);
191 auto subRowIndexer =
indexers_[indexerId];
192 const vector<int>& elmtOffset =
193 subRowIndexer->getGIDFieldOffsets(blockId, subFieldNum);
194 int numBases(elmtOffset.size());
197 for (
int cell(0); cell < numCells; ++cell)
199 LO cellLocalId = localCellIds[cell];
200 auto LIDs = subRowIndexer->getElementLIDs(cellLocalId);
203 for (
int basis(0); basis < numBases; ++basis)
205 int offset(elmtOffset[basis]), lid(LIDs[offset]);
206 field(cell, basis) = (*xEvRoGed)[lid];
This class encapsulates the needs of a gather operation to do a halo exchange for blocked vectors.
WorksetDetailsAccessor wda
std::vector< Teuchos::RCP< const GlobalIndexer > > indexers_
These map the local (field, element, basis) triplet to a global ID for scattering.
Teuchos::RCP< std::vector< std::string > > indexerNames_
A list of the names of the fields to be gathered.
Teuchos::RCP< panzer::BlockedVector_ReadOnly_GlobalEvaluationData > xBvRoGed_
The GlobalEvaluationData containing both the owned and ghosted tangent vectors.
void preEvaluate(typename TRAITS::PreEvalData d)
Pre-Evaluate: Sets the tangent vector.
bool useTimeDerivativeSolutionVector_
A flag indicating whether we're to be working with or .
std::vector< int > indexerIds_
The block index into indexers_.
std::vector< PHX::MDField< ScalarT, Cell, NODE > > gatherFields_
The fields to be gathered.
GatherTangent_BlockedEpetra()
Default Constructor (disabled).
std::string globalDataKey_
The key identifying the GlobalEvaluationData.
void postRegistrationSetup(typename TRAITS::SetupData d, PHX::FieldManager< TRAITS > &vm)
Post-Registration Setup.
void evaluateFields(typename TRAITS::EvalData d)
Evaluate Fields: Gather operation.
std::vector< int > subFieldIds_
Sub-field IDs, which need to be mapped.
Description and data layouts associated with a particular basis.
int getFieldBlock(const std::string &fieldName, const std::vector< Teuchos::RCP< const GlobalIndexer > > &ugis)