43 #ifndef __Panzer_Integerator_BasisTimesVector_impl_hpp__
44 #define __Panzer_Integerator_BasisTimesVector_impl_hpp__
65 template<
typename EvalT,
typename Traits>
69 const std::string& resName,
70 const std::string& valName,
74 const std::vector<std::string>& fmNames
77 evalStyle_(evalStyle),
78 useDescriptors_(false),
79 multiplier_(multiplier),
80 basisName_(basis.name())
90 using std::invalid_argument;
91 using std::logic_error;
97 "Integrator_BasisTimesVector called with an empty residual name.")
99 "Integrator_BasisTimesVector called with an empty value name.")
102 "Error: Integrator_BasisTimesVector: Basis of type \""
103 << tmpBasis->name() <<
"\" is not a vector basis.");
105 logic_error,
"Integrator_BasisTimesVector: Basis of type \""
106 << tmpBasis->name() <<
"\" does not require orientations. This seems " \
107 "very strange, so I'm failing.");
109 "ERROR: Integrator_BasisTimesVector only supports up to three multipliers!");
113 this->addDependentField(vector_);
119 this->addContributedField(
field_);
121 this->addEvaluatedField(
field_);
126 for (
const auto& name : fmNames) {
132 string n(
"Integrator_BasisTimesVector<");
133 n += std::to_string(fmNames.size()) +
">(";
138 n +=
", " + print<EvalT>() +
"): " +
field_.fieldTag().name();
147 template<
typename EvalT,
typename Traits>
156 const std::vector<PHX::FieldTag>& multipliers
159 evalStyle_(evalStyle),
160 useDescriptors_(true),
163 multiplier_(multiplier)
173 using std::invalid_argument;
174 using std::logic_error;
180 (
bd_.
getType() ==
"HDiv")), logic_error,
"Error: " \
181 "Integrator_BasisTimesVector: Basis of type \"" <<
bd_.
getType()
182 <<
"\" is not a vector basis.")
185 "ERROR: Integrator_BasisTimesVector only supports up to three multipliers!");
189 this->addDependentField(vector_);
195 this->addContributedField(
field_);
197 this->addEvaluatedField(
field_);
202 for (
const auto& fm : multipliers)
209 string n(
"Integrator_BasisTimesVector<");
210 n += std::to_string(multipliers.size()) +
">(";
215 n +=
", " + print<EvalT>() +
"): " +
field_.fieldTag().name();
224 template<
typename EvalT,
typename Traits>
231 p.get<std::string>(
"Residual Name"),
232 p.get<std::string>(
"Value Name"),
235 p.get<double>(
"Multiplier"),
236 p.isType<Teuchos::
RCP<
const std::vector<std::string>>>
237 (
"Field Multipliers") ?
238 (*p.get<Teuchos::
RCP<
const std::vector<std::string>>>
239 (
"Field Multipliers")) : std::vector<std::string>())
254 template<
typename EvalT,
typename Traits>
265 for (
size_t i=0; i < fieldMults_.size(); ++i)
266 kokkosFieldMults_[i] = fieldMults_[i].get_static_view();
270 numQP_ = vector_.extent(1);
271 numDim_ = vector_.extent(2);
274 if (not useDescriptors_)
284 template<
typename EvalT,
typename Traits>
285 template<
int NUM_FIELD_MULT>
286 KOKKOS_INLINE_FUNCTION
294 const int cell = team.league_rank();
295 const int numBases = basis_.extent(1);
299 Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,numBases), [&] (
const int basis) {
300 field_(cell, basis) = 0.0;
306 if constexpr (NUM_FIELD_MULT == 0) {
310 for (
int qp(0); qp < numQP_; ++qp) {
311 for (
int dim(0); dim < numDim_; ++dim) {
312 Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,numBases), [&] (
const int basis) {
313 field_(cell, basis) += basis_(cell, basis, qp, dim) * multiplier_ * vector_(cell, qp, dim);
318 else if constexpr (NUM_FIELD_MULT == 1) {
322 for (
int qp(0); qp < numQP_; ++qp) {
323 for (
int dim(0); dim < numDim_; ++dim) {
324 Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,numBases), [&] (
const int basis) {
325 field_(cell, basis) += basis_(cell, basis, qp, dim) * multiplier_ * vector_(cell, qp, dim)
326 * kokkosFieldMults_[0](cell, qp);
331 else if constexpr (NUM_FIELD_MULT == 2) {
335 for (
int qp(0); qp < numQP_; ++qp) {
336 for (
int dim(0); dim < numDim_; ++dim) {
337 Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,numBases), [&] (
const int basis) {
338 field_(cell, basis) += basis_(cell, basis, qp, dim) * multiplier_ * vector_(cell, qp, dim)
339 * kokkosFieldMults_[0](cell, qp) * kokkosFieldMults_[1](cell, qp);
344 else if constexpr (NUM_FIELD_MULT == 3) {
348 for (
int qp(0); qp < numQP_; ++qp) {
349 for (
int dim(0); dim < numDim_; ++dim) {
350 Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,numBases), [&] (
const int basis) {
351 field_(cell, basis) += basis_(cell, basis, qp, dim) * multiplier_ * vector_(cell, qp, dim)
352 * kokkosFieldMults_[0](cell, qp) * kokkosFieldMults_[1](cell, qp) * kokkosFieldMults_[2](cell, qp);
358 Kokkos::abort(
"Panzer_Integrator_BasisTimesVector: NUM_FIELD_MULT out of range!");
368 template<
typename EvalT,
typename Traits>
374 using Kokkos::parallel_for;
375 using Kokkos::RangePolicy;
380 *this->wda(workset).bases[basisIndex_];
387 if (fieldMults_.size() == 0) {
389 parallel_for(
"Panzer_Integrator_BasisTimesVector<0>", policy, *
this);
391 else if (fieldMults_.size() == 1) {
393 parallel_for(
"Panzer_Integrator_BasisTimesVector<1>", policy, *
this);
395 else if (fieldMults_.size() == 2) {
397 parallel_for(
"Panzer_Integrator_BasisTimesVector<2>", policy, *
this);
399 else if (fieldMults_.size() == 3) {
401 parallel_for(
"Panzer_Integrator_BasisTimesVector<3>", policy, *
this);
410 template<
typename EvalT,
typename Traits>
425 p->set<
string>(
"Residual Name",
"?");
426 p->set<
string>(
"Value Name",
"?");
428 p->set(
"Basis", basis);
431 p->set<
double>(
"Multiplier", 1.0);
433 p->set(
"Field Multipliers", fms);
439 #endif // __Panzer_Integerator_BasisTimesVector_impl_hpp__
int num_cells
DEPRECATED - use: numCells()
Kokkos::TeamPolicy< TeamPolicyProperties...> teamPolicy(const int &league_size)
Returns a TeamPolicy for hierarchic parallelism.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
BasisDescriptor bd_
The BasisDescriptor for the basis to use.
EvaluatorStyle
An indication of how an Evaluator will behave.
Teuchos::RCP< const PureBasis > getBasis() const
Teuchos::RCP< Teuchos::ParameterList > getValidParameters() const
Get Valid Parameters.
double multiplier
The scalar multiplier out in front of the integral ( ).
KOKKOS_INLINE_FUNCTION void operator()(const FieldMultTag< NUM_FIELD_MULT > &tag, const typename Kokkos::TeamPolicy< FieldMultTag< NUM_FIELD_MULT >, PHX::exec_space >::member_type &team) const
Perform the integration.
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_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
const std::string & getType() const
Get type of basis.
Teuchos::RCP< PHX::DataLayout > dl_scalar
Data layout for scalar fields.
void evaluateFields(typename Traits::EvalData workset)
Evaluate Fields.
ConstArray_CellBasisIP getBasisValues(const bool weighted, const bool cache=true, const bool force=false) const
Get the basis values evaluated at mesh points.
panzer::EvaluatorStyle evalStyle
The EvaluatorStyle of the parent Integrator_CurlBasisDotVector object.
typename EvalT::ScalarT ScalarT
The scalar type.
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.
This empty struct allows us to optimize operator()() depending on the number of field multipliers...
void postRegistrationSetup(typename Traits::SetupData sd, PHX::FieldManager< Traits > &fm)
Post-Registration Setup.
void validateParameters(ParameterList const &validParamList, int const depth=1000, EValidateUsed const validateUsed=VALIDATE_USED_ENABLED, EValidateDefaults const validateDefaults=VALIDATE_DEFAULTS_ENABLED) const
Array_CellBasisIPDim weighted_basis_vector
ConstArray_CellBasisIPDim getVectorBasisValues(const bool weighted, const bool cache=true, const bool force=false) const
Get the vector basis values evaluated at mesh points.
Teuchos::RCP< PHX::DataLayout > dl_vector
Data layout for vector fields.
static HP & inst()
Private ctor.
Integrator_BasisTimesVector(const panzer::EvaluatorStyle &evalStyle, const std::string &resName, const std::string &valName, const panzer::BasisIRLayout &basis, const panzer::IntegrationRule &ir, const double &multiplier=1, const std::vector< std::string > &fmNames=std::vector< std::string >())
Main Constructor.
const std::vector< std::pair< int, LocalOrdinal > > &pid_and_lid const
PHX::MDField< const ScalarT, panzer::Cell, panzer::IP, panzer::Dim > vector_
A field representing the vector-valued function we're integrating ( ).
Description and data layouts associated with a particular basis.
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 ( ...
Teuchos::RCP< PHX::DataLayout > functional
<Cell,Basis>
Teuchos::RCP< const std::vector< panzer::Workset > > worksets_