VertexCFD  0.0-dev
VertexCFD_BoundaryState_IncompressibleLSVOFNoSlip_impl.hpp
1 #ifndef VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLELSVOFNOSLIP_IMPL_HPP
2 #define VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLELSVOFNOSLIP_IMPL_HPP
3 
4 #include "utils/VertexCFD_Utils_PhaseLayout.hpp"
5 #include "utils/VertexCFD_Utils_VectorField.hpp"
6 
7 #include <Panzer_HierarchicParallelism.hpp>
8 #include <Panzer_Workset_Utilities.hpp>
9 #include <Teuchos_StandardParameterEntryValidators.hpp>
10 
11 namespace VertexCFD
12 {
13 namespace BoundaryCondition
14 {
15 //---------------------------------------------------------------------------//
16 template<class EvalType, class Traits, int NumSpaceDim>
17 IncompressibleLSVOFNoSlip<EvalType, Traits, NumSpaceDim>::IncompressibleLSVOFNoSlip(
18  const panzer::IntegrationRule& ir,
19  const int& num_lsvof_dofs,
20  const std::string& continuity_model_name,
21  const bool& build_mom_equ)
22  : _phase_layout(Utils::buildPhaseLayout(ir.dl_scalar, num_lsvof_dofs))
23  , _boundary_lagrange_pressure("BOUNDARY_lagrange_pressure", ir.dl_scalar)
24  , _boundary_grad_lagrange_pressure("BOUNDARY_GRAD_lagrange_pressure",
25  ir.dl_vector)
26  , _boundary_alphas("BOUNDARY_volume_fractions", _phase_layout)
27  , _lagrange_pressure("lagrange_pressure", ir.dl_scalar)
28  , _grad_lagrange_pressure("GRAD_lagrange_pressure", ir.dl_vector)
29  , _normals("Side Normal", ir.dl_vector)
30  , _alphas("volume_fractions", _phase_layout)
31  , _is_edac(continuity_model_name == "EDAC" ? true : false)
32  , _build_mom_equ(build_mom_equ)
33 {
34  // Evaluated fields
35  if (_build_mom_equ)
36  {
37  this->addEvaluatedField(_boundary_lagrange_pressure);
38  if (_is_edac)
39  this->addEvaluatedField(_boundary_grad_lagrange_pressure);
40 
41  Utils::addEvaluatedVectorField(
42  *this, ir.dl_scalar, _boundary_velocity, "BOUNDARY_velocity_");
43  Utils::addEvaluatedVectorField(*this,
44  ir.dl_vector,
45  _boundary_grad_velocity,
46  "BOUNDARY_GRAD_velocity_");
47  }
48 
49  this->addEvaluatedField(_boundary_alphas);
50 
51  // Dependent fields
52  if (_build_mom_equ)
53  {
54  this->addDependentField(_lagrange_pressure);
55  if (_is_edac)
56  this->addDependentField(_grad_lagrange_pressure);
57  this->addDependentField(_normals);
58 
59  Utils::addDependentVectorField(
60  *this, ir.dl_vector, _grad_velocity, "GRAD_velocity_");
61  }
62 
63  this->addDependentField(_alphas);
64 
65  this->setName("Boundary State Incompressible LSVOF No-Slip");
66 }
67 
68 //---------------------------------------------------------------------------//
69 template<class EvalType, class Traits, int NumSpaceDim>
70 void IncompressibleLSVOFNoSlip<EvalType, Traits, NumSpaceDim>::evaluateFields(
71  typename Traits::EvalData workset)
72 {
73  auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
74  workset.num_cells);
75  Kokkos::parallel_for(this->getName(), policy, *this);
76 }
77 
78 //---------------------------------------------------------------------------//
79 template<class EvalType, class Traits, int NumSpaceDim>
80 KOKKOS_INLINE_FUNCTION void
81 IncompressibleLSVOFNoSlip<EvalType, Traits, NumSpaceDim>::operator()(
82  const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
83 {
84  const int cell = team.league_rank();
85  const int num_point = _boundary_lagrange_pressure.extent(1);
86  const int num_grad_dim = _boundary_grad_velocity[0].extent(2);
87 
88  Kokkos::parallel_for(
89  Kokkos::TeamThreadRange(team, 0, num_point), [&](const int point) {
90  // Set boundary velocity, pressure, and their gradients
91  if (_build_mom_equ)
92  {
93  for (int vel_dim = 0; vel_dim < num_space_dim; ++vel_dim)
94  {
95  _boundary_velocity[vel_dim](cell, point) = 0.0;
96  }
97 
98  _boundary_lagrange_pressure(cell, point)
99  = _lagrange_pressure(cell, point);
100 
101  // Set gradients at the boundaries.
102  for (int d = 0; d < num_grad_dim; ++d)
103  {
104  // Initialize lagrange pressure gradient for EDAC model
105  if (_is_edac)
106  {
107  _boundary_grad_lagrange_pressure(cell, point, d)
108  = _grad_lagrange_pressure(cell, point, d);
109  }
110 
111  for (int vel_dim = 0; vel_dim < num_space_dim; ++vel_dim)
112  {
113  _boundary_grad_velocity[vel_dim](cell, point, d)
114  = _grad_velocity[vel_dim](cell, point, d);
115 
116  // Subtract wall-normal pressure gradient for EDAC
117  // model
118  if (_is_edac)
119  {
120  _boundary_grad_lagrange_pressure(cell, point, d)
121  -= _grad_lagrange_pressure(cell, point, vel_dim)
122  * _normals(cell, point, vel_dim)
123  * _normals(cell, point, d);
124  }
125  }
126  }
127  }
128 
129  // Set boundary phase fraction fields
130  for (size_t phase = 0; phase < _alphas.extent(2); ++phase)
131  {
132  _boundary_alphas(cell, point, phase)
133  = _alphas(cell, point, phase);
134  }
135  });
136 }
137 
138 //---------------------------------------------------------------------------//
139 
140 } // end namespace BoundaryCondition
141 } // end namespace VertexCFD
142 
143 #endif // VERTEXCFD_BOUNDARYSTATE_INCOMPRESSIBLELSVOFNOSLIP_IMPL_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23