1 #ifndef VERTEXCFD_INCOMPRESSIBLELSVOFCLOSUREMODELFACTORY_IMPL_HPP
2 #define VERTEXCFD_INCOMPRESSIBLELSVOFCLOSUREMODELFACTORY_IMPL_HPP
4 #include "utils/VertexCFD_Utils_PhaseIndex.hpp"
5 #include "utils/VertexCFD_Utils_ScalarToVector.hpp"
7 #include "closure_models/VertexCFD_Closure_ConstantVectorField.hpp"
8 #include "closure_models/VertexCFD_Closure_MetricTensor.hpp"
9 #include "closure_models/VertexCFD_Closure_MetricTensorElementLength.hpp"
10 #include "closure_models/VertexCFD_Closure_VariableOldValue.hpp"
12 #include "incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleCLSEpsilon.hpp"
13 #include "incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleCLSLambda.hpp"
14 #include "incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleCLSNonReconstructedNormal.hpp"
15 #include "incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleCLSRegularization.hpp"
16 #include "incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleCLSSign.hpp"
17 #include "incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleLSVOFArtificialCompression.hpp"
18 #include "incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleLSVOFBubbleExact.hpp"
19 #include "incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleLSVOFBuoyancySource.hpp"
20 #include "incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleLSVOFConvectiveFlux.hpp"
21 #include "incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleLSVOFErrorNorms.hpp"
22 #include "incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleLSVOFNthPhaseFraction.hpp"
23 #include "incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleLSVOFScalarConvectiveFlux.hpp"
24 #include "incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleLSVOFScalarTimeDerivative.hpp"
25 #include "incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleLSVOFSurfaceTensionForce.hpp"
26 #include "incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleLSVOFTimeDerivative.hpp"
27 #include "incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleLSVOFVariableProperties.hpp"
28 #include "incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleLSVOFViscousFlux.hpp"
29 #include "incompressible_lsvof_solver/closure_models/VertexCFD_Closure_IncompressibleLSVOFVortexVelocity.hpp"
31 #include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleLocalTimeStepSize.hpp"
33 #include <Teuchos_RCP.hpp>
34 #include <Teuchos_StandardParameterEntryValidators.hpp>
40 namespace ClosureModel
43 template<
class EvalType,
int NumSpaceDim>
44 void IncompressibleLSVOFFactory<EvalType, NumSpaceDim>::buildClosureModel(
45 const std::string& closure_type,
46 const Teuchos::RCP<panzer::IntegrationRule>& ir,
47 const Teuchos::ParameterList& ,
48 const Teuchos::ParameterList& closure_params,
49 const Teuchos::RCP<panzer::GlobalData>& ,
51 std::string& error_msg,
52 Teuchos::RCP<std::vector<Teuchos::RCP<PHX::Evaluator<panzer::Traits>>>>
56 if (isDefaultClosureModel(closure_type))
64 if (closure_type ==
"IncompressibleLSVOFVortexVelocity")
66 const auto eval_vof_vortex = Teuchos::rcp(
67 new IncompressibleLSVOFVortexVelocity<EvalType,
70 *ir, closure_params));
72 evaluators->push_back(eval_vof_vortex);
78 if (closure_type ==
"IncompressibleLSVOFConstantVectorField")
80 auto eval = Teuchos::rcp(
81 new ConstantVectorField<EvalType, panzer::Traits, num_space_dim>(
82 *ir, closure_params));
83 evaluators->push_back(eval);
88 if (closure_type ==
"IncompressibleLSVOFErrorNorms")
91 const auto eval_vof_errors = Teuchos::rcp(
92 new IncompressibleLSVOFErrorNorms<EvalType,
95 *ir, closure_params));
97 evaluators->push_back(eval_vof_errors);
103 if (closure_type ==
"IncompressibleLSVOFBubbleExact")
105 const auto eval_bubble_exact = Teuchos::rcp(
106 new IncompressibleLSVOFBubbleExact<EvalType,
109 *ir, closure_params));
111 evaluators->push_back(eval_bubble_exact);
118 error_msg +=
"Default IncompressibleLSVOF closure models:\n";
119 error_msg +=
"IncompressibleCLSEpsilon\n";
120 error_msg +=
"IncompressibleCLSLambda\n";
121 error_msg +=
"IncompressibleCLSNonReconstructedNormal\n";
122 error_msg +=
"IncompressibleCLSRegularization\n";
123 error_msg +=
"IncompressibleCLSSign\n";
124 error_msg +=
"IncompressibleLocalTimeStepSize\n";
125 error_msg +=
"IncompressibleLSVOFArtificialCompression\n";
126 error_msg +=
"IncompressibleLSVOFBuoyancySource\n";
127 error_msg +=
"IncompressibleLSVOFConvectiveFlux\n";
128 error_msg +=
"IncompressibleLSVOFNthPhaseFraction\n";
129 error_msg +=
"IncompressibleLSVOFScalarConvectiveFlux\n";
130 error_msg +=
"IncompressibleLSVOFSurfaceTensionForce\n";
131 error_msg +=
"IncompressibleLSVOFTimeDerivative\n";
132 error_msg +=
"IncompressibleLSVOFVariableProperties\n";
133 error_msg +=
"IncompressibleLSVOFViscousFlux\n";
135 error_msg +=
"\nOptional IncompressibleLSVOF closure models:\n";
136 error_msg +=
"IncompressibleLSVOFBubbleExact\n";
137 error_msg +=
"IncompressibleLSVOFConstantVectorField\n";
138 error_msg +=
"IncompressibleLSVOFErrorNorms\n";
139 error_msg +=
"IncompressibleLSVOFVortexVelocity\n";
143 template<
class EvalType,
int NumSpaceDim>
144 void IncompressibleLSVOFFactory<EvalType, NumSpaceDim>::buildDefaultClosureModels(
145 const Teuchos::RCP<panzer::IntegrationRule>& ir,
146 const Teuchos::ParameterList& closure_model_list,
147 const Teuchos::ParameterList& user_params,
148 const Teuchos::RCP<panzer::GlobalData>& global_data,
149 Teuchos::RCP<std::vector<Teuchos::RCP<PHX::Evaluator<panzer::Traits>>>>
153 Teuchos::ParameterList lsvof_params
154 = closure_model_list.sublist(
"LSVOF_Properties");
157 const auto type_validator = Teuchos::rcp(
158 new Teuchos::StringToIntegralParameterEntryValidator<LSVOFModelType>(
159 Teuchos::tuple<std::string>(
"None",
"CLS",
"VOF"),
"None"));
161 const LSVOFModelType lsvof_model_name = type_validator->getIntegralValue(
162 lsvof_params.get<std::string>(
"LSVOF Model"));
164 if (lsvof_model_name == LSVOFModelType::None)
166 std::string msg =
"Error: LSVOF Model cannot be missing";
167 msg +=
" or set to 'None' when Closure Factory Type is set to 'LSVOF'.";
169 throw std::runtime_error(msg);
173 const bool build_lsvofmom_equ
174 = lsvof_params.isType<
bool>(
"Build LSVOF Navier-Stokes Equations")
175 ? lsvof_params.get<
bool>(
"Build LSVOF Navier-Stokes Equations")
179 const int num_phases = lsvof_params.get<
int>(
"Number of Phases");
180 const int num_lsvof_dofs = num_phases - 1;
184 const std::string msg =
"Must have 2 or more phases for LSVOF model.";
186 throw std::runtime_error(msg);
188 else if (num_phases > 2)
190 const std::string msg
191 =
"More than 2 phases not currently supported in LSVOF model.";
193 throw std::runtime_error(msg);
197 std::vector<std::string> phase_names;
200 const bool _build_lsvof_buoyancy_source
201 = lsvof_params.get<
bool>(
"Build LSVOF Buoyancy Source",
true);
203 const bool _build_lsvof_surface_tension
204 = lsvof_params.get<
bool>(
"Build LSVOF Surface Tension",
true);
207 if (lsvof_model_name == LSVOFModelType::VOF)
209 for (
int n = 1; n <= num_phases; ++n)
211 Teuchos::ParameterList vof_names_list;
213 const std::string list_name =
"Phase " + std::to_string(n);
215 Teuchos::ParameterList phase_list = lsvof_params.sublist(list_name);
217 const std::string phase_name
218 = phase_list.get<std::string>(
"Phase Name");
219 const std::string phase_fraction_name =
"alpha_" + phase_name;
221 vof_names_list.set(
"Field Name", phase_fraction_name);
222 vof_names_list.set(
"Equation Name",
223 phase_fraction_name +
"_equation");
229 phase_names.push_back(phase_fraction_name);
232 const auto eval_vof_dqdt = Teuchos::rcp(
233 new IncompressibleLSVOFScalarTimeDerivative<EvalType,
237 phase_fraction_name +
"_equation"));
239 evaluators->push_back(eval_vof_dqdt);
242 const auto eval_vof_conv = Teuchos::rcp(
243 new IncompressibleLSVOFScalarConvectiveFlux<EvalType,
249 phase_fraction_name +
"_equation"));
251 evaluators->push_back(eval_vof_conv);
254 const auto eval_vof_compress = Teuchos::rcp(
255 new IncompressibleLSVOFArtificialCompression<EvalType,
261 phase_fraction_name +
"_equation"));
263 evaluators->push_back(eval_vof_compress);
271 const bool include_time_deriv =
true;
272 const bool include_grads =
false;
274 = Utils::ScalarToVector<EvalType, PhaseIndex>::createFromList(
281 evaluators->push_back(phase_vec);
283 phase_names.push_back(phase_fraction_name);
287 const auto eval_nth_phase = Teuchos::rcp(
288 new IncompressibleLSVOFNthPhaseFraction<EvalType,
292 evaluators->push_back(eval_nth_phase);
296 else if (lsvof_model_name == LSVOFModelType::CLS)
299 for (
int n = 1; n <= num_phases; ++n)
301 Teuchos::ParameterList phase_list
302 = lsvof_params.sublist(
"Phase " + std::to_string(n));
304 const std::string phase_name
305 = phase_list.get<std::string>(
"Phase Name");
307 phase_names.push_back(phase_name);
311 const auto type_validator = Teuchos::rcp(
312 new Teuchos::StringToIntegralParameterEntryValidator<
313 LSNormalReconstructionType>(Teuchos::tuple<std::string>(
"NonRe"
317 "NonReconstructed"));
319 const LSNormalReconstructionType reconstruction_type
320 = type_validator->getIntegralValue(lsvof_params.get<std::string>(
321 "LS Normal Reconstruction Type"));
325 = Teuchos::rcp(
new MetricTensor<EvalType, panzer::Traits>(*ir));
327 evaluators->push_back(eval_mt);
329 const auto eval_mt_el = Teuchos::rcp(
330 new MetricTensorElementLength<EvalType, panzer::Traits>(*ir));
332 evaluators->push_back(eval_mt_el);
335 const auto eval_cls_epsilon = Teuchos::rcp(
336 new IncompressibleCLSEpsilon<EvalType, panzer::Traits, num_space_dim>(
339 evaluators->push_back(eval_cls_epsilon);
343 const auto eval_phi_star = Teuchos::rcp(
344 new VariableOldValue<EvalType, panzer::Traits>(*ir, lsvof_params));
346 evaluators->push_back(eval_phi_star);
349 const auto eval_cls_sign = Teuchos::rcp(
350 new IncompressibleCLSSign<EvalType, panzer::Traits>(*ir));
352 evaluators->push_back(eval_cls_sign);
355 const auto eval_cls_lambda = Teuchos::rcp(
356 new IncompressibleCLSLambda<EvalType, panzer::Traits, num_space_dim>(
357 *ir, lsvof_params, global_data));
359 evaluators->push_back(eval_cls_lambda);
362 if (reconstruction_type == LSNormalReconstructionType::NonReconstructed)
364 const auto eval_cls_q = Teuchos::rcp(
365 new IncompressibleCLSNonReconstructedNormal<EvalType,
367 num_space_dim>(*ir));
369 evaluators->push_back(eval_cls_q);
373 const auto eval_cls_reg = Teuchos::rcp(
374 new IncompressibleCLSRegularization<EvalType,
376 num_space_dim>(*ir));
378 evaluators->push_back(eval_cls_reg);
382 const auto eval_lsvof_props = Teuchos::rcp(
383 new IncompressibleLSVOFVariableProperties<EvalType, panzer::Traits>(
384 *ir, lsvof_params, phase_names));
386 evaluators->push_back(eval_lsvof_props);
389 if (build_lsvofmom_equ)
391 const auto eval_ns_dqdt = Teuchos::rcp(
392 new IncompressibleLSVOFTimeDerivative<EvalType,
397 evaluators->push_back(eval_ns_dqdt);
399 const auto eval_ns_conv = Teuchos::rcp(
400 new IncompressibleLSVOFConvectiveFlux<EvalType,
402 num_space_dim>(*ir));
404 evaluators->push_back(eval_ns_conv);
406 const auto eval_ns_visc
407 = Teuchos::rcp(
new IncompressibleLSVOFViscousFlux<EvalType,
412 evaluators->push_back(eval_ns_visc);
415 if (_build_lsvof_buoyancy_source)
417 const auto eval_ns_buo = Teuchos::rcp(
418 new IncompressibleLSVOFBuoyancySource<EvalType,
423 evaluators->push_back(eval_ns_buo);
427 if (_build_lsvof_surface_tension)
429 const auto eval_ns_surf = Teuchos::rcp(
430 new IncompressibleLSVOFSurfaceTensionForce<EvalType,
433 *ir, lsvof_params, phase_names));
435 evaluators->push_back(eval_ns_surf);
440 const auto eval_local_dt = Teuchos::rcp(
441 new IncompressibleLocalTimeStepSize<EvalType, panzer::Traits, num_space_dim>(
444 evaluators->push_back(eval_local_dt);
448 template<
class EvalType,
int NumSpaceDim>
449 bool IncompressibleLSVOFFactory<EvalType, NumSpaceDim>::isDefaultClosureModel(
450 const std::string& closure_type)
452 std::vector<std::string> default_closures;
454 default_closures.push_back(
"IncompressibleCLSEpsilon");
455 default_closures.push_back(
"IncompressibleCLSLambda");
456 default_closures.push_back(
"IncompressibleCLSSign");
457 default_closures.push_back(
"IncompressibleLocalTimeStepSize");
458 default_closures.push_back(
"IncompressibleLSVOFArtificialCompression");
459 default_closures.push_back(
"IncompressibleLSVOFBuoyancySource");
460 default_closures.push_back(
"IncompressibleLSVOFConvectiveFlux");
461 default_closures.push_back(
"IncompressibleLSVOFProperties");
462 default_closures.push_back(
"IncompressibleLSVOFScalarConvectiveFlux");
463 default_closures.push_back(
"IncompressibleLSVOFSurfaceTensionForce");
464 default_closures.push_back(
"IncompressibleLSVOFTimeDerivative");
465 default_closures.push_back(
"IncompressibleLSVOFVariableProperties");
466 default_closures.push_back(
"IncompressibleLSVOFViscousFlux");
468 for (
const auto& closure : default_closures)
470 if (closure == closure_type)
480 #endif // end VERTEXCFD_INCOMPRESSIBLELSVOFCLOSUREMODELFACTORY_IMPL_HPP