11 #ifndef PANZER_STK_GATHER_EXODUS_CELL_DATA_TO_IP_IMPL_HPP
12 #define PANZER_STK_GATHER_EXODUS_CELL_DATA_TO_IP_IMPL_HPP
14 #include "Teuchos_Assert.hpp"
15 #include "Phalanx_DataLayout.hpp"
17 #include "Teuchos_FancyOStream.hpp"
24 template<
typename EvalT,
typename Traits>
27 const std::vector<std::string>& fieldNames,
28 const std::vector<std::string>& exodusNames,
31 exodusNames_(exodusNames)
42 for (std::size_t fd = 0; fd < fieldNames.size(); ++fd) {
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());
58 template<
typename EvalT,
typename Traits>
63 for (std::size_t fd = 0; fd < gatherFields_.size(); ++fd) {
64 std::string fieldName = gatherFields_[fd].fieldTag().name();
66 stkFields_[fd] = mesh_->getMetaData()->get_field<
double>(stk::topology::ELEMENT_RANK, exodusNames_[fd]);
68 if(stkFields_[fd]==0) {
70 mesh_->printMetaData(ss);
72 "panzer_stk::GatherExodusCellDataToIP: STK field " <<
"\"" << fieldName <<
"\" "
73 "not found.\n STK meta data follows: \n\n" << ss.str());
79 template<
typename EvalT,
typename Traits>
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);
std::vector< PHX::MDField< ScalarT, panzer::Cell, panzer::IP > > gatherFields_
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
panzer_stk::STK_Interface::SolutionFieldType VariableField
void evaluateFields(typename Traits::EvalData d)
Teuchos::RCP< PHX::DataLayout > dl_scalar
Data layout for scalar fields.
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &vm)
GatherExodusCellDataToIP(const Teuchos::RCP< const panzer_stk::STK_Interface > &mesh, const std::vector< std::string > &fieldNames, const std::vector< std::string > &exodusNames, const Teuchos::RCP< panzer::IntegrationRule > &integrationRule)
std::vector< VariableField * > stkFields_
bool nonnull(const boost::shared_ptr< T > &p)
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...
#define TEUCHOS_ASSERT(assertion_test)