VertexCFD  0.0-dev
VertexCFD_Closure_IncompressibleRotatingAnnulusExact_impl.hpp
1 #ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLEROTATINGANNULUSEXACT_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_INCOMPRESSIBLEROTATINGANNULUSEXACT_IMPL_HPP
3 
4 #include <utils/VertexCFD_Utils_VectorField.hpp>
5 
6 #include "Panzer_GlobalIndexer.hpp"
7 #include "Panzer_PureBasis.hpp"
8 #include "Panzer_Workset_Utilities.hpp"
9 #include <Panzer_HierarchicParallelism.hpp>
10 
11 #include <string>
12 
13 namespace VertexCFD
14 {
15 namespace ClosureModel
16 {
17 //---------------------------------------------------------------------------//
18 template<class EvalType, class Traits, int NumSpaceDim>
19 IncompressibleRotatingAnnulusExact<EvalType, Traits, NumSpaceDim>::
20  IncompressibleRotatingAnnulusExact(
21  const panzer::IntegrationRule& ir,
22  const Teuchos::ParameterList& closure_params)
23  : _temperature("Exact_temperature", ir.dl_scalar)
24  , _lagrange_pressure("Exact_lagrange_pressure", ir.dl_scalar)
25  , _nu(closure_params.get<double>("Kinematic viscosity"))
26  , _rho(closure_params.get<double>("Density"))
27  , _k(closure_params.get<double>("Thermal conductivity"))
28  , _ro(closure_params.get<double>("Outer radius"))
29  , _ri(closure_params.get<double>("Inner radius"))
30  , _kappa(_ri / _ro)
31  , _omega(closure_params.get<double>("Angular velocity"))
32  , _To(closure_params.get<double>("Outer wall temperature"))
33  , _Ti(closure_params.get<double>("Inner wall temperature"))
34  , _ir_degree(ir.cubature_degree)
35 {
36  using std::pow;
37 
38  // Evaluated fields
39  this->addEvaluatedField(_temperature);
40  this->addEvaluatedField(_lagrange_pressure);
41 
42  Utils::addEvaluatedVectorField(
43  *this, ir.dl_scalar, _velocity, "Exact_velocity_");
44 
45  // Brinkman number
46  _N = _nu * _rho * pow(_omega, 2.0) * pow(_ro, 2.0) / _k / (_To - _Ti)
47  * pow(_kappa, 4.0) / pow(1.0 - pow(_kappa, 2.0), 2.0);
48 
49  this->setName("Exact Solution Rotating Annulus");
50 }
51 
52 //---------------------------------------------------------------------------//
53 template<class EvalType, class Traits, int NumSpaceDim>
54 void IncompressibleRotatingAnnulusExact<EvalType, Traits, NumSpaceDim>::
55  postRegistrationSetup(typename Traits::SetupData sd,
56  PHX::FieldManager<Traits>&)
57 {
58  _ir_index = panzer::getIntegrationRuleIndex(_ir_degree, (*sd.worksets_)[0]);
59 }
60 
61 //---------------------------------------------------------------------------//
62 template<class EvalType, class Traits, int NumSpaceDim>
63 void IncompressibleRotatingAnnulusExact<EvalType, Traits, NumSpaceDim>::
64  evaluateFields(typename Traits::EvalData workset)
65 {
66  _ip_coords = workset.int_rules[_ir_index]->ip_coordinates;
67  auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
68  workset.num_cells);
69  Kokkos::parallel_for(this->getName(), policy, *this);
70 }
71 
72 //---------------------------------------------------------------------------//
73 template<class EvalType, class Traits, int NumSpaceDim>
74 KOKKOS_INLINE_FUNCTION void
75 IncompressibleRotatingAnnulusExact<EvalType, Traits, NumSpaceDim>::operator()(
76  const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
77 {
78  const int cell = team.league_rank();
79  const int num_point = _temperature.extent(1);
80 
81  using std::log;
82  using std::sqrt;
83 
84  Kokkos::parallel_for(
85  Kokkos::TeamThreadRange(team, 0, num_point), [&](const int point) {
86  // Note: an analytical solution is only available for the velocity
87  // and temperature fields
88  _lagrange_pressure(cell, point) = 0.0;
89 
90  // Get radius
91  const double x = _ip_coords(cell, point, 0);
92  const double y = _ip_coords(cell, point, 1);
93  const double r = sqrt(x * x + y * y);
94  const double ksi = r / _ro;
95 
96  // Calculate non-dimensional temperature
97  const double theta = (1.0 - log(ksi) / log(_kappa))
98  + _N
99  * ((1 - 1 / (ksi * ksi))
100  - (1 - 1 / (_kappa * _kappa))
101  * log(ksi) / log(_kappa));
102 
103  // Back out exact temperature
104  _temperature(cell, point) = theta * (_To - _Ti) + _Ti;
105 
106  // Tangential velocity
107  const double u_phi = _omega * _ro * _ro / (_ro * _ro - _ri * _ri)
108  * (r - (_ri * _ri / r));
109 
110  // Exact velocity
111  _velocity[0](cell, point) = -u_phi * y / r;
112  _velocity[1](cell, point) = u_phi * x / r;
113 
114  if (num_space_dim == 3)
115  _velocity[2](cell, point) = 0.0;
116  });
117 }
118 
119 //---------------------------------------------------------------------------//
120 
121 } // end namespace ClosureModel
122 } // end namespace VertexCFD
123 
124 #endif // end VERTEXCFD_CLOSURE_INCOMPRESSIBLEROTATINGANNULUSEXACT_IMPL_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23