43#ifndef PANZER_EVALUATOR_SCALAR_IMPL_HPP
44#define PANZER_EVALUATOR_SCALAR_IMPL_HPP
46#include "Intrepid2_FunctionSpaceTools.hpp"
49#include "Kokkos_ViewFactory.hpp"
50#include "Phalanx_DataLayout_MDALayout.hpp"
55template<
typename EvalT,
typename Traits>
58 const Teuchos::ParameterList& p) : quad_index(0)
61 p.validateParameters(*valid_params);
63 Teuchos::RCP<panzer::IntegrationRule> ir = p.get< Teuchos::RCP<panzer::IntegrationRule> >(
"IR");
66 Teuchos::RCP<PHX::DataLayout> dl_cell = Teuchos::rcp(
new PHX::MDALayout<Cell>(ir->dl_scalar->extent(0)));
67 integral = PHX::MDField<ScalarT>( p.get<std::string>(
"Integral Name"), dl_cell);
68 scalar = PHX::MDField<const ScalarT,Cell,IP>( p.get<std::string>(
"Integrand Name"), ir->dl_scalar);
71 this->addDependentField(
scalar);
74 if(p.isType<
double>(
"Multiplier"))
77 if (p.isType<Teuchos::RCP<
const std::vector<std::string> > >(
"Field Multipliers")) {
78 const std::vector<std::string>& field_multiplier_names =
79 *(p.get<Teuchos::RCP<const std::vector<std::string> > >(
"Field Multipliers"));
81 field_multipliers_h =
typename PHX::View<PHX::UnmanagedView<const ScalarT**>* >::HostMirror(
"FieldMultipliersHost", field_multiplier_names.size());
82 field_multipliers = PHX::View<PHX::UnmanagedView<const ScalarT**>* >(
"FieldMultipliersDevice", field_multiplier_names.size());
85 for (std::vector<std::string>::const_iterator name =
86 field_multiplier_names.begin();
87 name != field_multiplier_names.end(); ++name, ++cnt) {
88 PHX::MDField<const ScalarT,Cell,IP> tmp_field(*name, p.get< Teuchos::RCP<panzer::IntegrationRule> >(
"IR")->dl_scalar);
93 std::string n =
"Integrator_Scalar: " +
integral.fieldTag().name();
98template<
typename EvalT,
typename Traits>
105 num_qp = scalar.extent(1);
106 tmp = Kokkos::createDynRankView(scalar.get_static_view(),
"tmp", scalar.extent(0), num_qp);
109 Kokkos::deep_copy(field_multipliers, field_multipliers_h);
114template<
typename EvalT,
typename Traits>
121 const auto wm = this->wda(workset).int_rules[quad_index]->weighted_measure;
125 auto l_scalar = scalar;
126 auto l_field_multipliers = field_multipliers;
127 auto l_num_qp = num_qp;
128 auto l_integral = integral.get_static_view();
130 Kokkos::parallel_for(
"IntegratorScalar", workset.
num_cells, KOKKOS_LAMBDA (
int cell) {
131 for (std::size_t qp = 0; qp < l_num_qp; ++qp) {
132 l_tmp(cell,qp) = l_multiplier * l_scalar(cell,qp);
133 for (
size_t f=0;f<l_field_multipliers.extent(0); ++f)
134 l_tmp(cell,qp) *= l_field_multipliers(f)(cell,qp);
136 l_integral(cell) = 0.0;
137 for (std::size_t qp = 0; qp < l_num_qp; ++qp) {
138 l_integral(cell) += l_tmp(cell, qp)*wm(cell, qp);
145template<
typename EvalT,
typename TRAITS>
146Teuchos::RCP<Teuchos::ParameterList>
149 Teuchos::RCP<Teuchos::ParameterList> p = Teuchos::rcp(
new Teuchos::ParameterList);
150 p->set<std::string>(
"Integral Name",
"?");
151 p->set<std::string>(
"Integrand Name",
"?");
153 Teuchos::RCP<panzer::IntegrationRule> ir;
155 p->set<
double>(
"Multiplier", 1.0);
157 Teuchos::RCP<const std::vector<std::string> > fms;
158 p->set(
"Field Multipliers", fms);
double multiplier
The scalar multiplier out in front of the integral ( ).
PHX::MDField< const ScalarT, Cell, IP > scalar
Integrator_Scalar(const Teuchos::ParameterList &p)
PHX::View< PHX::UnmanagedView< constScalarT ** > * >::HostMirror field_multipliers_h
Teuchos::RCP< Teuchos::ParameterList > getValidParameters() const
PHX::View< PHX::UnmanagedView< const ScalarT ** > * > field_multipliers
PHX::MDField< ScalarT > integral
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &fm)
void evaluateFields(typename Traits::EvalData d)
int num_cells
DEPRECATED - use: numCells()
std::vector< int >::size_type getIntegrationRuleIndex(int ir_degree, const panzer::Workset &workset, WorksetDetailsAccessor &wda)
Teuchos::RCP< const std::vector< panzer::Workset > > worksets_