27 const Teuchos::ParameterList& p) : quad_index(0)
30 p.validateParameters(*valid_params);
34 if(p.isType<
bool>(
"Use Max"))
35 use_max = p.get<
bool>(
"Use Max");
37 Teuchos::RCP<panzer::IntegrationRule> ir = p.get< Teuchos::RCP<panzer::IntegrationRule> >(
"IR");
40 Teuchos::RCP<PHX::DataLayout> dl_cell = Teuchos::rcp(
new PHX::MDALayout<Cell>(ir->dl_scalar->extent(0)));
41 extreme = PHX::MDField<ScalarT>( p.get<std::string>(
"Extreme Name"), dl_cell);
42 scalar = PHX::MDField<const ScalarT,Cell,IP>( p.get<std::string>(
"Field Name"), ir->dl_scalar);
44 this->addEvaluatedField(
extreme);
45 this->addDependentField(
scalar);
48 if(p.isType<
double>(
"Multiplier"))
51 if (p.isType<Teuchos::RCP<
const std::vector<std::string> > >(
"Field Multipliers")) {
52 const std::vector<std::string>& field_multiplier_names =
53 *(p.get<Teuchos::RCP<const std::vector<std::string> > >(
"Field Multipliers"));
55 for (std::vector<std::string>::const_iterator name =
56 field_multiplier_names.begin();
57 name != field_multiplier_names.end(); ++name) {
58 PHX::MDField<const ScalarT,Cell,IP> tmp_field(*name, p.get< Teuchos::RCP<panzer::IntegrationRule> >(
"IR")->dl_scalar);
63 for (
typename std::vector<PHX::MDField<const ScalarT,Cell,IP> >::iterator
field =
field_multipliers.begin();
65 this->addDependentField(*
field);
67 std::string n =
"CellExtreme: " +
extreme.fieldTag().name();
91 std::size_t num_pt = this->num_qp;
92 bool extreme_max = this->use_max;
93 auto scalar_view = scalar.get_view();
94 auto extreme_view = extreme.get_view();
97 PHX::View<ScalarT**> mult_field(
"Multiplied Field", workset.
num_cells, scalar.extent(1));
100 Kokkos::parallel_for(
"Initialize Muliplier Field", workset.
num_cells, KOKKOS_LAMBDA(
const int cell) {
101 for (std::size_t qp = 0; qp < num_pt; ++qp) {
102 mult_field(cell, qp) = mult * scalar_view(cell, qp);
107 for (std::size_t field_num = 0; field_num < field_multipliers.size(); ++field_num)
109 auto field = field_multipliers[field_num];
110 Kokkos::parallel_for(
"CellExtreme: Multiply Fields", workset.
num_cells, KOKKOS_LAMBDA(
const int cell) {
111 for (std::size_t qp = 0; qp < num_pt; ++qp) {
112 mult_field(cell, qp) *=
field(cell, qp);
119 Kokkos::parallel_for (
"CellExtreme (max)", workset.
num_cells, KOKKOS_LAMBDA(
const int cell) {
120 for (std::size_t qp = 0; qp < num_pt; ++qp) {
121 auto current = mult_field(cell, qp);
125 extreme_view(cell) = current;
127 extreme_view(cell) = extreme_view(cell)<current ? current : extreme_view(cell);
131 Kokkos::parallel_for (
"CellExtreme (min)", workset.
num_cells, KOKKOS_LAMBDA(
const int cell) {
132 for (std::size_t qp = 0; qp < num_pt; ++qp) {
133 auto current = mult_field(cell, qp);
137 extreme_view(cell) = current;
139 extreme_view(cell) = extreme_view(cell)>current ? current : extreme_view(cell);
PHX::MDField< ScalarT, panzer::Cell, panzer::BASIS > field
A field to which we'll contribute, or in which we'll store, the result of computing this integral.