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>
153 DOFDiv(
const Teuchos::ParameterList & p) :
154 use_descriptors_(false),
159 Teuchos::RCP<const PureBasis> basis
160 = p.get< Teuchos::RCP<BasisIRLayout> >(
"Basis")->getBasis();
163 TEUCHOS_TEST_FOR_EXCEPTION(!basis->supportsDiv(),std::logic_error,
164 "DOFDiv: Basis of type \"" << basis->name() <<
"\" does not support DIV");
165 TEUCHOS_TEST_FOR_EXCEPTION(!basis->requiresOrientations(),std::logic_error,
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"),
170 p.get< Teuchos::RCP<panzer::IntegrationRule> >(
"IR")->dl_scalar );
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)
192 TEUCHOS_ASSERT(bd.
getType()==
"HDiv");
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>
241 DOFDiv(
const Teuchos::ParameterList & p) :
242 use_descriptors_(false),
247 Teuchos::RCP<const PureBasis> basis
248 = p.get< Teuchos::RCP<BasisIRLayout> >(
"Basis")->getBasis();
252 if(p.isType<Teuchos::RCP<
const std::vector<int> > >(
"Jacobian Offsets Vector")) {
253 offsets = *p.get<Teuchos::RCP<const std::vector<int> > >(
"Jacobian Offsets Vector");
254 accelerate_jacobian =
true;
257 accelerate_jacobian =
false;
258 accelerate_jacobian =
false;
261 TEUCHOS_TEST_FOR_EXCEPTION(!basis->supportsDiv(),std::logic_error,
262 "DOFDiv: Basis of type \"" << basis->name() <<
"\" does not support DIV");
263 TEUCHOS_TEST_FOR_EXCEPTION(!basis->requiresOrientations(),std::logic_error,
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"),
268 p.get< Teuchos::RCP<panzer::IntegrationRule> >(
"IR")->dl_scalar );
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)
290 TEUCHOS_ASSERT(bd.
getType()==
"HDiv");
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());
336 TEUCHOS_ASSERT(
false);
panzer::BasisDescriptor bd_
panzer::IntegrationDescriptor id_
bool useSharedMemory() const
DOFDiv(const Teuchos::ParameterList &p)
Kokkos::TeamPolicy< TeamPolicyProperties... > teamPolicy(const int &league_size)
Returns a TeamPolicy for hierarchic parallelism.
size_t team_shmem_size(int) const
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
PHX::MDField< const ScalarT, Cell, Point > dof_value
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)
PHX::MDField< const ScalarT, Cell, Point > dof_value
WorksetDetailsAccessor wda
static HP & inst()
Private ctor.
PHX::MDField< const ScalarT, Cell, Point > dof_value
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)
const std::string & getType() const
Get type of basis.
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
KOKKOS_INLINE_FUNCTION void operator()(const Kokkos::TeamPolicy< PHX::exec_space >::member_type &team) const