VertexCFD  0.0-dev
VertexCFD_BoundaryState_IncompressibleFreeSlip_impl.hpp
1 #ifndef VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEFREESLIP_IMPL_HPP
2 #define VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEFREESLIP_IMPL_HPP
3 
4 #include "utils/VertexCFD_Utils_VectorField.hpp"
5 
6 #include <Panzer_HierarchicParallelism.hpp>
7 
8 namespace VertexCFD
9 {
10 namespace BoundaryCondition
11 {
12 //---------------------------------------------------------------------------//
13 template<class EvalType, class Traits, int NumSpaceDim>
14 IncompressibleFreeSlip<EvalType, Traits, NumSpaceDim>::IncompressibleFreeSlip(
15  const panzer::IntegrationRule& ir,
16  const Teuchos::ParameterList& fluid_params,
17  const bool is_edac)
18  : _boundary_lagrange_pressure("BOUNDARY_lagrange_pressure", ir.dl_scalar)
19  , _boundary_grad_lagrange_pressure("BOUNDARY_GRAD_lagrange_pressure",
20  ir.dl_vector)
21  , _boundary_temperature("BOUNDARY_temperature", ir.dl_scalar)
22  , _boundary_grad_temperature("BOUNDARY_GRAD_temperature", ir.dl_vector)
23  , _lagrange_pressure("lagrange_pressure", ir.dl_scalar)
24  , _grad_lagrange_pressure("GRAD_lagrange_pressure", ir.dl_vector)
25  , _temperature("temperature", ir.dl_scalar)
26  , _grad_temperature("GRAD_temperature", ir.dl_vector)
27  , _normals("Side Normal", ir.dl_vector)
28  , _solve_temp(fluid_params.get<bool>("Build Temperature Equation"))
29  , _is_edac(is_edac)
30 {
31  this->addEvaluatedField(_boundary_lagrange_pressure);
32  if (_is_edac)
33  this->addEvaluatedField(_boundary_grad_lagrange_pressure);
34  Utils::addEvaluatedVectorField(
35  *this, ir.dl_scalar, _boundary_velocity, "BOUNDARY_velocity_");
36 
37  Utils::addEvaluatedVectorField(*this,
38  ir.dl_vector,
39  _boundary_grad_velocity,
40  "BOUNDARY_GRAD_velocity_");
41 
42  if (_solve_temp)
43  {
44  this->addDependentField(_temperature);
45  this->addEvaluatedField(_boundary_temperature);
46  this->addDependentField(_grad_temperature);
47  this->addEvaluatedField(_boundary_grad_temperature);
48  }
49 
50  Utils::addDependentVectorField(*this, ir.dl_scalar, _velocity, "velocity_");
51  this->addDependentField(_lagrange_pressure);
52  if (_is_edac)
53  this->addDependentField(_grad_lagrange_pressure);
54 
55  this->addDependentField(_normals);
56 
57  Utils::addDependentVectorField(
58  *this, ir.dl_vector, _grad_velocity, "GRAD_velocity_");
59 
60  this->setName("Boundary State Incompressible Free Slip "
61  + std::to_string(num_space_dim) + "D");
62 }
63 
64 //---------------------------------------------------------------------------//
65 template<class EvalType, class Traits, int NumSpaceDim>
66 void IncompressibleFreeSlip<EvalType, Traits, NumSpaceDim>::evaluateFields(
67  typename Traits::EvalData workset)
68 {
69  auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
70  workset.num_cells);
71  Kokkos::parallel_for(this->getName(), policy, *this);
72 }
73 
74 //---------------------------------------------------------------------------//
75 template<class EvalType, class Traits, int NumSpaceDim>
76 KOKKOS_INLINE_FUNCTION void
77 IncompressibleFreeSlip<EvalType, Traits, NumSpaceDim>::operator()(
78  const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
79 {
80  const int cell = team.league_rank();
81  const int num_point = _lagrange_pressure.extent(1);
82  const int num_grad_dim = _normals.extent(2);
83 
84  Kokkos::parallel_for(
85  Kokkos::TeamThreadRange(team, 0, num_point), [&](const int point) {
86  // Set boundary Lagrange pressure
87  _boundary_lagrange_pressure(cell, point)
88  = _lagrange_pressure(cell, point);
89 
90  // Compute \vec{vel} \cdot \vec{n}
91  scalar_type vel_dot_n = 0.0;
92  scalar_type grad_T_dot_n = 0.0;
93  for (int dim = 0; dim < num_grad_dim; ++dim)
94  {
95  vel_dot_n += _velocity[dim](cell, point)
96  * _normals(cell, point, dim);
97  if (_solve_temp)
98  {
99  grad_T_dot_n += _grad_temperature(cell, point, dim)
100  * _normals(cell, point, dim);
101  }
102  }
103 
104  if (_solve_temp)
105  _boundary_temperature(cell, point) = _temperature(cell, point);
106 
107  // Set boundary velocity and boundary gradients
108  for (int dim = 0; dim < num_grad_dim; ++dim)
109  {
110  if (_is_edac)
111  {
112  _boundary_grad_lagrange_pressure(cell, point, dim)
113  = _grad_lagrange_pressure(cell, point, dim);
114  }
115 
116  _boundary_velocity[dim](cell, point)
117  = _velocity[dim](cell, point)
118  - vel_dot_n * _normals(cell, point, dim);
119 
120  for (int vel_dim = 0; vel_dim < num_space_dim; ++vel_dim)
121  {
122  _boundary_grad_velocity[vel_dim](cell, point, dim)
123  = _grad_velocity[vel_dim](cell, point, dim);
124  }
125 
126  if (_solve_temp)
127  {
128  _boundary_grad_temperature(cell, point, dim)
129  = _grad_temperature(cell, point, dim)
130  - grad_T_dot_n * _normals(cell, point, dim);
131  }
132  }
133  });
134 }
135 
136 //---------------------------------------------------------------------------//
137 
138 } // end namespace BoundaryCondition
139 } // end namespace VertexCFD
140 
141 #endif // VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEFREESLIP_IMPL_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23