https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PinUniverseEngUnit.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://www.mooseframework.org
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 "PinUniverseEngUnit.h"
11#include "CSGZCylinder.h"
12#include "CSGUtils.h"
13
14namespace CSG
15{
16
18 const std::vector<Real> & ring_radii,
19 const std::vector<std::string> & fill_mats)
20 : CSGUniverseEngUnit(name), _ring_radii(ring_radii), _fill_mats(fill_mats)
21{
22 unsigned int n_radial = _ring_radii.size();
23
24 if (n_radial == 0)
25 mooseError("Pin universe engineering unit must have at least one ring radius defined");
26
27 // Check radii in ascending order
28 if (n_radial > 1)
29 for (const auto i : make_range(_ring_radii.size() - 1))
30 if (_ring_radii[i] >= _ring_radii[i + 1])
31 mooseError("Pin engineering unit must have ring radii defined in strictly ascending order");
32
33 if (_fill_mats.size() != n_radial + 1)
34 mooseError("Size of region IDs must be one more than the number of radial rings in pin");
35}
36
37std::unordered_map<std::string, AttributeVariant>
39{
40 return {{"ring_radii", _ring_radii}, {"fill_mats", _fill_mats}};
41}
42
43std::unique_ptr<CSGUniverseEngUnit>
45{
46 return std::make_unique<PinUniverseEngUnit>(_name, _ring_radii, _fill_mats);
47}
48
49void
51{
52 CSG::CSGRegion inner_region, outer_region, cell_region;
53
54 // Add surfaces and regions for each pin ring
55 // Iterate through all rings and define all corresponding surfaces, regions, and cells
56 for (const auto i : index_range(_fill_mats))
57 {
58 const bool build_ring_surf = i < _ring_radii.size();
59 if (build_ring_surf)
60 {
61 // Add surfaces corresponding to pin rings
62 const auto & radius = _ring_radii[i];
63 const auto surf_name = _name + "_radial_ring_" + std::to_string(i);
64 std::unique_ptr<CSG::CSGSurface> ring_surf_ptr =
65 std::make_unique<CSG::CSGZCylinder>(surf_name, 0, 0, radius);
66 const auto & ring_surf = _internal_base->addSurface(std::move(ring_surf_ptr));
67
68 // Define radial region for each incremental radial ring
69 if (inner_region.getRegionType() == CSG::CSGRegion::RegionType::EMPTY)
70 {
71 // We are in the innermost radial region, the radial region is inner_region
72 inner_region = CSGUtils::getInnerRegion({ring_surf}, Point(0, 0, 0));
73 cell_region = inner_region;
74 }
75 else
76 {
77 // For all other regions, the radial region is the intersection of inner_region and
78 // outer_region
79 outer_region = ~inner_region;
80 inner_region = CSGUtils::getInnerRegion({ring_surf}, Point(0, 0, 0));
81 cell_region = inner_region & outer_region;
82 }
83 }
84 else
85 cell_region = ~inner_region;
86
87 // Define all cells within pin domain
88 auto cell_name = _name + "_cell_radial_" + std::to_string(i);
89 const auto fill_mat = _fill_mats[i];
90 _internal_base->createCell(cell_name, fill_mat, cell_region);
91 }
92}
93
94} // namespace CSG
void mooseError(Args &&... args)
const std::string name
Definition Setup.h:21
std::unique_ptr< CSGBase > _internal_base
RegionType getRegionType() const
void expandUnit() override
Represent the pin cell as a single universe that contains cells that define each region of the pin ce...
const std::vector< Real > _ring_radii
List of ring radii of pin cell.
std::unique_ptr< CSGUniverseEngUnit > clone() const override
Return a deep copy of this unit.
std::vector< std::string > _fill_mats
Region IDs of pin cell.
std::unordered_map< std::string, AttributeVariant > getAttributes() const override
Return the pin engineering unit attributes for this object.
PinUniverseEngUnit(const std::string &name, const std::vector< Real > &ring_radii, const std::vector< std::string > &fill_mats)
Constructor for PinUniverseEngUnit.
CSG::CSGRegion getInnerRegion(const std::vector< std::reference_wrapper< const CSG::CSGSurface > > &surfaces, const libMesh::Point &origin)
const Real radius