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 "FVBoundedValueConstraint.h" 11 : 12 : #include "MooseVariableScalar.h" 13 : #include "MooseVariableFV.h" 14 : #include "Assembly.h" 15 : 16 : registerMooseObject("MooseApp", FVBoundedValueConstraint); 17 : 18 : InputParameters 19 14290 : FVBoundedValueConstraint::validParams() 20 : { 21 14290 : InputParameters params = FVScalarLagrangeMultiplierConstraint::validParams(); 22 14290 : params.addClassDescription( 23 : "This class is used to enforce a min or max value for a finite volume variable"); 24 14290 : params.setDocString("phi0", "The min or max bound"); 25 : // Define the min/max enumeration 26 14290 : MooseEnum type_options("lower_than=0 higher_than=1"); 27 14290 : params.addRequiredParam<MooseEnum>( 28 : "bound_type", type_options, "Whether a minimum or a maximum bound"); 29 28580 : return params; 30 14290 : } 31 : 32 13 : FVBoundedValueConstraint::FVBoundedValueConstraint(const InputParameters & parameters) 33 13 : : FVScalarLagrangeMultiplierConstraint(parameters), _bound_type(getParam<MooseEnum>("bound_type")) 34 : { 35 13 : } 36 : 37 : ADReal 38 2240 : FVBoundedValueConstraint::computeQpResidual() 39 : { 40 2240 : if (_bound_type == BoundType::LOWER_THAN && _u[_qp] > _phi0) 41 0 : return _var(makeElemArg(_current_elem), determineState()) - _phi0; 42 2240 : else if (_bound_type == BoundType::HIGHER_THAN && _u[_qp] < _phi0) 43 3168 : return _phi0 - _var(makeElemArg(_current_elem), determineState()); 44 : else 45 656 : return 0; 46 : }