VertexCFD  0.0-dev
VertexCFD_BoundaryState_ViscousGradient_impl.hpp
1 #ifndef VERTEXCFD_BOUNDARYSTATE_VISCOUSGRADIENT_IMPL_HPP
2 #define VERTEXCFD_BOUNDARYSTATE_VISCOUSGRADIENT_IMPL_HPP
3 
4 #include "Panzer_Workset_Utilities.hpp"
5 #include <Panzer_HierarchicParallelism.hpp>
6 
7 namespace VertexCFD
8 {
9 namespace BoundaryCondition
10 {
11 //---------------------------------------------------------------------------//
12 template<class EvalType, class Traits>
13 ViscousGradient<EvalType, Traits>::ViscousGradient(
14  const panzer::IntegrationRule& ir, const std::string& dof_name)
15  : _grad("PENALTY_GRAD_" + dof_name, ir.dl_vector)
16  , _scaled_grad("SYMMETRY_GRAD_" + dof_name, ir.dl_vector)
17  , _num_space_dim(ir.spatial_dimension)
18  , _dof(dof_name, ir.dl_scalar)
19  , _bnd_dof("BOUNDARY_" + dof_name, ir.dl_scalar)
20  , _penalty_param("viscous_penalty_parameter_" + dof_name, ir.dl_scalar)
21  , _normals("Side Normal", ir.dl_vector)
22 {
23  // Add evaluated fields
24  this->addEvaluatedField(_grad);
25  this->addEvaluatedField(_scaled_grad);
26 
27  // Add dependent fields
28  this->addDependentField(_dof);
29  this->addDependentField(_bnd_dof);
30  this->addDependentField(_penalty_param);
31  this->addDependentField(_normals);
32 
33  this->setName("Boundary State Viscous Gradient "
34  + std::to_string(_num_space_dim) + "D");
35 }
36 
37 //---------------------------------------------------------------------------//
38 template<class EvalType, class Traits>
39 void ViscousGradient<EvalType, Traits>::evaluateFields(
40  typename Traits::EvalData workset)
41 {
42  auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
43  workset.num_cells);
44  Kokkos::parallel_for(this->getName(), policy, *this);
45 }
46 
47 //---------------------------------------------------------------------------//
48 template<class EvalType, class Traits>
49 KOKKOS_INLINE_FUNCTION void ViscousGradient<EvalType, Traits>::operator()(
50  const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
51 {
52  const int cell = team.league_rank();
53  const int num_point = _dof.extent(1);
54 
55  Kokkos::parallel_for(
56  Kokkos::TeamThreadRange(team, 0, num_point), [&](const int point) {
57  const auto u = _dof(cell, point);
58  const auto u_bnd = _bnd_dof(cell, point);
59  const auto delta = _penalty_param(cell, point);
60 
61  for (int dim = 0; dim < _num_space_dim; ++dim)
62  {
63  _grad(cell, point, dim) = _normals(cell, point, dim)
64  * (u - u_bnd);
65 
66  _scaled_grad(cell, point, dim) = delta
67  * _grad(cell, point, dim);
68  }
69  });
70 }
71 
72 //---------------------------------------------------------------------------//
73 
74 } // end namespace BoundaryCondition
75 } // end namespace VertexCFD
76 
77 #endif // VERTEXCFD_BOUNDARYSTATE_VISCOUSGRADIENT_IMPL_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23