11 #ifndef PANZER_GATHER_TANGENT_BLOCKED_TPETRA_IMPL_HPP
12 #define PANZER_GATHER_TANGENT_BLOCKED_TPETRA_IMPL_HPP
14 #include "Teuchos_Assert.hpp"
15 #include "Phalanx_DataLayout.hpp"
20 #include "Panzer_TpetraLinearObjFactory.hpp"
24 #include "Teuchos_FancyOStream.hpp"
26 #include "Thyra_SpmdVectorBase.hpp"
27 #include "Thyra_ProductVectorBase.hpp"
29 #include "Tpetra_Map.hpp"
31 template <
typename EvalT,
typename TRAITS,
typename S,
typename LO,
typename GO,
typename NodeT>
36 : gidIndexer_(indexer)
37 , useTimeDerivativeSolutionVector_(false)
38 , globalDataKey_(
"Tangent Gather Container")
40 const std::vector<std::string>& names =
49 for (std::size_t fd = 0; fd < names.size(); ++fd) {
55 if (p.
isType<
bool>(
"Use Time Derivative Solution Vector"))
58 if (p.
isType<std::string>(
"Global Data Key"))
61 this->setName(
"Gather Tangent");
65 template <
typename EvalT,
typename TRAITS,
typename S,
typename LO,
typename GO,
typename NodeT>
72 fieldIds_.resize(gatherFields_.size());
74 for (std::size_t fd = 0; fd < gatherFields_.size(); ++fd) {
76 const std::string& fieldName = (*indexerNames_)[fd];
77 fieldIds_[fd] = gidIndexer_->getFieldNum(fieldName);
80 indexerNames_ = Teuchos::null;
84 template <
typename EvalT,
typename TRAITS,
typename S,
typename LO,
typename GO,
typename NodeT>
89 if (d.gedc->containsDataObject(globalDataKey_)) {
90 blockedContainer_ = Teuchos::rcp_dynamic_cast<
const ContainerType>(d.gedc->getDataObject(globalDataKey_),
true);
95 template <
typename EvalT,
typename TRAITS,
typename S,
typename LO,
typename GO,
typename NodeT>
101 using Teuchos::ptrFromRef;
102 using Teuchos::rcp_dynamic_cast;
105 using Thyra::SpmdVectorBase;
110 if (blockedContainer_ == Teuchos::null)
117 std::vector<std::pair<int,GO> > GIDs;
118 std::vector<LO> LIDs;
121 std::string blockId = this->wda(workset).block_id;
122 const std::vector<std::size_t> & localCellIds = this->wda(workset).cell_local_ids;
125 if (useTimeDerivativeSolutionVector_)
126 x = rcp_dynamic_cast<ProductVectorBase<double> >(blockedContainer_->get_dxdt());
128 x = rcp_dynamic_cast<ProductVectorBase<double> >(blockedContainer_->get_x());
131 for(std::size_t worksetCellIndex=0;worksetCellIndex<localCellIds.size();++worksetCellIndex) {
132 LO cellLocalId = localCellIds[worksetCellIndex];
134 gidIndexer_->getElementGIDsPair(cellLocalId,GIDs,blockId);
137 LIDs.resize(GIDs.size());
138 for(std::size_t i=0;i<GIDs.size();i++) {
142 LIDs[i] = x_map->getLocalElement(GIDs[i].second);
147 for (std::size_t fieldIndex=0; fieldIndex<gatherFields_.size();fieldIndex++) {
148 int fieldNum = fieldIds_[fieldIndex];
149 int indexerId = gidIndexer_->getFieldBlock(fieldNum);
153 block_x->getLocalData(ptrFromRef(local_x));
155 const std::vector<int> & elmtOffset = gidIndexer_->getGIDFieldOffsets(blockId,fieldNum);
158 for(std::size_t basis=0;basis<elmtOffset.size();basis++) {
159 int offset = elmtOffset[basis];
160 int lid = LIDs[offset];
162 (gatherFields_[fieldIndex])(worksetCellIndex,basis) = local_x[lid];
Teuchos::RCP< std::vector< std::string > > indexerNames_
basic_FancyOStream & setShowProcRank(const bool showProcRank)
GatherTangent_BlockedTpetra()
T & get(const std::string &name, T def_value)
void postRegistrationSetup(typename TRAITS::SetupData d, PHX::FieldManager< TRAITS > &vm)
bool useTimeDerivativeSolutionVector_
std::string globalDataKey_
void evaluateFields(typename TRAITS::EvalData d)
basic_FancyOStream & setOutputToRootOnly(const int rootRank)
std::vector< PHX::MDField< ScalarT, Cell, NODE > > gatherFields_
void preEvaluate(typename TRAITS::PreEvalData d)
bool isType(const std::string &name) const
#define TEUCHOS_ASSERT(assertion_test)