https://mooseframework.inl.gov
HeatConductionModel.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "HeatConductionModel.h"
11 #include "THMProblem.h"
12 #include "Factory.h"
13 #include "Component.h"
14 #include "ThermalHydraulicsApp.h"
15 #include "HeatStructureInterface.h"
17 
18 using namespace libMesh;
19 
22 {
24  params.addPrivateParam<THMProblem *>("_thm_problem");
25  params.addPrivateParam<HeatStructureInterface *>("_hs");
26  params.addRequiredParam<Real>("scaling_factor_temperature",
27  "Scaling factor for solid temperature variable.");
28  params.registerBase("THM:heat_conduction_model");
29  return params;
30 }
31 
32 registerMooseObject("ThermalHydraulicsApp", HeatConductionModel);
33 
34 const std::string HeatConductionModel::DENSITY = "density";
35 const std::string HeatConductionModel::TEMPERATURE = "T_solid";
36 const std::string HeatConductionModel::THERMAL_CONDUCTIVITY = "thermal_conductivity";
37 const std::string HeatConductionModel::SPECIFIC_HEAT_CONSTANT_PRESSURE = "specific_heat";
38 
40 
42  : MooseObject(params),
43  _sim(*params.getCheckedPointerParam<THMProblem *>("_thm_problem")),
44  _factory(_app.getFactory()),
45  _hs_interface(*params.getCheckedPointerParam<HeatStructureInterface *>("_hs")),
46  _geometrical_component(
47  dynamic_cast<GeometricalComponent &>(_hs_interface)), // TODO: do something safer
48  _comp_name(name())
49 {
50 }
51 
52 void
54 {
55  const auto & subdomain_names = _geometrical_component.getSubdomainNames();
56  const Real & scaling_factor = getParam<Real>("scaling_factor_temperature");
57 
58  _sim.addSimVariable(true, TEMPERATURE, _fe_type, subdomain_names, scaling_factor);
59 }
60 
61 void
63 {
64  const auto & subdomain_names = _geometrical_component.getSubdomainNames();
66 }
67 
68 void
70 {
72  const auto & material_names =
73  _geometrical_component.getParam<std::vector<std::string>>("materials");
74 
75  for (std::size_t i = 0; i < blocks.size(); i++)
76  {
77  std::string class_name = "ADSolidMaterial";
78  InputParameters params = _factory.getValidParams(class_name);
79  params.set<std::vector<SubdomainName>>("block") = {blocks[i]};
80  params.set<std::vector<VariableName>>("T") = {TEMPERATURE};
81  params.set<UserObjectName>("properties") = material_names[i];
82  _sim.addMaterial(class_name, genName(blocks[i], "mat"), params);
83  }
84 }
85 
86 void
88 {
90 
91  // add transient term
93  {
94  std::string class_name = "ADHeatConductionTimeDerivative";
95  InputParameters pars = _factory.getValidParams(class_name);
96  pars.set<NonlinearVariableName>("variable") = TEMPERATURE;
97  pars.set<std::vector<SubdomainName>>("block") = blocks;
98  pars.set<MaterialPropertyName>("specific_heat") = SPECIFIC_HEAT_CONSTANT_PRESSURE;
99  pars.set<MaterialPropertyName>("density_name") = DENSITY;
100  pars.set<bool>("use_displaced_mesh") = false;
101  _sim.addKernel(class_name, genName(_comp_name, "td"), pars);
102  }
103  // add diffusion term
104  {
105  std::string class_name = "ADHeatConduction";
106  InputParameters pars = _factory.getValidParams(class_name);
107  pars.set<NonlinearVariableName>("variable") = TEMPERATURE;
108  pars.set<std::vector<SubdomainName>>("block") = blocks;
109  pars.set<MaterialPropertyName>("thermal_conductivity") = THERMAL_CONDUCTIVITY;
110  pars.set<bool>("use_displaced_mesh") = false;
111  _sim.addKernel(class_name, genName(_comp_name, "hc"), pars);
112  }
113 }
114 
115 void
117 {
120 
121  const auto & blocks = hs_cyl.getSubdomainNames();
122  const auto & position = hs_cyl.getPosition();
123  const auto & direction = hs_cyl.getDirection();
124 
125  // add transient term
127  {
128  std::string class_name = "ADHeatConductionTimeDerivativeRZ";
129  InputParameters pars = _factory.getValidParams(class_name);
130  pars.set<NonlinearVariableName>("variable") = TEMPERATURE;
131  pars.set<std::vector<SubdomainName>>("block") = blocks;
132  pars.set<MaterialPropertyName>("specific_heat") = SPECIFIC_HEAT_CONSTANT_PRESSURE;
133  pars.set<MaterialPropertyName>("density_name") = DENSITY;
134  pars.set<bool>("use_displaced_mesh") = false;
135  pars.set<Point>("axis_point") = position;
136  pars.set<RealVectorValue>("axis_dir") = direction;
137  _sim.addKernel(class_name, genName(_comp_name, "td"), pars);
138  }
139  // add diffusion term
140  {
141  std::string class_name = "ADHeatConductionRZ";
142  InputParameters pars = _factory.getValidParams(class_name);
143  pars.set<NonlinearVariableName>("variable") = TEMPERATURE;
144  pars.set<std::vector<SubdomainName>>("block") = blocks;
145  pars.set<MaterialPropertyName>("thermal_conductivity") = THERMAL_CONDUCTIVITY;
146  pars.set<bool>("use_displaced_mesh") = false;
147  pars.set<Point>("axis_point") = position;
148  pars.set<RealVectorValue>("axis_dir") = direction;
149  _sim.addKernel(class_name, genName(_comp_name, "hc"), pars);
150  }
151 }
virtual void addHeatEquationXYZ()
Add heat conduction equation for cartesian coordinate system.
Specialization of FEProblem to run with component subsystem.
Definition: THMProblem.h:18
registerMooseObject("ThermalHydraulicsApp", HeatConductionModel)
static const std::string DENSITY
std::string genName(const std::string &prefix, unsigned int id, const std::string &suffix="") const
Build a name from a prefix, number and possible suffix.
char ** blocks
void addPrivateParam(const std::string &name, const T &value)
virtual void addMaterial(const std::string &material_name, const std::string &name, InputParameters &parameters)
HeatConductionModel(const InputParameters &params)
T & set(const std::string &name, bool quiet_mode=false)
virtual void addInitialConditions()
Add initial conditions.
FunctionName getInitialT() const
Gets the initial temperature function name.
virtual RealVectorValue getDirection() const
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...
virtual void addKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
const std::string _comp_name
Name of the component.
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addFunctionIC(const VariableName &var_name, const std::string &func_name, const std::vector< SubdomainName > &block_names)
Definition: Simulation.C:532
virtual void addMaterials()
Add materials used by this model.
void registerBase(const std::string &value)
void addSimVariable(bool nl, const VariableName &name, libMesh::FEType fe_type, Real scaling_factor=1.0)
Queues a variable of type MooseVariableScalar to be added to the nonlinear or aux system...
Definition: Simulation.C:271
Base class for cylindrical heat structure components.
static const std::string THERMAL_CONDUCTIVITY
static const std::string TEMPERATURE
const std::string name
Definition: Setup.h:20
bool problemIsTransient() const
Whether the problem is transient.
Definition: Component.h:252
virtual void addHeatEquationRZ()
Add heat conduction equation for RZ coordinate system.
Factory & _factory
The Factory associated with the MooseApp.
static InputParameters validParams()
const T & getParam(const std::string &name) const
Interface class for heat structure components.
GeometricalComponent & _geometrical_component
The geometrical component that built this class.
virtual void addVariables()
Add field variables used by this model.
static const std::string SPECIFIC_HEAT_CONSTANT_PRESSURE
HeatStructureInterface & _hs_interface
The heat structure interface that built this class.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Intermediate class for components that have mesh.
static libMesh::FEType _fe_type
virtual const std::vector< SubdomainName > & getSubdomainNames() const
Gets the subdomain names for this component.
Definition: Component.C:307
static InputParameters validParams()
Provides functions to setup the heat conduction model.