VertexCFD  0.0-dev
VertexCFD_BoundaryState_IncompressibleWallFunction_impl.hpp
1 #ifndef VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEWALLFUNCTION_IMPL_HPP
2 #define VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEWALLFUNCTION_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 IncompressibleWallFunction<EvalType, Traits, NumSpaceDim>::IncompressibleWallFunction(
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  this->setName("Boundary State Incompressible Wall Function "
58  + std::to_string(num_space_dim) + "D");
59 }
60 
61 //---------------------------------------------------------------------------//
62 template<class EvalType, class Traits, int NumSpaceDim>
63 void IncompressibleWallFunction<EvalType, Traits, NumSpaceDim>::evaluateFields(
64  typename Traits::EvalData workset)
65 {
66  auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
67  workset.num_cells);
68  Kokkos::parallel_for(this->getName(), policy, *this);
69 }
70 
71 //---------------------------------------------------------------------------//
72 template<class EvalType, class Traits, int NumSpaceDim>
73 KOKKOS_INLINE_FUNCTION void
74 IncompressibleWallFunction<EvalType, Traits, NumSpaceDim>::operator()(
75  const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
76 {
77  const int cell = team.league_rank();
78  const int num_point = _lagrange_pressure.extent(1);
79  const int num_grad_dim = _normals.extent(2);
80 
81  Kokkos::parallel_for(
82  Kokkos::TeamThreadRange(team, 0, num_point), [&](const int point) {
83  // Set boundary Lagrange pressure
84  _boundary_lagrange_pressure(cell, point)
85  = _lagrange_pressure(cell, point);
86 
87  if (_solve_temp)
88  {
89  _boundary_temperature(cell, point) = _temperature(cell, point);
90  }
91 
92  // Set boundary velocity and boundary gradients
93  for (int dim = 0; dim < num_grad_dim; ++dim)
94  {
95  if (_is_edac)
96  {
97  _boundary_grad_lagrange_pressure(cell, point, dim)
98  = _grad_lagrange_pressure(cell, point, dim);
99  }
100  // Initialize boundary velocity and temperature gradient to
101  // interior fields (modified in subsequent loop)
102  _boundary_velocity[dim](cell, point)
103  = _velocity[dim](cell, point);
104 
105  if (_solve_temp)
106  {
107  _boundary_grad_temperature(cell, point, dim)
108  = _grad_temperature(cell, point, dim);
109  }
110 
111  for (int vel_dim = 0; vel_dim < num_space_dim; ++vel_dim)
112  {
113  // Set no-penetration velocity condition
114  _boundary_velocity[dim](cell, point)
115  -= _velocity[vel_dim](cell, point)
116  * _normals(cell, point, vel_dim)
117  * _normals(cell, point, dim);
118 
119  // Set boundary velocity gradient to arbitrary value (zero)
120  // The boundary velocity gradient is required for the
121  // viscous flux closure, which is called on the boundary
122  // for the continuity and energy equations even if a wall
123  // function is used for velocity.
124  _boundary_grad_velocity[dim](cell, point, vel_dim) = 0.0;
125 
126  if (_solve_temp)
127  {
128  // TODO: this BC currently assumes an insulated wall.
129  // A future MR should implement the correct wall
130  // function for the energy equation.
131  _boundary_grad_temperature(cell, point, dim)
132  -= _grad_temperature(cell, point, vel_dim)
133  * _normals(cell, point, vel_dim)
134  * _normals(cell, point, dim);
135  }
136 
137  if (_is_edac)
138  {
139  _boundary_grad_lagrange_pressure(cell, point, dim)
140  -= _grad_lagrange_pressure(cell, point, vel_dim)
141  * _normals(cell, point, vel_dim)
142  * _normals(cell, point, dim);
143  }
144  }
145  }
146  });
147 }
148 
149 //---------------------------------------------------------------------------//
150 
151 } // end namespace BoundaryCondition
152 } // end namespace VertexCFD
153 
154 #endif // VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEWALLFUNCTION_IMPL_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23