VertexCFD  0.0-dev
VertexCFD_Closure_IncompressibleSUPGExactSolution_impl.hpp
1 #ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLESUPGEXACTSOLUTION_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_INCOMPRESSIBLESUPGEXACTSOLUTION_IMPL_HPP
3 
4 #include "utils/VertexCFD_Utils_VectorField.hpp"
5 
6 #include <Panzer_GlobalIndexer.hpp>
7 #include <Panzer_HierarchicParallelism.hpp>
8 #include <Panzer_PureBasis.hpp>
9 #include <Panzer_Workset_Utilities.hpp>
10 
11 #include <Teuchos_Array.hpp>
12 
13 #include <cmath>
14 #include <string>
15 
16 namespace VertexCFD
17 {
18 namespace ClosureModel
19 {
20 //---------------------------------------------------------------------------//
21 template<class EvalType, class Traits, int NumSpaceDim>
22 IncompressibleSUPGExactSolution<EvalType, Traits, NumSpaceDim>::
23  IncompressibleSUPGExactSolution(const panzer::IntegrationRule& ir,
24  const Teuchos::ParameterList& closure_params)
25  : _lagrange_pressure("Exact_lagrange_pressure", ir.dl_scalar)
26  , _temperature("Exact_temperature", ir.dl_scalar)
27  , _ir_degree(ir.cubature_degree)
28  , _D(closure_params.get<double>("Thermal diffusivity"))
29  , _u(closure_params.get<double>("Uniform advection velocity"))
30 {
31  this->addEvaluatedField(_lagrange_pressure);
32  this->addEvaluatedField(_temperature);
33  Utils::addEvaluatedVectorField(
34  *this, ir.dl_scalar, _velocity, "Exact_velocity_");
35 
36  this->setName("Incompressible SUPG Exact Solution");
37 }
38 
39 //---------------------------------------------------------------------------//
40 template<class EvalType, class Traits, int NumSpaceDim>
41 void IncompressibleSUPGExactSolution<EvalType, Traits, NumSpaceDim>::
42  postRegistrationSetup(typename Traits::SetupData sd,
43  PHX::FieldManager<Traits>&)
44 {
45  _ir_index = panzer::getIntegrationRuleIndex(_ir_degree, (*sd.worksets_)[0]);
46 }
47 
48 //---------------------------------------------------------------------------//
49 template<class EvalType, class Traits, int NumSpaceDim>
50 void IncompressibleSUPGExactSolution<EvalType, Traits, NumSpaceDim>::evaluateFields(
51  typename Traits::EvalData workset)
52 {
53  auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
54  workset.num_cells);
55 
56  _ip_coords = workset.int_rules[_ir_index]->ip_coordinates;
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 IncompressibleSUPGExactSolution<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 = _lagrange_pressure.extent(1);
68 
69  using Kokkos::exp;
70 
71  Kokkos::parallel_for(
72  Kokkos::TeamThreadRange(team, 0, num_point), [&](const int point) {
73  const double x = _ip_coords(cell, point, 0);
74 
75  // Pressure and velocity are set to zero because assumed uniform
76  _lagrange_pressure(cell, point) = 0.0;
77  _velocity[0](cell, point) = 0.0;
78  _velocity[1](cell, point) = 0.0;
79  _temperature(cell, point)
80  = (x - (1.0 - exp(_u * x / _D)) / (1.0 - exp(_u / _D))) / _u;
81  });
82 }
83 
84 //---------------------------------------------------------------------------//
85 
86 } // end namespace ClosureModel
87 } // end namespace VertexCFD
88 
89 #endif // VERTEXCFD_CLOSURE_INCOMPRESSIBLESUPGEXACTSOLUTION_IMPL_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23