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 "GradientJumpIndicator.h" 11 : 12 : registerMooseObject("MooseApp", GradientJumpIndicator); 13 : 14 : InputParameters 15 15252 : GradientJumpIndicator::validParams() 16 : { 17 15252 : InputParameters params = InternalSideIndicator::validParams(); 18 15252 : params.addClassDescription( 19 : "Compute the jump of the solution gradient across element boundaries."); 20 45756 : params.addParam<bool>("variable_is_FV", 21 30504 : false, 22 : "Whether the solution variable is using a finite volume discretization"); 23 : 24 : // We need more ghosting to compute finite volume gradients across from a boundary 25 : // We do not use skewness correction here, therefore avoiding needing three layers 26 15252 : params.addRelationshipManager( 27 : "ElementSideNeighborLayers", 28 : Moose::RelationshipManagerType::ALGEBRAIC, 29 0 : [](const InputParameters & obj_params, InputParameters & rm_params) { 30 1402 : rm_params.set<unsigned short>("layers") = obj_params.get<bool>("variable_is_FV") ? 2 : 1; 31 1402 : }); 32 : 33 15252 : return params; 34 0 : } 35 : 36 517 : GradientJumpIndicator::GradientJumpIndicator(const InputParameters & parameters) 37 517 : : InternalSideIndicator(parameters) 38 : { 39 517 : } 40 : 41 : Real 42 2811966 : GradientJumpIndicator::computeQpIntegral() 43 : { 44 2811966 : Real jump = 0; 45 : // If the variable is not defined in the neighbor cell, we cant define the block 46 : // If the indicator is not defined in the neighbor cell, we should not be looking at it 47 : mooseAssert(_neighbor_elem, "Should have a neighbor"); 48 2811966 : if (_var.hasBlocks(_neighbor_elem->subdomain_id()) && hasBlocks(_neighbor_elem->subdomain_id())) 49 : { 50 2809998 : if (_var.isFV()) 51 : jump = 52 139008 : (MetaPhysicL::raw_value(_var.gradient( 53 69504 : Moose::ElemArg{_current_elem, /*correct_skewness=*/false}, Moose::currentState())) - 54 69504 : MetaPhysicL::raw_value( 55 208512 : _var.gradient(Moose::ElemArg{_neighbor_elem, false}, Moose::currentState()))) * 56 69504 : _normals[_qp]; 57 : else 58 2740494 : jump = (_grad_u[_qp] - _grad_u_neighbor[_qp]) * _normals[_qp]; 59 : } 60 : 61 2811966 : return jump * jump; 62 : }