1 #ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLELIFTDRAG_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_INCOMPRESSIBLELIFTDRAG_IMPL_HPP
4 #include "utils/VertexCFD_Utils_SmoothMath.hpp"
5 #include "utils/VertexCFD_Utils_VectorField.hpp"
7 #include <Panzer_HierarchicParallelism.hpp>
11 namespace ClosureModel
14 template<
class EvalType,
class Traits,
int NumSpaceDim>
15 IncompressibleLiftDrag<EvalType, Traits, NumSpaceDim>::IncompressibleLiftDrag(
16 const panzer::IntegrationRule& ir,
17 const Teuchos::ParameterList& user_params,
18 const bool use_turbulence_model)
19 : _normals(
"Side Normal", ir.dl_vector)
20 , _lagrange_pressure(
"lagrange_pressure", ir.dl_scalar)
21 , _rho(
"density", ir.dl_scalar)
22 , _nu(
"kinematic_viscosity", ir.dl_scalar)
23 , _nu_t(
"turbulent_eddy_viscosity", ir.dl_scalar)
24 , _use_turbulence_model(use_turbulence_model)
25 , _use_compressible_formula(user_params.isType<bool>(
"Compressible "
27 ? user_params.get<bool>(
"Compressible "
32 Utils::addEvaluatedVectorField(
33 *
this, ir.dl_scalar, _shear_tensor,
"shear_tensor_");
34 Utils::addEvaluatedVectorField(
35 *
this, ir.dl_scalar, _viscous_force,
"viscous_force_");
36 Utils::addEvaluatedVectorField(
37 *
this, ir.dl_scalar, _pressure_force,
"pressure_force_");
38 Utils::addEvaluatedVectorField(
39 *
this, ir.dl_scalar, _total_force,
"total_force_");
42 this->addDependentField(_normals);
43 this->addDependentField(_lagrange_pressure);
44 Utils::addDependentVectorField(
45 *
this, ir.dl_vector, _grad_velocity,
"GRAD_velocity_");
46 this->addDependentField(_rho);
47 this->addDependentField(_nu);
49 if (_use_turbulence_model)
51 this->addDependentField(_nu_t);
54 this->setName(
"Incompressible Lift/Drag " + std::to_string(num_space_dim)
59 template<
class EvalType,
class Traits,
int NumSpaceDim>
60 void IncompressibleLiftDrag<EvalType, Traits, NumSpaceDim>::evaluateFields(
61 typename Traits::EvalData workset)
63 auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
65 Kokkos::parallel_for(this->getName(), policy, *
this);
69 template<
class EvalType,
class Traits,
int NumSpaceDim>
70 KOKKOS_INLINE_FUNCTION
void
71 IncompressibleLiftDrag<EvalType, Traits, NumSpaceDim>::operator()(
72 const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team)
const
74 const int cell = team.league_rank();
75 const int num_point = _lagrange_pressure.extent(1);
77 Kokkos::TeamThreadRange(team, 0, num_point), [&](
const int point) {
79 for (
int i = 0; i < num_space_dim; ++i)
81 _shear_tensor[i](cell, point) = 0;
82 for (
int j = 0; j < num_space_dim; ++j)
84 _shear_tensor[i](cell, point)
85 += (_grad_velocity[j](cell, point, i)
86 + _grad_velocity[i](cell, point, j))
87 * _normals(cell, point, j);
90 if (_use_compressible_formula)
92 _shear_tensor[i](cell, point)
93 -= 2.0 * _grad_velocity[j](cell, point, j)
94 / num_space_dim * _normals(cell, point, i);
97 _pressure_force[i](cell, point)
98 = _lagrange_pressure(cell, point)
99 * _normals(cell, point, i);
100 _viscous_force[i](cell, point)
101 = -_rho(cell, point) * _nu(cell, point)
102 * _shear_tensor[i](cell, point);
103 if (_use_turbulence_model)
105 _viscous_force[i](cell, point)
106 -= _rho(cell, point) * _nu_t(cell, point)
107 * _shear_tensor[i](cell, point);
109 _total_force[i](cell, point)
110 = _viscous_force[i](cell, point)
111 + _pressure_force[i](cell, point);
121 #endif // end VERTEXCFD_CLOSURE_INCOMPRESSIBLELIFTDRAG_IMPL_HPP