1 #ifndef VERTEXCFD_CLOSURE_ELEMENTLENGTH_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_ELEMENTLENGTH_IMPL_HPP
4 #include <Panzer_HierarchicParallelism.hpp>
10 namespace ClosureModel
13 template<
class EvalType,
class Traits>
14 ElementLength<EvalType, Traits>::ElementLength(
const panzer::IntegrationRule& ir,
15 const std::string& prefix)
16 : _element_length(prefix +
"element_length", ir.dl_vector)
18 this->addEvaluatedField(_element_length);
19 this->setName(
"Element Length");
23 template<
class EvalType,
class Traits>
24 void ElementLength<EvalType, Traits>::evaluateFields(
25 typename Traits::EvalData workset)
28 _grad_basis = this->wda(workset).bases[0]->grad_basis;
29 auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
31 Kokkos::parallel_for(this->getName(), policy, *
this);
35 template<
class EvalType,
class Traits>
36 KOKKOS_INLINE_FUNCTION
void ElementLength<EvalType, Traits>::operator()(
37 const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team)
const
39 const int cell = team.league_rank();
40 const int num_point = _element_length.extent(1);
41 const int num_space_dim = _element_length.extent(2);
42 const int num_basis = _grad_basis.extent(1);
45 Kokkos::TeamThreadRange(team, 0, num_point), [&](
const int point) {
48 for (
int dim = 0; dim < num_space_dim; ++dim)
50 double grad_basis_squared = 0.0;
51 for (
int basis = 0; basis < num_basis; ++basis)
54 += pow(_grad_basis(cell, basis, point, dim), 2);
56 _element_length(cell, point, dim)
57 = pow(grad_basis_squared, -0.5);
67 #endif // end VERTEXCFD_CLOSURE_ELEMENTLENGTH_IMPL_HPP