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 57650 : PenaltyInterfaceDiffusionTempl<T, is_ad>::validParams() 20 : { 21 57650 : InputParameters params = GenericInterfaceKernelTempl<T, is_ad>::validParams(); 22 57650 : params.addRequiredParam<Real>( 23 : "penalty", "The penalty that penalizes jump between primary and neighbor variables."); 24 57650 : params.addParam<MaterialPropertyName>( 25 : "jump_prop_name", "the name of the material property that calculates the jump."); 26 57650 : params.addClassDescription( 27 : "A penalty-based interface condition that forces" 28 : "the continuity of variables and the flux equivalence across an interface."); 29 57650 : return params; 30 0 : } 31 : 32 : template <typename T, bool is_ad> 33 308 : PenaltyInterfaceDiffusionTempl<T, is_ad>::PenaltyInterfaceDiffusionTempl( 34 : const InputParameters & parameters) 35 : : GenericInterfaceKernelTempl<T, is_ad>(parameters), 36 308 : _penalty(this->template getParam<Real>("penalty")), 37 616 : _jump(isParamValid("jump_prop_name") 38 308 : ? &this->template getGenericMaterialProperty<T, is_ad>("jump_prop_name") 39 616 : : nullptr) 40 : { 41 308 : } 42 : 43 : template <typename T, bool is_ad> 44 : GenericReal<is_ad> 45 65968 : PenaltyInterfaceDiffusionTempl<T, is_ad>::computeQpResidual(Moose::DGResidualType type) 46 : { 47 65968 : GenericReal<is_ad> r = 0; 48 : 49 65968 : Moose::GenericType<T, is_ad> jump_value = 0; 50 : 51 65968 : if (_jump != nullptr) 52 7648 : jump_value = (*_jump)[_qp]; 53 : else 54 58320 : jump_value = _u[_qp] - _neighbor_value[_qp]; 55 : 56 65968 : switch (type) 57 : { 58 33096 : case Moose::Element: 59 33096 : r = _test[_i][_qp] * _penalty * jump_value; 60 33096 : break; 61 : 62 32872 : case Moose::Neighbor: 63 32872 : r = _test_neighbor[_i][_qp] * -_penalty * jump_value; 64 32872 : break; 65 : } 66 : 67 66064 : return r; 68 96 : } 69 : 70 : template <typename T, bool is_ad> 71 : Real 72 396416 : PenaltyInterfaceDiffusionTempl<T, is_ad>::computeQpJacobian(Moose::DGJacobianType type) 73 : { 74 396416 : Real jac = 0; 75 : 76 396416 : switch (type) 77 : { 78 99224 : case Moose::ElementElement: 79 99224 : jac = _test[_i][_qp] * _penalty * _phi[_j][_qp]; 80 99224 : break; 81 : 82 99064 : case Moose::ElementNeighbor: 83 99064 : jac = _test[_i][_qp] * _penalty * -_phi_neighbor[_j][_qp]; 84 99064 : break; 85 : 86 99064 : case Moose::NeighborElement: 87 99064 : jac = _test_neighbor[_i][_qp] * -_penalty * _phi[_j][_qp]; 88 99064 : break; 89 : 90 99064 : case Moose::NeighborNeighbor: 91 99064 : jac = _test_neighbor[_i][_qp] * -_penalty * -_phi_neighbor[_j][_qp]; 92 99064 : break; 93 : } 94 : 95 396416 : 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>;