VertexCFD  0.0-dev
VertexCFD_ConductionClosureModelFactory_impl.hpp
1 #ifndef VERTEXCFD_CONDUCTIONCLOSUREMODELFACTORY_IMPL_HPP
2 #define VERTEXCFD_CONDUCTIONCLOSUREMODELFACTORY_IMPL_HPP
3 
4 #include "conduction/closure_models/VertexCFD_ConductionClosureModelFactory.hpp"
5 
6 #include "closure_models/VertexCFD_Closure_ConstantScalarField.hpp"
7 #include "closure_models/VertexCFD_Closure_ElementLength.hpp"
8 
9 #include "conduction/closure_models/VertexCFD_Closure_ConductionErrorNorms.hpp"
10 #include "conduction/closure_models/VertexCFD_Closure_ConductionExactSolution.hpp"
11 #include "conduction/closure_models/VertexCFD_Closure_ConductionFlux.hpp"
12 #include "conduction/closure_models/VertexCFD_Closure_ConductionThermalConductivity.hpp"
13 #include "conduction/closure_models/VertexCFD_Closure_ConductionTimeDerivative.hpp"
14 #include "conduction/closure_models/VertexCFD_Closure_ConductionTimeStepSize.hpp"
15 #include "conduction/closure_models/VertexCFD_Closure_ConductionVolumetricSource.hpp"
16 
17 namespace VertexCFD
18 {
19 namespace ClosureModel
20 {
21 
22 //---------------------------------------------------------------------------//
23 template<class EvalType, int NumSpaceDim>
24 Teuchos::RCP<std::vector<Teuchos::RCP<PHX::Evaluator<panzer::Traits>>>>
26  const std::string& model_id,
27  const Teuchos::ParameterList& model_params,
28  const panzer::FieldLayoutLibrary&,
29  const Teuchos::RCP<panzer::IntegrationRule>& ir,
30  const Teuchos::ParameterList& ,
31  const Teuchos::ParameterList& ,
32  const Teuchos::RCP<panzer::GlobalData>& ,
33  PHX::FieldManager<panzer::Traits>&) const
34 {
35  constexpr int num_space_dim = NumSpaceDim;
36 
37  auto evaluators = Teuchos::rcp(
38  new std::vector<Teuchos::RCP<PHX::Evaluator<panzer::Traits>>>);
39 
40  if (!model_params.isSublist(model_id))
41  {
42  throw std::runtime_error("Conduction closure model id " + model_id
43  + "not in list.");
44  }
45 
46  // Get closure model list for 'model_id'
47  const Teuchos::ParameterList& closure_model_list
48  = model_params.sublist(model_id);
49 
50  // Check for closure model factory type. If not `Conduction` return empty
51  // evaluator
52  const std::string factory_type
53  = closure_model_list.isType<std::string>("Closure Factory Type")
54  ? closure_model_list.get<std::string>("Closure Factory Type")
55  : "Navier Stokes";
56 
57  if (factory_type != "Conduction")
58  return evaluators;
59 
60  // Adding default closure models to solve conduction equation
61  const std::string default_closure_models
62  = "ConductionTimeDerivative,\nConductionFlux,\n"
63  "ConductionTimeStepSize,\n"
64  "ElementLength.\n";
65 
66  // Conduction time derivative
67  {
68  auto eval_conduction = Teuchos::rcp(
70  evaluators->push_back(eval_conduction);
71  }
72 
73  // Conduction flux
74  {
75  auto eval_conduction
76  = Teuchos::rcp(new ConductionFlux<EvalType, panzer::Traits>(*ir));
77  evaluators->push_back(eval_conduction);
78  }
79 
80  // Time step size
81  {
82  auto eval_conduction = Teuchos::rcp(
84  evaluators->push_back(eval_conduction);
85  }
86 
87  // Element length
88  {
89  auto eval
90  = Teuchos::rcp(new ElementLength<EvalType, panzer::Traits>(*ir));
91  evaluators->push_back(eval);
92  }
93 
94  // Loop over closure models
95  for (const auto& closure_model : closure_model_list)
96  {
97  bool found_model = false;
98 
99  const auto closure_name = closure_model.first;
100  if (closure_name == "Closure Factory Type")
101  continue;
102 
103  // Get closure parameters for current closure model
104  const auto& closure_params
105  = Teuchos::getValue<Teuchos::ParameterList>(closure_model.second);
106 
107  if (closure_params.isType<std::string>("Type"))
108  {
109  const auto closure_type = closure_params.get<std::string>("Type");
110 
111  // Check if 'closure_type' is a default closure model
112  if (default_closure_models.find(closure_type) != std::string::npos)
113  {
114  std::string msg = "\n\nConduction closure model/type '" + closure_name + "'/'" + closure_type
115  + "' found in model id '" + model_id + "' is a default closure model and should not be added to the input file.\n";
116  msg += "The list of default closure models for the conduction equation is:\n";
117  msg += default_closure_models;
118  throw std::runtime_error(msg);
119  }
120 
121  // Error norm
122  if (closure_type == "ConductionErrorNorms")
123  {
124  auto eval = Teuchos::rcp(
126  *ir));
127  evaluators->push_back(eval);
128  found_model = true;
129  }
130 
131  // Exact solution
132  if (closure_type == "ConductionExactSolution")
133  {
134  auto eval
135  = Teuchos::rcp(new ConductionExactSolution<EvalType,
136  panzer::Traits,
137  num_space_dim>(
138  *ir, closure_params));
139  evaluators->push_back(eval);
140  found_model = true;
141  }
142 
143  // Volumetric source
144  if (closure_type == "ConductionVolumetricSource")
145  {
146  auto eval = Teuchos::rcp(
148  *ir, closure_params));
149  evaluators->push_back(eval);
150  found_model = true;
151  }
152 
153  // Constant material properties
154  if (closure_type == "ConstantMaterialProperties")
155  {
156  // Density
157  auto eval_rho = Teuchos::rcp(
159  *ir,
160  "solid_density",
161  closure_params.get<double>("Density Value")));
162  evaluators->push_back(eval_rho);
163 
164  // Cp
165  auto eval_cp = Teuchos::rcp(
167  *ir,
168  "solid_specific_heat_capacity",
169  closure_params.get<double>("Specific Heat Capacity "
170  "Value")));
171  evaluators->push_back(eval_cp);
172 
173  // Thermal conductivity
174  auto eval_k = Teuchos::rcp(
176  *ir, closure_params));
177  evaluators->push_back(eval_k);
178  found_model = true;
179  }
180 
181  // Error message if closure model not found
182  if (!found_model)
183  {
184  std::string msg = "\n\nConduction closure model/type "
185  + closure_name + "/" + closure_type
186  + " failed to build in model id " + model_id
187  + ".\n";
188  msg += "The conduction closure models available in Vertex-CFD are:\n";
189  msg += "ConductionErrorNorms,\n";
190  msg += "ConductionExactSolution,\n";
191  msg += "ConductionVolumetricSource,\n";
192  msg += "ConstantMaterialProperties,\n";
193  msg += "\n";
194 
195  throw std::runtime_error(msg);
196  }
197  }
198  }
199 
200  return evaluators;
201 }
202 
203 //---------------------------------------------------------------------------//
204 
205 } // end namespace ClosureModel
206 } // end namespace VertexCFD
207 
208 #endif // end VERTEXCFD_CONDUCTIONCLOSUREMODELFACTORY_IMPL_HPP
VertexCFD::ClosureModel::ConductionFactory::buildClosureModels
Teuchos::RCP< std::vector< Teuchos::RCP< PHX::Evaluator< panzer::Traits > > > > buildClosureModels(const std::string &model_id, const Teuchos::ParameterList &model_params, const panzer::FieldLayoutLibrary &fl, const Teuchos::RCP< panzer::IntegrationRule > &ir, const Teuchos::ParameterList &default_params, const Teuchos::ParameterList &user_params, const Teuchos::RCP< panzer::GlobalData > &global_data, PHX::FieldManager< panzer::Traits > &fm) const override
Build the closure model evaluators for a specific model.
Definition: VertexCFD_ConductionClosureModelFactory_impl.hpp:25
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23
VertexCFD::ClosureModel::ConductionVolumetricSource
Evaluator that adds a volumetric heat source (or sink) to the energy equation for conduction problems...
Definition: VertexCFD_Closure_ConductionVolumetricSource.hpp:39
VertexCFD::ClosureModel::ConductionTimeStepSize
Compute a stable time‑step size for the conduction equation.
Definition: VertexCFD_Closure_ConductionTimeStepSize.hpp:30
VertexCFD::ClosureModel::ConductionTimeDerivative
Definition: VertexCFD_Closure_ConductionTimeDerivative.hpp:22
VertexCFD::ClosureModel::ConductionThermalConductivity
Evaluates temperature‑dependent thermal conductivity for conduction models.
Definition: VertexCFD_Closure_ConductionThermalConductivity.hpp:38
VertexCFD::ClosureModel::ConductionFlux
Evaluator that computes the conductive heat flux for a given temperature gradient and thermal conduc...
Definition: VertexCFD_Closure_ConductionFlux.hpp:37
VertexCFD::ClosureModel::ConstantScalarField
Definition: VertexCFD_Closure_ConstantScalarField.hpp:26
VertexCFD::ClosureModel::ConductionErrorNorms
Compute error norms between exact and numerical conduction solutions.
Definition: VertexCFD_Closure_ConductionErrorNorms.hpp:34
VertexCFD::ClosureModel::ConductionExactSolution
Evaluator providing the exact analytical solution for a steady conduction problem.
Definition: VertexCFD_Closure_ConductionExactSolution.hpp:40
VertexCFD::ClosureModel::ElementLength
Definition: VertexCFD_Closure_ElementLength.hpp:24