https://mooseframework.inl.gov
Loading...
Searching...
No Matches
BlockToMeshConverterGenerator.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 "CastUniquePointer.h"
12#include "libmesh/elem.h"
13#include "MooseMeshUtils.h"
14
16
19{
21
23 "Converts one or more blocks (subdomains) from a mesh into a stand-alone mesh with a "
24 "single block in it.");
25
26 params.addRequiredParam<MeshGeneratorName>("input", "The mesh we want to modify");
27 params.addRequiredParam<std::vector<SubdomainName>>(
28 "target_blocks",
29 "The (list of) blocks (or 'subdomains') we wish to have moved to a new mesh (by name, not "
30 "ID)");
31
32 return params;
33}
34
36 : MeshGenerator(parameters),
37 _input(getMesh("input")),
38 _target_blocks(getParam<std::vector<SubdomainName>>("target_blocks"))
39{
40}
41
42std::unique_ptr<MeshBase>
44{
45 std::unique_ptr<MeshBase> mesh = std::move(_input);
46
47 auto new_mesh = buildMeshBaseObject();
48
49 try
50 {
52 }
53 catch (MooseException & e)
54 {
55 paramError("target_blocks", e.what());
56 }
57
58 return dynamic_pointer_cast<MeshBase>(new_mesh);
59}
registerMooseObject("MooseApp", BlockToMeshConverterGenerator)
Creates a new mesh out of one or more subdomains/blocks from another mesh.
BlockToMeshConverterGenerator(const InputParameters &parameters)
const std::vector< SubdomainName > _target_blocks
Blocks to extract to form a mesh.
std::unique_ptr< MeshBase > & _input
Mesh that comes from another generator.
std::unique_ptr< MeshBase > generate() override
Generate / modify the 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...
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.
MeshGenerators are objects that can modify or add to an existing mesh.
static InputParameters validParams()
std::unique_ptr< MeshBase > buildMeshBaseObject(unsigned int dim=libMesh::invalid_uint)
Build a MeshBase object whose underlying type will be determined by the Mesh input file block.
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:457
Provides a way for users to bail out of the current solve.
virtual const char * what() const
Get out the error message.
MeshBase & mesh
void convertBlockToMesh(MeshBase &source_mesh, MeshBase &target_mesh, const std::vector< SubdomainName > &target_blocks)
Convert a list of blocks in a given mesh to a standalone new mesh.