Line data Source code
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 : #pragma once 11 : 12 : #include "GeneratedMeshComponent.h" 13 : 14 : class Component2D : public GeneratedMeshComponent 15 : { 16 : public: 17 : /// External boundary type 18 : enum class ExternalBoundaryType 19 : { 20 : INNER = 0, 21 : OUTER = 1, 22 : START = 2, 23 : END = 3 24 : }; 25 : 26 : Component2D(const InputParameters & params); 27 : 28 : virtual void buildMesh() override; 29 : 30 : /** 31 : * Gets the total width of all transverse regions 32 : */ 33 1688 : const Real & getTotalWidth() const { return _total_width; } 34 : 35 : /** 36 : * Gets the number of transverse regions 37 : */ 38 : unsigned int getNumRegions() const { return _n_regions; } 39 : 40 : /** 41 : * Returns true if there is a transverse region of a given name 42 : * 43 : * @param name The name of the transverse region 44 : */ 45 : bool hasBlock(const std::string & name) const; 46 : 47 : /** 48 : * Gets the names of the transverse regions 49 : */ 50 1954 : const std::vector<std::string> & getNames() const { return _names; } 51 : 52 : /** 53 : * Gets the volumes of the transverse regions 54 : */ 55 : const std::vector<Real> & getVolumes() const { return _volume; } 56 : 57 : /** 58 : * Returns true if the supplied boundary is in the given vector 59 : */ 60 : bool isBoundaryInVector(const BoundaryName & boundary_name, 61 : const std::vector<BoundaryName> & boundary_name_vector) const; 62 : 63 : /** 64 : * Returns true if this component has the supplied boundary 65 : * 66 : * @param[in] boundary_name Boundary name to check 67 : */ 68 : bool hasBoundary(const BoundaryName & boundary_name) const; 69 : 70 : /** 71 : * Returns true if this component has the supplied external boundary 72 : * 73 : * @param[in] boundary_name Boundary name to check 74 : */ 75 : bool hasExternalBoundary(const BoundaryName & boundary_name) const; 76 : 77 : /** 78 : * Gets boundary info associated with the component boundary 79 : * 80 : * @param[in] boundary Boundary name of a component boundary 81 : * 82 : * @return The list of tuples (element id, local side id) that is associated with boundary 83 : * `boundary` 84 : */ 85 : const std::vector<std::tuple<dof_id_type, unsigned short int>> & 86 : getBoundaryInfo(const BoundaryName & boundary_name) const; 87 : 88 : /** 89 : * Gets boundary info associated with a external boundary type 90 : * 91 : * @param[in] boundary_type The external boundary type 92 : * @return The list of tuples (element id, local side id) associated the external boundary type 93 : */ 94 : const std::vector<std::tuple<dof_id_type, unsigned short int>> & 95 : getBoundaryInfo(const ExternalBoundaryType & boundary_type) const; 96 : 97 : /** 98 : * Gets the external boundary type of the given boundary 99 : * 100 : * An error is thrown if the supplied boundary name does not exist in this 101 : * component or if the boundary is interior. 102 : * 103 : * @param[in] boundary_name Boundary name for which to get boundary type 104 : */ 105 : ExternalBoundaryType getExternalBoundaryType(const BoundaryName & boundary_name) const; 106 : 107 : /** 108 : * Gets the axial offset for the mesh 109 : */ 110 : Real getAxialOffset() const { return _axial_offset; } 111 : 112 : /** 113 : * Gets the name of an external boundary by type 114 : * 115 : * @param[in] boundary_type The external boundary type 116 : */ 117 : const BoundaryName & getExternalBoundaryName(const ExternalBoundaryType & boundary_type) const; 118 : 119 : /** 120 : * Gets the area for a boundary 121 : */ 122 : const Real & getBoundaryArea(const BoundaryName & boundary_name) const; 123 : 124 : /** 125 : * Computes the area of a radial boundary 126 : * 127 : * @param[in] length Length of the radial boundary 128 : * @param[in] y Transverse position of the surface, which ranges from 129 : * 0 (inner) to total width (outer). 130 : */ 131 : virtual Real computeRadialBoundaryArea(const Real & length, const Real & y) const = 0; 132 : 133 : /** 134 : * Computes the area of an axial boundary 135 : * 136 : * @param[in] y_min Minimum transverse position of the surface, which ranges from 137 : * 0 (inner) to total width (outer). 138 : * @param[in] y_max Maximum transverse position of the surface, which ranges from 139 : * 0 (inner) to total width (outer). 140 : */ 141 : virtual Real computeAxialBoundaryArea(const Real & y_min, const Real & y_max) const = 0; 142 : 143 : protected: 144 : virtual void check() const override; 145 : 146 : /** 147 : * Builds a 2D, first-order mesh 148 : */ 149 : void build2DMesh(); 150 : 151 : /** 152 : * Builds a 2D, second-order mesh 153 : */ 154 : void build2DMesh2ndOrder(); 155 : 156 : /// Number of transverse regions 157 : unsigned int _n_regions; 158 : /// Names of each transverse region 159 : std::vector<std::string> _names; 160 : /// Width of each transverse region 161 : std::vector<Real> _width; 162 : /// Total width of all transverse regions 163 : Real _total_width; 164 : /// Volume of each transverse region 165 : std::vector<Real> _volume; 166 : /// Number of elements in each transverse region 167 : std::vector<unsigned int> _n_part_elems; 168 : /// Total number of transverse elements 169 : unsigned int _total_elem_number; 170 : 171 : /// BC ID of the component (outer) 172 : unsigned int _outer_bc_id; 173 : /// BC ID of the component (inner) 174 : unsigned int _inner_bc_id; 175 : /// BC ID of the component (start) 176 : unsigned int _start_bc_id; 177 : /// BC ID of the component (end) 178 : unsigned int _end_bc_id; 179 : /// BC ID of the interior axial boundaries (per radial section) of the component 180 : std::vector<unsigned int> _interior_axial_per_radial_section_bc_id; 181 : /// BC ID of the axial regions of the outer boundary of the component 182 : std::vector<unsigned int> _axial_outer_bc_id; 183 : /// BC ID of the axial regions of the inner boundary of the component 184 : std::vector<unsigned int> _axial_inner_bc_id; 185 : /// BC ID of the radial regions of the start boundary of the component 186 : std::vector<unsigned int> _radial_start_bc_id; 187 : /// BC ID of the radial regions of the end boundary of the component 188 : std::vector<unsigned int> _radial_end_bc_id; 189 : /// BC ID of the inner radial boundary regions of the component 190 : std::vector<unsigned int> _inner_radial_bc_id; 191 : 192 : /// Boundary name of the outer side of the component 193 : BoundaryName _boundary_name_outer; 194 : /// Boundary name of the inner side of the component 195 : BoundaryName _boundary_name_inner; 196 : /// Boundary name of the start side of the component 197 : BoundaryName _boundary_name_start; 198 : /// Boundary name of the end side of the component 199 : BoundaryName _boundary_name_end; 200 : /// Boundary names of the interior axial boundaries (per radial section) of the component 201 : std::vector<BoundaryName> _boundary_names_interior_axial_per_radial_section; 202 : /// Boundary names of the axial regions of the outer side of the component 203 : std::vector<BoundaryName> _boundary_names_axial_outer; 204 : /// Boundary names of the axial regions of the inner side of the component 205 : std::vector<BoundaryName> _boundary_names_axial_inner; 206 : /// Boundary names of the radial regions of the start side of the component 207 : std::vector<BoundaryName> _boundary_names_radial_start; 208 : /// Boundary names of the radial regions of the end side of the component 209 : std::vector<BoundaryName> _boundary_names_radial_end; 210 : /// Boundary names of the inner radial boundary regions of the component 211 : std::vector<BoundaryName> _boundary_names_inner_radial; 212 : 213 : /// Map of boundary name to boundary area 214 : std::map<BoundaryName, Real> _boundary_name_to_area; 215 : 216 : /// Map of boundary name to list of tuples of element and side IDs for that boundary 217 : std::map<BoundaryName, std::vector<std::tuple<dof_id_type, unsigned short int>>> _boundary_info; 218 : 219 : /// Distance by which to offset the mesh from the component axis 220 : mutable Real _axial_offset; 221 : 222 : private: 223 : public: 224 : static InputParameters validParams(); 225 : 226 : /** 227 : * Gets the MooseEnum corresponding to ExternalBoundaryType 228 : * 229 : * @param[in] default_value Default value; omit to have no default 230 : */ 231 : static MooseEnum getExternalBoundaryTypeMooseEnum(const std::string & default_value = ""); 232 : 233 : /// map of external boundary type string to enum 234 : static const std::map<std::string, ExternalBoundaryType> _external_boundary_type_to_enum; 235 : }; 236 : 237 : namespace THM 238 : { 239 : template <> 240 : Component2D::ExternalBoundaryType stringToEnum(const std::string & s); 241 : }