https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ThresholdElementSubdomainModifier.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
14{
16
17 params.addRequiredParam<Real>("threshold",
18 "The value above (or below) which to change the element subdomain");
19 params.addParam<MooseEnum>("criterion_type",
20 MooseEnum("BELOW EQUAL ABOVE", "ABOVE"),
21 "Criterion to use for the threshold");
22 params.addRequiredParam<SubdomainID>("subdomain_id",
23 "The subdomain ID of the element when the criterion is met");
24 params.addParam<SubdomainID>(
25 "complement_subdomain_id",
26 "The subdomain ID of the element when the criterion is not met. If not provided, the element "
27 "subdomain ID will not be modified if the criterion is not met.");
28 return params;
29}
30
32 const InputParameters & parameters)
33 : ElementSubdomainModifier(parameters),
34 _threshold(getParam<Real>("threshold")),
35 _criterion_type(getParam<MooseEnum>("criterion_type").getEnum<CriterionType>()),
36 _subdomain_id(getParam<SubdomainID>("subdomain_id")),
37 _complement_subdomain_id(isParamValid("complement_subdomain_id")
38 ? getParam<SubdomainID>("complement_subdomain_id")
39 : Moose::INVALID_BLOCK_ID)
40{
41}
42
45{
46 Real criterion = computeValue();
47
48 bool criterion_met = false;
49 switch (_criterion_type)
50 {
52 criterion_met = MooseUtils::absoluteFuzzyEqual(criterion - _threshold, 0);
53 break;
54
56 criterion_met = criterion < _threshold;
57 break;
58
60 criterion_met = criterion > _threshold;
61 break;
62 }
63
64 return criterion_met ? _subdomain_id : _complement_subdomain_id;
65}
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 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
ThresholdElementSubdomainModifier(const InputParameters &parameters)
const Real _threshold
Threshold to modify the element subdomain ID.
enum ThresholdElementSubdomainModifier::CriterionType _criterion_type
virtual SubdomainID computeSubdomainID() override
Compute the subdomain ID of the current element.
const SubdomainID _subdomain_id
Target subdomain ID.
virtual Real computeValue()=0
Compute the value used in the criterion.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...