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 
18 {
20 
21  params.addParam<Real>("coarsen",
22  "The threshold value for coarsening. Elements with variable "
23  "values beyond this will be marked for coarsening.");
24  params.addParam<Real>("refine",
25  "The threshold value for refinement. Elements with variable "
26  "values beyond this will be marked for refinement.");
27  params.addClassDescription(
28  "The refinement state based on a threshold value compared to the specified variable.");
29  return params;
30 }
31 
33  : QuadraturePointMarker(parameters),
34  _coarsen_set(parameters.isParamValid("coarsen")),
35  _coarsen(parameters.get<Real>("coarsen")),
36  _refine_set(parameters.isParamValid("refine")),
37  _refine(parameters.get<Real>("refine")),
38  _invert(parameters.get<bool>("invert"))
39 {
41  {
42  Real diff = _refine - _coarsen;
43  if ((diff > 0 && _invert) || (diff < 0 && !_invert))
44  mooseError("Invalid combination of refine, coarsen, and invert values specified");
45  }
46 }
47 
50 {
51  if (!_invert)
52  {
53  if (_refine_set && _u[_qp] > _refine)
54  return REFINE;
55 
56  if (_coarsen_set && _u[_qp] < _coarsen)
57  return COARSEN;
58  }
59  else
60  {
61  if (_refine_set && _u[_qp] < _refine)
62  return REFINE;
63 
64  if (_coarsen_set && _u[_qp] > _coarsen)
65  return COARSEN;
66  }
67 
68  return _third_state;
69 }
const VariableValue & _u
Holds the solution at current quadrature points.
registerMooseObject("MooseApp", ValueThresholdMarker)
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
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:53
unsigned int _qp
The current quadrature point.
static InputParameters validParams()
static InputParameters validParams()
ValueThresholdMarker(const InputParameters &parameters)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
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)