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 622 : PorousFlowSquarePulsePointSource::validParams() 16 : { 17 622 : InputParameters params = DiracKernel::validParams(); 18 1244 : 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 1244 : params.addRequiredParam<Point>("point", "The x,y,z coordinates of the point source (sink)"); 22 1244 : params.addParam<Real>( 23 1244 : "start_time", 0.0, "The time at which the source will start (Default is 0)"); 24 1244 : params.addParam<Real>( 25 1244 : "end_time", 1.0e30, "The time at which the source will end (Default is 1e30)"); 26 622 : 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 622 : return params; 29 0 : } 30 : 31 335 : PorousFlowSquarePulsePointSource::PorousFlowSquarePulsePointSource( 32 335 : const InputParameters & parameters) 33 : : DiracKernel(parameters), 34 335 : _mass_flux(getParam<Real>("mass_flux")), 35 670 : _p(getParam<Point>("point")), 36 670 : _start_time(getParam<Real>("start_time")), 37 1005 : _end_time(getParam<Real>("end_time")) 38 : { 39 : // Sanity check to ensure that the end_time is greater than the start_time 40 335 : 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 335 : } 47 : 48 : void 49 13732 : PorousFlowSquarePulsePointSource::addPoints() 50 : { 51 13732 : addPoint(_p, 0); 52 13732 : } 53 : 54 : Real 55 13024 : 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 13024 : if (_t < _start_time || _t - _dt >= _end_time) 66 : factor = 0.0; 67 8744 : else if (_t - _dt < _start_time) 68 : { 69 936 : if (_t <= _end_time) 70 936 : factor = (_t - _start_time) / _dt; 71 : else 72 0 : factor = (_end_time - _start_time) / _dt; 73 : } 74 : else 75 : { 76 7808 : if (_t <= _end_time) 77 : factor = 1.0; 78 : else 79 180 : factor = (_end_time - (_t - _dt)) / _dt; 80 : } 81 : 82 : // Negative sign to make a positive mass_flux in the input file a source 83 13024 : return -_test[_i][_qp] * factor * _mass_flux; 84 : }