www.mooseframework.org
OrientedSubdomainBoundingBox.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
16 #include "MooseMesh.h"
17 
18 template <>
21 {
24 
25  MooseEnum location("INSIDE OUTSIDE", "INSIDE");
26  params.addRequiredParam<SubdomainID>("block_id",
27  "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");
30 
31  return params;
32 }
33 
35  : MeshModifier(parameters),
36  OrientedBoxInterface(parameters),
37  _location(parameters.get<MooseEnum>("location")),
38  _block_id(parameters.get<SubdomainID>("block_id"))
39 
40 {
41 }
42 
43 void
45 {
46  // Check that we have access to the mesh
47  if (!_mesh_ptr)
48  mooseError("_mesh_ptr must be initialized before calling SubdomainBoundingBox::modify()");
49 
50  // Loop over the elements
51  for (const auto & elem : _mesh_ptr->getMesh().active_element_ptr_range())
52  {
53  bool contains = containsPoint(elem->centroid());
54  if (contains && _location == "INSIDE")
55  elem->subdomain_id() = _block_id;
56  else if (!contains && _location == "OUTSIDE")
57  elem->subdomain_id() = _block_id;
58  }
59 }
bool containsPoint(const Point &point)
Test if the supplied point is within the defined oriented bounding box.
subdomain_id_type SubdomainID
Definition: MooseTypes.h:77
MeshModifiers are objects that can modify or add to an existing mesh.
Definition: MeshModifier.h:31
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
MooseMesh * _mesh_ptr
Pointer to the mesh.
Definition: MeshModifier.h:74
InputParameters validParams< OrientedSubdomainBoundingBox >()
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:2355
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:37
OrientedSubdomainBoundingBox(const InputParameters &parameters)
Class constructor.
const SubdomainID _block_id
Block ID to assign to the region.
void mooseError(Args &&...args) const
Definition: MooseObject.h:80
const MooseEnum _location
ID location (inside of outside of box)
virtual void modify() override
Pure virtual modify function MUST be overridden by children classes.
InputParameters validParams< MeshModifier >()
Definition: MeshModifier.C:20
InputParameters validParams< OrientedBoxInterface >()