1 #ifndef VERTEXCFD_FULLINDUCTIONCLOSUREMODELFACTORY_IMPL_HPP
2 #define VERTEXCFD_FULLINDUCTIONCLOSUREMODELFACTORY_IMPL_HPP
4 #include "closure_models/VertexCFD_Closure_ConstantScalarField.hpp"
5 #include "closure_models/VertexCFD_Closure_ExternalMagneticField.hpp"
6 #include "closure_models/VertexCFD_Closure_VectorFieldDivergence.hpp"
8 #include "incompressible_solver/closure_models/VertexCFD_Closure_IncompressibleVariableTimeDerivative.hpp"
10 #include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_DivergenceCleaningSource.hpp"
11 #include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_FullInductionLocalTimeStepSize.hpp"
12 #include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_FullInductionModelErrorNorms.hpp"
13 #include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_GodunovPowellSource.hpp"
14 #include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionConstantSource.hpp"
15 #include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionConvectiveFlux.hpp"
16 #include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionConvectiveMomentumFlux.hpp"
17 #include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_InductionResistiveFlux.hpp"
18 #include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_MHDVortexProblemExact.hpp"
19 #include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_MagneticCorrectionDampingSource.hpp"
20 #include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_MagneticPressure.hpp"
21 #include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_TotalMagneticField.hpp"
22 #include "full_induction_mhd_solver/closure_models/VertexCFD_Closure_TotalMagneticFieldGradient.hpp"
23 #include "full_induction_mhd_solver/mhd_properties/VertexCFD_FullInductionMHDProperties.hpp"
25 #include <Panzer_String_Utilities.hpp>
29 namespace ClosureModel
32 template<
class EvalType,
int NumSpaceDim>
33 Teuchos::RCP<std::vector<Teuchos::RCP<PHX::Evaluator<panzer::Traits>>>>
35 const std::string& model_id,
36 const Teuchos::ParameterList& model_params,
37 const panzer::FieldLayoutLibrary&,
38 const Teuchos::RCP<panzer::IntegrationRule>& ir,
39 const Teuchos::ParameterList& ,
40 const Teuchos::ParameterList& user_params,
41 const Teuchos::RCP<panzer::GlobalData>& ,
42 PHX::FieldManager<panzer::Traits>&)
const
44 auto evaluators = Teuchos::rcp(
45 new std::vector<Teuchos::RCP<PHX::Evaluator<panzer::Traits>>>);
47 if (!model_params.isSublist(model_id))
49 throw std::runtime_error(
"Full Induction closure model id " + model_id
54 const Teuchos::ParameterList& closure_model_list
55 = model_params.sublist(model_id);
59 const std::string factory_type
60 = closure_model_list.isType<std::string>(
"Closure Factory Type")
61 ? closure_model_list.get<std::string>(
"Closure Factory Type")
64 if (factory_type !=
"Full Induction MHD")
68 const auto full_induction_params
69 = closure_model_list.sublist(
"Full Induction MHD Properties");
71 full_induction_params);
72 const bool build_magn_corr = mhd_props.buildMagnCorr();
75 for (
const auto& closure_model : closure_model_list)
77 bool found_model =
false;
79 const auto closure_name = closure_model.first;
80 if (closure_name ==
"Closure Factory Type"
81 || closure_name ==
"Full Induction MHD Properties"
82 || closure_name ==
"Fluid Properties")
86 const auto& closure_params
87 = Teuchos::getValue<Teuchos::ParameterList>(closure_model.second);
89 if (!closure_params.isType<std::string>(
"Type"))
92 const auto closure_type = closure_params.get<std::string>(
"Type");
95 if (closure_type ==
"InductionConvectiveFlux")
98 auto ind_eval = Teuchos::rcp(
101 evaluators->push_back(ind_eval);
104 auto mtm_eval = Teuchos::rcp(
109 evaluators->push_back(mtm_eval);
114 if (closure_type ==
"InductionResistiveFlux")
116 auto eval = Teuchos::rcp(
119 evaluators->push_back(eval);
123 if (closure_type ==
"MagneticPressure")
125 auto eval = Teuchos::rcp(
127 evaluators->push_back(eval);
131 if (closure_type ==
"FullInductionTimeDerivative")
133 std::vector<Teuchos::ParameterList> mhd_names_list_vct;
134 for (
int dim = 0; dim < num_space_dim; ++dim)
136 Teuchos::ParameterList ind_names_list;
139 "induced_magnetic_field_" + std::to_string(dim));
140 ind_names_list.set(
"Equation Name",
141 "induction_" + std::to_string(dim));
142 mhd_names_list_vct.push_back(ind_names_list);
146 Teuchos::ParameterList magn_corr_names_list;
147 magn_corr_names_list.set(
"Field Name",
148 "scalar_magnetic_potential");
149 magn_corr_names_list.set(
"Equation Name",
150 "magnetic_correction_potential");
151 mhd_names_list_vct.push_back(magn_corr_names_list);
153 for (
auto& mhd_names_list : mhd_names_list_vct)
155 auto eval_time = Teuchos::rcp(
158 *ir, mhd_names_list));
159 evaluators->push_back(eval_time);
164 if (closure_type ==
"TotalMagneticField")
166 auto eval = Teuchos::rcp(
169 evaluators->push_back(eval);
170 auto eval_grad = Teuchos::rcp(
173 num_space_dim>(*ir));
174 evaluators->push_back(eval_grad);
178 if (closure_type ==
"MHDVortexProblemExact")
180 auto eval = Teuchos::rcp(
182 *ir, closure_params));
183 evaluators->push_back(eval);
187 if (closure_type ==
"FullInductionModelErrorNorm")
189 auto eval = Teuchos::rcp(
193 evaluators->push_back(eval);
197 if (closure_type ==
"DivergenceCleaningSource")
199 auto eval = Teuchos::rcp(
202 evaluators->push_back(eval);
206 if (closure_type ==
"GodunovPowellSource")
208 auto eval = Teuchos::rcp(
211 evaluators->push_back(eval);
215 if (closure_type ==
"MagneticCorrectionDampingSource")
217 auto eval = Teuchos::rcp(
220 evaluators->push_back(eval);
224 if (closure_type ==
"FullInductionLocalTimeStepSize")
226 auto eval = Teuchos::rcp(
229 NumSpaceDim>(*ir, mhd_props));
230 evaluators->push_back(eval);
234 if (closure_type ==
"Resistivity")
236 if (mhd_props.variableResistivity())
238 throw std::runtime_error(
239 "No closure models currently exist to evaluate variable "
240 "resistivity. Use a constant resistivity only.");
244 auto eval = Teuchos::rcp(
246 *ir,
"resistivity", mhd_props.resistivity()));
247 evaluators->push_back(eval);
252 if (closure_type ==
"InductionConstantSource")
254 auto eval = Teuchos::rcp(
256 *ir, closure_params));
257 evaluators->push_back(eval);
261 if (closure_type ==
"ExternalMagneticField")
263 auto eval = Teuchos::rcp(
266 evaluators->push_back(eval);
270 if (std::string::npos != closure_type.find(
"VectorFieldDivergence"))
272 const auto field_names
273 = closure_params.get<std::string>(
"Field Names");
274 std::vector<std::string> tokens;
275 panzer::StringTokenizer(tokens, field_names,
",",
true);
276 for (
auto& field : tokens)
278 if (std::string::npos != field.find(
"total_magnetic_field"))
280 throw std::runtime_error(
281 "The layout of \"total_magnetic_field\" is "
282 "incompatible with the current implementation of "
283 "\"VectorFieldDivergence\", and should not be "
284 "included in the list of field names for this closure "
285 "model. The field \"divergence_total_magnetic_field\" "
286 "is evaluated within the "
287 "\"TotalMagneticFieldGradient\" closure model.");
290 auto eval = Teuchos::rcp(
292 *ir, field, closure_type));
293 evaluators->push_back(eval);
300 const std::string msg =
"\n\nFull Induction MHD closure model/type "
301 + closure_name +
"/" + closure_type
302 +
" failed to build in model id " + model_id
304 "The conduction closure models available in Vertex-CFD are:\n"
305 + availableClosureModels();
306 throw std::runtime_error(msg);
318 #endif // end VERTEXCFD_FULLINDUCTIONCLOSUREMODELFACTORY_IMPL_HPP