43 #ifndef PANZER_SCALAR_TO_VECTOR_IMPL_HPP
44 #define PANZER_SCALAR_TO_VECTOR_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<const ScalarT,Cell,Point>(scalar_names[i], scalar_dl);
71 PHX::MDField<ScalarT,Cell,Point,Dim>(p.
get<std::string>
72 (
"Vector Name"), vector_dl);
74 for (std::size_t i=0; i < scalar_fields.size(); ++i)
75 this->addDependentField(scalar_fields[i]);
77 this->addEvaluatedField(vector_field);
79 std::string n =
"ScalarToVector: " + vector_field.fieldTag().name();
85 template<typename EvalT, typename Traits> \
86 ScalarToVector<EvalT,Traits>::
87 ScalarToVector(
const std::vector<PHX::Tag<ScalarT>> & input,
88 const PHX::FieldTag & output)
91 vector_field = output;
93 scalar_fields.resize(input.size());
94 for(std::size_t i=0;i<input.size();i++)
95 scalar_fields[i] = input[i];
98 this->addEvaluatedField(vector_field);
100 for (std::size_t i=0; i < scalar_fields.size(); ++i)
101 this->addDependentField(scalar_fields[i]);
104 std::string n =
"ScalarToVector: " + vector_field.fieldTag().name();
109 template<
typename EvalT,
typename Traits>
117 internal_scalar_fields = Kokkos::View<KokkosScalarFields_t*>(
"ScalarToVector::internal_scalar_fields", scalar_fields.size());
118 for (std::size_t i=0; i < scalar_fields.size(); ++i)
119 internal_scalar_fields(i) = scalar_fields[i].get_static_view();
123 template<
typename EvalT,
typename Traits>
130 using Scalar =
typename EvalT::ScalarT;
133 const int num_points = vector_field.extent_int(1);
134 const int num_vector_scalars = vector_field.extent_int(2);
135 const int num_scalars = std::min(internal_scalar_fields.extent_int(0),
139 auto vector = vector_field;
140 auto scalars = internal_scalar_fields;
143 Kokkos::parallel_for (workset.
num_cells,KOKKOS_LAMBDA (
const int cell){
144 for (
int pt = 0; pt < num_points; ++pt){
147 for (
int sc = 0; sc < num_scalars; ++sc)
148 vector(cell,pt,sc) = scalars(sc)(cell,pt);
151 for(
int sc = num_scalars; sc < num_vector_scalars; ++sc)
152 vector(cell,pt,sc) = Scalar(0);
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)