<commit_before>/****************************************************************/
/* MOOSE - Multiphysics Object Oriented Simulation Environment  */
/*                                                              */
/*          All contents are licensed under LGPL V2.1           */
/*             See LICENSE for full restrictions                */
/****************************************************************/

#include "PorousFlowSquarePulsePointSource.h"

template<>
InputParameters validParams<PorousFlowSquarePulsePointSource>()
{
  InputParameters params = validParams<DiracKernel>();
  params.addRequiredParam<Real>("mass_flux", "The mass flux at this point in kg/s (positive is flux in, negative is flux out)");
  params.addRequiredParam<Point>("point", "The x,y,z coordinates of the point source (sink)");
  params.addParam<Real>("start_time", 0.0, "The time at which the source will start (Default is 0)");
  params.addParam<Real>("end_time", 1.0e30, "The time at which the source will end (Default is 1e30)");
  return params;
}

PorousFlowSquarePulsePointSource::PorousFlowSquarePulsePointSource(const InputParameters & parameters) :
    DiracKernel(parameters),
    _mass_flux(getParam<Real>("mass_flux")),
    _p(getParam<Point>("point")),
    _start_time(getParam<Real>("start_time")),
    _end_time(getParam<Real>("end_time"))
{
  /// Sanity check to ensure that the end_time is greater than the start_time
  if (_end_time <= _start_time)
    mooseError("Start time for PorousFlowSquarePulsePointSource is " << _start_time << " but it must be less than end time " << _end_time);
}

void
PorousFlowSquarePulsePointSource::addPoints()
{
  addPoint(_p, 0);
}

Real
PorousFlowSquarePulsePointSource::computeQpResidual()
{
  Real factor = 0.0;

  /**
   * There are six cases for the start and end time in relation to t-dt and t.
   * If the interval (t-dt,t) is only partly but not fully within the (start,end)
   * interval, then the  mass_flux is scaled so that the total mass added
   * (or removed) is correct
   */
  if (_t < _start_time || _t - _dt >= _end_time)
    factor = 0.0;
  else if (_t - _dt < _start_time)
  {
    if (_t <= _end_time)
	    factor = (_t - _start_time) / _dt ;
    else
	    factor = (_end_time - _start_time) / _dt ;
  }
  else
  {
    if (_t <= _end_time)
      factor = 1.0;
    else<commit_msg>Convert tab to spaces<commit_after>/****************************************************************/
/* MOOSE - Multiphysics Object Oriented Simulation Environment  */
/*                                                              */
/*          All contents are licensed under LGPL V2.1           */
/*             See LICENSE for full restrictions                */
/****************************************************************/

#include "PorousFlowSquarePulsePointSource.h"

template<>
InputParameters validParams<PorousFlowSquarePulsePointSource>()
{
  InputParameters params = validParams<DiracKernel>();
  params.addRequiredParam<Real>("mass_flux", "The mass flux at this point in kg/s (positive is flux in, negative is flux out)");
  params.addRequiredParam<Point>("point", "The x,y,z coordinates of the point source (sink)");
  params.addParam<Real>("start_time", 0.0, "The time at which the source will start (Default is 0)");
  params.addParam<Real>("end_time", 1.0e30, "The time at which the source will end (Default is 1e30)");
  return params;
}

PorousFlowSquarePulsePointSource::PorousFlowSquarePulsePointSource(const InputParameters & parameters) :
    DiracKernel(parameters),
    _mass_flux(getParam<Real>("mass_flux")),
    _p(getParam<Point>("point")),
    _start_time(getParam<Real>("start_time")),
    _end_time(getParam<Real>("end_time"))
{
  /// Sanity check to ensure that the end_time is greater than the start_time
  if (_end_time <= _start_time)
    mooseError("Start time for PorousFlowSquarePulsePointSource is " << _start_time << " but it must be less than end time " << _end_time);
}

void
PorousFlowSquarePulsePointSource::addPoints()
{
  addPoint(_p, 0);
}

Real
PorousFlowSquarePulsePointSource::computeQpResidual()
{
  Real factor = 0.0;

  /**
   * There are six cases for the start and end time in relation to t-dt and t.
   * If the interval (t-dt,t) is only partly but not fully within the (start,end)
   * interval, then the  mass_flux is scaled so that the total mass added
   * (or removed) is correct
   */
  if (_t < _start_time || _t - _dt >= _end_time)
    factor = 0.0;
  else if (_t - _dt < _start_time)
  {
    if (_t <= _end_time)
      factor = (_t - _start_time) / _dt ;
    else
      factor = (_end_time - _start_time) / _dt ;
  }
  else
  {
    if (_t <= _end_time)
      factor = 1.0;
    else
{'fraction_non_alphanumeric': 0.16071428571428573, 'fraction_numerical': 0.008078231292517007, 'mean_word_length': 3.472433460076046, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7251224', 'n_tokens_mistral': 1454, 'n_tokens_neox': 1427, 'n_words': 412}