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"
57template<
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");
85template<
typename EvalT,
typename Traits>
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());
106template<
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++) {
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);
WorksetDetailsAccessor wda
std::vector< VariableField * > stkFields_
Teuchos::RCP< const STK_Interface > mesh_
void evaluateFields(typename Traits::EvalData d)
panzer_stk::STK_Interface::SolutionFieldType VariableField
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &vm)
std::vector< PHX::MDField< ScalarT, panzer::Cell, panzer::NODE > > gatherFields_