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 "PenaltyInterfaceDiffusion.h" 11 : 12 : registerMooseObject("MooseApp", PenaltyInterfaceDiffusion); 13 : registerMooseObject("MooseApp", ADPenaltyInterfaceDiffusion); 14 : registerMooseObject("MooseApp", VectorPenaltyInterfaceDiffusion); 15 : registerMooseObject("MooseApp", ADVectorPenaltyInterfaceDiffusion); 16 : 17 : template <typename T, bool is_ad> 18 : InputParameters 19 57696 : PenaltyInterfaceDiffusionTempl<T, is_ad>::validParams() 20 : { 21 57696 : InputParameters params = GenericInterfaceKernelTempl<T, is_ad>::validParams(); 22 57696 : params.addRequiredParam<Real>( 23 : "penalty", "The penalty that penalizes jump between primary and neighbor variables."); 24 57696 : params.addParam<MaterialPropertyName>( 25 : "jump_prop_name", "the name of the material property that calculates the jump."); 26 57696 : params.addClassDescription( 27 : "A penalty-based interface condition that forces" 28 : "the continuity of variables and the flux equivalence across an interface."); 29 57696 : return params; 30 0 : } 31 : 32 : template <typename T, bool is_ad> 33 331 : PenaltyInterfaceDiffusionTempl<T, is_ad>::PenaltyInterfaceDiffusionTempl( 34 : const InputParameters & parameters) 35 : : GenericInterfaceKernelTempl<T, is_ad>(parameters), 36 331 : _penalty(this->template getParam<Real>("penalty")), 37 662 : _jump(isParamValid("jump_prop_name") 38 331 : ? &this->template getGenericMaterialProperty<T, is_ad>("jump_prop_name") 39 662 : : nullptr) 40 : { 41 331 : } 42 : 43 : template <typename T, bool is_ad> 44 : GenericReal<is_ad> 45 74296 : PenaltyInterfaceDiffusionTempl<T, is_ad>::computeQpResidual(Moose::DGResidualType type) 46 : { 47 74296 : GenericReal<is_ad> r = 0; 48 : 49 74296 : Moose::GenericType<T, is_ad> jump_value = 0; 50 : 51 74296 : if (_jump != nullptr) 52 8884 : jump_value = (*_jump)[_qp]; 53 : else 54 65412 : jump_value = _u[_qp] - _neighbor_value[_qp]; 55 : 56 74296 : switch (type) 57 : { 58 37274 : case Moose::Element: 59 37274 : r = _test[_i][_qp] * _penalty * jump_value; 60 37274 : break; 61 : 62 37022 : case Moose::Neighbor: 63 37022 : r = _test_neighbor[_i][_qp] * -_penalty * jump_value; 64 37022 : break; 65 : } 66 : 67 74404 : return r; 68 108 : } 69 : 70 : template <typename T, bool is_ad> 71 : Real 72 448996 : PenaltyInterfaceDiffusionTempl<T, is_ad>::computeQpJacobian(Moose::DGJacobianType type) 73 : { 74 448996 : Real jac = 0; 75 : 76 448996 : switch (type) 77 : { 78 112384 : case Moose::ElementElement: 79 112384 : jac = _test[_i][_qp] * _penalty * _phi[_j][_qp]; 80 112384 : break; 81 : 82 112204 : case Moose::ElementNeighbor: 83 112204 : jac = _test[_i][_qp] * _penalty * -_phi_neighbor[_j][_qp]; 84 112204 : break; 85 : 86 112204 : case Moose::NeighborElement: 87 112204 : jac = _test_neighbor[_i][_qp] * -_penalty * _phi[_j][_qp]; 88 112204 : break; 89 : 90 112204 : case Moose::NeighborNeighbor: 91 112204 : jac = _test_neighbor[_i][_qp] * -_penalty * -_phi_neighbor[_j][_qp]; 92 112204 : break; 93 : } 94 : 95 448996 : return jac; 96 : } 97 : 98 : template class PenaltyInterfaceDiffusionTempl<Real, false>; 99 : template class PenaltyInterfaceDiffusionTempl<Real, true>; 100 : template class PenaltyInterfaceDiffusionTempl<RealVectorValue, false>; 101 : template class PenaltyInterfaceDiffusionTempl<RealVectorValue, true>;