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 "NSSUPGMass.h" 11 : 12 : registerMooseObject("NavierStokesApp", NSSUPGMass); 13 : 14 : InputParameters 15 41 : NSSUPGMass::validParams() 16 : { 17 : // Initialize the params object from the base class 18 41 : InputParameters params = NSSUPGBase::validParams(); 19 41 : params.addClassDescription( 20 : "Compute residual and Jacobian terms form the SUPG terms in the mass equation."); 21 41 : return params; 22 0 : } 23 : 24 22 : NSSUPGMass::NSSUPGMass(const InputParameters & parameters) : NSSUPGBase(parameters) {} 25 : 26 : Real 27 5483520 : NSSUPGMass::computeQpResidual() 28 : { 29 : // From "Component SUPG contributions" section of the notes, 30 : // the mass equation is stabilized by taum and the gradient of 31 : // phi_i dotted with the momentum equation strong residuals. 32 : // Note that the momentum equation strong residuals are stored 33 : // in entries 1,2,3 of the "_strong_residuals" vector, regardless 34 : // of what dimension we're solving in. 35 : RealVectorValue Ru( 36 5483520 : _strong_residuals[_qp][1], _strong_residuals[_qp][2], _strong_residuals[_qp][3]); 37 : 38 : // Separate variable just for printing purposes... 39 5483520 : Real result = _taum[_qp] * (Ru * _grad_test[_i][_qp]); 40 : 41 5483520 : return result; 42 : } 43 : 44 : Real 45 3354624 : NSSUPGMass::computeQpJacobian() 46 : { 47 : // This is the density equation, so pass the on-diagonal variable number 48 3354624 : return computeJacobianHelper(_rho_var_number); 49 : } 50 : 51 : Real 52 10063872 : NSSUPGMass::computeQpOffDiagJacobian(unsigned int jvar) 53 : { 54 10063872 : return computeJacobianHelper(jvar); 55 : } 56 : 57 : Real 58 13418496 : NSSUPGMass::computeJacobianHelper(unsigned var) 59 : { 60 13418496 : if (isNSVariable(var)) 61 : { 62 : 63 : // Convert the Moose numbering to canonical NS variable numbering. 64 13418496 : unsigned m = mapVarNumber(var); 65 : 66 : // Time derivative contributions only for momentum 67 : Real time_part = 0.; 68 : 69 : // The derivative of "udot" wrt u for each of the momentum variables. 70 : // This is always 1/dt unless you are using BDF2... 71 13418496 : Real d_udot_du[3] = {_d_rhoudot_du[_qp], _d_rhovdot_du[_qp], _d_rhowdot_du[_qp]}; 72 : 73 13418496 : switch (m) 74 : { 75 6709248 : case 1: 76 : case 2: 77 : case 3: 78 : // time_part = _grad_test[_i][_qp](m-1) * (_phi[_j][_qp]/_subproblem.parent()->dt()); 79 6709248 : time_part = _grad_test[_i][_qp](m - 1) * (_phi[_j][_qp] * d_udot_du[m - 1]); 80 6709248 : break; 81 : } 82 : 83 : // Store result so we can print it before returning 84 : Real result = 85 13418496 : _taum[_qp] * (time_part + _grad_test[_i][_qp] * (_calA[_qp][m] * _grad_phi[_j][_qp])); 86 : 87 : return result; 88 : } 89 : else 90 : return 0.0; 91 : }