https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ActivateElementsCoupled.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
11
13
16{
18
19 params.addRequiredParam<Real>("activate_value", "The value above which to activate the element");
21 "coupled_var",
22 "The variable value will be used to decide wether an element whould be activated.");
23 params.addParam<MooseEnum>("activate_type",
24 MooseEnum(getActivateTypeOptions(), "above"),
25 "Activate element when below or above the activate_value");
26 return params;
27}
28
31 _coupled_var(coupledValue("coupled_var")),
32 _activate_value(
33 declareRestartableData<Real>("activate_value", getParam<Real>("activate_value"))),
34 _activate_type(getParam<MooseEnum>("activate_type").getEnum<ActivateType>())
35{
36}
37
38bool
40{
41 bool is_activated = false;
42 Real avg_val = 0.0;
43
44 for (unsigned int qp = 0; qp < _qrule->n_points(); ++qp)
45 avg_val += _coupled_var[qp];
46 avg_val /= _qrule->n_points();
47
48 switch (_activate_type)
49 {
50 case ActivateType::BELOW:
51 is_activated = (avg_val < _activate_value);
52 break;
53
54 case ActivateType::EQUAL:
55 is_activated = MooseUtils::absoluteFuzzyEqual(avg_val - _activate_value, 0.0);
56 break;
57
58 case ActivateType::ABOVE:
59 is_activated = (avg_val > _activate_value);
60 break;
61 }
62
63 return is_activated;
64}
registerMooseObject("MooseApp", ActivateElementsCoupled)
const VariableValue & _coupled_var
variable value to decide wether an element whould be activated
const Real _activate_value
variable value to decide wether an element whould be activated
ActivateElementsCoupled(const InputParameters &parameters)
virtual bool isElementActivated() override
static InputParameters validParams()
const QBase *const & _qrule
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
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 addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55