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,
42 const Teuchos::RCP<PHX::DataLayout>& vecDL )
45 basisName_(basis.name())
52 using PHX::DataLayout;
54 using std::invalid_argument;
55 using std::logic_error;
60 TEUCHOS_TEST_FOR_EXCEPTION(resName ==
"", invalid_argument,
"Error: " \
61 "Integrator_GradBasisDotTensorTimesVector called with an empty residual name.")
62 TEUCHOS_TEST_FOR_EXCEPTION(fluxName ==
"", invalid_argument,
"Error: " \
63 "Integrator_GradBasisDotTensorTimesVector called with an empty flux name.")
64 RCP<const PureBasis> tmpBasis = basis.
getBasis();
65 TEUCHOS_TEST_FOR_EXCEPTION(not tmpBasis->supportsGrad(), logic_error,
66 "Error: Integrator_GradBasisDotTensorTimesVector: Basis of type \""
67 << tmpBasis->name() <<
"\" does not support the gradient operator.")
69 if (not vecDL.is_null())
72 TEUCHOS_TEST_FOR_EXCEPTION(
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>
112 const Teuchos::ParameterList& p)
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") :
125 using Teuchos::ParameterList;
130 p.validateParameters(*validParams);
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>
319 Teuchos::RCP<Teuchos::ParameterList>
325 using PHX::DataLayout;
328 using Teuchos::ParameterList;
333 RCP<ParameterList> p = rcp(
new ParameterList);
334 p->set<
string>(
"Residual Name",
"?");
335 p->set<
string>(
"Flux Name",
"?");
336 RCP<BasisIRLayout> basis;
337 p->set(
"Basis", basis);
338 RCP<IntegrationRule> ir;
340 p->set<std::string>(
"Tensor Name",
"?");
341 RCP<DataLayout> vecDL;
342 p->set(
"Vector Data Layout", vecDL);
panzer::EvaluatorStyle evalStyle
The EvaluatorStyle of the parent Integrator_CurlBasisDotVector object.
Teuchos::RCP< PHX::DataLayout > functional
<Cell,Basis>
Teuchos::RCP< const PureBasis > getBasis() const
static HP & inst()
Private ctor.
bool useSharedMemory() const
Kokkos::TeamPolicy< TeamPolicyProperties... > teamPolicy(const int &league_size)
Returns a TeamPolicy for hierarchic parallelism.
void evaluateFields(typename Traits::EvalData d)
Evaluate Fields.
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.
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.
KOKKOS_INLINE_FUNCTION void operator()(const FieldMultTag &tag, const Kokkos::TeamPolicy< PHX::exec_space >::member_type &team) const
Perform the integration.
Teuchos::RCP< Teuchos::ParameterList > getValidParameters() const
Get Valid Parameters.
Kokkos::View< ScalarT *,typename PHX::DevLayout< ScalarT >::type, typename PHX::exec_space::scratch_memory_space, Kokkos::MemoryUnmanaged > scratch_view
Type for shared memory.
typename EvalT::ScalarT ScalarT
The scalar type.
PHX::MDField< const ScalarT, panzer::Cell, panzer::IP, panzer::Dim, panzer::Dim > tensor_
The tensor field( ).
PHX::MDField< const ScalarT, panzer::Cell, panzer::IP, panzer::Dim > vector_
A field representing the vector-valued function we're integrating ( ).
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &fm)
Post-Registration Setup.
const panzer::EvaluatorStyle evalStyle_
An enum determining the behavior of this Evaluator.
Teuchos::RCP< PHX::DataLayout > dl_vector
Data layout for vector fields.
Teuchos::RCP< PHX::DataLayout > dl_tensor
Data layout for rank-2 tensor fields.
int num_cells
DEPRECATED - use: numCells()
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.
EvaluatorStyle
An indication of how an Evaluator will behave.
This empty struct allows us to optimize operator()() depending on the number of field multipliers....
This empty struct allows us to optimize operator()() depending on the number of field multipliers....
Teuchos::RCP< const std::vector< panzer::Workset > > worksets_