VertexCFD  0.0-dev
VertexCFD_Closure_IncompressibleLSVOFBubbleExact_impl.hpp
1 #ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLELSVOFBUBBLEEXACT_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_INCOMPRESSIBLELSVOFBUBBLEEXACT_IMPL_HPP
3 
4 #include <Panzer_GlobalIndexer.hpp>
5 #include <Panzer_HierarchicParallelism.hpp>
6 #include <Panzer_PureBasis.hpp>
7 #include <Panzer_Workset_Utilities.hpp>
8 
9 #include <string>
10 
11 namespace VertexCFD
12 {
13 namespace ClosureModel
14 {
15 //---------------------------------------------------------------------------//
16 template<class EvalType, class Traits, int NumSpaceDim>
17 IncompressibleLSVOFBubbleExact<EvalType, Traits, NumSpaceDim>::
18  IncompressibleLSVOFBubbleExact(const panzer::IntegrationRule& ir,
19  const Teuchos::ParameterList& closure_params)
20  : _dof_name(closure_params.get<std::string>("DOF Name"))
21  , _radius(closure_params.get<double>("Bubble Radius"))
22  , _ir_degree(ir.cubature_degree)
23  , _exact_dof("Exact_" + _dof_name, ir.dl_scalar)
24 {
25  // Get location from closure params
26  const auto location
27  = closure_params.get<Teuchos::Array<double>>("Bubble Location");
28 
29  for (int d = 0; d < num_space_dim; ++d)
30  {
31  _location[d] = location[d];
32  }
33 
34  // Evaluated fields
35  this->addEvaluatedField(_exact_dof);
36 
37  this->setName("Exact Solution LSVOF " + _dof_name + " Bubble");
38 }
39 
40 //---------------------------------------------------------------------------//
41 template<class EvalType, class Traits, int NumSpaceDim>
42 void IncompressibleLSVOFBubbleExact<EvalType, Traits, NumSpaceDim>::
43  postRegistrationSetup(typename Traits::SetupData sd,
44  PHX::FieldManager<Traits>&)
45 {
46  _ir_index = panzer::getIntegrationRuleIndex(_ir_degree, (*sd.worksets_)[0]);
47 }
48 
49 //---------------------------------------------------------------------------//
50 template<class EvalType, class Traits, int NumSpaceDim>
51 void IncompressibleLSVOFBubbleExact<EvalType, Traits, NumSpaceDim>::evaluateFields(
52  typename Traits::EvalData workset)
53 {
54  _ip_coords = workset.int_rules[_ir_index]->ip_coordinates;
55  auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
56  workset.num_cells);
57  Kokkos::parallel_for(this->getName(), policy, *this);
58 }
59 
60 //---------------------------------------------------------------------------//
61 template<class EvalType, class Traits, int NumSpaceDim>
62 KOKKOS_INLINE_FUNCTION void
63 IncompressibleLSVOFBubbleExact<EvalType, Traits, NumSpaceDim>::operator()(
64  const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
65 {
66  const int cell = team.league_rank();
67  const int num_point = _exact_dof.extent(1);
68 
69  using Kokkos::pow;
70 
71  Kokkos::parallel_for(
72  Kokkos::TeamThreadRange(team, 0, num_point), [&](const int point) {
73  double r = 0.0;
74 
75  for (int d = 0; d < num_space_dim; ++d)
76  {
77  r += pow(_location[d] - _ip_coords(cell, point, d), 2.0);
78  }
79 
80  r = pow(r, 0.5);
81 
82  if (r <= _radius)
83  {
84  _exact_dof(cell, point) = 1.0;
85  }
86  else
87  {
88  _exact_dof(cell, point) = 0.0;
89  }
90  });
91 }
92 
93 //---------------------------------------------------------------------------//
94 
95 } // end namespace ClosureModel
96 } // end namespace VertexCFD
97 
98 #endif // end VERTEXCFD_CLOSURE_INCOMPRESSIBLELSVOFBUBBLEEXACT_IMPL_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23