33 const Teuchos::ParameterList& p) :
40 std::string scatterName = p.get<std::string>(
"Scatter Name");
42 if (p.isParameter(
"Variable Scale Factors Map"))
43 varScaleFactors_ = p.get<Teuchos::RCP<std::map<std::string,double>>>(
"Variable Scale Factors Map");
45 const std::vector<std::string> & names =
46 *(p.get< Teuchos::RCP< std::vector<std::string> > >(
"Field Names"));
48 Teuchos::RCP<panzer::IntegrationRule> intRule =
49 p.get< Teuchos::RCP<panzer::IntegrationRule> >(
"IR");
54 for (std::size_t fd = 0; fd < names.size(); ++fd)
56 scatterFields_[fd] = PHX::MDField<const ScalarT,Cell,Point,Dim>(names[fd],intRule->dl_vector);
61 PHX::Tag<ScalarT> scatterHolder(scatterName,Teuchos::rcp(
new PHX::MDALayout<panzer::Dummy>(0)));
62 this->addEvaluatedField(scatterHolder);
64 this->setName(scatterName+
": PanzerSTK::ScatterCellAvgVectors");
88 typename Traits::EvalData workset)
93 const std::vector<std::size_t> & localCellIds = this->wda(workset).cell_local_ids;
94 std::string blockId = this->wda(workset).block_id;
95 std::string d_mod[3] = {
"X",
"Y",
"Z"};
98 for(std::size_t fieldIndex = 0; fieldIndex < scatterFields_.size(); fieldIndex++)
100 PHX::MDField<const ScalarT,panzer::Cell,panzer::Point,panzer::Dim> &
field = scatterFields_[fieldIndex];
101 std::string fieldName =
field.fieldTag().name();
102 const int numCells = workset.num_cells;
104 const int numDims =
field.extent(2);
106 for (
int dim = 0; dim < numDims; dim++)
112 Kokkos::parallel_for(
"ScatterCellAvgVector",numCells,KOKKOS_LAMBDA(
const int i){
115 average(i,0) += Sacado::scalarValue(
field(i,j,dim));
121 if (!varScaleFactors_.is_null())
123 std::map<std::string,double> *tmp_sfs = varScaleFactors_.get();
124 if(tmp_sfs->find(fieldName) != tmp_sfs->end())
125 scalef = (*tmp_sfs)[fieldName];
128 PHX::Device().fence();
129 mesh_->setCellFieldData(fieldName+d_mod[dim],blockId,localCellIds,average.get_view(),scalef);
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.