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 15322 : GradientJumpIndicator::validParams() 16 : { 17 15322 : InputParameters params = InternalSideIndicator::validParams(); 18 15322 : params.addClassDescription( 19 : "Compute the jump of the solution gradient across element boundaries."); 20 45966 : params.addParam<bool>("variable_is_FV", 21 30644 : 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 15322 : params.addRelationshipManager( 27 : "ElementSideNeighborLayers", 28 : Moose::RelationshipManagerType::ALGEBRAIC, 29 0 : [](const InputParameters & obj_params, InputParameters & rm_params) { 30 1507 : rm_params.set<unsigned short>("layers") = obj_params.get<bool>("variable_is_FV") ? 2 : 1; 31 1507 : }); 32 : 33 15322 : return params; 34 0 : } 35 : 36 552 : GradientJumpIndicator::GradientJumpIndicator(const InputParameters & parameters) 37 552 : : InternalSideIndicator(parameters) 38 : { 39 552 : } 40 : 41 : Real 42 3051174 : GradientJumpIndicator::computeQpIntegral() 43 : { 44 3051174 : 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 3051174 : if (_var.hasBlocks(_neighbor_elem->subdomain_id()) && hasBlocks(_neighbor_elem->subdomain_id())) 49 : { 50 3048958 : if (_var.isFV()) 51 : jump = 52 156384 : (MetaPhysicL::raw_value(_var.gradient( 53 78192 : Moose::ElemArg{_current_elem, /*correct_skewness=*/false}, Moose::currentState())) - 54 78192 : MetaPhysicL::raw_value( 55 234576 : _var.gradient(Moose::ElemArg{_neighbor_elem, false}, Moose::currentState()))) * 56 78192 : _normals[_qp]; 57 : else 58 2970766 : jump = (_grad_u[_qp] - _grad_u_neighbor[_qp]) * _normals[_qp]; 59 : } 60 : 61 3051174 : return jump * jump; 62 : }