VertexCFD  0.0-dev
VertexCFD_Closure_SolidElectricConductivity_impl.hpp
1 #ifndef VERTEXCFD_CLOSURE_SOLIDELECTRICCONDUCTIVITY_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_SOLIDELECTRICCONDUCTIVITY_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>
14 SolidElectricConductivity<EvalType, Traits>::SolidElectricConductivity(
15  const panzer::IntegrationRule& ir,
16  const Teuchos::ParameterList& closure_params)
17  : _sigma("solid_electric_conductivity", ir.dl_scalar)
18  , _electric_potential("electric_potential", ir.dl_scalar)
19  , _sigma0(std::numeric_limits<double>::quiet_NaN())
20  , _elec_cond_type(ElecCondType::constant)
21 {
22  // Evaluated field
23  this->addEvaluatedField(_sigma);
24 
25  // Get electric conductivity type
26  if (closure_params.isType<std::string>("Electric Conductivity Type"))
27  {
28  const auto type_validator = Teuchos::rcp(
29  new Teuchos::StringToIntegralParameterEntryValidator<ElecCondType>(
30  Teuchos::tuple<std::string>("constant", "inverse_proportional"),
31  "constant"));
32  _elec_cond_type = type_validator->getIntegralValue(
33  closure_params.get<std::string>("Electric Conductivity Type"));
34  }
35 
36  // Get values based on the electric conductivity type
37  if (_elec_cond_type == ElecCondType::constant)
38  {
39  _sigma0 = closure_params.get<double>("Electric Conductivity Value");
40  }
41  else if (_elec_cond_type == ElecCondType::inverse_proportional)
42  {
43  _sigma0
44  = closure_params.get<double>("Electric Conductivity Coefficient");
45  // Dependent field
46  this->addDependentField(_electric_potential);
47  }
48 
49  this->setName("Solid Electric Conductivity");
50 }
51 
52 //---------------------------------------------------------------------------//
53 template<class EvalType, class Traits>
54 void SolidElectricConductivity<EvalType, Traits>::evaluateFields(
55  typename Traits::EvalData workset)
56 {
57  if (_elec_cond_type == ElecCondType::constant)
58  _sigma.deep_copy(_sigma0);
59  else if (_elec_cond_type == ElecCondType::inverse_proportional)
60  {
61  auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
62  workset.num_cells);
63  Kokkos::parallel_for(this->getName(), policy, *this);
64  }
65 }
66 
67 //---------------------------------------------------------------------------//
68 template<class EvalType, class Traits>
69 KOKKOS_INLINE_FUNCTION void
70 SolidElectricConductivity<EvalType, Traits>::operator()(
71  const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
72 {
73  const int cell = team.league_rank();
74  const int num_point = _sigma.extent(1);
75 
76  Kokkos::parallel_for(
77  Kokkos::TeamThreadRange(team, 0, num_point), [&](const int point) {
78  _sigma(cell, point) = _sigma0 / _electric_potential(cell, point);
79  });
80 }
81 
82 //---------------------------------------------------------------------------//
83 
84 } // end namespace ClosureModel
85 } // end namespace VertexCFD
86 
87 #endif // end VERTEXCFD_CLOSURE_SOLIDELECTRICCONDUCTIVITY_IMPL_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23