https://mooseframework.inl.gov
LowerDBlockFromSidesetGenerator.C
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 
11 #include "InputParameters.h"
12 #include "MooseTypes.h"
13 #include "CastUniquePointer.h"
14 #include "MooseMeshUtils.h"
15 
16 #include "libmesh/distributed_mesh.h"
17 #include "libmesh/elem.h"
18 #include "libmesh/parallel_elem.h"
19 #include "libmesh/parallel_node.h"
20 #include "libmesh/compare_elems_by_level.h"
21 #include "libmesh/mesh_communication.h"
22 
23 #include "timpi/parallel_sync.h"
24 
25 #include <set>
26 #include <typeinfo>
27 
29 
32 {
34 
35  params.addRequiredParam<MeshGeneratorName>("input", "The mesh we want to modify");
36  params.addParam<SubdomainID>("new_block_id", "The lower dimensional block id to create");
37  params.addParam<SubdomainName>("new_block_name",
38  "The lower dimensional block name to create (optional)");
39  params.addRequiredParam<std::vector<BoundaryName>>(
40  "sidesets", "The sidesets from which to create the new block");
41 
42  params.addClassDescription("Adds lower dimensional elements on the specified sidesets.");
43 
44  return params;
45 }
46 
48  : MeshGenerator(parameters),
49  _input(getMesh("input")),
50  _sideset_names(getParam<std::vector<BoundaryName>>("sidesets"))
51 {
52 }
53 
54 std::unique_ptr<MeshBase>
56 {
57  std::unique_ptr<MeshBase> mesh = std::move(_input);
58 
59  // Generate a new block id if one isn't supplied.
60  SubdomainID new_block_id = isParamValid("new_block_id")
61  ? getParam<SubdomainID>("new_block_id")
63  try
64  {
67  new_block_id,
68  isParamValid("new_block_name")
69  ? getParam<SubdomainName>("new_block_name")
70  : SubdomainName(),
71  type());
72  }
73  catch (MooseException & e)
74  {
75  if (((std::string)e.what()).compare(0, 12, "The sideset ") == 0)
76  paramError("sidesets", e.what());
77  else
78  mooseError(e.what());
79  }
80 
81  return mesh;
82 }
virtual const char * what() const
Get out the error message.
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition: MooseBase.h:435
void createSubdomainFromSidesets(std::unique_ptr< MeshBase > &mesh, std::vector< BoundaryName > boundary_names, const SubdomainID new_subdomain_id, const SubdomainName new_subdomain_name, const std::string type_name)
Create a new subdomain by generating new side elements from a list of sidesets in a given mesh...
MeshBase & mesh
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
registerMooseObject("MooseApp", LowerDBlockFromSidesetGenerator)
LowerDBlockFromSidesetGenerator(const InputParameters &parameters)
const std::string & type() const
Get the type of this class.
Definition: MooseBase.h:89
static InputParameters validParams()
Definition: MeshGenerator.C:23
Provides a way for users to bail out of the current solve.
Creates lower-dimensional elements on the specified sidesets.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition: MooseBase.h:267
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 optional parameter and a documentation string to the InputParameters object...
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseBase.h:195
SubdomainID getNextFreeSubdomainID(MeshBase &input_mesh)
Checks input mesh and returns max(block ID) + 1, which represents a block ID that is not currently in...
const std::vector< BoundaryName > _sideset_names
a vector of the names of the sidesets to add the lower-D elements to
MeshGenerators are objects that can modify or add to an existing mesh.
Definition: MeshGenerator.h:32