Line data Source code
1 : /****************************************************************************/ 2 : /* DO NOT MODIFY THIS HEADER */ 3 : /* */ 4 : /* MALAMUTE: MOOSE Application Library for Advanced Manufacturing UTilitiEs */ 5 : /* */ 6 : /* Copyright 2021 - 2024, Battelle Energy Alliance, LLC */ 7 : /* ALL RIGHTS RESERVED */ 8 : /****************************************************************************/ 9 : 10 : #include "VariableGradientRegularization.h" 11 : 12 : registerMooseObject("MalamuteApp", VariableGradientRegularization); 13 : 14 : InputParameters 15 24 : VariableGradientRegularization::validParams() 16 : { 17 24 : InputParameters params = ADVectorKernel::validParams(); 18 24 : params.addClassDescription( 19 : "Performs L2 projection of a variable's gradient onto a new vector variable."); 20 48 : params.addRequiredCoupledVar("regularized_var", "The variable to be regularized."); 21 24 : return params; 22 0 : } 23 : 24 12 : VariableGradientRegularization::VariableGradientRegularization(const InputParameters & parameters) 25 12 : : ADVectorKernel(parameters), _grad_c(adCoupledGradient("regularized_var")) 26 : { 27 12 : } 28 : 29 : ADReal 30 16629760 : VariableGradientRegularization::computeQpResidual() 31 : { 32 16629760 : if (MetaPhysicL::raw_value(_grad_c[_qp].norm()) > libMesh::TOLERANCE) 33 14952448 : return _test[_i][_qp] * (_u[_qp] - _grad_c[_qp]); 34 : else 35 1677312 : return _test[_i][_qp] * _u[_qp]; 36 : }