11 #ifndef __Panzer_Integrator_GradBasisDotTensorTimesVector_impl_hpp__
12 #define __Panzer_Integrator_GradBasisDotTensorTimesVector_impl_hpp__
33 template<
typename EvalT,
typename Traits>
37 const std::string& resName,
38 const std::string& fluxName,
41 const std::string& tensorName,
44 evalStyle_(evalStyle),
45 basisName_(basis.name())
54 using std::invalid_argument;
55 using std::logic_error;
61 "Integrator_GradBasisDotTensorTimesVector called with an empty residual name.")
63 "Integrator_GradBasisDotTensorTimesVector called with an empty flux name.")
66 "Error: Integrator_GradBasisDotTensorTimesVector: Basis of type \""
67 << tmpBasis->name() <<
"\" does not support the gradient operator.")
73 tmpVecDL->extent(2) < ir.
dl_vector->extent(2), logic_error,
74 "Integrator_GradBasisDotTensorTimesVector: Dimension of space exceeds " \
75 "dimension of Vector Data Layout.");
79 vector_ = MDField<const ScalarT, Cell, IP, Dim>(fluxName, tmpVecDL);
80 this->addDependentField(
vector_);
86 this->addContributedField(
field_);
88 this->addEvaluatedField(
field_);
91 tensor_ = MDField<const ScalarT, Cell, IP, Dim, Dim>(tensorName, ir.
dl_tensor);
92 this->addDependentField(
tensor_);
95 string n(
"Integrator_GradBasisDotTensorTimesVector (");
100 n +=
"): " +
field_.fieldTag().name();
109 template<
typename EvalT,
typename Traits>
116 p.get<std::string>(
"Residual Name"),
117 p.get<std::string>(
"Flux Name"),
120 p.get<std::string>(
"Tensor Name"),
121 p.isType<Teuchos::
RCP<PHX::DataLayout>>(
"Vector Data Layout") ?
122 p.get<Teuchos::
RCP<PHX::DataLayout>>(
"Vector Data Layout") :
138 template<
typename EvalT,
typename Traits>
149 kokkosTensor_ = tensor_.get_static_view();
156 if (!use_shared_memory) {
157 if (Sacado::IsADType<ScalarT>::value) {
158 const auto fadSize = Kokkos::dimension_scalar(field_.get_view());
159 tmp_ = PHX::View<ScalarT*>(
"GradBasisDotTensorTimesVector::tmp_",field_.extent(0),fadSize);
161 tmp_ = PHX::View<ScalarT*>(
"GradBasisDotTensorTimesVector::tmp_",field_.extent(0));
171 template<
typename EvalT,
typename Traits>
172 KOKKOS_INLINE_FUNCTION
177 const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team)
const
180 const int cell = team.league_rank();
183 const int numQP(vector_.extent(1)), numDim(vector_.extent(2)),
184 numBases(basis_.extent(1));
186 Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,numBases), [&] (
const int basis) {
187 field_(cell, basis) = 0.0;
194 for (
int qp(0); qp < numQP; ++qp)
196 for (
int dim(0); dim < numDim; ++dim)
199 for (
int dim2(0); dim2 < numDim; ++dim2)
200 tmp_(cell) += kokkosTensor_(cell, qp, dim, dim2) * vector_(cell, qp, dim2);
201 Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,numBases), [&] (
const int basis) {
202 field_(cell, basis) += basis_(cell, basis, qp, dim) * tmp_(cell);
214 template<
typename EvalT,
typename Traits>
215 KOKKOS_INLINE_FUNCTION
220 const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team)
const
223 const int cell = team.league_rank();
224 const int numQP = vector_.extent(1);
225 const int numDim = vector_.extent(2);
226 const int numBases = basis_.extent(1);
227 const int fadSize = Kokkos::dimension_scalar(field_.get_view());
231 if (Sacado::IsADType<ScalarT>::value) {
233 tmp_field =
scratch_view(team.team_shmem(),numBases,fadSize);
241 Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,numBases), [&] (
const int basis) {
242 tmp_field(basis) = 0.0;
249 for (
int qp(0); qp < numQP; ++qp)
251 for (
int dim(0); dim < numDim; ++dim)
254 for (
int dim2(0); dim2 < numDim; ++dim2)
255 tmp_(cell) += kokkosTensor_(cell, qp, dim, dim2) * vector_(cell, qp, dim2);
256 Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,numBases), [&] (
const int basis) {
257 tmp_field(basis) += basis_(cell, basis, qp, dim) * tmp_(cell);
265 Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,numBases),[&] (
const int basis) {
266 field_(cell,basis) = tmp_field(basis);
270 Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,numBases),[&] (
const int basis) {
271 field_(cell,basis) += tmp_field(basis);
282 template<
typename EvalT,
typename Traits>
288 using Kokkos::parallel_for;
289 using Kokkos::TeamPolicy;
292 basis_ = this->wda(workset).bases[basisIndex_]->weighted_grad_basis;
295 if (use_shared_memory) {
297 if (Sacado::IsADType<ScalarT>::value) {
298 const int fadSize = Kokkos::dimension_scalar(field_.get_view());
299 bytes = scratch_view::shmem_size(1,fadSize) + scratch_view::shmem_size(basis_.extent(1),fadSize);
302 bytes = scratch_view::shmem_size(1) + scratch_view::shmem_size(basis_.extent(1));
305 parallel_for(this->getName(), policy, *
this);
309 parallel_for(this->getName(), policy, *
this);
318 template<
typename EvalT,
typename TRAITS>
334 p->set<
string>(
"Residual Name",
"?");
335 p->set<
string>(
"Flux Name",
"?");
337 p->set(
"Basis", basis);
340 p->set<std::string>(
"Tensor Name",
"?");
342 p->set(
"Vector Data Layout", vecDL);
348 #endif // __Panzer_Integrator_GradBasisDotTensorTimesVector_impl_hpp__
int num_cells
DEPRECATED - use: numCells()
This empty struct allows us to optimize operator()() depending on the number of field multipliers...
Kokkos::TeamPolicy< TeamPolicyProperties...> teamPolicy(const int &league_size)
Returns a TeamPolicy for hierarchic parallelism.
Teuchos::RCP< PHX::DataLayout > dl_tensor
Data layout for rank-2 tensor fields.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
KOKKOS_INLINE_FUNCTION void operator()(const FieldMultTag &tag, const Kokkos::TeamPolicy< PHX::exec_space >::member_type &team) const
Perform the integration.
PHX::MDField< const ScalarT, panzer::Cell, panzer::IP, panzer::Dim, panzer::Dim > tensor_
The tensor field( ).
EvaluatorStyle
An indication of how an Evaluator will behave.
typename EvalT::ScalarT ScalarT
The scalar type.
Teuchos::RCP< const PureBasis > getBasis() const
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &fm)
Post-Registration Setup.
Teuchos::RCP< Teuchos::ParameterList > getValidParameters() const
Get Valid Parameters.
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...
Integrator_GradBasisDotTensorTimesVector(const panzer::EvaluatorStyle &evalStyle, const std::string &resName, const std::string &fluxName, const panzer::BasisIRLayout &basis, const panzer::IntegrationRule &ir, const std::string &tensorName, const Teuchos::RCP< PHX::DataLayout > &vecDL=Teuchos::null)
Main Constructor.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
panzer::EvaluatorStyle evalStyle
The EvaluatorStyle of the parent Integrator_CurlBasisDotVector object.
bool useSharedMemory() const
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.
PHX::MDField< const ScalarT, panzer::Cell, panzer::IP, panzer::Dim > vector_
A field representing the vector-valued function we're integrating ( ).
void validateParameters(ParameterList const &validParamList, int const depth=1000, EValidateUsed const validateUsed=VALIDATE_USED_ENABLED, EValidateDefaults const validateDefaults=VALIDATE_DEFAULTS_ENABLED) const
const panzer::EvaluatorStyle evalStyle_
An enum determining the behavior of this Evaluator.
This empty struct allows us to optimize operator()() depending on the number of field multipliers...
void evaluateFields(typename Traits::EvalData d)
Evaluate Fields.
Teuchos::RCP< PHX::DataLayout > dl_vector
Data layout for vector fields.
static HP & inst()
Private ctor.
Teuchos::RCP< PHX::DataLayout > functional
<Cell,Basis>
Teuchos::RCP< const std::vector< panzer::Workset > > worksets_