VertexCFD  0.0-dev
VertexCFD_Closure_ElectricPotentialDiffusionFlux_impl.hpp
1 #ifndef VERTEXCFD_CLOSURE_ELECTRICPOTENTIALDIFFUSIONFLUX_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_ELECTRICPOTENTIALDIFFUSIONFLUX_IMPL_HPP
3 
4 #include <Panzer_HierarchicParallelism.hpp>
5 
6 #include <string>
7 
8 namespace VertexCFD
9 {
10 namespace ClosureModel
11 {
12 //---------------------------------------------------------------------------//
13 template<class EvalType, class Traits>
14 ElectricPotentialDiffusionFlux<EvalType, Traits>::ElectricPotentialDiffusionFlux(
15  const panzer::IntegrationRule& ir,
16  const std::string& flux_prefix,
17  const std::string& gradient_prefix)
18  : _electric_potential_flux(
19  flux_prefix + "ELECTRIC_POTENTIAL_FLUX_electric_potential_equation",
20  ir.dl_vector)
21  , _sigma("electrical_conductivity", ir.dl_scalar)
22  , _grad_electric_potential(gradient_prefix + "GRAD_electric_potential",
23  ir.dl_vector)
24  , _num_grad_dim(ir.spatial_dimension)
25 {
26  // Evaluated fields
27  this->addEvaluatedField(_electric_potential_flux);
28 
29  // Dependent fields
30  this->addDependentField(_sigma);
31  this->addDependentField(_grad_electric_potential);
32 
33  this->setName("Electric Potential Diffusion Flux "
34  + std::to_string(_num_grad_dim) + "D");
35 }
36 
37 //---------------------------------------------------------------------------//
38 template<class EvalType, class Traits>
39 void ElectricPotentialDiffusionFlux<EvalType, Traits>::evaluateFields(
40  typename Traits::EvalData workset)
41 {
42  auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
43  workset.num_cells);
44  Kokkos::parallel_for(this->getName(), policy, *this);
45 }
46 
47 //---------------------------------------------------------------------------//
48 template<class EvalType, class Traits>
49 KOKKOS_INLINE_FUNCTION void
50 ElectricPotentialDiffusionFlux<EvalType, Traits>::operator()(
51  const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
52 {
53  const int cell = team.league_rank();
54  const int num_point = _electric_potential_flux.extent(1);
55 
56  Kokkos::parallel_for(
57  Kokkos::TeamThreadRange(team, 0, num_point), [&](const int point) {
58  for (int dim = 0; dim < _num_grad_dim; ++dim)
59  {
60  _electric_potential_flux(cell, point, dim)
61  = -_sigma(cell, point)
62  * _grad_electric_potential(cell, point, dim);
63  }
64  });
65 }
66 
67 //---------------------------------------------------------------------------//
68 
69 } // end namespace ClosureModel
70 } // end namespace VertexCFD
71 
72 #endif // end VERTEXCFD_CLOSURE_ELECTRICPOTENTIALDIFFUSIONFLUX_IMPL_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23