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:
30 void findBoundaryName(const MeshBase & mesh,
31 subdomain_id_type primaryBlockID,
32 subdomain_id_type secondaryBlockID,
33 BoundaryName & boundary_name,
34 boundary_id_type boundaryID,
35 BoundaryInfo & boundary_info);
36
38 std::set<std::pair<std::string, BoundaryID>> _bName_bID_set;
39
41 BoundaryName generateBoundaryName(const MeshBase & mesh,
42 subdomain_id_type primaryBlockID,
43 subdomain_id_type secondaryBlockID);
44
46 void mapBoundaryIdAndBoundaryName(boundary_id_type boundaryID, const std::string & boundaryName);
47
49 void addInterface(MeshBase & mesh);
50
60 std::unordered_map<dof_id_type, std::set<subdomain_id_type>> syncConnectedBlocks(
61 const std::unordered_map<dof_id_type, std::vector<dof_id_type>> & node_to_elem_map,
62 const MeshBase & mesh);
63
73 subdomain_id_type blockRestrictedElementSubdomainID(const Elem * elem);
74
76 bool findBlockPairs(subdomain_id_type block_one, subdomain_id_type block_two);
77
79 std::unique_ptr<MeshBase> & _input;
81 std::unordered_set<std::pair<SubdomainID, SubdomainID>> _block_pairs;
83 std::unordered_set<SubdomainID> _block_set;
88
89 using NodeConnectedBlocksPair = std::pair<dof_id_type, std::vector<subdomain_id_type>>;
90 using SubdomainPair = std::pair<subdomain_id_type, subdomain_id_type>;
91 using ElemSide = std::tuple<const Elem *, unsigned int>;
92
94 std::set<SubdomainPair> _neighboring_block_list;
95
98 std::unordered_map<SubdomainPair, std::set<ElemSide>> _subid_pairs_to_sides;
99
101 std::unordered_map<std::pair<subdomain_id_type, subdomain_id_type>, boundary_id_type>
103};
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
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.
std::pair< dof_id_type, std::vector< subdomain_id_type > > NodeConnectedBlocksPair
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
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
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
MeshBase & mesh