/
ValueThresholdMarker.C
70 lines (61 loc) · 2.06 KB
/
ValueThresholdMarker.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html
#include "ValueThresholdMarker.h"
#include "FEProblem.h"
#include "MooseEnum.h"
registerMooseObject("MooseApp", ValueThresholdMarker);
template <>
InputParameters
validParams<ValueThresholdMarker>()
{
InputParameters params = validParams<QuadraturePointMarker>();
params.addParam<Real>("coarsen",
"The threshold value for coarsening. Elements with variable "
"values beyond this will be marked for coarsening.");
params.addParam<Real>("refine",
"The threshold value for refinement. Elements with variable "
"values beyond this will be marked for refinement.");
params.addClassDescription(
"The the refinement state based on a threshold value compared to the specified variable.");
return params;
}
ValueThresholdMarker::ValueThresholdMarker(const InputParameters & parameters)
: QuadraturePointMarker(parameters),
_coarsen_set(parameters.isParamValid("coarsen")),
_coarsen(parameters.get<Real>("coarsen")),
_refine_set(parameters.isParamValid("refine")),
_refine(parameters.get<Real>("refine")),
_invert(parameters.get<bool>("invert"))
{
if (_refine_set && _coarsen_set)
{
Real diff = _refine - _coarsen;
if ((diff > 0 && _invert) || (diff < 0 && !_invert))
mooseError("Invalid combination of refine, coarsen, and invert values specified");
}
}
Marker::MarkerValue
ValueThresholdMarker::computeQpMarker()
{
if (!_invert)
{
if (_refine_set && _u[_qp] > _refine)
return REFINE;
if (_coarsen_set && _u[_qp] < _coarsen)
return COARSEN;
}
else
{
if (_refine_set && _u[_qp] < _refine)
return REFINE;
if (_coarsen_set && _u[_qp] > _coarsen)
return COARSEN;
}
return _third_state;
}