www.mooseframework.org
ValueRangeMarker.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 
15 #include "ValueRangeMarker.h"
16 #include "FEProblem.h"
17 #include "MooseEnum.h"
18 
19 template <>
22 {
24 
25  MooseEnum third_state("DONT_MARK=-1 COARSEN DO_NOTHING REFINE", "DONT_MARK");
26  params.addParam<MooseEnum>(
27  "third_state",
28  third_state,
29  "The Marker state to apply to values in the buffer zone (both ends of the range).");
30  params.addRequiredParam<Real>("lower_bound", "The lower bound value for the range.");
31  params.addRequiredParam<Real>("upper_bound", "The upper bound value for the range.");
32  params.addParam<Real>("buffer_size",
33  0.0,
34  "A buffer zone value added to both ends of the range "
35  "where a third_state marker can be returned.");
36  params.addParam<bool>("invert",
37  false,
38  "If this is true then values inside the range will be "
39  "coarsened, and values outside the range will be "
40  "refined.");
41  params.addRequiredCoupledVar("variable", "The variable whose values are used in this marker.");
42  params.addClassDescription("Mark elements for adaptivity based on the supplied upper and lower "
43  "bounds and the specified variable.");
44  return params;
45 }
46 
48  : QuadraturePointMarker(parameters),
49  _lower_bound(parameters.get<Real>("lower_bound")),
50  _upper_bound(parameters.get<Real>("upper_bound")),
51  _buffer_size(parameters.get<Real>("buffer_size")),
52  _third_state(getParam<MooseEnum>("third_state").getEnum<MarkerValue>()),
53  _inside(getParam<bool>("invert") ? COARSEN : REFINE),
54  _outside(getParam<bool>("invert") ? REFINE : COARSEN),
55 
56  _u(coupledValue("variable"))
57 {
59  mooseError("Invalid bounds specified (upper_bound < lower_bound)");
60 
61  if (_buffer_size < 0.0)
62  mooseError("Buffer size must be non-negative: ", _buffer_size);
63 }
64 
67 {
68  // Is the variable value inside the range?
69  if (_u[_qp] >= _lower_bound && _u[_qp] <= _upper_bound)
70  return _inside;
71 
72  // How about the buffer zone?
74  return _third_state;
75 
76  // Must be outside the range
77  return _outside;
78 }
InputParameters validParams< Marker >()
Definition: Marker.C:25
const VariableValue & _u
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:58
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...
unsigned int _qp
The current quadrature point.
ValueRangeMarker(const InputParameters &parameters)
virtual MarkerValue computeQpMarker() override
Override this to compute a marker value at each quadrature point.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:37
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
InputParameters validParams< ValueRangeMarker >()
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 option parameter and a documentation string to the InputParameters object...
void mooseError(Args &&...args) const
Definition: MooseObject.h:80
MarkerValue _outside
MarkerValue _third_state
MarkerValue _inside