VertexCFD  0.0-dev
VertexCFD_Closure_ConductionThermalConductivity_impl.hpp
1 #ifndef VERTEXCFD_CLOSURE_CONDUCTIONTHERMALCONDUCTIVITY_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_CONDUCTIONTHERMALCONDUCTIVITY_IMPL_HPP
3 
4 #include <Panzer_HierarchicParallelism.hpp>
5 
6 #include <Teuchos_StandardParameterEntryValidators.hpp>
7 
8 namespace VertexCFD
9 {
10 namespace ClosureModel
11 {
12 //---------------------------------------------------------------------------//
13 template<class EvalType, class Traits>
15  const panzer::IntegrationRule& ir,
16  const Teuchos::ParameterList& closure_params)
17  : _thermal_conductivity("thermal_conductivity", ir.dl_scalar)
18  , _temperature("temperature", ir.dl_scalar)
19  , _num_space_dim(ir.spatial_dimension)
20  , _k0(std::numeric_limits<double>::quiet_NaN())
21  , _therm_cond_type(ThermCondType::constant)
22 {
23  // Evaluated fields
24  this->addEvaluatedField(_thermal_conductivity);
25 
26  // Get thermal conductivity type
27  if (closure_params.isType<std::string>("Thermal Conductivity Type"))
28  {
29  const auto type_validator = Teuchos::rcp(
30  new Teuchos::StringToIntegralParameterEntryValidator<ThermCondType>(
31  Teuchos::tuple<std::string>("constant", "inverse_proportional"),
32  "constant"));
33  _therm_cond_type = type_validator->getIntegralValue(
34  closure_params.get<std::string>("Thermal Conductivity Type"));
35  }
36 
37  // Get values based on the thermal conductivity type
38  if (_therm_cond_type == ThermCondType::constant)
39  {
40  _k0 = closure_params.get<double>("Thermal Conductivity Value");
41  }
42  else
43  {
44  _k0 = closure_params.get<double>("Thermal Conductivity Coefficient");
45  }
46 
47  // Dependent fields
48  this->addDependentField(_temperature);
49 
50  this->setName("Conduction Thermal Conductivity "
51  + std::to_string(_num_space_dim) + "D");
52 }
53 
54 //---------------------------------------------------------------------------//
55 template<class EvalType, class Traits>
57  typename Traits::EvalData workset)
58 {
59  auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
60  workset.num_cells);
61  Kokkos::parallel_for(this->getName(), policy, *this);
62 }
63 
64 //---------------------------------------------------------------------------//
65 template<class EvalType, class Traits>
66 KOKKOS_INLINE_FUNCTION void
68  const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
69 {
70  const int cell = team.league_rank();
71  const int num_point = _thermal_conductivity.extent(1);
72 
73  Kokkos::parallel_for(Kokkos::TeamThreadRange(team, 0, num_point),
74  [&](const int point) {
75  if (_therm_cond_type == ThermCondType::constant)
76  {
77  _thermal_conductivity(cell, point) = _k0;
78  }
79  else
80  {
81  _thermal_conductivity(cell, point)
82  = _k0 / _temperature(cell, point);
83  }
84  });
85 }
86 
87 //---------------------------------------------------------------------------//
88 
89 } // end namespace ClosureModel
90 } // end namespace VertexCFD
91 
92 #endif // end VERTEXCFD_CLOSURE_CONDUCTIONTHERMALCONDUCTIVITY_IMPL_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23
VertexCFD::ClosureModel::ConductionThermalConductivity::_thermal_conductivity
PHX::MDField< scalar_type, panzer::Cell, panzer::Point > _thermal_conductivity
Evaluated field containing the computed thermal conductivity.
Definition: VertexCFD_Closure_ConductionThermalConductivity.hpp:79
VertexCFD::ClosureModel::ConductionThermalConductivity::operator()
KOKKOS_INLINE_FUNCTION void operator()(const Kokkos::TeamPolicy< PHX::exec_space >::member_type &team) const
Kokkos functor for parallel evaluation over a team policy.
Definition: VertexCFD_Closure_ConductionThermalConductivity_impl.hpp:67
VertexCFD::ClosureModel::ConductionThermalConductivity::evaluateFields
void evaluateFields(typename Traits::EvalData workset) override
Compute the thermal conductivity field for the current workset.
Definition: VertexCFD_Closure_ConductionThermalConductivity_impl.hpp:56
VertexCFD::ClosureModel::ConductionThermalConductivity::scalar_type
typename EvalType::ScalarT scalar_type
Scalar type used by the evaluator (extracted from EvalType).
Definition: VertexCFD_Closure_ConductionThermalConductivity.hpp:41
VertexCFD::ClosureModel::ConductionThermalConductivity::ConductionThermalConductivity
ConductionThermalConductivity(const panzer::IntegrationRule &ir, const Teuchos::ParameterList &closure_params)
Constructor.
Definition: VertexCFD_Closure_ConductionThermalConductivity_impl.hpp:14