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>
66 const std::vector<std::string>& names =
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);
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);
T & get(const std::string &name, T def_value)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Teuchos::RCP< const PureBasis > getBasis() const
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...
Teuchos::RCP< PHX::DataLayout > functional
<Cell,Basis>
panzer_stk::STK_Interface::SolutionFieldType VariableField
void evaluateFields(typename Traits::EvalData d)