VertexCFD  0.0-dev
VertexCFD_Closure_IncompressibleLSVOFViscousFlux_impl.hpp
1 #ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLELSVOFVISCOUSFLUX_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_INCOMPRESSIBLELSVOFVISCOUSFLUX_IMPL_HPP
3 
4 #include "utils/VertexCFD_Utils_VectorField.hpp"
5 
6 #include <Panzer_HierarchicParallelism.hpp>
7 
8 namespace VertexCFD
9 {
10 namespace ClosureModel
11 {
12 //---------------------------------------------------------------------------//
13 template<class EvalType, class Traits, int NumSpaceDim>
14 IncompressibleLSVOFViscousFlux<EvalType, Traits, NumSpaceDim>::
15  IncompressibleLSVOFViscousFlux(const panzer::IntegrationRule& ir,
16  const Teuchos::ParameterList& lsvof_params,
17  const std::string& flux_prefix,
18  const std::string& gradient_prefix,
19  const std::string& field_prefix)
20  : _continuity_flux(flux_prefix + "VISCOUS_FLUX_continuity", ir.dl_vector)
21  , _grad_press(gradient_prefix + "GRAD_lagrange_pressure", ir.dl_vector)
22  , _rho(field_prefix + "density", ir.dl_scalar)
23  , _mu(field_prefix + "dynamic_viscosity", ir.dl_scalar)
24  , _betam(lsvof_params.get<double>("Mixture Artificial Compressibility"))
25  , _continuity_model_name(lsvof_params.isType<std::string>("Continuity "
26  "Model")
27  ? lsvof_params.get<std::string>("Continuity "
28  "Model")
29  : "AC")
30  , _is_edac(_continuity_model_name == "EDAC" ? true : false)
31 
32 {
33  // Add evaludated fields
34  this->addEvaluatedField(_continuity_flux);
35  Utils::addEvaluatedVectorField(*this, ir.dl_vector, _momentum_flux,
36  flux_prefix + "VISCOUS_FLUX_"
37  "momentum_");
38 
39  // Add dependent fields
40  this->addDependentField(_rho);
41  this->addDependentField(_mu);
42 
43  if (_is_edac)
44  {
45  this->addDependentField(_grad_press);
46  }
47 
48  Utils::addDependentVectorField(*this,
49  ir.dl_vector,
50  _grad_velocity,
51  gradient_prefix + "GRAD_velocity_");
52 
53  this->setName("Incompressible LSVOF Viscous Flux "
54  + std::to_string(num_space_dim) + "D");
55 }
56 
57 //---------------------------------------------------------------------------//
58 template<class EvalType, class Traits, int NumSpaceDim>
59 void IncompressibleLSVOFViscousFlux<EvalType, Traits, NumSpaceDim>::evaluateFields(
60  typename Traits::EvalData workset)
61 {
62  auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
63  workset.num_cells);
64  Kokkos::parallel_for(this->getName(), policy, *this);
65 }
66 
67 //---------------------------------------------------------------------------//
68 template<class EvalType, class Traits, int NumSpaceDim>
69 KOKKOS_INLINE_FUNCTION void
70 IncompressibleLSVOFViscousFlux<EvalType, Traits, NumSpaceDim>::operator()(
71  const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
72 {
73  const int cell = team.league_rank();
74  const int num_point = _continuity_flux.extent(1);
75 
76  Kokkos::parallel_for(
77  Kokkos::TeamThreadRange(team, 0, num_point), [&](const int point) {
78  // Loop over spatial dimension
79  for (int i = 0; i < num_space_dim; ++i)
80  {
81  // Set stress tensor for EDAC continuity model
82  if (_is_edac)
83  {
84  _continuity_flux(cell, point, i)
85  = _mu(cell, point) * _grad_press(cell, point, i)
86  / _betam;
87  }
88  // Set stress tensor to zero for AC continuity model
89  else
90  {
91  _continuity_flux(cell, point, i) = 0.0;
92  }
93 
94  // Loop over velocity/momentum components
95  for (int j = 0; j < num_space_dim; ++j)
96  {
97  _momentum_flux[j](cell, point, i)
98  = _mu(cell, point)
99  * (_grad_velocity[j](cell, point, i)
100  + _grad_velocity[i](cell, point, j));
101  }
102  }
103  });
104 }
105 
106 //---------------------------------------------------------------------------//
107 
108 } // end namespace ClosureModel
109 } // end namespace VertexCFD
110 
111 #endif // end VERTEXCFD_CLOSURE_INCOMPRESSIBLELSVOFVISCOUSFLUX_IMPL_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23