VertexCFD  0.0-dev
VertexCFD_Closure_GodunovPowellSource_impl.hpp
1 #ifndef VERTEXCFD_CLOSURE_GODUNOVPOWELLSOURCE_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_GODUNOVPOWELLSOURCE_IMPL_HPP
3 
4 #include "utils/VertexCFD_Utils_MagneticLayout.hpp"
5 #include "utils/VertexCFD_Utils_VectorField.hpp"
6 
7 #include <Panzer_HierarchicParallelism.hpp>
8 
9 #include <string>
10 
11 namespace VertexCFD
12 {
13 namespace ClosureModel
14 {
15 //---------------------------------------------------------------------------//
16 template<class EvalType, class Traits, int NumSpaceDim>
17 GodunovPowellSource<EvalType, Traits, NumSpaceDim>::GodunovPowellSource(
18  const panzer::IntegrationRule& ir,
19  const MHDProperties::FullInductionMHDProperties& mhd_props)
20  : _magnetic_permeability(mhd_props.vacuumMagneticPermeability())
21  , _divergence_total_magnetic_field("divergence_total_magnetic_field",
22  ir.dl_scalar)
23  , _total_magnetic_field(
24  "total_magnetic_field",
25  Utils::buildMagneticLayout(ir.dl_scalar, num_magnetic_field_dim))
26 {
27  // Evaluated fields
28  Utils::addEvaluatedVectorField(*this,
29  ir.dl_scalar,
30  _godunov_powell_momentum_source,
31  "GODUNOV_POWELL_SOURCE_momentum_");
32  Utils::addEvaluatedVectorField(*this,
33  ir.dl_scalar,
34  _godunov_powell_induction_source,
35  "GODUNOV_POWELL_SOURCE_induction_");
36 
37  // Dependent fields
38  this->addDependentField(_divergence_total_magnetic_field);
39  Utils::addDependentVectorField(*this, ir.dl_scalar, _velocity, "velocity_");
40  this->addDependentField(_total_magnetic_field);
41 
42  this->setName("Godunov-Powell Source " + std::to_string(num_space_dim)
43  + "D");
44 }
45 
46 //---------------------------------------------------------------------------//
47 template<class EvalType, class Traits, int NumSpaceDim>
48 void GodunovPowellSource<EvalType, Traits, NumSpaceDim>::evaluateFields(
49  typename Traits::EvalData workset)
50 {
51  auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
52  workset.num_cells);
53  Kokkos::parallel_for(this->getName(), policy, *this);
54 }
55 
56 //---------------------------------------------------------------------------//
57 template<class EvalType, class Traits, int NumSpaceDim>
58 KOKKOS_INLINE_FUNCTION void
59 GodunovPowellSource<EvalType, Traits, NumSpaceDim>::operator()(
60  const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
61 {
62  const int cell = team.league_rank();
63  const int num_point = _divergence_total_magnetic_field.extent(1);
64 
65  Kokkos::parallel_for(
66  Kokkos::TeamThreadRange(team, 0, num_point), [&](const int point) {
67  for (int dim = 0; dim < num_space_dim; ++dim)
68  {
69  _godunov_powell_momentum_source[dim](cell, point)
70  = -_divergence_total_magnetic_field(cell, point)
71  * _total_magnetic_field(cell, point, dim)
72  / _magnetic_permeability;
73  _godunov_powell_induction_source[dim](cell, point)
74  = -_divergence_total_magnetic_field(cell, point)
75  * _velocity[dim](cell, point);
76  }
77  });
78 }
79 
80 //---------------------------------------------------------------------------//
81 
82 } // end namespace ClosureModel
83 } // end namespace VertexCFD
84 
85 #endif // end VERTEXCFD_CLOSURE_GODUNOVPOWELLSOURCE_IMPL_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23