1 #ifndef VERTEXCFD_EQUATIONSET_INCOMPRESSIBLE_LSVOF_IMPL_HPP
2 #define VERTEXCFD_EQUATIONSET_INCOMPRESSIBLE_LSVOF_IMPL_HPP
4 #include <Panzer_BasisIRLayout.hpp>
5 #include <Panzer_IntegrationRule.hpp>
7 #include <Panzer_Integrator_BasisTimesScalar.hpp>
8 #include <Panzer_Integrator_GradBasisDotVector.hpp>
10 #include <Phalanx_FieldManager.hpp>
12 #include <Teuchos_ParameterList.hpp>
13 #include <Teuchos_RCP.hpp>
14 #include <Teuchos_StandardParameterEntryValidators.hpp>
21 template<
class EvalType>
22 IncompressibleLSVOF<EvalType>::IncompressibleLSVOF(
23 const Teuchos::RCP<Teuchos::ParameterList>& params,
24 const int& default_integration_order,
25 const panzer::CellData& cell_data,
26 const Teuchos::RCP<panzer::GlobalData>& global_data,
27 const bool build_transient_support)
28 : panzer::EquationSet_DefaultImpl<EvalType>(params,
29 default_integration_order,
32 build_transient_support)
35 if (!this->buildTransientSupport())
37 throw std::logic_error(
38 "Transient support is required for solving all equation sets.");
42 _num_space_dim = cell_data.baseCellDimension();
43 if (!(_num_space_dim == 2 || _num_space_dim == 3))
45 throw std::runtime_error(
"Number of space dimensions not supported");
49 const int basis_order = params->get<
int>(
"Basis Order", 1);
50 const int integration_order
51 = params->get<
int>(
"Integration Order", basis_order + 1);
52 const std::string model_id = params->get<std::string>(
"Model ID");
55 Teuchos::ParameterList& lsvof_params = params->sublist(
"LSVOF_Properties");
58 = params->get<
bool>(
"Build LSVOF Navier-Stokes Equations",
true);
60 _lsvof_model_name = lsvof_params.get<std::string>(
"LSVOF Model");
62 const int num_phases = lsvof_params.get<
int>(
"Number of Phases");
64 _build_lsvof_buoyancy_source
65 = lsvof_params.get<
bool>(
"Build LSVOF Buoyancy Source",
true);
67 _build_lsvof_surface_tension
68 = lsvof_params.get<
bool>(
"Build LSVOF Surface Tension",
true);
71 if (_build_lsvofmom_equ)
73 _equ_dof_ns_pair.insert({
"continuity",
"lagrange_pressure"});
75 for (
int d = 0; d < _num_space_dim; ++d)
77 const std::string ds = std::to_string(d);
78 _equ_dof_ns_pair.insert({
"momentum_" + ds,
"velocity_" + ds});
83 if (_lsvof_model_name ==
"VOF")
85 for (
int n = 1; n < num_phases; ++n)
87 const std::string list_name =
"Phase " + std::to_string(n);
89 Teuchos::ParameterList phase_list = lsvof_params.sublist(list_name);
91 const std::string phase_name
92 = phase_list.get<std::string>(
"Phase Name");
94 const std::string phase_fraction_name =
"alpha_" + phase_name;
96 _equ_dof_lsvof_pair.insert(
97 {phase_fraction_name +
"_equation", phase_fraction_name});
100 else if (_lsvof_model_name ==
"CLS")
102 _equ_dof_lsvof_pair.insert({
"level_set_equation",
"level_set"});
107 = [&,
this](
const std::string& equ_name,
const std::string& dof_name) {
108 const std::string residual_name =
"RESIDUAL_" + equ_name;
109 const std::string scatter_name =
"SCATTER_" + equ_name;
110 const std::string basis_type =
"HGrad";
111 this->addDOF(dof_name,
117 this->addDOFGrad(dof_name);
118 this->addDOFTimeDerivative(dof_name);
122 if (_build_lsvofmom_equ)
124 for (
const auto& [equ_name, dof_name] : _equ_dof_ns_pair)
126 set_dofs(equ_name, dof_name);
131 for (
const auto& [equ_name, dof_name] : _equ_dof_lsvof_pair)
133 set_dofs(equ_name, dof_name);
137 this->addClosureModel(model_id);
142 template<
class EvalType>
143 void IncompressibleLSVOF<EvalType>::buildAndRegisterEquationSetEvaluators(
144 PHX::FieldManager<panzer::Traits>& fm,
145 const panzer::FieldLibrary&,
146 const Teuchos::ParameterList&)
const
151 const auto it = _equ_dof_lsvof_pair.begin();
152 const auto ir = this->getIntRuleForDOF(it->second);
153 const auto basis = this->getBasisIRLayoutForDOF(it->second);
156 auto add_basis_time_scalar_residual = [&,
this](
157 const std::string& equ_name,
158 const std::string& residual_name,
159 const double& multiplier,
160 std::vector<std::string>& op_names) {
161 const std::string closure_model_residual = residual_name +
"_"
163 const std::string full_residual =
"RESIDUAL_" + closure_model_residual;
164 auto op = Teuchos::rcp(
165 new panzer::Integrator_BasisTimesScalar<EvalType, panzer::Traits>(
166 panzer::EvaluatorStyle::EVALUATES,
168 closure_model_residual,
172 this->
template registerEvaluator<EvalType>(fm, op);
173 op_names.push_back(full_residual);
177 auto add_grad_basis_time_residual = [&,
this](
178 const std::string& equ_name,
179 const std::string& residual_name,
180 const double& multiplier,
181 std::vector<std::string>& op_names) {
182 const std::string closure_model_residual = residual_name +
"_"
184 const std::string full_residual =
"RESIDUAL_" + closure_model_residual;
185 auto op = Teuchos::rcp(
186 new panzer::Integrator_GradBasisDotVector<EvalType, panzer::Traits>(
187 panzer::EvaluatorStyle::EVALUATES,
189 closure_model_residual,
193 this->
template registerEvaluator<EvalType>(fm, op);
194 op_names.push_back(full_residual);
198 if (_build_lsvofmom_equ)
200 for (
const auto& [equ_name, dof_name] : _equ_dof_ns_pair)
202 std::vector<std::string> residual_operator_names;
205 add_basis_time_scalar_residual(
206 equ_name,
"DQDT", 1.0, residual_operator_names);
209 add_grad_basis_time_residual(
210 equ_name,
"CONVECTIVE_FLUX", -1.0, residual_operator_names);
213 add_grad_basis_time_residual(
214 equ_name,
"VISCOUS_FLUX", 1.0, residual_operator_names);
219 if (std::string::npos != equ_name.find(
"momentum"))
222 if (_build_lsvof_buoyancy_source)
224 add_basis_time_scalar_residual(equ_name,
225 "LSVOF_BUOYANCY_SOURCE",
227 residual_operator_names);
230 if (_build_lsvof_surface_tension)
232 add_grad_basis_time_residual(equ_name,
233 "SURFACE_TENSION_FLUX",
235 residual_operator_names);
240 this->buildAndRegisterResidualSummationEvaluator(
241 fm, dof_name, residual_operator_names,
"RESIDUAL_" + equ_name);
246 for (
const auto& [equ_name, dof_name] : _equ_dof_lsvof_pair)
248 std::vector<std::string> residual_operator_names;
251 add_basis_time_scalar_residual(
252 equ_name,
"DQDT", 1.0, residual_operator_names);
254 add_grad_basis_time_residual(
255 equ_name,
"CONVECTIVE_FLUX", -1.0, residual_operator_names);
257 if (_lsvof_model_name ==
"VOF")
259 add_grad_basis_time_residual(equ_name,
260 "ARTIFICIAL_COMPRESSION",
262 residual_operator_names);
264 else if (_lsvof_model_name ==
"CLS")
266 add_grad_basis_time_residual(
267 equ_name,
"REG", -1.0, residual_operator_names);
274 this->buildAndRegisterResidualSummationEvaluator(
275 fm, dof_name, residual_operator_names,
"RESIDUAL_" + equ_name);
284 #endif // end VERTEXCFD_EQUATIONSET_INCOMPRESSIBLE_LSVOF_IMPL_HPP