VertexCFD  0.0-dev
VertexCFD_Closure_DivergenceCleaningSource_impl.hpp
1 #ifndef VERTEXCFD_CLOSURE_DIVERGENCECLEANINGSOURCE_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_DIVERGENCECLEANINGSOURCE_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 DivergenceCleaningSource<EvalType, Traits, NumSpaceDim>::DivergenceCleaningSource(
17  const panzer::IntegrationRule& ir)
18  : _div_cleaning_potential_source(
19  "DIV_CLEANING_SOURCE_magnetic_correction_potential", ir.dl_scalar)
20  , _grad_scalar_magnetic_potential("GRAD_scalar_magnetic_potential",
21  ir.dl_vector)
22 {
23  // Evaluated fields
24  this->addEvaluatedField(_div_cleaning_potential_source);
25 
26  // Dependent fields
27  this->addDependentField(_grad_scalar_magnetic_potential);
28  Utils::addDependentVectorField(*this, ir.dl_scalar, _velocity, "velocity_");
29 
30  this->setName("Divergence Cleaning Source " + std::to_string(num_space_dim)
31  + "D");
32 }
33 
34 //---------------------------------------------------------------------------//
35 template<class EvalType, class Traits, int NumSpaceDim>
36 void DivergenceCleaningSource<EvalType, Traits, NumSpaceDim>::evaluateFields(
37  typename Traits::EvalData workset)
38 {
39  auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
40  workset.num_cells);
41  Kokkos::parallel_for(this->getName(), policy, *this);
42 }
43 
44 //---------------------------------------------------------------------------//
45 template<class EvalType, class Traits, int NumSpaceDim>
46 KOKKOS_INLINE_FUNCTION void
47 DivergenceCleaningSource<EvalType, Traits, NumSpaceDim>::operator()(
48  const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
49 {
50  const int cell = team.league_rank();
51  const int num_point = _grad_scalar_magnetic_potential.extent(1);
52  const int num_grad_dim = _grad_scalar_magnetic_potential.extent(2);
53 
54  Kokkos::parallel_for(
55  Kokkos::TeamThreadRange(team, 0, num_point), [&](const int point) {
56  _div_cleaning_potential_source(cell, point) = 0.0;
57 
58  for (int dim = 0; dim < num_grad_dim; ++dim)
59  {
60  _div_cleaning_potential_source(cell, point)
61  -= _velocity[dim](cell, point)
62  * _grad_scalar_magnetic_potential(cell, point, dim);
63  }
64  });
65 }
66 
67 //---------------------------------------------------------------------------//
68 
69 } // end namespace ClosureModel
70 } // end namespace VertexCFD
71 
72 #endif // end VERTEXCFD_CLOSURE_DIVERGENCECLEANINGSOURCE_IMPL_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23