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 "INSChorinPressurePoisson.h" 11 : #include "MooseMesh.h" 12 : 13 : registerMooseObject("NavierStokesApp", INSChorinPressurePoisson); 14 : 15 : InputParameters 16 41 : INSChorinPressurePoisson::validParams() 17 : { 18 41 : InputParameters params = Kernel::validParams(); 19 : 20 41 : params.addClassDescription("This class computes the pressure Poisson solve which is part of the " 21 : "'split' scheme used for solving the incompressible Navier-Stokes " 22 : "equations."); 23 : // Coupled variables 24 82 : params.addRequiredCoupledVar("u_star", "star x-velocity"); 25 82 : params.addCoupledVar("v_star", "star y-velocity"); // only required in 2D and 3D 26 82 : params.addCoupledVar("w_star", "star z-velocity"); // only required in 3D 27 : 28 : // Optional parameters 29 82 : params.addParam<MaterialPropertyName>("rho_name", "rho", "density_name"); 30 : 31 41 : return params; 32 0 : } 33 : 34 22 : INSChorinPressurePoisson::INSChorinPressurePoisson(const InputParameters & parameters) 35 : : Kernel(parameters), 36 : 37 : // Gradients 38 22 : _grad_u_star(coupledGradient("u_star")), 39 22 : _grad_v_star(_mesh.dimension() >= 2 ? coupledGradient("v_star") : _grad_zero), 40 22 : _grad_w_star(_mesh.dimension() == 3 ? coupledGradient("w_star") : _grad_zero), 41 : 42 : // Variable numberings 43 22 : _u_vel_star_var_number(coupled("u_star")), 44 22 : _v_vel_star_var_number(_mesh.dimension() >= 2 ? coupled("v_star") : libMesh::invalid_uint), 45 22 : _w_vel_star_var_number(_mesh.dimension() == 3 ? coupled("w_star") : libMesh::invalid_uint), 46 : 47 : // Material properties 48 66 : _rho(getMaterialProperty<Real>("rho_name")) 49 : { 50 22 : } 51 : 52 : Real 53 5888000 : INSChorinPressurePoisson::computeQpResidual() 54 : { 55 : // Laplacian part 56 5888000 : Real laplacian_part = _grad_u[_qp] * _grad_test[_i][_qp]; 57 : 58 : // Divergence part, don't forget to *divide* by _dt 59 5888000 : Real div_part = (_rho[_qp] / _dt) * 60 5888000 : (_grad_u_star[_qp](0) + _grad_v_star[_qp](1) + _grad_w_star[_qp](2)) * 61 5888000 : _test[_i][_qp]; 62 : 63 : // Return the result 64 5888000 : return laplacian_part + div_part; 65 : } 66 : 67 : Real 68 23552000 : INSChorinPressurePoisson::computeQpJacobian() 69 : { 70 23552000 : return _grad_phi[_j][_qp] * _grad_test[_i][_qp]; 71 : } 72 : 73 : Real 74 75366400 : INSChorinPressurePoisson::computeQpOffDiagJacobian(unsigned jvar) 75 : { 76 75366400 : if (jvar == _u_vel_star_var_number) 77 18841600 : return (_rho[_qp] / _dt) * _grad_phi[_j][_qp](0) * _test[_i][_qp]; 78 : 79 56524800 : else if (jvar == _v_vel_star_var_number) 80 18841600 : return (_rho[_qp] / _dt) * _grad_phi[_j][_qp](1) * _test[_i][_qp]; 81 : 82 37683200 : else if (jvar == _w_vel_star_var_number) 83 0 : return (_rho[_qp] / _dt) * _grad_phi[_j][_qp](2) * _test[_i][_qp]; 84 : 85 : else 86 : return 0; 87 : }