https://mooseframework.inl.gov
Loading...
Searching...
No Matches
OrientedSubdomainBoundingBoxGenerator.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
13#include "libmesh/elem.h"
14
16
19{
22
23 MooseEnum location("INSIDE OUTSIDE", "INSIDE");
24
25 params.addRequiredParam<MeshGeneratorName>("input", "The mesh we want to modify");
26 params.addRequiredParam<subdomain_id_type>(
27 "block_id", "Subdomain id to set for inside/outside the bounding box");
28 params.addParam<MooseEnum>(
29 "location", location, "Control of where the subdomain id is to be set");
31 "Defines a subdomain inside or outside of a bounding box with arbitrary orientation.");
32
33 return params;
34}
35
37 const InputParameters & parameters)
38 : MeshGenerator(parameters),
39 OrientedBoxInterface(parameters),
40 _input(getMesh("input")),
41 _location(parameters.get<MooseEnum>("location")),
42 _block_id(parameters.get<subdomain_id_type>("block_id"))
43{
44}
45
46std::unique_ptr<MeshBase>
48{
49 std::unique_ptr<MeshBase> mesh = std::move(_input);
50
51 // Loop over the elements
52 for (const auto & elem : mesh->active_element_ptr_range())
53 {
54 bool contains = containsPoint(elem->vertex_average());
55 if (contains && _location == "INSIDE")
56 elem->subdomain_id() = _block_id;
57 else if (!contains && _location == "OUTSIDE")
58 elem->subdomain_id() = _block_id;
59 }
60
61 mesh->unset_is_prepared();
62 return dynamic_pointer_cast<MeshBase>(mesh);
63}
registerMooseObject("MooseApp", OrientedSubdomainBoundingBoxGenerator)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
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()
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
bool containsPoint(const Point &point)
Test if the supplied point is within the defined oriented bounding box.
static InputParameters validParams()
Class constructor.
MeshGenerator for defining a Subdomain inside or outside of a bounding box with arbitrary orientation...
OrientedSubdomainBoundingBoxGenerator(const InputParameters &parameters)
const subdomain_id_type _block_id
Block ID to assign to the region.
const MooseEnum _location
ID location (inside or outside of the bounding box)
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
MeshBase & mesh