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 : #include "StitchBoundaryMeshGenerator.h" 11 : #include "CastUniquePointer.h" 12 : #include "MooseUtils.h" 13 : #include "libmesh/unstructured_mesh.h" 14 : 15 : registerMooseObject("MooseApp", StitchBoundaryMeshGenerator); 16 : 17 : InputParameters 18 14301 : StitchBoundaryMeshGenerator::validParams() 19 : { 20 14301 : InputParameters params = StitchMeshGeneratorBase::validParams(); 21 14301 : params.addRequiredParam<MeshGeneratorName>("input", "The mesh we want to modify"); 22 14301 : params.renameParam("stitch_boundaries_pairs", 23 : "stitch_boundaries_pair", 24 : "Pair of boundaries to be stitched together."); 25 14301 : params.addClassDescription("Allows a pair of boundaries to be stitched together."); 26 : 27 14301 : return params; 28 0 : } 29 : 30 18 : StitchBoundaryMeshGenerator::StitchBoundaryMeshGenerator(const InputParameters & parameters) 31 18 : : StitchMeshGeneratorBase(parameters), _input(getMesh("input")) 32 : { 33 18 : if (_stitch_boundaries_pairs.size() != 1 && _stitch_boundaries_pairs[0].size() != 2) 34 0 : paramError("stitch_boundaries_pair", "Can only stitch two boundaries together."); 35 18 : } 36 : 37 : std::unique_ptr<MeshBase> 38 18 : StitchBoundaryMeshGenerator::generate() 39 : { 40 : std::unique_ptr<UnstructuredMesh> mesh = 41 18 : dynamic_pointer_cast<UnstructuredMesh>(std::move(_input)); 42 : 43 18 : const bool use_binary_search = (_algorithm == "BINARY"); 44 : 45 : // stitch_surfaces only recognizes node_set boundaries 46 18 : mesh->get_boundary_info().build_node_list_from_side_list(); 47 : 48 : // Check that boundaries exist 49 18 : const auto first_bid = getBoundaryIdToStitch(*mesh, name(), _stitch_boundaries_pairs[0][0]); 50 18 : const auto second_bid = getBoundaryIdToStitch(*mesh, name(), _stitch_boundaries_pairs[0][1]); 51 : 52 : // Stitch the boundaries 53 18 : mesh->stitch_surfaces(first_bid, 54 : second_bid, 55 : TOLERANCE, 56 18 : _clear_stitched_boundary_ids, 57 18 : getParam<bool>("verbose_stitching"), 58 : use_binary_search, 59 36 : getParam<Real>("stitching_hmin_tolerance_factor")); 60 : 61 18 : mesh->set_isnt_prepared(); 62 36 : return dynamic_pointer_cast<MeshBase>(mesh); 63 18 : }