11 #ifndef __Panzer_CellExtreme_impl_hpp__
12 #define __Panzer_CellExtreme_impl_hpp__
16 #include "Intrepid2_FunctionSpaceTools.hpp"
19 #include "Phalanx_DataLayout_MDALayout.hpp"
24 template<
typename EvalT,
typename Traits>
34 if(p.
isType<
bool>(
"Use Max"))
44 this->addEvaluatedField(
extreme);
45 this->addDependentField(
scalar);
48 if(p.
isType<
double>(
"Multiplier"))
52 const std::vector<std::string>& field_multiplier_names =
55 for (std::vector<std::string>::const_iterator name =
56 field_multiplier_names.begin();
57 name != field_multiplier_names.end(); ++name) {
65 this->addDependentField(*
field);
67 std::string n =
"CellExtreme: " +
extreme.fieldTag().name();
72 template<
typename EvalT,
typename Traits>
79 num_qp = scalar.extent(1);
84 template<
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);
146 template<
typename EvalT,
typename TRAITS>
151 p->
set<std::string>(
"Extreme Name",
"?");
152 p->
set<std::string>(
"Field Name",
"?");
156 p->
set<
bool>(
"Use Max",
true);
157 p->
set<
double>(
"Multiplier", 1.0);
160 p->
set(
"Field Multipliers", fms);
int num_cells
DEPRECATED - use: numCells()
void evaluateFields(typename Traits::EvalData d)
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)
CellExtreme(const Teuchos::ParameterList &p)
std::vector< PHX::MDField< const ScalarT, Cell, IP > > field_multipliers
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)
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &fm)
PHX::MDField< ScalarT > extreme
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, panzer::Cell, panzer::BASIS > field
A field to which we'll contribute, or in which we'll store, the result of computing this integral...
bool isType(const std::string &name) const
PHX::MDField< const ScalarT, Cell, IP > scalar
Teuchos::RCP< const std::vector< panzer::Workset > > worksets_