1 #ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLELSVOFNTHPHASEFRACTION_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_INCOMPRESSIBLELSVOFNTHPHASEFRACTION_IMPL_HPP
4 #include "utils/VertexCFD_Utils_PhaseLayout.hpp"
5 #include "utils/VertexCFD_Utils_SmoothMath.hpp"
7 #include <Panzer_HierarchicParallelism.hpp>
8 #include <Panzer_Workset_Utilities.hpp>
10 #include <Phalanx_DataLayout_DynamicLayout.hpp>
12 #include <Sacado_Traits.hpp>
18 namespace ClosureModel
21 template<
class EvalType,
class Traits>
22 IncompressibleLSVOFNthPhaseFraction<EvalType, Traits>::
23 IncompressibleLSVOFNthPhaseFraction(
24 const panzer::IntegrationRule& ir,
25 const std::vector<std::string>& phase_names,
26 const std::string& field_prefix)
27 : _alpha_n(field_prefix + phase_names[phase_names.size() - 1], ir.dl_scalar)
29 Utils::buildPhaseLayout(ir.dl_scalar, phase_names.size() - 1))
30 , _alphas(field_prefix +
"volume_fractions", _phase_layout)
33 this->addEvaluatedField(_alpha_n);
36 this->addDependentField(_alphas);
38 this->setName(
"Incompressible LSVOF Nth Phase Fraction");
42 template<
class EvalType,
class Traits>
43 void IncompressibleLSVOFNthPhaseFraction<EvalType, Traits>::evaluateFields(
44 typename Traits::EvalData workset)
46 auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
48 Kokkos::parallel_for(this->getName(), policy, *
this);
52 template<
class EvalType,
class Traits>
53 KOKKOS_INLINE_FUNCTION
void
54 IncompressibleLSVOFNthPhaseFraction<EvalType, Traits>::operator()(
55 const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team)
const
57 const int cell = team.league_rank();
58 const int num_point = _alpha_n.extent(1);
61 Kokkos::TeamThreadRange(team, 0, num_point), [&](
const int point) {
63 _alpha_n(cell, point) = 1.0;
65 for (
size_t phase = 0; phase < _alphas.extent(2); ++phase)
67 _alpha_n(cell, point) -= _alphas(cell, point, phase);
71 _alpha_n(cell, point) = SmoothMath::max(
72 SmoothMath::min(_alpha_n(cell, point), 1.0, 0.0), 0.0, 0.0);
81 #endif // end VERTEXCFD_CLOSURE_INCOMPRESSIBLELSVOFNTHPHASEFRACTION_IMPL_HPP