www.mooseframework.org
BreakMeshByBlockGeneratorBase.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
11 #include "InputParameters.h"
12 
13 template <>
16 {
18 
19  params.addParam<std::string>(
20  "interface_name",
21  "interface",
22  "the name of the new interface. Cannot be used whit `split_interface=true`");
23  params.addParam<bool>("split_interface",
24  false,
25  "If true, it create a "
26  "different interface for each block pair.");
27  params.addClassDescription("This is the base class used to split a monolithic"
28  "mesh by blocks pairs");
29 
30  return params;
31 }
32 
34  : MeshGenerator(parameters),
35  _interface_name(getParam<std::string>("interface_name")),
36  _split_interface(getParam<bool>("split_interface"))
37 {
38  // check input consistency
39  if (getParam<bool>("split_interface") && _pars.isParamSetByUser("interface_name"))
40  {
41  mooseError("if split_interface == true, the new interface_name"
42  " cannot be specified by the user. It will be autoamtically assigned");
43  }
44 }
45 
46 boundary_id_type
48 {
49  const std::set<boundary_id_type> & currentBoundaryIds =
50  mesh.get_boundary_info().get_boundary_ids();
51  bool freeBoundaryNotFound = true;
52  boundary_id_type freeId;
53  for (freeId = 0; freeId < std::numeric_limits<boundary_id_type>::max(); freeId++)
54  {
55  if (currentBoundaryIds.count(freeId) == 0)
56  {
57  // bid is not in the set, boundaryID is free
58  freeBoundaryNotFound = false;
59  break;
60  }
61  }
62 
63  if (freeBoundaryNotFound)
64  mooseError("Too many boundaries. Maximum limit exceeded!");
65 
66  return freeId;
67 }
68 
69 std::string
71  const subdomain_id_type & masterBlockID,
72  const subdomain_id_type & slaveBlockID)
73 {
74  std::string master_block_name = mesh.subdomain_name(masterBlockID);
75  std::string slave_block_name = mesh.subdomain_name(slaveBlockID);
76  if (master_block_name.empty())
77  master_block_name = "Block" + std::to_string(masterBlockID);
78  if (slave_block_name.empty())
79  slave_block_name = "Block" + std::to_string(slaveBlockID);
80 
81  return master_block_name + "_" + slave_block_name;
82 }
83 
84 void
86  const std::string & boundaryName)
87 {
88  _bName_bID_set.insert(std::pair<std::string, int>(boundaryName, boundaryID));
89 }
90 
91 void
93  const subdomain_id_type & masterBlockID,
94  const subdomain_id_type & slaveBlockID,
95  std::string & boundaryName,
96  boundary_id_type & boundaryID,
97  BoundaryInfo & boundary_info)
98 {
99  // TODO need to be updated if distributed mesh is implemented
100  // comments are left to ease implementation
101 
102  // mpi barrier
103  // first check which boundary name will be created
104  boundaryName = generateBoundaryName(mesh, masterBlockID, slaveBlockID);
105 
106  // check if the boundary name already exist
107  bool checkBoundaryAlreadyExist = false;
108  for (auto b : _bName_bID_set)
109  {
110  if (b.first.compare(boundaryName) == 0)
111  {
112  boundaryID = b.second;
113  checkBoundaryAlreadyExist = true;
114  }
115  }
116 
117  if (checkBoundaryAlreadyExist)
118  {
119  // mpi barrier end
120  return;
121  }
122  else
123  {
124  boundaryID = findFreeBoundaryId(mesh);
125  mapBoundaryIdAndBoundaryName(boundaryID, boundaryName);
126 
127  boundary_info.sideset_name(boundaryID) = boundaryName;
128 
129  return;
130  }
131 }
void findBoundaryNameAndInd(MeshBase &mesh, const subdomain_id_type &, const subdomain_id_type &, std::string &, boundary_id_type &, BoundaryInfo &)
given the master and slave blocks this method return the appropriate boundary id and name ...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
InputParameters validParams< BreakMeshByBlockGeneratorBase >()
std::set< std::pair< std::string, BoundaryID > > _bName_bID_set
BreakMeshByBlockGeneratorBase(const InputParameters &parameters)
const InputParameters & _pars
Parameters of this object, references the InputParameters stored in the InputParametersWarehouse.
Definition: MooseObject.h:174
bool isParamSetByUser(const std::string &name) const
Method returns true if the parameter was by the user.
void mapBoundaryIdAndBoundaryName(boundary_id_type &, const std::string &)
this method save the boundary name/id pair
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
InputParameters validParams< MeshGenerator >()
Definition: MeshGenerator.C:16
BoundaryID findFreeBoundaryId(MeshBase &mesh)
this method finds the first free boundary id
std::string generateBoundaryName(MeshBase &mesh, const subdomain_id_type &, const subdomain_id_type &)
this method generate the boundary name by assembling subdomain names
MeshGenerators are objects that can modify or add to an existing mesh.
Definition: MeshGenerator.h:30