1 #ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLECLSLAMBDA_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_INCOMPRESSIBLECLSLAMBDA_IMPL_HPP
4 #include "utils/VertexCFD_Utils_SmoothMath.hpp"
5 #include "utils/VertexCFD_Utils_VectorField.hpp"
7 #include <Panzer_HierarchicParallelism.hpp>
9 #include <Teuchos_StandardParameterEntryValidators.hpp>
15 namespace ClosureModel
18 template<
class EvalType,
class Traits,
int NumSpaceDim>
19 IncompressibleCLSLambda<EvalType, Traits, NumSpaceDim>::IncompressibleCLSLambda(
20 const panzer::IntegrationRule& ir,
21 const Teuchos::ParameterList& lsvof_params,
22 const Teuchos::RCP<panzer::GlobalData>& global_data)
23 : _lambda(
"CLS_lambda", ir.dl_scalar)
24 , _mag_phi(
"level_set_magnitude", ir.dl_scalar)
25 , _d_phi(
"d_level_set", ir.dl_scalar)
26 , _phi(
"level_set", ir.dl_scalar)
27 , _epsilon(
"CLS_epsilon", ir.dl_scalar)
28 , _global_data(global_data)
29 , _domain_volume(lsvof_params.get<double>(
"Domain Volume"))
34 if (lsvof_params.isType<
double>(
"Regularization Coefficient"))
36 _C_lambda = lsvof_params.get<
double>(
"Regularization Coefficient");
40 if (lsvof_params.isType<
double>(
"Interface Thickness Coefficient"))
42 _C_alpha = lsvof_params.get<
double>(
"Interface Thickness Coefficient");
46 this->addEvaluatedField(_lambda);
47 this->addEvaluatedField(_mag_phi);
48 this->addEvaluatedField(_d_phi);
51 this->addDependentField(_phi);
52 this->addDependentField(_epsilon);
53 Utils::addDependentVectorField(*
this, ir.dl_scalar, _velocity,
"velocity_");
55 this->setName(
"Incompressible CLS Lambda " + std::to_string(num_space_dim)
60 template<
class EvalType,
class Traits,
int NumSpaceDim>
61 void IncompressibleCLSLambda<EvalType, Traits, NumSpaceDim>::evaluateFields(
62 typename Traits::EvalData workset)
66 const auto& pl = *_global_data->pl;
69 const std::string mag_phi_int_name
70 =
"Level Set Magnitude - level_set_magnitude";
71 const std::string d_phi_max_name =
"Max Dphi - d_level_set";
72 const std::string cfl_name =
"Min global_cfl_time_step - local_dt";
75 _avg_mag_phi = pl.getValue<EvalType>(mag_phi_int_name) / _domain_volume;
76 _max_d_phi = pl.getValue<EvalType>(d_phi_max_name);
77 _cfl = workset.step_size / max(pl.getValue<EvalType>(cfl_name), 1e-8);
79 auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
81 Kokkos::parallel_for(this->getName(), policy, *
this);
85 template<
class EvalType,
class Traits,
int NumSpaceDim>
86 KOKKOS_INLINE_FUNCTION
void
87 IncompressibleCLSLambda<EvalType, Traits, NumSpaceDim>::operator()(
88 const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team)
const
90 const int cell = team.league_rank();
91 const int num_point = _lambda.extent(1);
96 const double tol = 1e-10;
99 Kokkos::TeamThreadRange(team, 0, num_point), [&](
const int point) {
101 _mag_phi(cell, point) = abs(_phi(cell, point));
102 _d_phi(cell, point) = abs(_mag_phi(cell, point) - _avg_mag_phi);
105 _lambda(cell, point) = abs(_velocity[0](cell, point));
107 for (
int dim = 1; dim < num_space_dim; ++dim)
109 _lambda(cell, point) = max(_lambda(cell, point),
110 abs(_velocity[dim](cell, point)));
116 * (_epsilon(cell, point)
117 / (_C_alpha * SmoothMath::max(_max_d_phi, tol, 0.0))));