11 #ifndef PANZER_EVALUATOR_SCALAR_IMPL_HPP
12 #define PANZER_EVALUATOR_SCALAR_IMPL_HPP
14 #include "Intrepid2_FunctionSpaceTools.hpp"
17 #include "Kokkos_ViewFactory.hpp"
18 #include "Phalanx_DataLayout_MDALayout.hpp"
23 template<
typename EvalT,
typename Traits>
39 this->addDependentField(
scalar);
42 if(p.
isType<
double>(
"Multiplier"))
46 const std::vector<std::string>& field_multiplier_names =
49 field_multipliers_h =
typename PHX::View<PHX::UnmanagedView<const ScalarT**>* >::HostMirror(
"FieldMultipliersHost", field_multiplier_names.size());
50 field_multipliers = PHX::View<PHX::UnmanagedView<const ScalarT**>* >(
"FieldMultipliersDevice", field_multiplier_names.size());
53 for (std::vector<std::string>::const_iterator name =
54 field_multiplier_names.begin();
55 name != field_multiplier_names.end(); ++name, ++cnt) {
61 std::string n =
"Integrator_Scalar: " +
integral.fieldTag().name();
66 template<
typename EvalT,
typename Traits>
73 num_qp = scalar.extent(1);
77 Kokkos::deep_copy(field_multipliers, field_multipliers_h);
82 template<
typename EvalT,
typename Traits>
89 const auto wm = this->wda(workset).int_rules[quad_index]->weighted_measure;
93 auto l_scalar = scalar;
94 auto l_field_multipliers = field_multipliers;
95 auto l_num_qp = num_qp;
96 auto l_integral = integral.get_static_view();
98 Kokkos::parallel_for(
"IntegratorScalar", workset.
num_cells, KOKKOS_LAMBDA (
int cell) {
99 for (std::size_t qp = 0; qp < l_num_qp; ++qp) {
100 l_tmp(cell,qp) = l_multiplier * l_scalar(cell,qp);
101 for (
size_t f=0;f<l_field_multipliers.extent(0); ++f)
102 l_tmp(cell,qp) *= l_field_multipliers(f)(cell,qp);
104 l_integral(cell) = 0.0;
105 for (std::size_t qp = 0; qp < l_num_qp; ++qp) {
106 l_integral(cell) += l_tmp(cell, qp)*wm(cell, qp);
113 template<
typename EvalT,
typename TRAITS>
118 p->
set<std::string>(
"Integral Name",
"?");
119 p->
set<std::string>(
"Integrand Name",
"?");
123 p->
set<
double>(
"Multiplier", 1.0);
126 p->
set(
"Field Multipliers", fms);
Kokkos::DynRankView< typename InputArray::value_type, PHX::Device > createDynRankView(const InputArray &a, const std::string &name, const DimensionPack...dims)
Wrapper to simplify Panzer use of Sacado ViewFactory.
int num_cells
DEPRECATED - use: numCells()
T & get(const std::string &name, T def_value)
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
std::vector< int >::size_type getIntegrationRuleIndex(int ir_degree, const panzer::Workset &workset, WorksetDetailsAccessor &wda)
Teuchos::RCP< Teuchos::ParameterList > getValidParameters() const
double multiplier
The scalar multiplier out in front of the integral ( ).
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
PHX::View< PHX::UnmanagedView< const ScalarT ** > * >::HostMirror field_multipliers_h
Teuchos::RCP< PHX::DataLayout > dl_scalar
Data layout for scalar fields.
PHX::View< PHX::UnmanagedView< const ScalarT ** > * > field_multipliers
Integrator_Scalar(const Teuchos::ParameterList &p)
PHX::MDField< const ScalarT, Cell, IP > scalar
void validateParameters(ParameterList const &validParamList, int const depth=1000, EValidateUsed const validateUsed=VALIDATE_USED_ENABLED, EValidateDefaults const validateDefaults=VALIDATE_DEFAULTS_ENABLED) const
PHX::MDField< ScalarT > integral
bool isType(const std::string &name) const
void evaluateFields(typename Traits::EvalData d)
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &fm)
Teuchos::RCP< const std::vector< panzer::Workset > > worksets_