www.mooseframework.org
PorousFlowSquarePulsePointSource.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
11 
13 
16 {
18  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  params.addRequiredParam<Point>("point", "The x,y,z coordinates of the point source (sink)");
22  params.addParam<Real>(
23  "start_time", 0.0, "The time at which the source will start (Default is 0)");
24  params.addParam<Real>(
25  "end_time", 1.0e30, "The time at which the source will end (Default is 1e30)");
26  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  return params;
29 }
30 
32  const InputParameters & parameters)
33  : DiracKernel(parameters),
34  _mass_flux(getParam<Real>("mass_flux")),
35  _p(getParam<Point>("point")),
36  _start_time(getParam<Real>("start_time")),
37  _end_time(getParam<Real>("end_time"))
38 {
39  // Sanity check to ensure that the end_time is greater than the start_time
40  if (_end_time <= _start_time)
41  mooseError(name(),
42  ": start time for PorousFlowSquarePulsePointSource is ",
44  " but it must be less than end time ",
45  _end_time);
46 }
47 
48 void
50 {
51  addPoint(_p, 0);
52 }
53 
54 Real
56 {
57  Real factor = 0.0;
58 
65  if (_t < _start_time || _t - _dt >= _end_time)
66  factor = 0.0;
67  else if (_t - _dt < _start_time)
68  {
69  if (_t <= _end_time)
70  factor = (_t - _start_time) / _dt;
71  else
72  factor = (_end_time - _start_time) / _dt;
73  }
74  else
75  {
76  if (_t <= _end_time)
77  factor = 1.0;
78  else
79  factor = (_end_time - (_t - _dt)) / _dt;
80  }
81 
82  // Negative sign to make a positive mass_flux in the input file a source
83  return -_test[_i][_qp] * factor * _mass_flux;
84 }
const Real _end_time
The time at which the point source (sink) stops operating.
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addPoint(const Elem *elem, Point p, unsigned id=libMesh::invalid_uint)
const OutputTools< T >::VariableTestValue & _test
const Real _start_time
The time at which the point source (sink) starts operating.
const Real _mass_flux
The constant mass flux (kg/s)
Point source (or sink) that adds (removes) fluid at a constant mass flux rate for times between the s...
virtual const std::string & name() const
void addRequiredParam(const std::string &name, const std::string &doc_string)
const Point _p
The location of the point source (sink)
PorousFlowSquarePulsePointSource(const InputParameters &parameters)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
unsigned int _qp
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
unsigned int _i
static InputParameters validParams()
registerMooseObject("PorousFlowApp", PorousFlowSquarePulsePointSource)