VertexCFD  0.0-dev
VertexCFD_BoundaryState_TurbulenceBoundaryEddyViscosity_impl.hpp
1 #ifndef VERTEXCFD_BOUNDARYSTATE_TURBULENCEBOUNDARYEDDYVISCOSITY_IMPL_HPP
2 #define VERTEXCFD_BOUNDARYSTATE_TURBULENCEBOUNDARYEDDYVISCOSITY_IMPL_HPP
3 
4 #include <Panzer_HierarchicParallelism.hpp>
5 
6 namespace VertexCFD
7 {
8 namespace BoundaryCondition
9 {
10 //---------------------------------------------------------------------------//
11 template<class EvalType, class Traits>
12 TurbulenceBoundaryEddyViscosity<EvalType, Traits>::TurbulenceBoundaryEddyViscosity(
13  const panzer::IntegrationRule& ir,
14  const Teuchos::ParameterList& bc_params,
15  const std::string& flux_prefix)
16  : _boundary_nu_t(flux_prefix + "turbulent_eddy_viscosity", ir.dl_scalar)
17  , _interior_nu_t("turbulent_eddy_viscosity", ir.dl_scalar)
18  , _wall_func_nu_t("wall_func_turbulent_eddy_viscosity", ir.dl_scalar)
19  , _wall_func(false)
20 {
21  // Only check boundary if parameter list is populated
22  // (it should be empty in some models, i.e. WALE)
23  if (bc_params.numParams() > 0)
24  {
25  // Check boundary condition type is a wall function
26  const std::string bc_type = bc_params.get<std::string>("Type");
27 
28  if (std::string::npos != bc_type.find("Wall Function"))
29  {
30  _wall_func = true;
31  }
32  }
33 
34  // Add evaluated fields
35  this->addEvaluatedField(_boundary_nu_t);
36 
37  // Add dependent fields
38  if (_wall_func)
39  {
40  this->addDependentField(_wall_func_nu_t);
41  }
42  else
43  {
44  this->addDependentField(_interior_nu_t);
45  }
46 
47  this->setName("Boundary State Turbulence Eddy Viscosity");
48 }
49 
50 //---------------------------------------------------------------------------//
51 template<class EvalType, class Traits>
52 void TurbulenceBoundaryEddyViscosity<EvalType, Traits>::evaluateFields(
53  typename Traits::EvalData workset)
54 {
55  auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
56  workset.num_cells);
57  Kokkos::parallel_for(this->getName(), policy, *this);
58 }
59 
60 //---------------------------------------------------------------------------//
61 template<class EvalType, class Traits>
62 KOKKOS_INLINE_FUNCTION void
63 TurbulenceBoundaryEddyViscosity<EvalType, Traits>::operator()(
64  const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
65 {
66  const int cell = team.league_rank();
67  const int num_point = _boundary_nu_t.extent(1);
68 
69  Kokkos::parallel_for(
70  Kokkos::TeamThreadRange(team, 0, num_point), [&](const int point) {
71  // Set boundary nu_t according to BC type
72  if (_wall_func)
73  {
74  _boundary_nu_t(cell, point) = _wall_func_nu_t(cell, point);
75  }
76  else
77  {
78  _boundary_nu_t(cell, point) = _interior_nu_t(cell, point);
79  }
80  });
81 }
82 
83 //---------------------------------------------------------------------------//
84 
85 } // end namespace BoundaryCondition
86 } // end namespace VertexCFD
87 
88 #endif // end VERTEXCFD_BOUNDARYSTATE_TURBULENCEBOUNDARYEDDYVISCOSITY_IMPL_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23