43 #ifndef PANZER_GATHER_TANGENT_BLOCKED_TPETRA_IMPL_HPP
44 #define PANZER_GATHER_TANGENT_BLOCKED_TPETRA_IMPL_HPP
46 #include "Teuchos_Assert.hpp"
47 #include "Phalanx_DataLayout.hpp"
52 #include "Panzer_TpetraLinearObjFactory.hpp"
56 #include "Teuchos_FancyOStream.hpp"
58 #include "Thyra_SpmdVectorBase.hpp"
59 #include "Thyra_ProductVectorBase.hpp"
61 #include "Tpetra_Map.hpp"
63 template <
typename EvalT,
typename TRAITS,
typename S,
typename LO,
typename GO,
typename NodeT>
68 : gidIndexer_(indexer)
69 , useTimeDerivativeSolutionVector_(false)
70 , globalDataKey_(
"Tangent Gather Container")
72 const std::vector<std::string>& names =
81 for (std::size_t fd = 0; fd < names.size(); ++fd) {
83 PHX::MDField<ScalarT,Cell,NODE>(names[fd],basis->functional);
87 if (p.
isType<
bool>(
"Use Time Derivative Solution Vector"))
90 if (p.
isType<std::string>(
"Global Data Key"))
93 this->setName(
"Gather Tangent");
97 template <
typename EvalT,
typename TRAITS,
typename S,
typename LO,
typename GO,
typename NodeT>
104 fieldIds_.resize(gatherFields_.size());
106 for (std::size_t fd = 0; fd < gatherFields_.size(); ++fd) {
108 const std::string& fieldName = (*indexerNames_)[fd];
109 fieldIds_[fd] = gidIndexer_->getFieldNum(fieldName);
112 indexerNames_ = Teuchos::null;
116 template <
typename EvalT,
typename TRAITS,
typename S,
typename LO,
typename GO,
typename NodeT>
121 if (d.gedc->containsDataObject(globalDataKey_)) {
122 blockedContainer_ = Teuchos::rcp_dynamic_cast<
const ContainerType>(d.gedc->getDataObject(globalDataKey_),
true);
127 template <
typename EvalT,
typename TRAITS,
typename S,
typename LO,
typename GO,
typename NodeT>
133 using Teuchos::ptrFromRef;
134 using Teuchos::rcp_dynamic_cast;
137 using Thyra::SpmdVectorBase;
142 if (blockedContainer_ == Teuchos::null)
149 std::vector<std::pair<int,GO> > GIDs;
150 std::vector<LO> LIDs;
153 std::string blockId = this->wda(workset).block_id;
154 const std::vector<std::size_t> & localCellIds = this->wda(workset).cell_local_ids;
157 if (useTimeDerivativeSolutionVector_)
158 x = rcp_dynamic_cast<ProductVectorBase<double> >(blockedContainer_->get_dxdt());
160 x = rcp_dynamic_cast<ProductVectorBase<double> >(blockedContainer_->get_x());
163 for(std::size_t worksetCellIndex=0;worksetCellIndex<localCellIds.size();++worksetCellIndex) {
164 LO cellLocalId = localCellIds[worksetCellIndex];
166 gidIndexer_->getElementGIDs(cellLocalId,GIDs,blockId);
169 LIDs.resize(GIDs.size());
170 for(std::size_t i=0;i<GIDs.size();i++) {
174 LIDs[i] = x_map->getLocalElement(GIDs[i].second);
179 for (std::size_t fieldIndex=0; fieldIndex<gatherFields_.size();fieldIndex++) {
180 int fieldNum = fieldIds_[fieldIndex];
181 int indexerId = gidIndexer_->getFieldBlock(fieldNum);
185 block_x->getLocalData(ptrFromRef(local_x));
187 const std::vector<int> & elmtOffset = gidIndexer_->getGIDFieldOffsets(blockId,fieldNum);
190 for(std::size_t basis=0;basis<elmtOffset.size();basis++) {
191 int offset = elmtOffset[basis];
192 int lid = LIDs[offset];
194 (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)