https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ErrorFractionMarker.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
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 "ErrorFractionMarker.h"
11
12#include "libmesh/error_vector.h"
13
15
18{
20 params.addRangeCheckedParam<Real>("coarsen",
21 0,
22 "coarsen>=0 & coarsen<=1",
23 "Elements within this percentage of the min error "
24 "will be coarsened. Must be between 0 and 1!");
25 params.addRangeCheckedParam<Real>("refine",
26 0,
27 "refine>=0 & refine<=1",
28 "Elements within this percentage of the max error will "
29 "be refined. Must be between 0 and 1!");
30
31 params.addParam<bool>("clear_extremes",
32 true,
33 "Whether or not to clear the extremes during each error calculation. "
34 " Changing this to `false` will result in the global extremes ever "
35 "encountered during the run to be used as the min and max error.");
36
37 params.addClassDescription("Marks elements for refinement or coarsening based on the fraction of "
38 "the min/max error from the supplied indicator.");
39 return params;
40}
41
43 : IndicatorMarker(parameters),
44 _coarsen(parameters.get<Real>("coarsen")),
45 _refine(parameters.get<Real>("refine")),
46 _clear_extremes(parameters.get<bool>("clear_extremes")),
47 _max(0),
48 _min(std::numeric_limits<Real>::max())
49{
50}
51
52void
54{
56 {
57 _min = std::numeric_limits<Real>::max();
58 _max = 0;
59 }
60
61 // First find the max and min error
62 for (const auto & val : _error_vector)
63 {
64 _min = std::min(_min, static_cast<Real>(val));
65 _max = std::max(_max, static_cast<Real>(val));
66 }
67
68 _delta = _max - _min;
69 _refine_cutoff = (1.0 - _refine) * _max;
71}
72
75{
76 Real error = _error_vector[_current_elem->id()];
77
78 if (error > _refine_cutoff)
79 return REFINE;
80 else if (error < _coarsen_cutoff)
81 return COARSEN;
82
83 return DO_NOTHING;
84}
registerMooseObject("MooseApp", ErrorFractionMarker)
virtual MarkerValue computeElementMarker() override
virtual void markerSetup() override
Is called before any element looping is started so any "global" computation can be done.
ErrorFractionMarker(const InputParameters &parameters)
static InputParameters validParams()
ErrorVector & _error_vector
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
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 addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
const Elem *const & _current_elem
Pointer to the current element being considered in the marker element-based loop.
Definition Marker.h:122
MarkerValue
This mirrors the main refinement flag values in libMesh in Elem::RefinementState but adds "dont_mark"...
Definition Marker.h:60
@ REFINE
Definition Marker.h:64
@ DO_NOTHING
Definition Marker.h:63
@ COARSEN
Definition Marker.h:62