VertexCFD  0.0-dev
VertexCFD_Closure_ElectricPotentialCrossProductFlux_impl.hpp
1 #ifndef VERTEXCFD_CLOSURE_ELECTRICPOTENTIALCROSSPRODUCTFLUX_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_ELECTRICPOTENTIALCROSSPRODUCTFLUX_IMPL_HPP
3 
4 #include <utils/VertexCFD_Utils_VectorField.hpp>
5 
6 #include <Panzer_HierarchicParallelism.hpp>
7 
8 #include <string>
9 
10 namespace VertexCFD
11 {
12 namespace ClosureModel
13 {
14 //---------------------------------------------------------------------------//
15 template<class EvalType, class Traits, int NumSpaceDim>
16 ElectricPotentialCrossProductFlux<EvalType, Traits, NumSpaceDim>::
17  ElectricPotentialCrossProductFlux(const panzer::IntegrationRule& ir,
18  const std::string& flux_prefix,
19  const std::string& field_prefix)
20  : _electric_potential_flux(
21  flux_prefix + "ELECTRIC_POTENTIAL_FLUX_electric_potential_equation",
22  ir.dl_vector)
23  , _sigma("electrical_conductivity", ir.dl_scalar)
24 {
25  // Evaluated fields
26  this->addContributedField(_electric_potential_flux);
27 
28  // Dependent fields
29  this->addDependentField(_sigma);
30  Utils::addDependentVectorField(
31  *this, ir.dl_scalar, _velocity, field_prefix + "velocity_");
32  Utils::addDependentVectorField(
33  *this, ir.dl_scalar, _ext_magn_field, "external_magnetic_field_");
34 
35  this->setName("Electric Potential Cross Product Flux "
36  + std::to_string(num_space_dim) + "D");
37 }
38 
39 //---------------------------------------------------------------------------//
40 template<class EvalType, class Traits, int NumSpaceDim>
41 void ElectricPotentialCrossProductFlux<EvalType, Traits, NumSpaceDim>::evaluateFields(
42  typename Traits::EvalData workset)
43 {
44  auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
45  workset.num_cells);
46  Kokkos::parallel_for(this->getName(), policy, *this);
47 }
48 
49 //---------------------------------------------------------------------------//
50 template<class EvalType, class Traits, int NumSpaceDim>
51 KOKKOS_INLINE_FUNCTION void
52 ElectricPotentialCrossProductFlux<EvalType, Traits, NumSpaceDim>::operator()(
53  const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
54 {
55  const int cell = team.league_rank();
56  const int num_point = _electric_potential_flux.extent(1);
57 
58  Kokkos::parallel_for(
59  Kokkos::TeamThreadRange(team, 0, num_point), [&](const int point) {
60  // 2-D case (x- and y-components only)
61  _electric_potential_flux(cell, point, 0)
62  += _sigma(cell, point) * _velocity[1](cell, point)
63  * _ext_magn_field[2](cell, point);
64  _electric_potential_flux(cell, point, 1)
65  -= _sigma(cell, point) * _velocity[0](cell, point)
66  * _ext_magn_field[2](cell, point);
67 
68  // 3-D case
69  if (num_space_dim == 3)
70  {
71  // x-component
72  _electric_potential_flux(cell, point, 0)
73  -= _sigma(cell, point) * _velocity[2](cell, point)
74  * _ext_magn_field[1](cell, point);
75  // y-component
76  _electric_potential_flux(cell, point, 1)
77  += _sigma(cell, point) * _velocity[2](cell, point)
78  * _ext_magn_field[0](cell, point);
79  // z-component
80  _electric_potential_flux(cell, point, 2)
81  += _sigma(cell, point)
82  * (_velocity[0](cell, point)
83  * _ext_magn_field[1](cell, point)
84  - _velocity[1](cell, point)
85  * _ext_magn_field[0](cell, point));
86  }
87  });
88 }
89 
90 //---------------------------------------------------------------------------//
91 
92 } // end namespace ClosureModel
93 } // end namespace VertexCFD
94 
95 #endif // end VERTEXCFD_CLOSURE_ELECTRICPOTENTIALCROSSPRODUCTFLUX_IMPL_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23