VertexCFD  0.0-dev
VertexCFD_Closure_MeasureElementLength_impl.hpp
1 #ifndef VERTEXCFD_CLOSURE_MEASUREELEMENTLENGTH_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_MEASUREELEMENTLENGTH_IMPL_HPP
3 
4 #include <Panzer_HierarchicParallelism.hpp>
5 #include <Panzer_Workset_Utilities.hpp>
6 
7 #include <algorithm>
8 #include <cmath>
9 
17 namespace VertexCFD
18 {
19 namespace ClosureModel
20 {
21 //---------------------------------------------------------------------------//
22 template<class EvalType, class Traits>
23 MeasureElementLength<EvalType, Traits>::MeasureElementLength(
24  const panzer::IntegrationRule& ir, const std::string& prefix)
25  : _element_length(prefix + "element_length", ir.dl_vector)
26  , _ir_degree(ir.cubature_degree)
27 {
28  this->addEvaluatedField(_element_length);
29  this->setName("Measure Element Length");
30 }
31 
32 //---------------------------------------------------------------------------//
33 template<class EvalType, class Traits>
34 void MeasureElementLength<EvalType, Traits>::postRegistrationSetup(
35  typename Traits::SetupData sd, PHX::FieldManager<Traits>&)
36 {
37  _ir_index = panzer::getIntegrationRuleIndex(_ir_degree, (*sd.worksets_)[0]);
38 }
39 
40 //---------------------------------------------------------------------------//
41 template<class EvalType, class Traits>
42 void MeasureElementLength<EvalType, Traits>::evaluateFields(
43  typename Traits::EvalData workset)
44 {
45  _cell_det = workset.int_rules[_ir_index]->jac_det;
46  auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
47  workset.num_cells);
48  Kokkos::parallel_for(this->getName(), policy, *this);
49 }
50 
51 //---------------------------------------------------------------------------//
52 template<class EvalType, class Traits>
53 KOKKOS_INLINE_FUNCTION void MeasureElementLength<EvalType, Traits>::operator()(
54  const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
55 {
56  const int cell = team.league_rank();
57  const int num_point = _element_length.extent(1);
58  const int num_space_dim = _element_length.extent(2);
59 
60  Kokkos::parallel_for(
61  Kokkos::TeamThreadRange(team, 0, num_point), [&](const int point) {
62  using std::pow;
63  // Compute element size
64  const double h = pow(_cell_det(cell, point), 1.0 / num_space_dim);
65 
66  // Set value of the element length (same value for all
67  // directions)
68  for (int i = 0; i < num_space_dim; i++)
69  {
70  _element_length(cell, point, i) = h;
71  }
72  });
73 }
74 
75 //---------------------------------------------------------------------------//
76 
77 } // end namespace ClosureModel
78 } // end namespace VertexCFD
79 
80 #endif // end VERTEXCFD_CLOSURE_MEASUREELEMENTLENGTH_IMPL_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23