https://mooseframework.inl.gov
Loading...
Searching...
No Matches
HSBoundaryExternalAppHeatFlux.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
12#include "HeatConductionModel.h"
13
15
18{
20
21 params.addRequiredParam<VariableName>(
22 "heat_flux_name",
23 "Name to give the heat flux variable transferred from the external application");
24 params.addParam<bool>(
25 "heat_flux_is_monomial",
26 true,
27 "If true, makes the heat flux variable transferred from the external application to have the "
28 "FE type 'CONSTANT MONOMIAL'. Else, the FE type is 'FIRST LAGRANGE'.");
29 params.addRequiredParam<PostprocessorName>(
30 "perimeter_ext", "Name to give the external application perimeter post-processor");
31 params.addRequiredParam<bool>(
32 "heat_flux_is_inward",
33 "Set to true if the transferred heat flux corresponds to the inward direction on the heat "
34 "structure boundary; else the outward direction");
35
36 params.addClassDescription("Heat structure boundary condition to apply a heat flux transferred "
37 "from another application.");
38
39 return params;
40}
41
43 : HSBoundary(params),
44 _heat_flux_name(getParam<VariableName>("heat_flux_name")),
45 _perimeter_ext_pp_name(getParam<PostprocessorName>("perimeter_ext"))
46{
47}
48
49void
51{
53
54 // HeatStructurePlate and HeatStructureFromFile3D are not yet supported
55 checkComponentOfTypeExistsByName<HeatStructureCylindricalBase>(_hs_name);
56
57 // Check that all boundaries are of type INNER or OUTER
58 if (hasComponentByName<Component2D>(_hs_name))
59 {
63 {
64 const auto boundary_type = getCommonComponent2DExternalBoundaryType();
65 if (boundary_type != Component2D::ExternalBoundaryType::INNER &&
67 logError("The boundaries in 'boundary' must be of an inner/outer type, not of a "
68 "start/end type.");
69 }
70 }
71}
72
73void
75{
76 const HeatStructureInterface & hs = getComponentByName<HeatStructureInterface>(_hs_name);
77 const std::vector<SubdomainName> & subdomain_names =
79
80 const auto fe_type = getParam<bool>("heat_flux_is_monomial") ? libMesh::FEType(CONSTANT, MONOMIAL)
81 : libMesh::FEType(FIRST, LAGRANGE);
82 getTHMProblem().addSimVariable(false, _heat_flux_name, fe_type, subdomain_names);
83}
84
85void
87{
88 // Add external perimeter PP
89 {
90 const std::string class_name = "Receiver";
91 InputParameters params = _factory.getValidParams(class_name);
93 }
94
95 // Add BC
96 {
97 const std::string class_name = "FunctorNeumannBC";
98 InputParameters params = _factory.getValidParams(class_name);
99 params.set<std::vector<BoundaryName>>("boundary") = _boundary;
100 params.set<NonlinearVariableName>("variable") = HeatConductionModel::TEMPERATURE;
101 params.set<MooseFunctorName>("functor") = _heat_flux_name;
102 params.set<MooseFunctorName>("coefficient") = _perimeter_ext_pp_name;
103 params.set<bool>("flux_is_inward") = getParam<bool>("heat_flux_is_inward");
104 getTHMProblem().addBoundaryCondition(class_name, genName(name(), "bc"), params);
105 }
106
107 // Add scale function to use as 'prefactor' in heat rate PP
108 const FunctionName scale_fn_name = genName(name(), "scale_fn");
109 {
110 const std::string class_name = "ParsedFunction";
111 InputParameters params = _factory.getValidParams(class_name);
112 params.set<std::string>("expression") = "sign * P";
113 params.set<std::vector<std::string>>("symbol_names") = {"sign", "P"};
114 if (getParam<bool>("heat_flux_is_inward"))
115 params.set<std::vector<std::string>>("symbol_values") = {"1", _perimeter_ext_pp_name};
116 else
117 params.set<std::vector<std::string>>("symbol_values") = {"-1", _perimeter_ext_pp_name};
118 getTHMProblem().addFunction(class_name, scale_fn_name, params);
119 }
120
121 // Add heat rate PP
122 {
123 const std::string class_name = "SideIntegralFunctorPostprocessor";
124 InputParameters params = _factory.getValidParams(class_name);
125 params.set<std::vector<BoundaryName>>("boundary") = _boundary;
126 params.set<MooseFunctorName>("functor") = _heat_flux_name;
127 params.set<MooseFunctorName>("prefactor") = scale_fn_name;
128 params.set<MooseEnum>("functor_argument") = "qp";
129 params.set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL, EXEC_TIMESTEP_END};
130 getTHMProblem().addPostprocessor(class_name, genSafeName(name(), "integral"), params);
131 }
132}
registerMooseObject("ThermalHydraulicsApp", HSBoundaryExternalAppHeatFlux)
const ExecFlagType EXEC_TIMESTEP_END
const ExecFlagType EXEC_INITIAL
const std::string name
Definition Setup.h:21
virtual const std::vector< SubdomainName > & getSubdomainNames() const
Gets the subdomain names for this component.
Definition Component.C:345
void logError(Args &&... args) const
Logs an error.
Definition Component.h:226
THMProblem & getTHMProblem() const
Gets the THM problem.
Definition Component.C:135
Factory & _factory
The Factory associated with the MooseApp.
Definition Component.h:497
virtual void addFunction(const std::string &type, const std::string &name, InputParameters &parameters)
virtual void addBoundaryCondition(const std::string &bc_name, const std::string &name, InputParameters &parameters)
virtual void addPostprocessor(const std::string &pp_name, const std::string &name, InputParameters &parameters)
InputParameters getValidParams(const std::string &name) const
Heat structure boundary condition to apply a heat flux transferred from another application.
HSBoundaryExternalAppHeatFlux(const InputParameters &params)
const VariableName & _heat_flux_name
Heat flux variable name.
const PostprocessorName & _perimeter_ext_pp_name
External app perimeter post-processor name.
virtual void check() const override
Check the component integrity.
Base class for heat structure boundary components.
Definition HSBoundary.h:19
bool hasCommonComponent2DExternalBoundaryType() const
Returns true if all of the boundaries have the same external boundary type.
Definition HSBoundary.C:83
const std::vector< BoundaryName > & _boundary
Boundary names for which the boundary component applies.
Definition HSBoundary.h:56
bool allComponent2DBoundariesAreExternal() const
Returns true if all of the boundaries are external.
Definition HSBoundary.C:66
void checkAllComponent2DBoundariesAreExternal() const
Logs an error if any boundary is not external.
Definition HSBoundary.C:76
static InputParameters validParams()
Definition HSBoundary.C:15
const std::string & _hs_name
Heat structure name.
Definition HSBoundary.h:59
Component2D::ExternalBoundaryType getCommonComponent2DExternalBoundaryType() const
Gets the common external boundary type.
Definition HSBoundary.C:101
virtual void check() const override
Check the component integrity.
Definition HSBoundary.C:35
static const std::string TEMPERATURE
Interface class for heat structure components.
const GeometricalComponent & getGeometricalComponent() const
Gets the geometrical component inheriting from this interface.
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
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.
std::string genSafeName(const std::string &prefix, const std::string &middle, const std::string &suffix="") const
Build a name from strings that is safe to use in input files (i.e.
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.