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