https://mooseframework.inl.gov
HeatStructureBase.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 "HeatStructureBase.h"
11 #include "ConstantFunction.h"
12 
15 {
18 
19  params.addParam<Real>("T_rel_step_tol", 1e-5, "Temperature relative step tolerance");
20  params.addParam<Real>("res_tol", 1e-5, "Residual tolerance");
21 
22  return params;
23 }
24 
26  : Component2D(params), HeatStructureInterface(this), _number_of_hs(_n_regions)
27 {
28 }
29 
30 void
32 {
35 }
36 
37 void
39 {
42 }
43 
44 const unsigned int &
45 HeatStructureBase::getIndexFromName(const std::string & name) const
46 {
47  return _name_index.at(name);
48 }
49 
50 bool
52 {
54 }
55 
58 {
59  if (!isParamValid("solid_properties"))
60  mooseError("ComponentsConvergence may only be used if 'solid_properties' is provided.");
61 
63 }
64 
65 void
67 {
69 }
70 
71 void
73 {
75 
76  if (isParamValid("solid_properties"))
77  {
78  const auto sp_names = getParam<std::vector<UserObjectName>>("solid_properties");
79  const auto T_ref = getParam<std::vector<Real>>("solid_properties_T_ref");
80  for (unsigned int i = 0; i < sp_names.size(); i++)
81  addConstantDensitySolidPropertiesMaterial(sp_names[i], T_ref[i], i);
82 
83  // add objects needed for ComponentsConvergence
85  const auto & blocks = getSubdomainNames();
86  for (const auto i : make_range(blocks.size()))
87  {
89  addMaximumFunctorPostprocessor("hs_T_step", blocks[i] + "_T_step", T_ref[i], {blocks[i]});
90  addResidualNormPostprocessor(blocks[i], sp_names[i], T_ref[i]);
91  }
92 
93  std::vector<PostprocessorName> pp_names;
94  std::vector<std::string> descriptions;
95  std::vector<Real> tolerances;
96  for (const auto i : make_range(blocks.size()))
97  {
98  pp_names.push_back(blocks[i] + "_T_step");
99  descriptions.push_back("T step (" + blocks[i] + ")");
100  tolerances.push_back(getParam<Real>("T_rel_step_tol"));
101  }
102  for (const auto i : make_range(blocks.size()))
103  {
104  pp_names.push_back(blocks[i] + "_res");
105  descriptions.push_back("residual (" + blocks[i] + ")");
106  tolerances.push_back(getParam<Real>("res_tol"));
107  }
108  addMultiPostprocessorConvergence(pp_names, descriptions, tolerances);
109  }
110 }
111 
112 void
114  const Real & T_ref,
115  unsigned int i_region) const
116 {
117  const auto blocks = getSubdomainNames();
118  const auto region_names = getNames();
119 
120  const std::string class_name = "ADConstantDensityThermalSolidPropertiesMaterial";
121  InputParameters params = _factory.getValidParams(class_name);
122  params.set<std::vector<SubdomainName>>("block") = {blocks[i_region]};
123  params.set<std::vector<VariableName>>("temperature") = {HeatConductionModel::TEMPERATURE};
124  params.set<UserObjectName>("sp") = sp_name;
125  params.set<Real>("T_ref") = T_ref;
127  class_name, genName(name(), class_name, region_names[i_region]), params);
128 }
129 
130 void
132 {
133  const std::string class_name = "AverageElementSize";
134  InputParameters params = _factory.getValidParams(class_name);
135  params.set<std::vector<SubdomainName>>("block") = {block};
136  params.set<ExecFlagEnum>("execute_on") = EXEC_INITIAL;
137  params.set<std::vector<OutputName>>("outputs") = {"none"};
138  getTHMProblem().addPostprocessor(class_name, block + "_havg", params);
139 }
140 
141 void
143  const UserObjectName & sp_name,
144  Real T_ref)
145 {
146  const std::string class_name = "NormalizedHeatStructureResidualNorm";
147  InputParameters params = _factory.getValidParams(class_name);
148  params.set<VariableName>("variable") = HeatConductionModel::TEMPERATURE;
149  params.set<std::vector<SubdomainName>>("block") = {block};
150  params.set<MooseEnum>("norm_type") = "l_inf";
151  params.set<Real>("T_ref") = T_ref;
152  params.set<UserObjectName>("solid_properties") = sp_name;
153  params.set<PostprocessorName>("ref_elem_size") = block + "_havg";
154  params.set<ExecFlagEnum>("execute_on") = EXEC_NONLINEAR_CONVERGENCE;
155  params.set<std::vector<OutputName>>("outputs") = {"none"};
156  getTHMProblem().addPostprocessor(class_name, block + "_res", params);
157 }
void addConstantDensitySolidPropertiesMaterial(const UserObjectName &sp_name, const Real &T_ref, unsigned int i_region) const
Adds a ADConstantDensityThermalSolidPropertiesMaterial for a heat structure region.
void addMaximumFunctorPostprocessor(const std::string &functor_name, const std::string &pp_name, const Real normalization, const std::vector< SubdomainName > &subdomains)
Adds a Postprocessor to compute the maximum of a functor over some domain.
Definition: Component.C:252
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.
const ExecFlagType EXEC_NONLINEAR_CONVERGENCE
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
char ** blocks
THMProblem & getTHMProblem() const
Gets the THM problem.
Definition: Component.C:135
virtual void check() const override
Check the component integrity.
Definition: Component2D.C:47
virtual void addMaterial(const std::string &material_name, const std::string &name, InputParameters &parameters)
T & set(const std::string &name, bool quiet_mode=false)
InputParameters getValidParams(const std::string &name) const
OrderWrapper order
const unsigned int & getIndexFromName(const std::string &name) const
Get index of the block from its name.
SECOND
virtual void addPostprocessor(const std::string &pp_name, const std::string &name, InputParameters &parameters)
void addAverageElementSizePostprocessor(const SubdomainName &block)
Adds a PP for the average element size on a block.
void check() const
Method to be called in the component&#39;s check() method.
const std::string & name() const
virtual Convergence & getConvergence(const std::string &name, const THREAD_ID tid=0) const
static const std::string TEMPERATURE
const std::string name
Definition: Setup.h:21
static InputParameters validParams()
std::string nonlinearConvergenceName() const
Nonlinear Convergence name.
Definition: Component.h:486
virtual Convergence * getNonlinearConvergence() const override
Gets the Component&#39;s nonlinear Convergence object if it has one.
void addMultiPostprocessorConvergence(const std::vector< PostprocessorName > &postprocessors, const std::vector< std::string > &descriptions, const std::vector< Real > &tolerances)
Adds a MultiPostprocessorConvergence for nonlinear convergence for the component. ...
Definition: Component.C:269
virtual void init()
Initializes the component.
Definition: Component.h:405
HeatStructureBase(const InputParameters &params)
Interface class for heat structure components.
static const libMesh::FEType & feType()
Get the FE type used for heat conduction.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static InputParameters validParams()
void addNonlinearStepFunctorMaterial(const std::string &functor_name, const std::string &property, bool functor_is_ad)
Adds a functor material to compute the absolute value of the change (step) of some functor between no...
Definition: Component.C:236
void init()
Method to be called in the component&#39;s init() method.
Factory & _factory
The Factory associated with the MooseApp.
Definition: Component.h:497
void addMooseObjects()
Method to be called in the component&#39;s addMooseObjects() method.
void addVariables()
Method to be called in the component&#39;s addVariables() method.
IntRange< T > make_range(T beg, T end)
virtual void check() const override
Check the component integrity.
virtual void addVariables() override
virtual bool usingSecondOrderMesh() const override
Check if second order mesh is being used by this geometrical component.
void mooseError(Args &&... args) const
static InputParameters validParams()
Definition: Component2D.C:35
bool isParamValid(const std::string &name) const
virtual const std::vector< SubdomainName > & getSubdomainNames() const
Gets the subdomain names for this component.
Definition: Component.C:345
void addResidualNormPostprocessor(const SubdomainName &block, const UserObjectName &sp_name, Real T_ref)
Adds a residual norm PP for a block.
std::map< std::string, unsigned int > _name_index
Map from block name to block index.
virtual void addMooseObjects() override
virtual void init() override
Initializes the component.
const std::vector< std::string > & getNames() const
Gets the names of the transverse regions.
Definition: Component2D.h:50
const ExecFlagType EXEC_INITIAL