43#ifndef __Panzer_GatherTangent_BlockedEpetra_impl_hpp__
44#define __Panzer_GatherTangent_BlockedEpetra_impl_hpp__
53#include "Epetra_Map.h"
64#include "Phalanx_DataLayout.hpp"
67#include "Teuchos_Assert.hpp"
68#include "Teuchos_FancyOStream.hpp"
71#include "Thyra_ProductVectorBase.hpp"
72#include "Thyra_SpmdVectorBase.hpp"
79template<
typename EvalT,
typename TRAITS,
typename LO,
typename GO>
82 const std::vector<Teuchos::RCP<const GlobalIndexer>>&
84 const Teuchos::ParameterList& p)
87 useTimeDerivativeSolutionVector_(false),
88 globalDataKey_(
"Tangent Gather Container")
99 const vector<string>& names = *(p.get<RCP<vector<string>>>(
"DOF Names"));
101 RCP<PureBasis> basis = p.get<RCP<PureBasis>>(
"Basis");
102 if (p.isType<
bool>(
"Use Time Derivative Solution Vector"))
104 p.get<
bool>(
"Use Time Derivative Solution Vector");
105 if (p.isType<
string>(
"Global Data Key"))
114 MDField<ScalarT, Cell, NODE>(names[fd], basis->functional);
119 string firstName(
"<none>");
121 firstName = names[0];
122 string n(
"GatherTangent (Blocked Epetra): " + firstName +
" (" +
123 print<EvalT>() +
")");
132template<
typename EvalT,
typename TRAITS,
typename LO,
typename GO>
136 typename TRAITS::SetupData ,
142 TEUCHOS_ASSERT(gatherFields_.size() == indexerNames_->size());
149 const string& fieldName((*indexerNames_)[fd]);
151 subFieldIds_[fd] = indexers_[indexerIds_[fd]]->getFieldNum(fieldName);
152 TEUCHOS_ASSERT(indexerIds_[fd] >= 0);
154 indexerNames_ = null;
162template<
typename EvalT,
typename TRAITS,
typename LO,
typename GO>
166 typename TRAITS::PreEvalData d)
168 using std::logic_error;
170 using Teuchos::rcp_dynamic_cast;
171 using Teuchos::typeName;
175 if (d.gedc->containsDataObject(globalDataKey_))
177 RCP<GED> ged = d.gedc->getDataObject(globalDataKey_);
178 xBvRoGed_ = rcp_dynamic_cast<BVROGED>(ged,
true);
187template<
typename EvalT,
typename TRAITS,
typename LO,
typename GO>
191 typename TRAITS::EvalData workset)
197 using Teuchos::ArrayRCP;
198 using Teuchos::ptrFromRef;
200 using Teuchos::rcp_dynamic_cast;
202 using Thyra::SpmdVectorBase;
206 if (xBvRoGed_.is_null())
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());
215 for (
int fieldIndex(0); fieldIndex <
numFields; ++fieldIndex)
217 MDField<ScalarT, Cell, NODE>&
field = gatherFields_[fieldIndex];
218 int indexerId(indexerIds_[fieldIndex]),
219 subFieldNum(subFieldIds_[fieldIndex]);
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());
229 for (
int cell(0); cell < numCells; ++cell)
231 LO cellLocalId = localCellIds[cell];
232 auto LIDs = subRowIndexer->getElementLIDs(cellLocalId);
235 for (
int basis(0); basis < numBases; ++basis)
237 int offset(elmtOffset[basis]), lid(LIDs[offset]);
238 field(cell, basis) = (*xEvRoGed)[lid];
PHX::MDField< ScalarT, panzer::Cell, panzer::BASIS > field
A field to which we'll contribute, or in which we'll store, the result of computing this integral.
This class encapsulates the needs of a gather operation to do a halo exchange for blocked vectors.
Teuchos::RCP< std::vector< std::string > > indexerNames_
A list of the names of the fields to be gathered.
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< 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.
Description and data layouts associated with a particular basis.
int getFieldBlock(const std::string &fieldName, const std::vector< Teuchos::RCP< const GlobalIndexer > > &ugis)