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 "PorousFlowSquarePulsePointSource.h" 11 : 12 : registerMooseObject("PorousFlowApp", PorousFlowSquarePulsePointSource); 13 : 14 : InputParameters 15 294 : PorousFlowSquarePulsePointSource::validParams() 16 : { 17 294 : InputParameters params = DiracKernel::validParams(); 18 588 : params.addRequiredParam<Real>( 19 : "mass_flux", 20 : "The mass flux at this point in kg/s (positive is flux in, negative is flux out)"); 21 588 : params.addRequiredParam<Point>("point", "The x,y,z coordinates of the point source (sink)"); 22 588 : params.addParam<Real>( 23 588 : "start_time", 0.0, "The time at which the source will start (Default is 0)"); 24 588 : params.addParam<Real>( 25 588 : "end_time", 1.0e30, "The time at which the source will end (Default is 1e30)"); 26 294 : params.addClassDescription("Point source (or sink) that adds (removes) fluid at a constant mass " 27 : "flux rate for times between the specified start and end times."); 28 294 : return params; 29 0 : } 30 : 31 155 : PorousFlowSquarePulsePointSource::PorousFlowSquarePulsePointSource( 32 155 : const InputParameters & parameters) 33 : : DiracKernel(parameters), 34 155 : _mass_flux(getParam<Real>("mass_flux")), 35 310 : _p(getParam<Point>("point")), 36 310 : _start_time(getParam<Real>("start_time")), 37 465 : _end_time(getParam<Real>("end_time")) 38 : { 39 : // Sanity check to ensure that the end_time is greater than the start_time 40 155 : if (_end_time <= _start_time) 41 0 : mooseError(name(), 42 : ": start time for PorousFlowSquarePulsePointSource is ", 43 0 : _start_time, 44 : " but it must be less than end time ", 45 0 : _end_time); 46 155 : } 47 : 48 : void 49 7230 : PorousFlowSquarePulsePointSource::addPoints() 50 : { 51 7230 : addPoint(_p, 0); 52 7230 : } 53 : 54 : Real 55 8636 : PorousFlowSquarePulsePointSource::computeQpResidual() 56 : { 57 : Real factor = 0.0; 58 : 59 : /** 60 : * There are six cases for the start and end time in relation to t-dt and t. 61 : * If the interval (t-dt,t) is only partly but not fully within the (start,end) 62 : * interval, then the mass_flux is scaled so that the total mass added 63 : * (or removed) is correct 64 : */ 65 8636 : if (_t < _start_time || _t - _dt >= _end_time) 66 : factor = 0.0; 67 5820 : else if (_t - _dt < _start_time) 68 : { 69 600 : if (_t <= _end_time) 70 600 : factor = (_t - _start_time) / _dt; 71 : else 72 0 : factor = (_end_time - _start_time) / _dt; 73 : } 74 : else 75 : { 76 5220 : if (_t <= _end_time) 77 : factor = 1.0; 78 : else 79 120 : factor = (_end_time - (_t - _dt)) / _dt; 80 : } 81 : 82 : // Negative sign to make a positive mass_flux in the input file a source 83 8636 : return -_test[_i][_qp] * factor * _mass_flux; 84 : }