VertexCFD  0.0-dev
VertexCFD_Closure_ConstantScalarField_impl.hpp
1 #ifndef VERTEXCFD_CLOSURE_CONSTANTSCALARFIELD_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_CONSTANTSCALARFIELD_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 ConstantScalarField<EvalType, Traits>::ConstantScalarField(
15  const panzer::IntegrationRule& ir,
16  const std::string& field_name,
17  const double field_value)
18  : _scalar_field(field_name, ir.dl_scalar)
19  , _field_value(field_value)
20 {
21  this->addEvaluatedField(_scalar_field);
22 
23  this->setName("Constant Scalar Field \"" + field_name + "\"");
24 }
25 
26 //---------------------------------------------------------------------------//
27 template<class EvalType, class Traits>
28 void ConstantScalarField<EvalType, Traits>::evaluateFields(
29  typename Traits::EvalData workset)
30 {
31  auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
32  workset.num_cells);
33  Kokkos::parallel_for(this->getName(), policy, *this);
34 }
35 
36 //---------------------------------------------------------------------------//
37 template<class EvalType, class Traits>
38 KOKKOS_INLINE_FUNCTION void ConstantScalarField<EvalType, Traits>::operator()(
39  const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
40 {
41  const int cell = team.league_rank();
42  const int num_point = _scalar_field.extent(1);
43 
44  Kokkos::parallel_for(
45  Kokkos::TeamThreadRange(team, 0, num_point),
46  [&](const int point) { _scalar_field(cell, point) = _field_value; });
47 }
48 
49 //---------------------------------------------------------------------------//
50 
51 } // end namespace ClosureModel
52 } // end namespace VertexCFD
53 
54 #endif // end VERTEXCFD_CLOSURE_CONSTANTSCALARFIELD_IMPL_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23