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 "CoupledPenaltyInterfaceDiffusion.h" 11 : 12 : registerMooseObject("FsiApp", CoupledPenaltyInterfaceDiffusion); 13 : 14 : InputParameters 15 82 : CoupledPenaltyInterfaceDiffusion::validParams() 16 : { 17 82 : InputParameters params = InterfaceKernel::validParams(); 18 82 : params.addClassDescription( 19 : "Enforces continuity of flux and continuity of solution via penalty across an interface."); 20 164 : params.addRequiredParam<Real>( 21 : "penalty", 22 : "The penalty that penalizes jump between primary and neighbor secondary variables."); 23 164 : params.addCoupledVar("primary_coupled_var", "The coupled variable on the master side"); 24 164 : params.addCoupledVar("secondary_coupled_var", "The coupled variable on the slave side"); 25 82 : return params; 26 0 : } 27 : 28 44 : CoupledPenaltyInterfaceDiffusion::CoupledPenaltyInterfaceDiffusion( 29 44 : const InputParameters & parameters) 30 : : InterfaceKernel(parameters), 31 44 : _penalty(getParam<Real>("penalty")), 32 88 : _primary_coupled_value(isCoupled("primary_coupled_var") ? coupledValue("primary_coupled_var") 33 44 : : _var.sln()), 34 44 : _secondary_coupled_value(isCoupled("secondary_coupled_var") 35 88 : ? coupledNeighborValue("secondary_coupled_var") 36 0 : : _neighbor_var.slnNeighbor()), 37 88 : _primary_coupled_id(isCoupled("primary_coupled_var") ? coupled("primary_coupled_var") 38 44 : : _var.number()), 39 88 : _secondary_coupled_id(isCoupled("secondary_coupled_var") ? coupled("secondary_coupled_var") 40 44 : : _neighbor_var.number()) 41 : { 42 44 : } 43 : 44 : Real 45 529600 : CoupledPenaltyInterfaceDiffusion::computeQpResidual(Moose::DGResidualType type) 46 : { 47 : Real r = 0; 48 : 49 529600 : switch (type) 50 : { 51 264800 : case Moose::Element: 52 264800 : r = _test[_i][_qp] * _penalty * (_primary_coupled_value[_qp] - _secondary_coupled_value[_qp]); 53 264800 : break; 54 : 55 264800 : case Moose::Neighbor: 56 264800 : r = _test_neighbor[_i][_qp] * -_penalty * 57 264800 : (_primary_coupled_value[_qp] - _secondary_coupled_value[_qp]); 58 264800 : break; 59 : } 60 : 61 529600 : return r; 62 : } 63 : 64 0 : Real CoupledPenaltyInterfaceDiffusion::computeQpJacobian(Moose::DGJacobianType) { return 0; } 65 : 66 : Real 67 2661120 : CoupledPenaltyInterfaceDiffusion::computeQpOffDiagJacobian(Moose::DGJacobianType type, 68 : unsigned int jvar) 69 : { 70 2661120 : if (jvar == _primary_coupled_id) 71 : { 72 295680 : switch (type) 73 : { 74 147840 : case Moose::ElementElement: 75 147840 : return _test[_i][_qp] * _penalty * _phi[_j][_qp]; 76 147840 : case Moose::NeighborElement: 77 147840 : return _test_neighbor[_i][_qp] * -_penalty * _phi[_j][_qp]; 78 : case Moose::ElementNeighbor: 79 : case Moose::NeighborNeighbor: 80 : break; 81 : } 82 : } 83 2365440 : else if (jvar == _secondary_coupled_id) 84 : { 85 295680 : switch (type) 86 : { 87 147840 : case Moose::ElementNeighbor: 88 147840 : return _test[_i][_qp] * _penalty * -_phi_neighbor[_j][_qp]; 89 147840 : case Moose::NeighborNeighbor: 90 147840 : return _test_neighbor[_i][_qp] * -_penalty * -_phi_neighbor[_j][_qp]; 91 : case Moose::ElementElement: 92 : case Moose::NeighborElement: 93 : break; 94 : } 95 : } 96 : return 0; 97 : } 98 : 99 : void 100 32340 : CoupledPenaltyInterfaceDiffusion::computeElementOffDiagJacobian(unsigned int jvar) 101 : { 102 32340 : computeOffDiagElemNeighJacobian(Moose::ElementElement, jvar); 103 32340 : computeOffDiagElemNeighJacobian(Moose::ElementNeighbor, jvar); 104 32340 : } 105 : 106 : void 107 32340 : CoupledPenaltyInterfaceDiffusion::computeNeighborOffDiagJacobian(unsigned int jvar) 108 : { 109 32340 : computeOffDiagElemNeighJacobian(Moose::NeighborElement, jvar); 110 32340 : computeOffDiagElemNeighJacobian(Moose::NeighborNeighbor, jvar); 111 32340 : }