www.mooseframework.org
ValueThresholdMarker.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 "ValueThresholdMarker.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 falling in-between the coarsen and refine thresholds.");
30  params.addParam<Real>("coarsen",
31  "The threshold value for coarsening. Elements with variable "
32  "values beyond this will be marked for coarsening.");
33  params.addParam<Real>("refine",
34  "The threshold value for refinement. Elements with variable "
35  "values beyond this will be marked for refinement.");
36  params.addParam<bool>("invert",
37  false,
38  "If this is true then values _below_ 'refine' will be "
39  "refined and _above_ 'coarsen' will be coarsened.");
40  params.addRequiredCoupledVar("variable",
41  "The values of this variable will be compared to "
42  "'refine' and 'coarsen' to see what should be done with "
43  "the element");
44  params.addClassDescription(
45  "The the refinement state based on a threshold value compared to the specified variable.");
46  return params;
47 }
48 
50  : QuadraturePointMarker(parameters),
51  _coarsen_set(parameters.isParamValid("coarsen")),
52  _coarsen(parameters.get<Real>("coarsen")),
53  _refine_set(parameters.isParamValid("refine")),
54  _refine(parameters.get<Real>("refine")),
55 
56  _invert(parameters.get<bool>("invert")),
57  _third_state(getParam<MooseEnum>("third_state").getEnum<MarkerValue>()),
58 
59  _u(coupledValue("variable"))
60 {
62  {
63  Real diff = _refine - _coarsen;
64  if ((diff > 0 && _invert) || (diff < 0 && !_invert))
65  mooseError("Invalid combination of refine, coarsen, and invert values specified");
66  }
67 }
68 
71 {
72  if (!_invert)
73  {
74  if (_refine_set && _u[_qp] > _refine)
75  return REFINE;
76 
77  if (_coarsen_set && _u[_qp] < _coarsen)
78  return COARSEN;
79  }
80  else
81  {
82  if (_refine_set && _u[_qp] < _refine)
83  return REFINE;
84 
85  if (_coarsen_set && _u[_qp] > _coarsen)
86  return COARSEN;
87  }
88 
89  return _third_state;
90 }
InputParameters validParams< Marker >()
Definition: Marker.C:25
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual MarkerValue computeQpMarker() override
Override this to compute a marker value at each quadrature point.
MarkerValue
This mirrors the main refinement flag values in libMesh in Elem::RefinementState but adds "dont_mark"...
Definition: Marker.h:58
const VariableValue & _u
unsigned int _qp
The current quadrature point.
InputParameters validParams< ValueThresholdMarker >()
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.
ValueThresholdMarker(const InputParameters &parameters)
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