https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
30void
36
37void
43
44const unsigned int &
45HeatStructureBase::getIndexFromName(const std::string & name) const
46{
47 return _name_index.at(name);
48}
49
50bool
55
58{
59 if (!isParamValid("solid_properties"))
60 mooseError("ComponentsConvergence may only be used if 'solid_properties' is provided.");
61
63}
64
65void
70
71void
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
112void
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
130void
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
141void
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}
const ExecFlagType EXEC_INITIAL
const ExecFlagType EXEC_NONLINEAR_CONVERGENCE
char ** blocks
const std::string name
Definition Setup.h:21
static InputParameters validParams()
Definition Component2D.C:35
const std::vector< std::string > & getNames() const
Gets the names of the transverse regions.
Definition Component2D.h:50
virtual void check() const override
Check the component integrity.
Definition Component2D.C:47
virtual void init()
Initializes the component.
Definition Component.h:405
virtual const std::vector< SubdomainName > & getSubdomainNames() const
Gets the subdomain names for this component.
Definition Component.C:345
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
THMProblem & getTHMProblem() const
Gets the THM problem.
Definition Component.C:135
Factory & _factory
The Factory associated with the MooseApp.
Definition Component.h:497
std::string nonlinearConvergenceName() const
Nonlinear Convergence name.
Definition Component.h:486
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 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 addMaterial(const std::string &material_name, const std::string &name, InputParameters &parameters)
virtual Convergence & getConvergence(const std::string &name, const THREAD_ID tid=0) const
virtual void addPostprocessor(const std::string &pp_name, const std::string &name, InputParameters &parameters)
InputParameters getValidParams(const std::string &name) const
static const libMesh::FEType & feType()
Get the FE type used for heat conduction.
static const std::string TEMPERATURE
void addAverageElementSizePostprocessor(const SubdomainName &block)
Adds a PP for the average element size on a block.
static InputParameters validParams()
HeatStructureBase(const InputParameters &params)
void addConstantDensitySolidPropertiesMaterial(const UserObjectName &sp_name, const Real &T_ref, unsigned int i_region) const
Adds a ADConstantDensityThermalSolidPropertiesMaterial for a heat structure region.
virtual Convergence * getNonlinearConvergence() const override
Gets the Component's nonlinear Convergence object if it has one.
void addResidualNormPostprocessor(const SubdomainName &block, const UserObjectName &sp_name, Real T_ref)
Adds a residual norm PP for a block.
const unsigned int & getIndexFromName(const std::string &name) const
Get index of the block from its name.
virtual void check() const override
Check the component integrity.
virtual void addMooseObjects() override
virtual void addVariables() override
virtual void init() override
Initializes the component.
std::map< std::string, unsigned int > _name_index
Map from block name to block index.
virtual bool usingSecondOrderMesh() const override
Check if second order mesh is being used by this geometrical component.
Interface class for heat structure components.
void addMooseObjects()
Method to be called in the component's addMooseObjects() method.
void check() const
Method to be called in the component's check() method.
void init()
Method to be called in the component's init() method.
void addVariables()
Method to be called in the component's addVariables() method.
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
void mooseError(Args &&... args) const
bool isParamValid(const std::string &name) const
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.
OrderWrapper order