1 #ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLEENSTROPHY_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_INCOMPRESSIBLEENSTROPHY_IMPL_HPP
4 #include "utils/VertexCFD_Utils_SmoothMath.hpp"
5 #include "utils/VertexCFD_Utils_VectorField.hpp"
7 #include <Panzer_HierarchicParallelism.hpp>
13 namespace ClosureModel
16 template<
class EvalType,
class Traits,
int NumSpaceDim>
17 IncompressibleEnstrophy<EvalType, Traits, NumSpaceDim>::IncompressibleEnstrophy(
18 const panzer::IntegrationRule& ir)
19 : _vorticity(
"vorticity", ir.dl_vector)
20 , _enstrophy(
"enstrophy", ir.dl_scalar)
21 , _divergence(
"divergence", ir.dl_scalar)
22 , _mag_divergence(
"divergence_magnitude", ir.dl_scalar)
23 , _nu(
"kinematic_viscosity", ir.dl_scalar)
26 this->addEvaluatedField(_vorticity);
27 this->addEvaluatedField(_enstrophy);
28 this->addEvaluatedField(_divergence);
29 this->addEvaluatedField(_mag_divergence);
32 this->addDependentField(_nu);
33 Utils::addDependentVectorField(
34 *
this, ir.dl_vector, _grad_velocity,
"GRAD_velocity_");
36 this->setName(
"Incompressible Enstrophy " + std::to_string(num_space_dim)
41 template<
class EvalType,
class Traits,
int NumSpaceDim>
42 void IncompressibleEnstrophy<EvalType, Traits, NumSpaceDim>::evaluateFields(
43 typename Traits::EvalData workset)
45 auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
47 Kokkos::parallel_for(this->getName(), policy, *
this);
51 template<
class EvalType,
class Traits,
int NumSpaceDim>
52 KOKKOS_INLINE_FUNCTION
void
53 IncompressibleEnstrophy<EvalType, Traits, NumSpaceDim>::operator()(
54 const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team)
const
56 const int cell = team.league_rank();
57 const int num_point = _enstrophy.extent(1);
61 Kokkos::TeamThreadRange(team, 0, num_point), [&](
const int point) {
63 if (num_space_dim < 3)
65 _vorticity(cell, point, 0)
66 = _grad_velocity[1](cell, point, 0)
67 - _grad_velocity[0](cell, point, 1);
68 _vorticity(cell, point, 1) = 0.0;
72 _vorticity(cell, point, 0)
73 = _grad_velocity[2](cell, point, 1)
74 - _grad_velocity[1](cell, point, 2);
75 _vorticity(cell, point, 1)
76 = _grad_velocity[0](cell, point, 2)
77 - _grad_velocity[2](cell, point, 0);
78 _vorticity(cell, point, 2)
79 = _grad_velocity[1](cell, point, 0)
80 - _grad_velocity[0](cell, point, 1);
84 _enstrophy(cell, point) = 0.0;
85 _divergence(cell, point) = 0.0;
87 for (
int dim = 0; dim < num_space_dim; ++dim)
89 _enstrophy(cell, point)
90 += pow(_vorticity(cell, point, dim), 2.0);
91 _divergence(cell, point)
92 += _grad_velocity[dim](cell, point, dim);
95 _enstrophy(cell, point) *= _nu(cell, point);
96 _mag_divergence(cell, point)
97 = SmoothMath::abs(_divergence(cell, point), 0.0);
106 #endif // end VERTEXCFD_CLOSURE_INCOMPRESSIBLEENSTROPHY_IMPL_HPP