https://mooseframework.inl.gov
Loading...
Searching...
No Matches
BreakMeshByBlockGenerator.h
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#pragma once
11
12#include "MeshGenerator.h"
13#include <unordered_set>
14
15/*
16 * A mesh generator to split a mesh by a set of blocks
17 */
19{
20public:
22
24
25 std::unique_ptr<MeshBase> generate() override;
26
27private:
32
35 void findBoundaryName(const MeshBase & mesh,
36 subdomain_id_type primaryBlockID,
37 subdomain_id_type secondaryBlockID,
38 BoundaryName & boundary_name,
39 boundary_id_type boundaryID,
40 BoundaryInfo & boundary_info);
41
43 std::set<std::pair<std::string, BoundaryID>> _bName_bID_set;
44
46 BoundaryName generateBoundaryName(const MeshBase & mesh,
47 subdomain_id_type primaryBlockID,
48 subdomain_id_type secondaryBlockID);
49
51 void mapBoundaryIdAndBoundaryName(boundary_id_type boundaryID, const std::string & boundaryName);
52
54 void addInterface(MeshBase & mesh);
55
65 std::unordered_map<dof_id_type, std::set<subdomain_id_type>> syncConnectedBlocks(
66 const std::unordered_map<dof_id_type, std::vector<dof_id_type>> & node_to_elem_map,
67 const MeshBase & mesh);
68
78 subdomain_id_type blockRestrictedElementSubdomainID(const Elem * elem);
79
81 bool findBlockPairs(subdomain_id_type block_one, subdomain_id_type block_two);
82
84 std::unique_ptr<MeshBase> & _input;
86 std::string _interface_name;
90 std::unordered_set<std::pair<SubdomainID, SubdomainID>> _block_pairs;
92 std::unordered_set<SubdomainID> _block_set;
102 const BoundaryName _interface_transition_name;
105
106 using NodeConnectedBlocksPair = std::pair<dof_id_type, std::vector<subdomain_id_type>>;
107 using SubdomainPair = std::pair<subdomain_id_type, subdomain_id_type>;
108 using ElemSide = std::tuple<const Elem *, unsigned int>;
109
111 std::set<SubdomainPair> _neighboring_block_list;
112
115 std::unordered_map<SubdomainPair, std::set<ElemSide>> _subid_pairs_to_sides;
116
118 std::unordered_map<std::pair<subdomain_id_type, subdomain_id_type>, boundary_id_type>
120};
std::unordered_set< SubdomainID > _block_set
set of the blocks to split the mesh on
std::set< std::pair< std::string, BoundaryID > > _bName_bID_set
A container holding (boundary name, boundary ID) associations.
std::unordered_map< dof_id_type, std::set< subdomain_id_type > > syncConnectedBlocks(const std::unordered_map< dof_id_type, std::vector< dof_id_type > > &node_to_elem_map, const MeshBase &mesh)
Synchronizes connected blocks across all MPI ranks.
std::unique_ptr< MeshBase > & _input
the mesh to modify
const bool _surrounding_blocks_restricted
whether interfaces will be generated surrounding blocks
subdomain_id_type blockRestrictedElementSubdomainID(const Elem *elem)
This is a helper method to avoid recoding the same if everywhere.
BoundaryName generateBoundaryName(const MeshBase &mesh, subdomain_id_type primaryBlockID, subdomain_id_type secondaryBlockID)
this method generate the boundary name by assembling subdomain names
const bool _add_transition_interface
whether to add a boundary when splitting the mesh
std::unordered_map< SubdomainPair, std::set< ElemSide > > _subid_pairs_to_sides
Map from a pair of block ids to a set of ElemSide tuples.
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
const bool _split_transition_interface
whether to split the transition boundary between the blocks and the rest of the mesh
std::pair< dof_id_type, std::vector< subdomain_id_type > > NodeConnectedBlocksPair
const BoundaryName _interface_transition_name
the name of the transition interface
void findBoundaryName(const MeshBase &mesh, subdomain_id_type primaryBlockID, subdomain_id_type secondaryBlockID, BoundaryName &boundary_name, boundary_id_type boundaryID, BoundaryInfo &boundary_info)
given the primary and secondary blocks this method return the appropriate boundary id and name
std::tuple< const Elem *, unsigned int > ElemSide
static InputParameters validParams()
std::pair< subdomain_id_type, subdomain_id_type > SubdomainPair
bool _split_interface
the flag to split the interface by block
std::unordered_set< std::pair< SubdomainID, SubdomainID > > _block_pairs
set of subdomain pairs between which interfaces will be generated.
void addInterface(MeshBase &mesh)
generate the new boundary interface
bool findBlockPairs(subdomain_id_type block_one, subdomain_id_type block_two)
Return true if block_one and block_two are found in users' provided block_pairs list.
std::set< SubdomainPair > _neighboring_block_list
Set of pairs of block ids between which new boundary sides are created.
const bool _block_pairs_restricted
whether interfaces will be generated between block pairs
std::unordered_map< std::pair< subdomain_id_type, subdomain_id_type >, boundary_id_type > _subid_pairs_to_boundary_id
Map from a pair of block ids to the corresponding boundary id.
void mapBoundaryIdAndBoundaryName(boundary_id_type boundaryID, const std::string &boundaryName)
this method save the boundary name/id pair
std::string _interface_name
the name of the new interface
const bool _add_interface_on_two_sides
whether to add two sides interface boundaries
void checkInputParameter()
check that if split_interface==true interface_id and interface_name are not set by the user.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
MeshGenerators are objects that can modify or add to an existing mesh.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131