43 #ifndef PANZER_GATHER_TANGENT_TPETRA_IMPL_HPP
44 #define PANZER_GATHER_TANGENT_TPETRA_IMPL_HPP
46 #include "Teuchos_Assert.hpp"
47 #include "Phalanx_DataLayout.hpp"
55 #include "Teuchos_FancyOStream.hpp"
57 #include "Tpetra_Vector.hpp"
58 #include "Tpetra_Map.hpp"
60 template<
typename EvalT,
typename TRAITS,
typename LO,
typename GO,
typename NodeT>
65 : globalIndexer_(indexer)
66 , useTimeDerivativeSolutionVector_(false)
67 , globalDataKey_(
"Tangent Gather Container")
69 const std::vector<std::string>& names =
82 for (std::size_t fd = 0; fd < names.size(); ++fd) {
84 PHX::MDField<ScalarT,Cell,NODE>(names[fd],basis->functional);
88 if (p.
isType<
bool>(
"Use Time Derivative Solution Vector"))
91 if (p.
isType<std::string>(
"Global Data Key"))
94 this->setName(
"Gather Tangent");
98 template<
typename EvalT,
typename TRAITS,
typename LO,
typename GO,
typename NodeT>
105 fieldIds_.resize(gatherFields_.size());
107 for (std::size_t fd = 0; fd < gatherFields_.size(); ++fd) {
108 const std::string& fieldName = (*indexerNames_)[fd];
109 fieldIds_[fd] = globalIndexer_->getFieldNum(fieldName);
112 indexerNames_ = Teuchos::null;
116 template<
typename EvalT,
typename TRAITS,
typename LO,
typename GO,
typename NodeT>
121 using Teuchos::rcp_dynamic_cast;
126 if (d.gedc->containsDataObject(globalDataKey_)) {
131 if(loc_pair!=Teuchos::null) {
133 tpetraContainer_ = rcp_dynamic_cast<LOC>(loc,
true);
136 if(tpetraContainer_==Teuchos::null) {
137 tpetraContainer_ = rcp_dynamic_cast<LOC>(ged,
true);
143 template<
typename EvalT,
typename TRAITS,
typename LO,
typename GO,
typename NodeT>
149 if (tpetraContainer_ == Teuchos::null)
154 std::string blockId = this->wda(workset).block_id;
155 const std::vector<std::size_t> & localCellIds = this->wda(workset).cell_local_ids;
158 if (useTimeDerivativeSolutionVector_)
159 x = tpetraContainer_->get_dxdt();
161 x = tpetraContainer_->get_x();
171 for(std::size_t worksetCellIndex=0;worksetCellIndex<localCellIds.size();++worksetCellIndex) {
172 std::size_t cellLocalId = localCellIds[worksetCellIndex];
174 auto LIDs = globalIndexer_->getElementLIDs(cellLocalId);
177 for (std::size_t fieldIndex=0; fieldIndex<gatherFields_.size();fieldIndex++) {
178 int fieldNum = fieldIds_[fieldIndex];
179 const std::vector<int> & elmtOffset = globalIndexer_->getGIDFieldOffsets(blockId,fieldNum);
182 for(std::size_t basis=0;basis<elmtOffset.size();basis++) {
183 int offset = elmtOffset[basis];
184 LO lid = LIDs[offset];
185 (gatherFields_[fieldIndex])(worksetCellIndex,basis) = x_array[lid];
Teuchos::RCP< std::vector< std::string > > indexerNames_
void preEvaluate(typename TRAITS::PreEvalData d)
void evaluateFields(typename TRAITS::EvalData d)
T & get(const std::string &name, T def_value)
std::vector< PHX::MDField< ScalarT, Cell, NODE > > gatherFields_
Teuchos::RCP< LinearObjContainer > getGhostedLOC() const
bool useTimeDerivativeSolutionVector_
std::string globalDataKey_
bool isType(const std::string &name) const
void postRegistrationSetup(typename TRAITS::SetupData d, PHX::FieldManager< TRAITS > &vm)
#define TEUCHOS_ASSERT(assertion_test)