1 #ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLELSVOFVARIABLEPROPERTIES_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_INCOMPRESSIBLELSVOFVARIABLEPROPERTIES_IMPL_HPP
4 #include "utils/VertexCFD_Utils_PhaseLayout.hpp"
6 #include <Panzer_HierarchicParallelism.hpp>
7 #include <Panzer_Workset_Utilities.hpp>
9 #include <Phalanx_DataLayout_DynamicLayout.hpp>
11 #include <Sacado_Traits.hpp>
17 namespace ClosureModel
20 template<
class EvalType,
class Traits>
21 IncompressibleLSVOFVariableProperties<EvalType, Traits>::
22 IncompressibleLSVOFVariableProperties(
23 const panzer::IntegrationRule& ir,
24 const Teuchos::ParameterList& lsvof_params,
25 const std::vector<std::string>& phase_names,
26 const bool& build_dxdts,
27 const std::string& field_prefix)
28 : _rho(field_prefix +
"density", ir.dl_scalar)
29 , _mu(field_prefix +
"dynamic_viscosity", ir.dl_scalar)
30 , _dxdt_rho(
"DXDT_density", ir.dl_scalar)
31 , _build_dxdts(build_dxdts)
33 Utils::buildPhaseLayout(ir.dl_scalar, phase_names.size() - 1))
34 , _alphas(field_prefix +
"volume_fractions", _phase_layout)
35 , _dxdt_alphas(field_prefix +
"DXDT_volume_fractions", _phase_layout)
36 , _alpha_n(phase_names[lsvof_params.get<int>(
"Number of Phases") - 1],
38 , _phase_rho(Kokkos::ViewAllocateWithoutInitializing(
"Density"),
39 lsvof_params.get<int>(
"Number of Phases"))
40 , _phase_mu(Kokkos::ViewAllocateWithoutInitializing(
"Dynamic "
42 lsvof_params.get<int>(
"Number of Phases"))
45 this->addEvaluatedField(_rho);
46 this->addEvaluatedField(_mu);
49 this->addEvaluatedField(_dxdt_rho);
53 this->addDependentField(_alphas);
56 this->addDependentField(_dxdt_alphas);
58 this->addDependentField(_alpha_n);
60 = Kokkos::create_mirror_view(Kokkos::HostSpace{}, _phase_rho);
61 auto pmu_host = Kokkos::create_mirror_view(Kokkos::HostSpace{}, _phase_mu);
64 for (
int phase = 0; phase < lsvof_params.get<
int>(
"Number of Phases");
68 const std::string list_name =
"Phase " + std::to_string(phase + 1);
69 const Teuchos::ParameterList phase_list
70 = lsvof_params.sublist(list_name);
71 prho_host[phase] = phase_list.get<
double>(
"Density");
72 pmu_host[phase] = phase_list.get<
double>(
"Dynamic viscosity");
75 Kokkos::deep_copy(_phase_rho, prho_host);
76 Kokkos::deep_copy(_phase_mu, pmu_host);
77 this->setName(
"Incompressible LSVOF Variable Properties");
81 template<
class EvalType,
class Traits>
82 void IncompressibleLSVOFVariableProperties<EvalType, Traits>::evaluateFields(
83 typename Traits::EvalData workset)
85 auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
87 Kokkos::parallel_for(this->getName(), policy, *
this);
91 template<
class EvalType,
class Traits>
92 KOKKOS_INLINE_FUNCTION
void
93 IncompressibleLSVOFVariableProperties<EvalType, Traits>::operator()(
94 const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team)
const
96 const int cell = team.league_rank();
97 const int num_point = _rho.extent(1);
98 const size_t nb_phase = _alphas.extent(2);
100 Kokkos::parallel_for(
101 Kokkos::TeamThreadRange(team, 0, num_point), [&](
const int point) {
102 _rho(cell, point) = 0.0;
103 _mu(cell, point) = 0.0;
106 _dxdt_rho(cell, point) = 0.0;
110 for (
size_t phase = 0; phase < nb_phase; ++phase)
112 _rho(cell, point) += _phase_rho[phase]
113 * _alphas(cell, point, phase);
114 _mu(cell, point) += _phase_mu[phase]
115 * _alphas(cell, point, phase);
118 _dxdt_rho(cell, point)
119 += ((_phase_rho[phase] - _phase_rho[nb_phase])
120 * _dxdt_alphas(cell, point, phase));
123 _rho(cell, point) += _phase_rho[nb_phase] * _alpha_n(cell, point);
124 _mu(cell, point) += _phase_mu[nb_phase] * _alpha_n(cell, point);
133 #endif // end VERTEXCFD_CLOSURE_INCOMPRESSIBLELSVOFVARIABLEPROPERTIES_IMPL_HPP