LCOV - code coverage report
Current view: top level - src/dirackernels - PorousFlowSquarePulsePointSource.C (source / functions) Hit Total Coverage
Test: porous_flow Test Coverage Lines: 31 34 91.2 %
Date: 2017-11-21 14:47:27 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /****************************************************************/
       2             : /* MOOSE - Multiphysics Object Oriented Simulation Environment  */
       3             : /*                                                              */
       4             : /*          All contents are licensed under LGPL V2.1           */
       5             : /*             See LICENSE for full restrictions                */
       6             : /****************************************************************/
       7             : 
       8             : #include "PorousFlowSquarePulsePointSource.h"
       9             : 
      10             : template <>
      11             : InputParameters
      12           8 : validParams<PorousFlowSquarePulsePointSource>()
      13             : {
      14           8 :   InputParameters params = validParams<DiracKernel>();
      15          24 :   params.addRequiredParam<Real>(
      16             :       "mass_flux",
      17           8 :       "The mass flux at this point in kg/s (positive is flux in, negative is flux out)");
      18          24 :   params.addRequiredParam<Point>("point", "The x,y,z coordinates of the point source (sink)");
      19          24 :   params.addParam<Real>(
      20           8 :       "start_time", 0.0, "The time at which the source will start (Default is 0)");
      21          24 :   params.addParam<Real>(
      22           8 :       "end_time", 1.0e30, "The time at which the source will end (Default is 1e30)");
      23          16 :   params.addClassDescription("Point source (or sink) that adds (removes) fluid at a constant mass "
      24           8 :                              "flux rate for times between the specified start and end times.");
      25           8 :   return params;
      26             : }
      27             : 
      28           8 : PorousFlowSquarePulsePointSource::PorousFlowSquarePulsePointSource(
      29           8 :     const InputParameters & parameters)
      30             :   : DiracKernel(parameters),
      31          24 :     _mass_flux(getParam<Real>("mass_flux")),
      32             :     _p(getParam<Point>("point")),
      33          24 :     _start_time(getParam<Real>("start_time")),
      34          64 :     _end_time(getParam<Real>("end_time"))
      35             : {
      36             :   /// Sanity check to ensure that the end_time is greater than the start_time
      37           8 :   if (_end_time <= _start_time)
      38           0 :     mooseError("Start time for PorousFlowSquarePulsePointSource is ",
      39             :                _start_time,
      40             :                " but it must be less than end time ",
      41           0 :                _end_time);
      42           8 : }
      43             : 
      44             : void
      45        1406 : PorousFlowSquarePulsePointSource::addPoints()
      46             : {
      47        1406 :   addPoint(_p, 0);
      48        1406 : }
      49             : 
      50             : Real
      51        2400 : PorousFlowSquarePulsePointSource::computeQpResidual()
      52             : {
      53             :   Real factor = 0.0;
      54             : 
      55             :   /**
      56             :    * There are six cases for the start and end time in relation to t-dt and t.
      57             :    * If the interval (t-dt,t) is only partly but not fully within the (start,end)
      58             :    * interval, then the  mass_flux is scaled so that the total mass added
      59             :    * (or removed) is correct
      60             :    */
      61        2400 :   if (_t < _start_time || _t - _dt >= _end_time)
      62             :     factor = 0.0;
      63        1800 :   else if (_t - _dt < _start_time)
      64             :   {
      65         120 :     if (_t <= _end_time)
      66         120 :       factor = (_t - _start_time) / _dt;
      67             :     else
      68           0 :       factor = (_end_time - _start_time) / _dt;
      69             :   }
      70             :   else
      71             :   {
      72        1680 :     if (_t <= _end_time)
      73             :       factor = 1.0;
      74             :     else
      75          24 :       factor = (_end_time - (_t - _dt)) / _dt;
      76             :   }
      77             : 
      78             :   /// Negative sign to make a positive mass_flux in the input file a source
      79        4800 :   return -_test[_i][_qp] * factor * _mass_flux;
      80        2499 : }

Generated by: LCOV version 1.11