https://mooseframework.inl.gov
Loading...
Searching...
No Matches
HeatSourceBase.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 "HeatSourceBase.h"
11#include "HeatStructureBase.h"
14
17{
19 params.addRequiredParam<std::string>("hs", "Heat structure in which to apply heat source");
20 params.addRequiredParam<std::vector<std::string>>(
21 "regions", "Heat structure regions where heat generation is to be applied");
22 params.addClassDescription("Base class for heat source components");
23 return params;
24}
25
27 : Component(parameters),
28 _hs_name(getParam<std::string>("hs")),
29 _region_names(getParam<std::vector<std::string>>("regions"))
30{
31 checkSizeGreaterThan<std::string>("regions", 0);
32
33 for (auto && region : _region_names)
34 _subdomain_names.push_back(genName(_hs_name, region));
35}
36
37void
39{
41
42 checkComponentOfTypeExists<HeatStructureInterface>("hs");
43
44 if (hasComponent<HeatStructureBase>("hs"))
45 {
46 const HeatStructureBase & hs = getComponent<HeatStructureBase>("hs");
47 for (auto && region : _region_names)
48 if (!hs.hasBlock(region))
49 logError("Region '",
50 region,
51 "' does not exist in heat structure '",
52 getParam<std::string>("hs"),
53 "'.");
54 }
55 else if (hasComponent<HeatStructureFromFile3D>("hs"))
56 {
57 const HeatStructureFromFile3D & hs = getComponent<HeatStructureFromFile3D>("hs");
58 for (auto && region : _region_names)
59 if (!hs.hasRegion(region))
60 logError("Region '",
61 region,
62 "' does not exist in heat structure '",
63 getParam<std::string>("hs"),
64 "'.");
65 }
66 else
67 logError("Heat structure must be of type 'HeatStructureBase' or 'HeatStructureFromFile3D'.");
68}
bool hasBlock(const std::string &name) const
Returns true if there is a transverse region of a given name.
Definition Component2D.C:59
Base class for THM components.
Definition Component.h:32
void logError(Args &&... args) const
Logs an error.
Definition Component.h:226
virtual void check() const
Check the component integrity.
Definition Component.h:416
static InputParameters validParams()
Definition Component.C:18
const std::vector< std::string > & _region_names
Names of the heat structure regions where heat generation is to be applied.
HeatSourceBase(const InputParameters &parameters)
std::vector< SubdomainName > _subdomain_names
Names of the heat structure subdomains corresponding to the given regions.
const std::string & _hs_name
Heat structure name.
static InputParameters validParams()
virtual void check() const override
Check the component integrity.
Base class for 2D generated heat structures.
Heat structure component that loads the mesh from an ExodusII file.
bool hasRegion(const std::string &region) const
Has the given region?
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
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.