43 #ifndef __Panzer_Integrator_GradBasisDotVector_impl_hpp__ 44 #define __Panzer_Integrator_GradBasisDotVector_impl_hpp__ 64 template<
typename EvalT,
typename Traits>
68 const std::string& resName,
69 const std::string& fluxName,
73 const std::vector<std::string>& fmNames,
75 const Teuchos::RCP<PHX::DataLayout>& vecDL )
79 numDim_(static_cast<int>(ir.dl_vector->extent(2))),
80 basisName_(basis.name())
87 using PHX::DataLayout;
89 using PHX::typeAsString;
90 using std::invalid_argument;
91 using std::logic_error;
96 TEUCHOS_TEST_FOR_EXCEPTION(resName ==
"", invalid_argument,
"Error: " \
97 "Integrator_GradBasisDotVector called with an empty residual name.")
98 TEUCHOS_TEST_FOR_EXCEPTION(fluxName ==
"", invalid_argument,
"Error: " \
99 "Integrator_GradBasisDotVector called with an empty flux name.")
100 RCP<const PureBasis> tmpBasis = basis.
getBasis();
101 TEUCHOS_TEST_FOR_EXCEPTION(not tmpBasis->supportsGrad(), logic_error,
102 "Integrator_GradBasisDotVector: Basis of type \"" << tmpBasis->name() <<
103 "\" does not support the gradient operator.");
105 if (not vecDL.is_null())
108 TEUCHOS_TEST_FOR_EXCEPTION(
109 static_cast<int>(tmpVecDL->extent(2)) <
numDim_, logic_error,
110 "Integrator_GradBasisDotVector: Dimension of space exceeds " \
111 "dimension of Vector Data Layout.");
115 vector_ = MDField<const ScalarT, Cell, IP, Dim>(fluxName, tmpVecDL);
116 this->addDependentField(
vector_);
122 this->addContributedField(
field_);
124 this->addEvaluatedField(
field_);
130 View<View<const ScalarT**>*>(
"GradBasisDotVector::KokkosFieldMultipliers",
132 for (
const auto& name : fmNames)
139 string n(
"Integrator_GradBasisDotVector (");
144 n +=
", " + typeAsString<EvalT>() +
"): " +
field_.fieldTag().name();
153 template<
typename EvalT,
typename Traits>
156 const Teuchos::ParameterList& p)
160 p.get<
std::string>(
"Residual Name"),
161 p.get<
std::string>(
"Flux Name"),
164 p.get<double>(
"Multiplier"),
166 (
"Field Multipliers") ?
168 (
"Field Multipliers")) :
std::vector<
std::string>(),
169 p.isType<
Teuchos::RCP<
PHX::DataLayout>>(
"Vector Data Layout") ?
170 p.get<
Teuchos::RCP<
PHX::DataLayout>>(
"Vector Data Layout") :
173 using Teuchos::ParameterList;
178 p.validateParameters(*validParams);
186 template<
typename EvalT,
typename Traits>
197 for (
size_t i(0); i < fieldMults_.size(); ++i)
198 kokkosFieldMults_(i) = fieldMults_[i].get_static_view();
202 numQP_ = vector_.extent(1);
203 numDim_ = vector_.extent(2);
214 template<
typename EvalT,
typename Traits>
215 template<
int NUM_FIELD_MULT>
216 KOKKOS_INLINE_FUNCTION
221 const size_t& cell)
const 226 const int numBases(basis_.extent(1));
228 for (
int basis(0); basis < numBases; ++basis)
229 field_(cell, basis) = 0.0;
234 if (NUM_FIELD_MULT == 0)
239 for (
int qp(0); qp < numQP_; ++qp)
241 for (
int dim(0); dim < numDim_; ++dim)
243 tmp = multiplier_ * vector_(cell, qp, dim);
244 for (
int basis(0); basis < numBases; ++basis)
245 field_(cell, basis) += basis_(cell, basis, qp, dim) * tmp;
249 else if (NUM_FIELD_MULT == 1)
254 for (
int qp(0); qp < numQP_; ++qp)
256 for (
int dim(0); dim < numDim_; ++dim)
258 tmp = multiplier_ * vector_(cell, qp, dim) *
259 kokkosFieldMults_(0)(cell, qp);
260 for (
int basis(0); basis < numBases; ++basis)
261 field_(cell, basis) += basis_(cell, basis, qp, dim) * tmp;
272 const int numFieldMults(kokkosFieldMults_.extent(0));
273 for (
int qp(0); qp < numQP_; ++qp)
276 for (
int fm(0); fm < numFieldMults; ++fm)
277 fieldMultsTotal *= kokkosFieldMults_(fm)(cell, qp);
278 for (
int dim(0); dim < numDim_; ++dim)
280 tmp = multiplier_ * vector_(cell, qp, dim) * fieldMultsTotal;
281 for (
int basis(0); basis < numBases; ++basis)
282 field_(cell, basis) += basis_(cell, basis, qp, dim) * tmp;
293 template<
typename EvalT,
typename Traits>
299 using Kokkos::parallel_for;
300 using Kokkos::RangePolicy;
303 basis_ = this->wda(workset).bases[basisIndex_]->weighted_grad_basis;
308 if (fieldMults_.size() == 0)
310 else if (fieldMults_.size() == 1)
321 template<
typename EvalT,
typename TRAITS>
322 Teuchos::RCP<Teuchos::ParameterList>
328 using PHX::DataLayout;
331 using Teuchos::ParameterList;
336 RCP<ParameterList> p = rcp(
new ParameterList);
337 p->set<
string>(
"Residual Name",
"?");
338 p->set<
string>(
"Flux Name",
"?");
339 RCP<BasisIRLayout> basis;
340 p->set(
"Basis", basis);
341 RCP<IntegrationRule> ir;
343 p->set<
double>(
"Multiplier", 1.0);
344 RCP<const vector<string>> fms;
345 p->set(
"Field Multipliers", fms);
346 RCP<DataLayout> vecDL;
347 p->set(
"Vector Data Layout", vecDL);
353 #endif // __Panzer_Integrator_GradBasisDotVector_impl_hpp__
PHX::MDField< const ScalarT, panzer::Cell, panzer::IP, panzer::Dim > vector_
A field representing the vector-valued function we're integrating ( ).
typename EvalT::ScalarT ScalarT
The scalar type.
Integrator_GradBasisDotVector(const panzer::EvaluatorStyle &evalStyle, const std::string &resName, const std::string &fluxName, const panzer::BasisIRLayout &basis, const panzer::IntegrationRule &ir, const double &multiplier=1, const std::vector< std::string > &fmNames=std::vector< std::string >(), const Teuchos::RCP< PHX::DataLayout > &vecDL=Teuchos::null)
Main Constructor.
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...
Teuchos::RCP< Teuchos::ParameterList > getValidParameters() const
Get Valid Parameters.
Teuchos::RCP< const PureBasis > getBasis() const
Kokkos::View< Kokkos::View< const ScalarT ** > * > kokkosFieldMults_
The Kokkos::View representation of the (possibly empty) list of fields that are multipliers out in fr...
EvaluatorStyle
An indication of how an Evaluator will behave.
const panzer::EvaluatorStyle evalStyle_
An enum determining the behavior of this Evaluator.
std::vector< PHX::MDField< const ScalarT, panzer::Cell, panzer::IP > > fieldMults_
The (possibly empty) list of fields that are multipliers out in front of the integral ( ...
double multiplier
The scalar multiplier out in front of the integral ( ).
KOKKOS_INLINE_FUNCTION void operator()(const FieldMultTag< NUM_FIELD_MULT > &tag, const std::size_t &cell) const
Perform the integration.
Teuchos::RCP< PHX::DataLayout > dl_scalar
Data layout for scalar fields.
panzer::EvaluatorStyle evalStyle
The EvaluatorStyle of the parent Integrator_CurlBasisDotVector object.
int numDim_
The number of dimensions in the vector field .
std::vector< std::string >::size_type getBasisIndex(std::string basis_name, const panzer::Workset &workset, WorksetDetailsAccessor &wda)
Returns the index in the workset bases for a particular BasisIRLayout name.
void evaluateFields(typename Traits::EvalData d)
Evaluate Fields.
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &fm)
Post-Registration Setup.
Teuchos::RCP< PHX::DataLayout > dl_vector
Data layout for vector fields.
This empty struct allows us to optimize operator()() depending on the number of field multipliers...
Teuchos::RCP< PHX::DataLayout > functional
<Cell,Basis>
Teuchos::RCP< const std::vector< panzer::Workset > > worksets_