43 #ifndef PANZER_VECTOR_TO_SCALAR_IMPL_HPP
44 #define PANZER_VECTOR_TO_SCALAR_IMPL_HPP
51 template<
typename EvalT,
typename Traits>
62 const std::vector<std::string>& scalar_names =
65 scalar_fields.resize(scalar_names.size());
66 for (std::size_t i=0; i < scalar_names.size(); ++i)
68 PHX::MDField<ScalarT,Cell,Point>(scalar_names[i], scalar_dl);
71 PHX::MDField<const ScalarT,Cell,Point,Dim>(p.
get<std::string>
72 (
"Vector Name"), vector_dl);
74 this->addDependentField(vector_field);
76 for (std::size_t i=0; i < scalar_fields.size(); ++i)
77 this->addEvaluatedField(scalar_fields[i]);
79 std::string n =
"VectorToScalar: " + vector_field.fieldTag().name();
85 template<typename EvalT, typename Traits> \
86 VectorToScalar<EvalT,Traits>::
87 VectorToScalar(
const PHX::FieldTag & input,
88 const std::vector<PHX::Tag<ScalarT>> & output)
93 scalar_fields.resize(output.size());
94 for(std::size_t i=0;i<output.size();i++)
95 scalar_fields[i] = output[i];
98 this->addDependentField(vector_field);
100 for (std::size_t i=0; i < scalar_fields.size(); ++i)
101 this->addEvaluatedField(scalar_fields[i]);
104 std::string n =
"VectorToScalar: " + vector_field.fieldTag().name();
109 template<
typename EvalT,
typename Traits>
117 const int num_points = vector_field.extent_int(1);
118 const int num_scalars = std::min(static_cast<int>(scalar_fields.size()),
119 vector_field.extent_int(2));
122 auto local_vector_field = vector_field;
125 for (
int sc = 0; sc < num_scalars; ++sc) {
126 auto local_scalar_field = scalar_fields[sc];
127 Kokkos::parallel_for(workset.
num_cells, KOKKOS_LAMBDA (
const int cell) {
128 for (
int pt = 0; pt < num_points; ++pt)
129 local_scalar_field(cell,pt) = local_vector_field(cell,pt,sc);
134 for(
unsigned int sc = num_scalars; sc < scalar_fields.size(); ++sc)
135 Kokkos::deep_copy(scalar_fields[sc].get_static_view(), 0.);
T & get(const std::string &name, T def_value)
VectorToScalar(const Teuchos::ParameterList &p)
void evaluateFields(typename Traits::EvalData d)