VertexCFD  0.0-dev
VertexCFD_Closure_IncompressibleLSVOFScalarConvectiveFlux_impl.hpp
1 #ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLELSVOFSCALARCONVECTIVEFLUX_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_INCOMPRESSIBLELSVOFSCALARCONVECTIVEFLUX_IMPL_HPP
3 
4 #include "utils/VertexCFD_Utils_PhaseLayout.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 IncompressibleLSVOFScalarConvectiveFlux<EvalType, Traits, NumSpaceDim>::
18  IncompressibleLSVOFScalarConvectiveFlux(const panzer::IntegrationRule& ir,
19  const int& phase_index,
20  const int& num_lsvof_dofs,
21  const std::string& equation_name,
22  const std::string& flux_prefix,
23  const std::string& field_prefix)
24  : _scalar_flux(flux_prefix + "CONVECTIVE_FLUX_" + equation_name,
25  ir.dl_vector)
26  , _phase_index(phase_index)
27  , _phase_layout(Utils::buildPhaseLayout(ir.dl_scalar, num_lsvof_dofs))
28  , _volume_fractions(field_prefix + "volume_fractions", _phase_layout)
29 {
30  // Evaluated fields
31  this->addEvaluatedField(_scalar_flux);
32 
33  // Dependent fields
34  this->addDependentField(_volume_fractions);
35  Utils::addDependentVectorField(
36  *this, ir.dl_scalar, _velocity, field_prefix + "velocity_");
37 
38  this->setName(equation_name + " Incompressible Convective Flux "
39  + std::to_string(num_space_dim) + "D");
40 }
41 
42 //---------------------------------------------------------------------------//
43 template<class EvalType, class Traits, int NumSpaceDim>
44 void IncompressibleLSVOFScalarConvectiveFlux<EvalType, Traits, NumSpaceDim>::
45  evaluateFields(typename Traits::EvalData workset)
46 {
47  auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
48  workset.num_cells);
49  Kokkos::parallel_for(this->getName(), policy, *this);
50 }
51 
52 //---------------------------------------------------------------------------//
53 template<class EvalType, class Traits, int NumSpaceDim>
54 KOKKOS_INLINE_FUNCTION void
55 IncompressibleLSVOFScalarConvectiveFlux<EvalType, Traits, NumSpaceDim>::operator()(
56  const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team) const
57 {
58  const int cell = team.league_rank();
59  const int num_point = _scalar_flux.extent(1);
60 
61  Kokkos::parallel_for(
62  Kokkos::TeamThreadRange(team, 0, num_point), [&](const int point) {
63  for (int dim = 0; dim < num_space_dim; ++dim)
64  {
65  _scalar_flux(cell, point, dim)
66  = _volume_fractions(cell, point, _phase_index)
67  * _velocity[dim](cell, point);
68  }
69  });
70 }
71 
72 //---------------------------------------------------------------------------//
73 
74 } // end namespace ClosureModel
75 } // end namespace VertexCFD
76 
77 #endif // end
78  // VERTEXCFD_CLOSURE_INCOMPRESSIBLELSVOFSCALARCONVECTIVEFLUX_IMPL_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23