27 const std::vector<std::string>& fieldNames,
28 const std::vector<std::string>& exodusNames,
29 const Teuchos::RCP<panzer::IntegrationRule>& integrationRule)
31 exodusNames_(exodusNames)
36 TEUCHOS_ASSERT(fieldNames.size() == exodusNames.size());
37 TEUCHOS_ASSERT(nonnull(mesh));
38 TEUCHOS_ASSERT(nonnull(integrationRule));
42 for (std::size_t fd = 0; fd < fieldNames.size(); ++fd) {
43 gatherFields_[fd] = PHX::MDField<ScalarT,Cell,IP>(fieldNames[fd],integrationRule->dl_scalar);
47 std::ostringstream os;
48 for (
size_t i=0; i < fieldNames.size(); ++i) {
50 if (i < fieldNames.size()-1)
54 this->setName(
"GatherExodusCellDataToIP: "+os.str());
63 for (std::size_t fd = 0; fd < gatherFields_.size(); ++fd) {
64 std::string fieldName = gatherFields_[fd].fieldTag().name();
66 stkFields_[fd] = mesh_->getMetaData()->template get_field<double>(stk::topology::ELEMENT_RANK, exodusNames_[fd]);
68 if(stkFields_[fd]==0) {
70 mesh_->printMetaData(ss);
71 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
72 "panzer_stk::GatherExodusCellDataToIP: STK field " <<
"\"" << fieldName <<
"\" "
73 "not found.\n STK meta data follows: \n\n" << ss.str());
83 const std::vector<stk::mesh::Entity>& localElementEntities = *mesh_->getElementsOrderedByLID();
84 const std::vector<std::size_t>& localWorksetCellIds = this->wda(workset).cell_local_ids;
86 auto host_mirror = Kokkos::create_mirror_view(Kokkos::WithoutInitializing,gatherFields_[0].get_static_view());
88 for (std::size_t fieldIndex=0; fieldIndex < gatherFields_.size(); ++fieldIndex) {
90 const std::size_t numQuadPoints = gatherFields_[fieldIndex].extent(1);
92 for(std::size_t worksetCellIndex=0;worksetCellIndex<localWorksetCellIds.size();++worksetCellIndex) {
93 std::size_t cellLocalId = localWorksetCellIds[worksetCellIndex];
94 for(std::size_t qp=0; qp < numQuadPoints; ++qp) {
95 double value = *stk::mesh::field_data(*
field, localElementEntities[cellLocalId]);
96 host_mirror(worksetCellIndex,qp) = value;
100 Kokkos::deep_copy(gatherFields_[fieldIndex].get_static_view(),host_mirror);
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.