Line data Source code
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 "ActivateElementsCoupled.h" 11 : 12 : registerMooseObject("MooseApp", ActivateElementsCoupled); 13 : 14 : InputParameters 15 14265 : ActivateElementsCoupled::validParams() 16 : { 17 14265 : InputParameters params = ActivateElementsUserObjectBase::validParams(); 18 : 19 14265 : params.addRequiredParam<Real>("activate_value", "The value above which to activate the element"); 20 14265 : params.addRequiredCoupledVar( 21 : "coupled_var", 22 : "The variable value will be used to decide wether an element whould be activated."); 23 42795 : params.addParam<MooseEnum>("activate_type", 24 28530 : MooseEnum("below equal above", "above"), 25 : "Activate element when below or above the activate_value"); 26 14265 : return params; 27 0 : } 28 : 29 0 : ActivateElementsCoupled::ActivateElementsCoupled(const InputParameters & parameters) 30 : : ActivateElementsUserObjectBase(parameters), 31 0 : _coupled_var(coupledValue("coupled_var")), 32 0 : _activate_value( 33 0 : declareRestartableData<Real>("activate_value", getParam<Real>("activate_value"))), 34 0 : _activate_type(getParam<MooseEnum>("activate_type").getEnum<ActivateType>()) 35 : { 36 0 : } 37 : 38 : bool 39 0 : ActivateElementsCoupled::isElementActivated() 40 : { 41 0 : bool is_activated = false; 42 0 : Real avg_val = 0.0; 43 : 44 0 : for (unsigned int qp = 0; qp < _qrule->n_points(); ++qp) 45 0 : avg_val += _coupled_var[qp]; 46 0 : avg_val /= _qrule->n_points(); 47 : 48 0 : switch (_activate_type) 49 : { 50 0 : case ActivateType::BELOW: 51 0 : is_activated = (avg_val < _activate_value); 52 0 : break; 53 : 54 0 : case ActivateType::EQUAL: 55 0 : is_activated = MooseUtils::absoluteFuzzyEqual(avg_val - _activate_value, 0.0); 56 0 : break; 57 : 58 0 : case ActivateType::ABOVE: 59 0 : is_activated = (avg_val > _activate_value); 60 0 : break; 61 : } 62 : 63 0 : return is_activated; 64 : }