https://mooseframework.inl.gov
Loading...
Searching...
No Matches
HexagonMeshTrimmer.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 "HexagonMeshTrimmer.h"
11#include "MathUtils.h"
12#include "MooseMeshUtils.h"
13
14// C++ includes
15#include <cmath> // provides round, not std::round (see http://www.cplusplus.com/reference/cmath/round/)
16
18
21{
23 params.addRangeCheckedParam<std::vector<unsigned short>>(
24 "trim_peripheral_region",
25 std::vector<unsigned short>(6, 0),
26 "trim_peripheral_region<=1",
27 "Whether the peripheral region on each of the six sides will be trimmed "
28 "in an assembly "
29 "mesh. See documentation for numbering convention.");
30 params.addParamNamesToGroup("trim_peripheral_region", "Peripheral Trimming");
31 params.addClassDescription("This HexagonMeshTrimmer object performs peripheral and/or "
32 "across-center (0, 0, 0) trimming for "
33 "assembly or core 2D meshes generated by PatternedHexMG.");
34
35 return params;
36}
37
39 : PolygonMeshTrimmerBase(parameters)
40{
43 isParamValid("center_trim_starting_index")
44 ? MathUtils::euclideanMod(getParam<short>("center_trim_starting_index") - 3, 12)
45 : 12;
47 isParamValid("center_trim_ending_index")
48 ? MathUtils::euclideanMod(getParam<short>("center_trim_ending_index") - 3, 12)
49 : 12;
50 if ((_trimming_start_sector == 12 && _trimming_end_sector != 12) ||
52 paramError("center_trim_starting_index",
53 "this parameter must be provided along with center_trim_ending_index.");
56 else
60 paramError("center_trim_starting_index",
61 "the remaining mesh after center trimming defined by this parameter and "
62 "center_trim_ending_index must be equal or smaller than half of the input mesh.");
64 paramError("center_trimming_section_boundary",
65 "this input parameter is not used if center trimming is not "
66 "performed.");
67}
68
69std::unique_ptr<MeshBase>
71{
72 // Check if input mesh is trimmable
73 if (hasMeshProperty<bool>("hexagon_peripheral_trimmability", _input_name) &&
74 hasMeshProperty<bool>("hexagon_center_trimmability", _input_name))
75 {
76 if (!getMeshProperty<bool>("hexagon_peripheral_trimmability", _input_name) &&
77 std::accumulate(_trim_peripheral_region.begin(), _trim_peripheral_region.end(), 0) > 0)
78 paramError("input", "The input mesh does not have a trimmable peripheral region.");
79 if (!getMeshProperty<bool>("hexagon_center_trimmability", _input_name) &&
81 paramError("input", "The input mesh cannot be trimmed through its center.");
82 }
83 else
84 paramError("input",
85 "The input mesh is not compatible with HexagonMeshTrimmer because "
86 "the trimmability mesh meta data are absent.");
87
89}
registerMooseObject("ReactorApp", HexagonMeshTrimmer)
This HexagonMeshTrimmer object takes in a hexagonal assembly or core mesh and perform peripheral and/...
std::unique_ptr< MeshBase > generate() override
static InputParameters validParams()
HexagonMeshTrimmer(const InputParameters &parameters)
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
void addClassDescription(const std::string &doc_string)
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
void paramError(const std::string &param, Args... args) const
bool isParamValid(const std::string &name) const
This PolygonMeshTrimmerBase is the base class for CartesianMeshTrimmer and HexagonMeshTrimmer,...
unsigned short _center_trim_sector_number
Number of remaining sectors.
const MeshGeneratorName _input_name
Input mesh to be modified.
const BoundaryName _center_trimming_section_boundary
Name of the section formed by center trimming.
unsigned int _num_sides
Number of polygon sides.
std::unique_ptr< MeshBase > generate() override
std::vector< unsigned short > _trim_peripheral_region
Index of the peripheral regions to be trimmed (see moosedocs for indexing scheme)
short _trimming_end_sector
Index of the sector to end trimming at (counter-clockwise direction)
short _trimming_start_sector
Index of the sector to start trimming from (counter-clockwise direction)
static InputParameters validParams()
std::size_t euclideanMod(T1 dividend, T2 divisor)