www.mooseframework.org
ValueThresholdMarker.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 "ValueThresholdMarker.h"
11 #include "FEProblem.h"
12 #include "MooseEnum.h"
13 
15 
16 template <>
19 {
21 
22  params.addParam<Real>("coarsen",
23  "The threshold value for coarsening. Elements with variable "
24  "values beyond this will be marked for coarsening.");
25  params.addParam<Real>("refine",
26  "The threshold value for refinement. Elements with variable "
27  "values beyond this will be marked for refinement.");
28  params.addClassDescription(
29  "The the refinement state based on a threshold value compared to the specified variable.");
30  return params;
31 }
32 
34  : QuadraturePointMarker(parameters),
35  _coarsen_set(parameters.isParamValid("coarsen")),
36  _coarsen(parameters.get<Real>("coarsen")),
37  _refine_set(parameters.isParamValid("refine")),
38  _refine(parameters.get<Real>("refine")),
39  _invert(parameters.get<bool>("invert"))
40 {
42  {
43  Real diff = _refine - _coarsen;
44  if ((diff > 0 && _invert) || (diff < 0 && !_invert))
45  mooseError("Invalid combination of refine, coarsen, and invert values specified");
46  }
47 }
48 
51 {
52  if (!_invert)
53  {
54  if (_refine_set && _u[_qp] > _refine)
55  return REFINE;
56 
57  if (_coarsen_set && _u[_qp] < _coarsen)
58  return COARSEN;
59  }
60  else
61  {
62  if (_refine_set && _u[_qp] < _refine)
63  return REFINE;
64 
65  if (_coarsen_set && _u[_qp] > _coarsen)
66  return COARSEN;
67  }
68 
69  return _third_state;
70 }
const VariableValue & _u
Holds the solution at current quadrature points.
registerMooseObject("MooseApp", ValueThresholdMarker)
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:55
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
unsigned int _qp
The current quadrature point.
InputParameters validParams< QuadraturePointMarker >()
InputParameters validParams< ValueThresholdMarker >()
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...
MarkerValue _third_state
The behavior to use when "in-between" other states (what to do on the fringe)