1 #ifndef VERTEXCFD_INITIALCONDITION_INCOMPRESSIBLELSVOFBUBBLE_IMPL_HPP
2 #define VERTEXCFD_INITIALCONDITION_INCOMPRESSIBLELSVOFBUBBLE_IMPL_HPP
4 #include <Panzer_GlobalIndexer.hpp>
5 #include <Panzer_HierarchicParallelism.hpp>
6 #include <Panzer_PureBasis.hpp>
7 #include <Panzer_Workset_Utilities.hpp>
9 #include <Teuchos_Array.hpp>
10 #include <Teuchos_StandardParameterEntryValidators.hpp>
17 namespace InitialCondition
20 template<
class EvalType,
class Traits,
int NumSpaceDim>
21 IncompressibleLSVOFBubble<EvalType, Traits, NumSpaceDim>::IncompressibleLSVOFBubble(
22 const Teuchos::ParameterList& ic_params,
const panzer::PureBasis& basis)
23 : _alpha(ic_params.get<std::string>(
"Phase Name"), basis.functional)
24 , _basis_name(basis.name())
25 , _radius(ic_params.get<double>(
"Bubble Radius"))
26 , _phase_type(PhaseType::Dispersed)
29 if (ic_params.isType<std::string>(
"Phase Type"))
31 const auto type_validator = Teuchos::rcp(
32 new Teuchos::StringToIntegralParameterEntryValidator<PhaseType>(
33 Teuchos::tuple<std::string>(
"Dispersed",
"Continuous"),
36 _phase_type = type_validator->getIntegralValue(
37 ic_params.get<std::string>(
"Phase Type"));
42 = ic_params.get<Teuchos::Array<double>>(
"Bubble Location");
44 for (
int d = 0; d < num_space_dim; ++d)
46 _location[d] = location[d];
49 this->addEvaluatedField(_alpha);
50 this->addUnsharedField(_alpha.fieldTag().clone());
52 this->setName(
"LSVOF " + ic_params.get<std::string>(
"Phase Name")
53 +
" Bubble Initial Condition");
57 template<
class EvalType,
class Traits,
int NumSpaceDim>
58 void IncompressibleLSVOFBubble<EvalType, Traits, NumSpaceDim>::postRegistrationSetup(
59 typename Traits::SetupData sd, PHX::FieldManager<Traits>&)
61 _basis_index = panzer::getPureBasisIndex(
62 _basis_name, (*sd.worksets_)[0], this->wda);
66 template<
class EvalType,
class Traits,
int NumSpaceDim>
67 void IncompressibleLSVOFBubble<EvalType, Traits, NumSpaceDim>::evaluateFields(
68 typename Traits::EvalData workset)
70 _basis_coords = this->wda(workset).bases[_basis_index]->basis_coordinates;
71 auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
73 Kokkos::parallel_for(this->getName(), policy, *
this);
77 template<
class EvalType,
class Traits,
int NumSpaceDim>
78 KOKKOS_INLINE_FUNCTION
void
79 IncompressibleLSVOFBubble<EvalType, Traits, NumSpaceDim>::operator()(
80 const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team)
const
82 const int cell = team.league_rank();
83 const int num_basis = _alpha.extent(1);
88 Kokkos::TeamThreadRange(team, 0, num_basis), [&](
const int basis) {
91 for (
int d = 0; d < num_space_dim; ++d)
93 r += pow(_location[d] - _basis_coords(cell, basis, d), 2.0);
100 if (_phase_type == PhaseType::Dispersed)
102 _alpha(cell, basis) = 1.0;
106 _alpha(cell, basis) = 0.0;
111 if (_phase_type == PhaseType::Dispersed)
113 _alpha(cell, basis) = 0.0;
117 _alpha(cell, basis) = 1.0;
128 #endif // end VERTEXCFD_INITIALCONDITION_INCOMPRESSIBLELSVOFBUBBLE_IMPL_HPP