11#ifndef __Panzer_CellExtreme_impl_hpp__
12#define __Panzer_CellExtreme_impl_hpp__
16#include "Intrepid2_FunctionSpaceTools.hpp"
19#include "Phalanx_DataLayout_MDALayout.hpp"
24template<
typename EvalT,
typename Traits>
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();
72template<
typename EvalT,
typename Traits>
79 num_qp = scalar.extent(1);
84template<
typename EvalT,
typename Traits>
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);
146template<
typename EvalT,
typename TRAITS>
147Teuchos::RCP<Teuchos::ParameterList>
150 Teuchos::RCP<Teuchos::ParameterList> p = Teuchos::rcp(
new Teuchos::ParameterList);
151 p->set<std::string>(
"Extreme Name",
"?");
152 p->set<std::string>(
"Field Name",
"?");
154 Teuchos::RCP<panzer::IntegrationRule> ir;
156 p->set<
bool>(
"Use Max",
true);
157 p->set<
double>(
"Multiplier", 1.0);
159 Teuchos::RCP<const std::vector<std::string> > fms;
160 p->set(
"Field Multipliers", fms);
double multiplier
The scalar multiplier out in front of the integral ( ).
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.
PHX::MDField< ScalarT > extreme
Teuchos::RCP< Teuchos::ParameterList > getValidParameters() const
Returns the ParameterList of valid parameters/defaults for this evaluator's constructor.
std::vector< PHX::MDField< const ScalarT, Cell, IP > > field_multipliers
CellExtreme(const Teuchos::ParameterList &p)
Construct from a ParameterList as documented in the class description.
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &fm)
Looks up the quadrature index/order needed by evaluateFields(). Called once before the first evaluati...
PHX::MDField< const ScalarT, Cell, IP > scalar
void evaluateFields(typename Traits::EvalData d)
Computes the "Extreme Name" field for this workset per the class description.
int num_cells
DEPRECATED - use: numCells()
std::vector< int >::size_type getIntegrationRuleIndex(int ir_degree, const panzer::Workset &workset, WorksetDetailsAccessor &wda)
User-defined data passed to PHX::Evaluator::postRegistrationSetup() during the one-time setup phase.
Teuchos::RCP< const std::vector< panzer::Workset > > worksets_
All worksets that will be evaluated over the lifetime of this evaluator.