https://mooseframework.inl.gov
HSBoundary.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 "HSBoundary.h"
11 #include "HeatStructureBase.h"
12 #include "MooseUtils.h"
13 
16 {
18 
19  params.addRequiredParam<std::vector<BoundaryName>>(
20  "boundary", "List of boundary names for which this component applies");
21  params.addRequiredParam<std::string>("hs", "Heat structure name");
22 
23  return params;
24 }
25 
27  : BoundaryBase(params),
28 
29  _boundary(getParam<std::vector<BoundaryName>>("boundary")),
30  _hs_name(getParam<std::string>("hs"))
31 {
32 }
33 
34 void
36 {
37  checkComponentOfTypeExistsByName<HeatStructureInterface>(_hs_name);
38 
39  if (hasComponentByName<HeatStructureBase>(_hs_name))
40  {
41  const HeatStructureBase & hs = getComponentByName<HeatStructureBase>(_hs_name);
42 
43  // Check that no perimeter is zero; if so, there is not physically a boundary
44  for (unsigned int i = 0; i < _boundary.size(); i++)
45  {
46  if (hs.hasExternalBoundary(_boundary[i]))
47  {
48  auto hs_side = hs.getExternalBoundaryType(_boundary[i]);
51  {
53  logError("The heat structure side of the heat structure '",
54  _hs_name,
55  "' corresponding to the boundary name '",
56  _boundary[i],
57  "' has a zero perimeter. This can be caused by applying the boundary on the "
58  "axis of symmetry of a cylindrical heat structure.");
59  }
60  }
61  }
62  }
63 }
64 
65 bool
67 {
68  const auto & comp2d = getComponentByName<Component2D>(_hs_name);
69  for (const auto & boundary : _boundary)
70  if (!comp2d.hasExternalBoundary(boundary))
71  return false;
72  return true;
73 }
74 
75 void
77 {
79  logError("The boundaries given in 'boundary' must all be external.");
80 }
81 
82 bool
84 {
85  if (!_boundary.empty())
86  {
87  const auto & comp2d = getComponentByName<Component2D>(_hs_name);
88  const auto common_boundary_type = comp2d.getExternalBoundaryType(_boundary[0]);
89  for (unsigned int i = 1; i < _boundary.size(); i++)
90  {
91  const auto boundary_type = comp2d.getExternalBoundaryType(_boundary[i]);
92  if (boundary_type != common_boundary_type)
93  return false;
94  }
95  return true;
96  }
97  mooseError("No boundaries were supplied in 'boundary'.");
98 }
99 
102 {
104  {
105  const auto & comp2d = getComponentByName<Component2D>(_hs_name);
106  return comp2d.getExternalBoundaryType(_boundary[0]);
107  }
108  else
109  mooseError(
110  "The boundaries supplied in 'boundary' do not have a common external boundary type.");
111 }
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
static InputParameters validParams()
Definition: BoundaryBase.C:13
Component2D::ExternalBoundaryType getCommonComponent2DExternalBoundaryType() const
Gets the common external boundary type.
Definition: HSBoundary.C:101
Base class for components of a boundary type.
Definition: BoundaryBase.h:18
ExternalBoundaryType
External boundary type.
Definition: Component2D.h:18
const std::string & _hs_name
Heat structure name.
Definition: HSBoundary.h:59
void addRequiredParam(const std::string &name, const std::string &doc_string)
void logError(Args &&... args) const
Logs an error.
Definition: Component.h:215
const std::vector< BoundaryName > & _boundary
Boundary names for which the boundary component applies.
Definition: HSBoundary.h:56
bool hasCommonComponent2DExternalBoundaryType() const
Returns true if all of the boundaries have the same external boundary type.
Definition: HSBoundary.C:83
virtual void check() const override
Check the component integrity.
Definition: HSBoundary.C:35
virtual Real getUnitPerimeter(const ExternalBoundaryType &side) const =0
Gets the perimeter of one unit of this heat structure on the specified side.
HSBoundary(const InputParameters &params)
Definition: HSBoundary.C:26
ExternalBoundaryType getExternalBoundaryType(const BoundaryName &boundary_name) const
Gets the external boundary type of the given boundary.
Definition: Component2D.C:496
static InputParameters validParams()
Definition: HSBoundary.C:15
Base class for 2D generated heat structures.
void mooseError(Args &&... args) const
bool hasExternalBoundary(const BoundaryName &boundary_name) const
Returns true if this component has the supplied external boundary.
Definition: Component2D.C:483
void checkAllComponent2DBoundariesAreExternal() const
Logs an error if any boundary is not external.
Definition: HSBoundary.C:76
bool allComponent2DBoundariesAreExternal() const
Returns true if all of the boundaries are external.
Definition: HSBoundary.C:66