www.mooseframework.org
BoxMarker.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 
10 #include "BoxMarker.h"
11 #include "MooseUtils.h"
12 
13 registerMooseObject("MooseApp", BoxMarker);
14 
17 {
20  "bottom_left", "The bottom left point (in x,y,z with spaces in-between).");
22  "top_right", "The bottom left point (in x,y,z with spaces in-between).");
23 
24  MooseEnum marker_states = Marker::markerStates();
25 
27  "inside", marker_states, "How to mark elements inside the box.");
29  "outside", marker_states, "How to mark elements outside the box.");
30 
31  params.addClassDescription(
32  "Marks the region inside and outside of a 'box' domain for refinement or coarsening.");
33  return params;
34 }
35 
37  : Marker(parameters),
38  _inside(parameters.get<MooseEnum>("inside").getEnum<MarkerValue>()),
39  _outside(parameters.get<MooseEnum>("outside").getEnum<MarkerValue>()),
40  _bounding_box(MooseUtils::buildBoundingBox(parameters.get<RealVectorValue>("bottom_left"),
41  parameters.get<RealVectorValue>("top_right")))
42 {
43 }
44 
47 {
48  RealVectorValue centroid = _current_elem->vertex_average();
49 
50  if (_bounding_box.contains_point(centroid))
51  return _inside;
52 
53  return _outside;
54 }
registerMooseObject("MooseApp", BoxMarker)
static InputParameters validParams()
Definition: BoxMarker.C:16
MarkerValue _inside
Definition: BoxMarker.h:26
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
Definition: MooseUtils.h:1147
Definition: Marker.h:35
BoundingBox _bounding_box
Definition: BoxMarker.h:29
const Elem *const & _current_elem
Definition: Marker.h:113
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
MarkerValue
This mirrors the main refinement flag values in libMesh in Elem::RefinementState but adds "dont_mark"...
Definition: Marker.h:53
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...
static MooseEnum markerStates()
Helper function for getting the valid refinement flag states a marker can use as a MooseEnum...
Definition: Marker.C:62
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
MarkerValue _outside
Definition: BoxMarker.h:27
BoundingBox buildBoundingBox(const Point &p1, const Point &p2)
Construct a valid bounding box from 2 arbitrary points.
Definition: MooseUtils.C:1226
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...
BoxMarker(const InputParameters &parameters)
Definition: BoxMarker.C:36
static InputParameters validParams()
Definition: Marker.C:19
virtual MarkerValue computeElementMarker() override
Definition: BoxMarker.C:46