43 #ifndef PANZER_STK_SCATTER_CELL_AVG_QUANTITY_IMPL_HPP
44 #define PANZER_STK_SCATTER_CELL_AVG_QUANTITY_IMPL_HPP
46 #include "Teuchos_Assert.hpp"
48 #include "Phalanx_config.hpp"
49 #include "Phalanx_Evaluator_Macros.hpp"
50 #include "Phalanx_MDField.hpp"
51 #include "Phalanx_DataLayout.hpp"
52 #include "Phalanx_DataLayout_MDALayout.hpp"
57 #include "Teuchos_FancyOStream.hpp"
58 #include "Teuchos_ArrayRCP.hpp"
60 namespace panzer_stk {
62 template<
typename EvalT,
typename Traits>
71 std::string scatterName = p.
get<std::string>(
"Scatter Name");
73 const std::vector<std::string> & names =
82 for (std::size_t fd = 0; fd < names.size(); ++fd) {
84 PHX::MDField<const ScalarT,Cell,Point>(names[fd],intRule->
dl_scalar);
89 PHX::Tag<ScalarT> scatterHolder(scatterName,
Teuchos::rcp(
new PHX::MDALayout<panzer::Dummy>(0)));
90 this->addEvaluatedField(scatterHolder);
92 this->setName(scatterName+
": STK-Scatter Cell Fields");
95 template<
typename EvalT,
typename Traits>
99 typename Traits::SetupData ,
102 for (std::size_t fd = 0; fd < scatterFields_.size(); ++fd) {
103 std::string fieldName = scatterFields_[fd].fieldTag().name();
105 stkFields_[fd] = mesh_->getMetaData()->get_field<
VariableField>(stk::topology::ELEMENT_RANK, fieldName);
109 template<
typename EvalT,
typename Traits>
113 typename Traits::EvalData workset)
118 const std::vector<std::size_t> & localCellIds = this->wda(workset).cell_local_ids;
119 std::string blockId = this->wda(workset).block_id;
121 for(std::size_t fieldIndex=0; fieldIndex<scatterFields_.size();fieldIndex++) {
122 PHX::MDField<const ScalarT,panzer::Cell,panzer::Point> &
field = scatterFields_[fieldIndex];
125 for(
unsigned i=0; i<field.extent(0);i++) {
126 for(
unsigned j=0; j<field.extent(1);j++)
127 average(i,0) += Sacado::ScalarValue<ScalarT>::eval(
field(i,j));
128 average(i,0) /= field.extent(1);
131 mesh_->setCellFieldData(field.fieldTag().name(),blockId,localCellIds,average);
T & get(const std::string &name, T def_value)
panzer_stk::STK_Interface::SolutionFieldType VariableField
PHX::MDField< Scalar, T0 > buildStaticArray(const std::string &str, int d0) const
std::vector< PHX::MDField< const ScalarT, panzer::Cell, panzer::Point > > scatterFields_
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< PHX::DataLayout > dl_scalar
Data layout for scalar fields.
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...
void evaluateFields(typename Traits::EvalData d)
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &fm)
ScatterCellAvgQuantity(const Teuchos::ParameterList &p)
std::vector< VariableField * > stkFields_