VertexCFD  0.0-dev
VertexCFD_Closure_ConductionFlux_impl.hpp
1 #ifndef VERTEXCFD_CLOSURE_CONDUCTIONFLUX_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_CONDUCTIONFLUX_IMPL_HPP
3 
4 #include <Panzer_HierarchicParallelism.hpp>
5 
6 namespace VertexCFD
7 {
8 namespace ClosureModel
9 {
10 //---------------------------------------------------------------------------//
11 template<class EvalType, class Traits>
13  const panzer::IntegrationRule& ir,
14  const std::string& flux_prefix,
15  const std::string& gradient_prefix)
16  : _conduction_flux(flux_prefix + "CONDUCTION_FLUX_energy", ir.dl_vector)
17  , _grad_temperature(gradient_prefix + "GRAD_temperature", ir.dl_vector)
18  , _thermal_conductivity("thermal_conductivity", ir.dl_scalar)
19  , _num_space_dim(ir.spatial_dimension)
20 {
21  // Evaluated fields
22  this->addEvaluatedField(_conduction_flux);
23 
24  // Dependent fields
25  this->addDependentField(_grad_temperature);
26  this->addDependentField(_thermal_conductivity);
27 
28  this->setName("Conduction Flux " + std::to_string(_num_space_dim) + "D");
29 }
30 
31 //---------------------------------------------------------------------------//
32 template<class EvalType, class Traits>
34  typename Traits::EvalData workset)
35 {
36  auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
37  workset.num_cells);
38  Kokkos::parallel_for(this->getName(), policy, *this);
39 }
40 
41 //---------------------------------------------------------------------------//
42 template<class EvalType, class Traits>
44  const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
45 {
46  const int cell = team.league_rank();
47  const int num_point = _conduction_flux.extent(1);
48 
49  Kokkos::parallel_for(Kokkos::TeamThreadRange(team, 0, num_point),
50  [&](const int point) {
51  for (int dim = 0; dim < _num_space_dim; ++dim)
52  {
53  _conduction_flux(cell, point, dim)
54  = _thermal_conductivity(cell, point)
55  * _grad_temperature(cell, point, dim);
56  }
57  });
58 }
59 
60 //---------------------------------------------------------------------------//
61 
62 } // end namespace ClosureModel
63 } // end namespace VertexCFD
64 
65 #endif // end VERTEXCFD_CLOSURE_CONDUCTIONFLUX_IMPL_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23
VertexCFD::ClosureModel::ConductionFlux::_conduction_flux
PHX::MDField< scalar_type, panzer::Cell, panzer::Point, panzer::Dim > _conduction_flux
Field that stores the computed conductive flux.
Definition: VertexCFD_Closure_ConductionFlux.hpp:84
VertexCFD::ClosureModel::ConductionFlux::evaluateFields
void evaluateFields(typename Traits::EvalData workset) override
Evaluate the conductive flux for each cell/point.
Definition: VertexCFD_Closure_ConductionFlux_impl.hpp:33
VertexCFD::ClosureModel::ConductionFlux::ConductionFlux
ConductionFlux(const panzer::IntegrationRule &ir, const std::string &flux_prefix="", const std::string &gradient_prefix="")
Constructor.
Definition: VertexCFD_Closure_ConductionFlux_impl.hpp:12
VertexCFD::ClosureModel::ConductionFlux::operator()
KOKKOS_INLINE_FUNCTION void operator()(const Kokkos::TeamPolicy< PHX::exec_space >::member_type &team) const
Kokkos functor invoked for a team of threads.
Definition: VertexCFD_Closure_ConductionFlux_impl.hpp:43