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" 54 #include "Teuchos_FancyOStream.hpp" 56 #include "Tpetra_Vector.hpp" 57 #include "Tpetra_Map.hpp" 59 template<
typename EvalT,
typename TRAITS,
typename LO,
typename GO,
typename NodeT>
63 const Teuchos::ParameterList& p)
64 : globalIndexer_(indexer)
65 , useTimeDerivativeSolutionVector_(false)
66 , globalDataKey_(
"Tangent Gather Container")
68 const std::vector<std::string>& names =
69 *(p.get< Teuchos::RCP< std::vector<std::string> > >(
"DOF Names"));
71 indexerNames_ = p.get< Teuchos::RCP< std::vector<std::string> > >(
"Indexer Names");
74 Teuchos::RCP<const panzer::PureBasis>
basis;
75 if(p.isType< Teuchos::RCP<panzer::PureBasis> >(
"Basis"))
76 basis = p.get< Teuchos::RCP<panzer::PureBasis> >(
"Basis");
78 basis = p.get< Teuchos::RCP<const panzer::PureBasis> >(
"Basis");
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 LO,
typename GO,
typename NodeT>
102 TEUCHOS_ASSERT(gatherFields_.size() == indexerNames_->size());
104 fieldIds_.resize(gatherFields_.size());
106 for (std::size_t fd = 0; fd < gatherFields_.size(); ++fd) {
107 const std::string& fieldName = (*indexerNames_)[fd];
108 fieldIds_[fd] = globalIndexer_->getFieldNum(fieldName);
111 this->utils.setFieldData(gatherFields_[fd],fm);
114 indexerNames_ = Teuchos::null;
118 template<
typename EvalT,
typename TRAITS,
typename LO,
typename GO,
typename NodeT>
123 using Teuchos::rcp_dynamic_cast;
128 if (d.gedc.containsDataObject(globalDataKey_)) {
129 RCP<GlobalEvaluationData> ged = d.gedc.getDataObject(globalDataKey_);
130 RCP<LOCPair_GlobalEvaluationData> loc_pair =
133 if(loc_pair!=Teuchos::null) {
134 Teuchos::RCP<LinearObjContainer> loc = loc_pair->
getGhostedLOC();
135 tpetraContainer_ = rcp_dynamic_cast<LOC>(loc,
true);
138 if(tpetraContainer_==Teuchos::null) {
139 tpetraContainer_ = rcp_dynamic_cast<LOC>(ged,
true);
145 template<
typename EvalT,
typename TRAITS,
typename LO,
typename GO,
typename NodeT>
151 if (tpetraContainer_ == Teuchos::null)
156 std::vector<LO> LIDs;
159 std::string blockId = this->wda(workset).block_id;
160 const std::vector<std::size_t> & localCellIds = this->wda(workset).cell_local_ids;
162 Teuchos::RCP<typename LOC::VectorType> x;
163 if (useTimeDerivativeSolutionVector_)
166 x = tpetraContainer_->get_x();
168 Teuchos::ArrayRCP<const double> x_array = x->get1dView();
176 for(std::size_t worksetCellIndex=0;worksetCellIndex<localCellIds.size();++worksetCellIndex) {
177 std::size_t cellLocalId = localCellIds[worksetCellIndex];
179 LIDs = globalIndexer_->getElementLIDs(cellLocalId);
182 for (std::size_t fieldIndex=0; fieldIndex<gatherFields_.size();fieldIndex++) {
183 int fieldNum = fieldIds_[fieldIndex];
184 const std::vector<int> & elmtOffset = globalIndexer_->getGIDFieldOffsets(blockId,fieldNum);
190 (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)
std::vector< PHX::MDField< ScalarT, Cell, NODE > > gatherFields_
bool useTimeDerivativeSolutionVector_
std::string globalDataKey_
Teuchos::RCP< LinearObjContainer > getGhostedLOC() const
const Teuchos::RCP< VectorType > get_dxdt() const
Teuchos::RCP< const panzer::PureBasis > basis
Interpolates basis DOF values to IP DOF values.
void postRegistrationSetup(typename TRAITS::SetupData d, PHX::FieldManager< TRAITS > &vm)