43 #ifndef PANZER_DOF_DIV_IMPL_HPP
44 #define PANZER_DOF_DIV_IMPL_HPP
54 template<
typename ScalarT,
typename ArrayT>
65 using scratch_view = Kokkos::View<ScalarT* ,typename PHX::DevLayout<ScalarT>::type,
typename PHX::exec_space::scratch_memory_space,Kokkos::MemoryUnmanaged>;
68 PHX::MDField<const ScalarT,Cell,Point> & in_dof_value,
69 const ArrayT & in_div_basis,
70 const bool in_use_shared_memory =
false)
76 fad_size(static_cast<int>(Kokkos::dimension_scalar(in_dof_div.get_view()))),
80 KOKKOS_INLINE_FUNCTION
81 void operator()(
const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team)
const
83 const int cell = team.league_rank();
89 if (Sacado::IsADType<ScalarT>::value) {
98 Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,
num_fields), [&] (
const int& dof) {
102 Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,
num_points), [&] (
const int& pt) {
103 point_values(pt) = 0.0;
110 Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,
num_points), [&] (
const int& pt) {
111 point_values(pt) += dof_values(dof) *
div_basis(cell,dof,pt);
116 Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,
num_points), [&] (
const int& pt) {
117 dof_div(cell,pt) = point_values(pt);
121 Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,
num_points), [&] (
const int& pt) {
137 if (Sacado::IsADType<ScalarT>::value)
151 template<
typename EvalT,
typename TRAITS>
154 use_descriptors_(false),
164 "DOFDiv: Basis of type \"" << basis->name() <<
"\" does not support DIV");
166 "DOFDiv: Basis of type \"" << basis->name() <<
"\" in DOF Div should require orientations. So we are throwing.");
169 dof_div = PHX::MDField<ScalarT,Cell,IP>(p.
get<std::string>(
"Div Name"),
173 this->addEvaluatedField(dof_div);
176 std::string n =
"DOFDiv: " + dof_div.fieldTag().name() +
" ("+PHX::print<EvalT>()+
")";
181 template<
typename EvalT,
typename TRAITS>
184 const PHX::FieldTag & output,
187 : use_descriptors_(true)
198 this->addEvaluatedField(dof_div);
201 std::string n =
"DOFDiv: " + dof_div.fieldTag().name() +
" ("+PHX::print<EvalT>()+
")";
206 template<
typename EvalT,
typename TRAITS>
211 if(not use_descriptors_)
216 template<
typename EvalT,
typename TRAITS>
220 if (workset.num_cells == 0)
224 : *this->wda(workset).bases[basis_index];
229 Kokkos::parallel_for(policy,f,this->getName());
239 template<
typename TRAITS>
242 use_descriptors_(false),
254 accelerate_jacobian =
true;
257 accelerate_jacobian =
false;
258 accelerate_jacobian =
false;
262 "DOFDiv: Basis of type \"" << basis->name() <<
"\" does not support DIV");
264 "DOFDiv: Basis of type \"" << basis->name() <<
"\" in DOF Div should require orientations. So we are throwing.");
267 dof_div = PHX::MDField<ScalarT,Cell,IP>(p.
get<std::string>(
"Div Name"),
271 this->addEvaluatedField(dof_div);
274 std::string n =
"DOFDiv: " + dof_div.fieldTag().name() +
" ("+PHX::print<panzer::Traits::Jacobian>()+
")";
279 template<
typename TRAITS>
282 const PHX::FieldTag & output,
285 : use_descriptors_(true)
295 accelerate_jacobian =
false;
298 this->addEvaluatedField(dof_div);
301 std::string n =
"DOFDiv: " + dof_div.fieldTag().name() +
" ("+PHX::print<panzer::Traits::Jacobian>()+
")";
306 template<
typename TRAITS>
312 this->utils.setFieldData(
dof_div,fm);
318 template<
typename TRAITS>
322 if (workset.num_cells == 0)
328 if(!accelerate_jacobian) {
332 Kokkos::parallel_for(policy,f,this->getName());
panzer::BasisDescriptor bd_
panzer::IntegrationDescriptor id_
DOFDiv(const Teuchos::ParameterList &p)
T & get(const std::string &name, T def_value)
Kokkos::TeamPolicy< TeamPolicyProperties...> teamPolicy(const int &league_size)
Returns a TeamPolicy for hierarchic parallelism.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void postRegistrationSetup(typename TRAITS::SetupData d, PHX::FieldManager< TRAITS > &fm)
Array_CellBasisIP div_basis
panzer::Traits::Jacobian::ScalarT ScalarT
PHX::MDField< ScalarT, Cell, IP > dof_div
const std::string & getType() const
Get type of basis.
PHX::MDField< const ScalarT, Cell, Point > dof_value
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.
KOKKOS_INLINE_FUNCTION void operator()(const Kokkos::TeamPolicy< PHX::exec_space >::member_type &team) const
void evaluateFields(typename TRAITS::EvalData d)
PHX::MDField< const ScalarT, Cell, Point > dof_value
bool isType(const std::string &name) const
WorksetDetailsAccessor wda
static HP & inst()
Private ctor.
#define TEUCHOS_ASSERT(assertion_test)
PHX::MDField< const ScalarT, Cell, Point > dof_value
size_t team_shmem_size(int) const
EvaluateDOFDiv_withSens(PHX::MDField< ScalarT, Cell, IP > &in_dof_div, PHX::MDField< const ScalarT, Cell, Point > &in_dof_value, const ArrayT &in_div_basis, const bool in_use_shared_memory=false)
Kokkos::View< const int *, PHX::Device > offsets
const bool use_shared_memory
PHX::MDField< ScalarT, Cell, IP > dof_div
Kokkos::View< ScalarT *,typename PHX::DevLayout< ScalarT >::type, typename PHX::exec_space::scratch_memory_space, Kokkos::MemoryUnmanaged > scratch_view