22 params.
addRequiredParam<MeshGeneratorName>(
"input",
"The input mesh that needs to be trimmed.");
23 params.
addParam<BoundaryName>(
"peripheral_trimming_section_boundary",
24 "Boundary formed by peripheral trimming.");
26 "center_trim_starting_index",
27 "center_trim_starting_index>=0 & center_trim_starting_index<12",
28 "Index of the starting center trimming position.");
30 "center_trim_ending_index>=0 & center_trim_ending_index<12",
31 "Index of the ending center trimming position.");
32 params.
addParam<BoundaryName>(
"center_trimming_section_boundary",
33 "Boundary formed by center trimming (external_boundary will be " 34 "assigned if this parameter is not provided).");
35 params.
addParam<BoundaryName>(
"external_boundary",
36 "External boundary of the input mesh prior to the trimming.");
38 "tri_elem_subdomain_name_suffix",
40 "Suffix to the block name used for quad elements that are trimmed/converted into " 41 "triangular elements to avert degenerate quad elements");
43 "tri_elem_subdomain_shift",
44 "Customized id shift to define subdomain ids of the converted triangular elements.");
47 "center_trim_starting_index center_trim_ending_index center_trimming_section_boundary",
51 "Trimmed Boundary Repair");
54 "CartesianMeshTrimmer and HexagonMeshTrimmer.");
61 _input_name(getParam<MeshGeneratorName>(
"input")),
62 _trim_peripheral_region(getParam<
std::vector<unsigned short>>(
"trim_peripheral_region")),
63 _peripheral_trimming_section_boundary(
64 isParamValid(
"peripheral_trimming_section_boundary")
65 ? getParam<BoundaryName>(
"peripheral_trimming_section_boundary")
67 _center_trimming_section_boundary(
68 isParamValid(
"center_trimming_section_boundary")
69 ? getParam<BoundaryName>(
"center_trimming_section_boundary")
71 _external_boundary_name(isParamValid(
"external_boundary")
72 ? getParam<BoundaryName>(
"external_boundary")
74 _tri_elem_subdomain_name_suffix(getParam<SubdomainName>(
"tri_elem_subdomain_name_suffix")),
75 _tri_elem_subdomain_shift(isParamValid(
"tri_elem_subdomain_shift")
78 _input(getMeshByName(_input_name))
85 paramError(
"peripheral_trimming_section_boundary",
86 "this input parameter is not used if peripheral trimming is not performed.");
89 std::unique_ptr<MeshBase>
92 auto replicated_mesh_ptr =
dynamic_cast<ReplicatedMesh *
>(
_input.get());
93 if (!replicated_mesh_ptr)
94 paramError(
"input",
"Input is not a replicated mesh, which is required");
96 ReplicatedMesh &
mesh = *replicated_mesh_ptr;
99 if (hasMeshProperty<Real>(
"input_pitch_meta",
_input_name))
101 if (hasMeshProperty<bool>(
"is_control_drum_meta",
_input_name))
103 getMeshProperty<bool>(
"is_control_drum_meta",
_input_name));
111 "the provided external boundary does not exist in the input mesh.");
113 std::set<subdomain_id_type> subdomain_ids_set;
114 mesh.subdomain_ids(subdomain_ids_set);
120 ? external_boundary_id
125 external_boundary_id,
126 peripheral_trimming_section_boundary_id,
128 mesh.get_boundary_info().sideset_name(peripheral_trimming_section_boundary_id) =
131 else if (hasMeshProperty<Real>(
"pattern_pitch_meta",
_input_name))
138 ? external_boundary_id
145 external_boundary_id,
146 center_trimming_section_boundary_id,
148 mesh.get_boundary_info().sideset_name(center_trimming_section_boundary_id) =
154 mesh.prepare_for_use();
161 const unsigned int num_sides,
162 const unsigned int center_trim_sector_number,
163 const unsigned int trimming_start_sector,
166 const std::set<subdomain_id_type> subdomain_ids_set)
171 std::vector<std::vector<Real>> bdry_pars = {
172 {std::cos((
Real)trimming_start_sector * M_PI / (
Real)num_sides),
173 std::sin((
Real)trimming_start_sector * M_PI / (
Real)num_sides),
175 {-std::cos((
Real)(trimming_start_sector + center_trim_sector_number) * M_PI /
177 -std::sin((
Real)(trimming_start_sector + center_trim_sector_number) * M_PI /
181 for (
unsigned int i = 0; i < bdry_pars.size(); i++)
188 center_trimming_section_boundary_id,
189 external_boundary_id);
193 if (((std::string)e.
what())
194 .compare(
"The input mesh has degenerate quad element before trimming.") == 0)
195 paramError(
"input",
"The input mesh has degenerate quad element before trimming.");
196 else if (((std::string)e.
what())
197 .compare(
"The new subdomain name already exists in the mesh.") == 0)
199 "The new subdomain name already exists in the mesh.");
205 ReplicatedMesh & mesh,
206 const std::vector<unsigned short> trim_peripheral_region,
209 const std::set<subdomain_id_type> subdomain_ids_set)
211 const unsigned int num_sides = trim_peripheral_region.size();
215 const Real unit_length = getMeshProperty<Real>(
"input_pitch_meta",
_input_name) /
216 (num_sides == 6 ? std::sqrt(3.0) : 2.0);
218 const Real multiplier = ((
Real)getMeshProperty<unsigned int>(
"pattern_size",
_input_name) - 1.0) *
219 (num_sides == 6 ? 0.75 : 1.0);
220 const Real ch_length = multiplier * unit_length;
223 std::vector<std::vector<Real>> bdry_pars;
225 bdry_pars = {{1.0 / std::sqrt(3.0), 1.0, -ch_length / std::sqrt(3.0) * 2.0},
226 {-1.0 / std::sqrt(3.0), 1.0, -ch_length / std::sqrt(3.0) * 2.0},
227 {-1.0, 0.0, -ch_length},
228 {-1.0 / std::sqrt(3.0), -1.0, -ch_length / std::sqrt(3.0) * 2.0},
229 {1.0 / std::sqrt(3.0), -1.0, -ch_length / std::sqrt(3.0) * 2.0},
230 {1.0, 0.0, -ch_length}};
232 bdry_pars = {{1.0, 0.0, -ch_length},
233 {0.0, 1.0, -ch_length},
234 {-1.0, 0.0, -ch_length},
235 {0.0, -1.0, -ch_length}};
237 for (
unsigned int i = 0; i < bdry_pars.size(); i++)
238 if (trim_peripheral_region[i])
245 peripheral_trimming_section_boundary_id,
246 external_boundary_id,
247 std::vector<boundary_id_type>(),
252 if (((std::string)e.
what())
253 .compare(
"The input mesh has degenerate quad element before trimming.") == 0)
254 paramError(
"input",
"The input mesh has degenerate quad element before trimming.");
255 else if (((std::string)e.
what())
256 .compare(
"The new subdomain name already exists in the mesh.") == 0)
258 "The new subdomain name already exists in the mesh.");
std::vector< unsigned short > _trim_peripheral_region
Index of the peripheral regions to be trimmed (see moosedocs for indexing scheme) ...
const subdomain_id_type _tri_elem_subdomain_shift
Customized id shift to define subdomain ids of the converted triangular elements. ...
virtual const char * what() const
T & setMeshProperty(const std::string &data_name, Args &&... args)
unsigned int _num_sides
Number of polygon sides.
void peripheralTrimmer(ReplicatedMesh &mesh, const std::vector< unsigned short > trim_peripheral_region, const boundary_id_type external_boundary_id, const boundary_id_type peripheral_trimming_section_boundary_id, const std::set< subdomain_id_type > subdomain_ids_set)
Performs peripheral trimming on the input mesh.
std::unique_ptr< MeshBase > & _input
Reference to input mesh pointer.
static InputParameters validParams()
void lineRemoverMoveNode(libMesh::ReplicatedMesh &mesh, const std::vector< Real > &bdry_pars, const subdomain_id_type block_id_to_remove, const std::set< subdomain_id_type > &subdomain_ids_set, const boundary_id_type trimming_section_boundary_id, const boundary_id_type external_boundary_id, const std::vector< boundary_id_type > &other_boundaries_to_conform=std::vector< boundary_id_type >(), const bool assign_ext_to_new=false, const bool side_to_remove=true)
const BoundaryName _center_trimming_section_boundary
Name of the section formed by center trimming.
std::unique_ptr< MeshBase > generate() override
const SubdomainID INVALID_BLOCK_ID
BoundaryID getBoundaryID(const BoundaryName &boundary_name, const MeshBase &mesh)
static InputParameters validParams()
static const boundary_id_type invalid_id
unsigned short _center_trim_sector_number
Number of remaining sectors.
bool quasiTriElementsFixer(libMesh::ReplicatedMesh &mesh, const std::set< subdomain_id_type > &subdomain_ids_set, const subdomain_id_type tri_elem_subdomain_shift=Moose::INVALID_BLOCK_ID, const SubdomainName tri_elem_subdomain_name_suffix="tri")
std::vector< BoundaryID > getBoundaryIDs(const libMesh::MeshBase &mesh, const std::vector< BoundaryName > &boundary_name, bool generate_unknown, const std::set< BoundaryID > &mesh_boundary_ids)
void paramError(const std::string ¶m, Args... args) const
const BoundaryName _peripheral_trimming_section_boundary
Name of the section formed by peripheral trimming.
const BoundaryName _external_boundary_name
Name/ID of external boundary.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
PolygonMeshTrimmerBase(const InputParameters ¶meters)
A base class that contains common members for Reactor module mesh generators.
const MeshGeneratorName _input_name
Input mesh to be modified.
const SubdomainName _tri_elem_subdomain_name_suffix
SubdomainName suffix used to rename the converted triangular elements.
T & declareMeshProperty(const std::string &data_name, Args &&... args)
short _trimming_start_sector
Index of the sector to start trimming from (counter-clockwise direction)
void centerTrimmer(ReplicatedMesh &mesh, const unsigned int num_sides, const unsigned int center_trim_sector_number, const unsigned int trimming_start_sector, const boundary_id_type external_boundary_id, const boundary_id_type center_trimming_section_boundary_id, const std::set< subdomain_id_type > subdomain_ids_set)
Performs center trimming on the input mesh.