11 #ifndef PANZER_STK_SCATTER_CELL_AVG_VECTOR_IMPL_HPP
12 #define PANZER_STK_SCATTER_CELL_AVG_VECTOR_IMPL_HPP
14 #include "Teuchos_Assert.hpp"
16 #include "Phalanx_config.hpp"
17 #include "Phalanx_Evaluator_Macros.hpp"
18 #include "Phalanx_MDField.hpp"
19 #include "Phalanx_DataLayout.hpp"
20 #include "Phalanx_DataLayout_MDALayout.hpp"
25 #include "Teuchos_FancyOStream.hpp"
26 #include "Teuchos_ArrayRCP.hpp"
28 namespace panzer_stk {
30 template<
typename EvalT,
typename Traits>
40 std::string scatterName = p.
get<std::string>(
"Scatter Name");
45 const std::vector<std::string> & names =
54 for (std::size_t fd = 0; fd < names.size(); ++fd)
62 this->addEvaluatedField(scatterHolder);
64 this->setName(scatterName+
": PanzerSTK::ScatterCellAvgVectors");
68 template<
typename EvalT,
typename Traits>
72 typename Traits::SetupData ,
75 for (std::size_t fd = 0; fd < scatterFields_.size(); ++fd)
77 std::string fieldName = scatterFields_[fd].fieldTag().name();
79 stkFields_[fd] = mesh_->getMetaData()->get_field<
double>(stk::topology::ELEMENT_RANK, fieldName);
84 template<
typename EvalT,
typename Traits>
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++)
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);
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)
bool isParameter(const std::string &name) const
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_
Teuchos::RCP< std::map< std::string, double > > varScaleFactors_
void evaluateFields(typename Traits::EvalData d)