VertexCFD  0.0-dev
VertexCFD_BoundaryState_IncompressiblePressureOutflow_impl.hpp
1 #ifndef VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEPRESSUREOUTFLOW_IMPL_HPP
2 #define VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEPRESSUREOUTFLOW_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 BoundaryCondition
12 {
13 //---------------------------------------------------------------------------//
14 template<class EvalType, class Traits, int NumSpaceDim>
15 IncompressiblePressureOutflow<EvalType, Traits, NumSpaceDim>::
16  IncompressiblePressureOutflow(const panzer::IntegrationRule& ir,
17  const Teuchos::ParameterList& fluid_params,
18  const Teuchos::ParameterList& bc_params,
19  const bool is_edac)
20  : _boundary_lagrange_pressure("BOUNDARY_lagrange_pressure", ir.dl_scalar)
21  , _boundary_grad_lagrange_pressure("BOUNDARY_GRAD_lagrange_pressure",
22  ir.dl_vector)
23  , _boundary_temperature("BOUNDARY_temperature", ir.dl_scalar)
24  , _boundary_grad_temperature("BOUNDARY_GRAD_temperature", ir.dl_vector)
25  , _grad_lagrange_pressure("GRAD_lagrange_pressure", ir.dl_vector)
26  , _temperature("temperature", ir.dl_scalar)
27  , _grad_temperature("GRAD_temperature", ir.dl_vector)
28  , _solve_temp(fluid_params.get<bool>("Build Temperature Equation"))
29  , _is_edac(is_edac)
30  , _p_back(bc_params.get<double>("Back Pressure"))
31 {
32  // Add evaluated fields
33  this->addEvaluatedField(_boundary_lagrange_pressure);
34  if (_is_edac)
35  this->addEvaluatedField(_boundary_grad_lagrange_pressure);
36  if (_solve_temp)
37  {
38  this->addEvaluatedField(_boundary_temperature);
39  this->addEvaluatedField(_boundary_grad_temperature);
40  }
41  Utils::addEvaluatedVectorField(
42  *this, ir.dl_scalar, _boundary_velocity, "BOUNDARY_velocity_");
43 
44  Utils::addEvaluatedVectorField(*this,
45  ir.dl_vector,
46  _boundary_grad_velocity,
47  "BOUNDARY_GRAD_velocity_");
48 
49  // Add dependent fields
50  if (_is_edac)
51  this->addDependentField(_grad_lagrange_pressure);
52  Utils::addDependentVectorField(*this, ir.dl_scalar, _velocity, "velocity_");
53  if (_solve_temp)
54  {
55  this->addDependentField(_temperature);
56  this->addDependentField(_grad_temperature);
57  }
58 
59  Utils::addDependentVectorField(
60  *this, ir.dl_vector, _grad_velocity, "GRAD_velocity_");
61 
62  this->setName("Boundary State Incompressible Pressure Outflow "
63  + std::to_string(num_space_dim) + "D");
64 }
65 
66 //---------------------------------------------------------------------------//
67 template<class EvalType, class Traits, int NumSpaceDim>
68 void IncompressiblePressureOutflow<EvalType, Traits, NumSpaceDim>::evaluateFields(
69  typename Traits::EvalData workset)
70 {
71  auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
72  workset.num_cells);
73  Kokkos::parallel_for(this->getName(), policy, *this);
74 }
75 
76 //---------------------------------------------------------------------------//
77 template<class EvalType, class Traits, int NumSpaceDim>
78 KOKKOS_INLINE_FUNCTION void
79 IncompressiblePressureOutflow<EvalType, Traits, NumSpaceDim>::operator()(
80  const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
81 {
82  const int cell = team.league_rank();
83  const int num_point = _boundary_velocity[0].extent(1);
84  const int num_grad_dim = _boundary_grad_velocity[0].extent(2);
85 
86  Kokkos::parallel_for(
87  Kokkos::TeamThreadRange(team, 0, num_point), [&](const int point) {
88  // Assign velocity boundaries
89  for (int vel_dim = 0; vel_dim < num_space_dim; ++vel_dim)
90  {
91  _boundary_velocity[vel_dim](cell, point)
92  = _velocity[vel_dim](cell, point);
93  }
94 
95  // Assign boundary conditions for primitive variables
96  _boundary_lagrange_pressure(cell, point) = _p_back;
97 
98  // Temperature equation
99  if (_solve_temp)
100  _boundary_temperature(cell, point) = _temperature(cell, point);
101 
102  // Set boundary gradients
103  for (int d = 0; d < num_grad_dim; ++d)
104  {
105  if (_is_edac)
106  {
107  _boundary_grad_lagrange_pressure(cell, point, d)
108  = _grad_lagrange_pressure(cell, point, d);
109  }
110 
111  if (_solve_temp)
112  {
113  _boundary_grad_temperature(cell, point, d)
114  = _grad_temperature(cell, point, d);
115  }
116 
117  for (int vel_dim = 0; vel_dim < num_space_dim; ++vel_dim)
118  {
119  _boundary_grad_velocity[vel_dim](cell, point, d)
120  = _grad_velocity[vel_dim](cell, point, d);
121  }
122  }
123  });
124 }
125 
126 //---------------------------------------------------------------------------//
127 
128 } // end namespace BoundaryCondition
129 } // end namespace VertexCFD
130 
131 #endif // VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLEPRESSUREOUTFLOW_IMPL_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23