11 #ifndef PANZER_SCALAR_TO_VECTOR_IMPL_HPP
12 #define PANZER_SCALAR_TO_VECTOR_IMPL_HPP
19 template<
typename EvalT,
typename Traits>
30 const std::vector<std::string>& scalar_names =
33 scalar_fields.resize(scalar_names.size());
34 for (std::size_t i=0; i < scalar_names.size(); ++i)
40 (
"Vector Name"), vector_dl);
42 for (std::size_t i=0; i < scalar_fields.size(); ++i)
43 this->addDependentField(scalar_fields[i]);
45 this->addEvaluatedField(vector_field);
47 std::string n =
"ScalarToVector: " + vector_field.fieldTag().name();
53 template<typename EvalT, typename Traits> \
54 ScalarToVector<EvalT,Traits>::
59 vector_field = output;
61 scalar_fields.resize(input.size());
62 for(std::size_t i=0;i<input.size();i++)
63 scalar_fields[i] = input[i];
66 this->addEvaluatedField(vector_field);
68 for (std::size_t i=0; i < scalar_fields.size(); ++i)
69 this->addDependentField(scalar_fields[i]);
72 std::string n =
"ScalarToVector: " + vector_field.fieldTag().name();
77 template<
typename EvalT,
typename Traits>
85 internal_scalar_fields = PHX::View<KokkosScalarFields_t*>(
"ScalarToVector::internal_scalar_fields", scalar_fields.size());
86 for (std::size_t i=0; i < scalar_fields.size(); ++i)
87 internal_scalar_fields(i) = scalar_fields[i].get_static_view();
91 template<
typename EvalT,
typename Traits>
98 using Scalar =
typename EvalT::ScalarT;
101 const int num_points = vector_field.extent_int(1);
102 const int num_vector_scalars = vector_field.extent_int(2);
103 const int num_scalars = std::min(internal_scalar_fields.extent_int(0),
107 auto vector = vector_field;
108 auto scalars = internal_scalar_fields;
111 Kokkos::parallel_for (workset.
num_cells,KOKKOS_LAMBDA (
const int cell){
112 for (
int pt = 0; pt < num_points; ++pt){
115 for (
int sc = 0; sc < num_scalars; ++sc)
116 vector(cell,pt,sc) = scalars(sc)(cell,pt);
119 for(
int sc = num_scalars; sc < num_vector_scalars; ++sc)
120 vector(cell,pt,sc) = Scalar(0);
int num_cells
DEPRECATED - use: numCells()
T & get(const std::string &name, T def_value)
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &fm)
void evaluateFields(typename Traits::EvalData d)
ScalarToVector(const Teuchos::ParameterList &p)