43 #ifndef PANZER_STK_GATHER_FIELDS_IMPL_HPP 44 #define PANZER_STK_GATHER_FIELDS_IMPL_HPP 46 #include "Teuchos_Assert.hpp" 47 #include "Phalanx_DataLayout.hpp" 51 #include "Teuchos_FancyOStream.hpp" 57 template<
typename EvalT,
typename Traits>
59 GatherFields(
const Teuchos::RCP<const STK_Interface> & mesh,
const Teuchos::ParameterList& p)
66 const std::vector<std::string>& names =
67 *(p.get< Teuchos::RCP< std::vector<std::string> > >(
"Field Names"));
69 Teuchos::RCP<panzer::BasisIRLayout> basis =
70 p.get< Teuchos::RCP<panzer::BasisIRLayout> >(
"Basis");
73 gatherFields_.resize(names.size());
74 stkFields_.resize(names.size());
75 for (std::size_t fd = 0; fd < names.size(); ++fd) {
77 PHX::MDField<ScalarT,Cell,NODE>(names[fd],basis->functional);
78 this->addEvaluatedField(gatherFields_[fd]);
81 this->setName(
"Gather STK Fields");
85 template<
typename EvalT,
typename Traits>
90 for (std::size_t fd = 0; fd < gatherFields_.size(); ++fd) {
91 std::string fieldName = gatherFields_[fd].fieldTag().name();
93 stkFields_[fd] = mesh_->getMetaData()->get_field<
VariableField>(stk::topology::NODE_RANK, fieldName);
95 if(stkFields_[fd]==0) {
97 mesh_->printMetaData(ss);
98 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
99 "panzer_stk::GatherFields: STK field " <<
"\"" << fieldName <<
"\" " 100 "not found.\n STK meta data follows: \n\n" << ss.str());
106 template<
typename EvalT,
typename Traits>
110 const std::vector<stk::mesh::Entity> & localElements = *mesh_->getElementsOrderedByLID();
113 const std::vector<std::size_t> & localCellIds = this->wda(workset).cell_local_ids;
116 for(std::size_t worksetCellIndex=0;worksetCellIndex<localCellIds.size();++worksetCellIndex) {
117 std::size_t cellLocalId = localCellIds[worksetCellIndex];
118 stk::mesh::Entity
const* relations = mesh_->getBulkData()->begin_nodes(localElements[cellLocalId]);
121 for (std::size_t fieldIndex=0; fieldIndex<gatherFields_.size();fieldIndex++) {
124 std::size_t basisCnt = gatherFields_[fieldIndex].extent(1);
128 (gatherFields_[fieldIndex])(worksetCellIndex,0) = *stk::mesh::field_data(*
field, localElements[cellLocalId]);
132 for(std::size_t basis=0;basis<basisCnt;basis++) {
133 stk::mesh::Entity node = relations[basis];
134 (gatherFields_[fieldIndex])(worksetCellIndex,basis) = *stk::mesh::field_data(*
field, node);
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &vm)
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...
BASIS NODE
Spatial Dimension Tag.
panzer_stk::STK_Interface::SolutionFieldType VariableField
void evaluateFields(typename Traits::EvalData d)