43 #ifndef PANZER_STK_SCATTER_CELL_AVG_VECTOR_IMPL_HPP
44 #define PANZER_STK_SCATTER_CELL_AVG_VECTOR_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>
72 std::string scatterName = p.
get<std::string>(
"Scatter Name");
74 const std::vector<std::string> & names =
83 for (std::size_t fd = 0; fd < names.size(); ++fd)
90 PHX::Tag<ScalarT> scatterHolder(scatterName,
Teuchos::rcp(
new PHX::MDALayout<panzer::Dummy>(0)));
91 this->addEvaluatedField(scatterHolder);
93 this->setName(scatterName+
": STK-Scatter Cell Vectors");
97 template<
typename EvalT,
typename Traits>
101 typename Traits::SetupData ,
104 for (std::size_t fd = 0; fd < scatterFields_.size(); ++fd)
106 std::string fieldName = scatterFields_[fd].fieldTag().name();
108 stkFields_[fd] = mesh_->getMetaData()->get_field<
VariableField>(stk::topology::ELEMENT_RANK, fieldName);
113 template<
typename EvalT,
typename Traits>
117 typename Traits::EvalData workset)
122 const std::vector<std::size_t> & localCellIds = this->wda(workset).cell_local_ids;
123 std::string blockId = this->wda(workset).block_id;
124 std::string d_mod[3] = {
"X",
"Y",
"Z"};
127 for(std::size_t fieldIndex = 0; fieldIndex < scatterFields_.size(); fieldIndex++)
129 PHX::MDField<const ScalarT,panzer::Cell,panzer::Point,panzer::Dim> &
field = scatterFields_[fieldIndex];
130 std::string fieldName = field.fieldTag().name();
131 int numCells = field.extent(0);
133 int numDims = field.extent(2);
135 for (
int dim = 0; dim < numDims; dim++)
141 for(
int i = 0; i < numCells; i++)
145 average(i,0) += Sacado::ScalarValue<ScalarT>::eval(
field(i,j,dim));
150 mesh_->setCellFieldData(fieldName+d_mod[dim],blockId,localCellIds,average);
panzer_stk::STK_Interface::VectorFieldType VariableField
T & get(const std::string &name, T def_value)
PHX::MDField< Scalar, T0 > buildStaticArray(const std::string &str, int d0) const
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &fm)
ScatterCellAvgVector(const Teuchos::ParameterList &p)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
std::vector< VariableField * > stkFields_
Teuchos::RCP< PHX::DataLayout > dl_vector
Data layout for vector 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...
std::vector< PHX::MDField< const ScalarT, panzer::Cell, panzer::Point, panzer::Dim > > scatterFields_
void evaluateFields(typename Traits::EvalData d)