1 #ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLELSVOFVORTEXVELOCITY_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_INCOMPRESSIBLELSVOFVORTEXVELOCITY_IMPL_HPP
4 #include "utils/VertexCFD_Utils_Constants.hpp"
6 #include <Panzer_HierarchicParallelism.hpp>
7 #include <Panzer_Workset_Utilities.hpp>
9 #include <Teuchos_StandardParameterEntryValidators.hpp>
15 namespace ClosureModel
18 template<
class EvalType,
class Traits,
int NumSpaceDim>
19 IncompressibleLSVOFVortexVelocity<EvalType, Traits, NumSpaceDim>::
20 IncompressibleLSVOFVortexVelocity(
21 const panzer::IntegrationRule& ir,
22 const Teuchos::ParameterList& closure_params)
23 : _vel_0(
"velocity_0", ir.dl_scalar)
24 , _vel_1(
"velocity_1", ir.dl_scalar)
26 , _ir_degree(ir.cubature_degree)
29 if (num_space_dim != 2)
32 =
"ERROR: Incompressible LSVOF Vortex Velocity must be used for "
35 throw std::runtime_error(msg);
39 if (closure_params.isType<std::string>(
"Direction"))
41 const auto type_validator = Teuchos::rcp(
42 new Teuchos::StringToIntegralParameterEntryValidator<Direction>(
43 Teuchos::tuple<std::string>(
"Forward",
"Reverse"),
"Forward"));
45 const Direction direction = type_validator->getIntegralValue(
46 closure_params.get<std::string>(
"Direction"));
48 if (direction == Direction::Reverse)
55 this->addEvaluatedField(_vel_0);
56 this->addEvaluatedField(_vel_1);
58 this->setName(
"Incompressible LSVOF Vortex Velocity "
59 + std::to_string(num_space_dim) +
"D");
63 template<
class EvalType,
class Traits,
int NumSpaceDim>
64 void IncompressibleLSVOFVortexVelocity<EvalType, Traits, NumSpaceDim>::
65 postRegistrationSetup(
typename Traits::SetupData sd,
66 PHX::FieldManager<Traits>&)
68 _ir_index = panzer::getIntegrationRuleIndex(_ir_degree, (*sd.worksets_)[0]);
72 template<
class EvalType,
class Traits,
int NumSpaceDim>
73 void IncompressibleLSVOFVortexVelocity<EvalType, Traits, NumSpaceDim>::evaluateFields(
74 typename Traits::EvalData workset)
76 _ip_coords = workset.int_rules[_ir_index]->ip_coordinates;
78 auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
80 Kokkos::parallel_for(this->getName(), policy, *
this);
84 template<
class EvalType,
class Traits,
int NumSpaceDim>
85 KOKKOS_INLINE_FUNCTION
void
86 IncompressibleLSVOFVortexVelocity<EvalType, Traits, NumSpaceDim>::operator()(
87 const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team)
const
89 const int cell = team.league_rank();
90 const int num_point = _vel_0.extent(1);
95 using VertexCFD::Constants::pi;
98 Kokkos::TeamThreadRange(team, 0, num_point), [&](
const int point) {
99 const double x = _ip_coords(cell, point, 0);
100 const double y = _ip_coords(cell, point, 1);
102 _vel_0(cell, point) = _direction * sin(2.0 * pi * y)
103 * pow(sin(pi * x), 2.0);
104 _vel_1(cell, point) = -_direction * sin(2.0 * pi * x)
105 * pow(sin(pi * y), 2.0);