VertexCFD  0.0-dev
VertexCFD_Closure_IncompressibleNusseltNumber_impl.hpp
1 #ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLENUSSELTNUMBER_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_INCOMPRESSIBLENUSSELTNUMBER_IMPL_HPP
3 
4 #include "utils/VertexCFD_Utils_SmoothMath.hpp"
5 #include "utils/VertexCFD_Utils_VectorField.hpp"
6 
7 #include <Panzer_HierarchicParallelism.hpp>
8 
9 namespace VertexCFD
10 {
11 namespace ClosureModel
12 {
13 //---------------------------------------------------------------------------//
14 template<class EvalType, class Traits>
15 IncompressibleNusseltNumber<EvalType, Traits>::IncompressibleNusseltNumber(
16  const panzer::IntegrationRule& ir)
17  : _nusselt_number("nusselt_number", ir.dl_scalar)
18  , _grad_temperature("GRAD_temperature", ir.dl_vector)
19  , _normals("Side Normal", ir.dl_vector)
20  , _num_space_dim(ir.spatial_dimension)
21 {
22  // Add evaluated field
23  this->addEvaluatedField(_nusselt_number);
24 
25  // Add dependent field
26  this->addDependentField(_grad_temperature);
27  this->addDependentField(_normals);
28 
29  this->setName("Incompressible Nusselt Number "
30  + std::to_string(_num_space_dim) + "D");
31 }
32 
33 //---------------------------------------------------------------------------//
34 template<class EvalType, class Traits>
35 void IncompressibleNusseltNumber<EvalType, Traits>::evaluateFields(
36  typename Traits::EvalData workset)
37 {
38  auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
39  workset.num_cells);
40  Kokkos::parallel_for(this->getName(), policy, *this);
41 }
42 
43 //---------------------------------------------------------------------------//
44 template<class EvalType, class Traits>
45 KOKKOS_INLINE_FUNCTION void
46 IncompressibleNusseltNumber<EvalType, Traits>::operator()(
47  const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
48 {
49  const int cell = team.league_rank();
50  const int num_point = _grad_temperature.extent(1);
51  Kokkos::parallel_for(Kokkos::TeamThreadRange(team, 0, num_point),
52  [&](const int point) {
53  // Nusselt number calculated with VERTEX-CFD needs
54  // to be multiplied with
55  // k/k_{ref} * 1/(T_w-T_{inf})
56  // as the model that is used is
57  // Nu= k/k_{ref} * d(\theta)/d(n)
58  // where \theta = (T-T_{inf})/(T_w-T_{inf}).
59  _nusselt_number(cell, point) = 0;
60  for (int i = 0; i < _num_space_dim; ++i)
61  {
62  _nusselt_number(cell, point)
63  += _grad_temperature(cell, point, i)
64  * _normals(cell, point, i);
65  }
66  });
67 }
68 
69 //---------------------------------------------------------------------------//
70 
71 } // end namespace ClosureModel
72 } // end namespace VertexCFD
73 
74 #endif // end VERTEXCFD_CLOSURE_INCOMPRESSIBLENUSSELTNUMBER_IMPL_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23