www.mooseframework.org
MovingPlanarFront.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 
10 #include "MovingPlanarFront.h"
11 
12 registerMooseObject("PorousFlowApp", MovingPlanarFront);
13 
14 template <>
15 InputParameters
17 {
18  InputParameters params = validParams<Function>();
19  params.addRequiredParam<RealVectorValue>("start_posn", "Initial position of the front");
20  params.addRequiredParam<RealVectorValue>("end_posn", "Final position of the front");
21  params.addRequiredParam<FunctionName>(
22  "distance",
23  "The front is an infinite plane with normal pointing from start_posn to "
24  "end_posn. The front's distance from start_posn is defined by distance. You "
25  "should ensure that distance is positive");
26  params.addParam<Real>(
27  "active_length",
28  std::numeric_limits<Real>::max(),
29  "Points greater than active_length behind the front will return false_value");
30  params.addParam<Real>("true_value", 1.0, "Return this value if a point is in the active zone.");
31  params.addParam<Real>(
32  "false_value", 0.0, "Return this value if a point is not in the active zone.");
33  params.addParam<Real>("activation_time",
34  std::numeric_limits<Real>::lowest(),
35  "This function will return false_value when t < activation_time");
36  params.addParam<Real>("deactivation_time",
37  std::numeric_limits<Real>::max(),
38  "This function will return false_value when t >= deactivation_time");
39  params.addClassDescription(
40  "This function defines the position of a moving front. The front is "
41  "an infinite plane with normal pointing from start_posn to end_posn. The front's distance "
42  "from start_posn is defined by 'distance', so if the 'distance' function is time dependent, "
43  "the front's position will change with time. Roughly speaking, the function returns "
44  "true_value for points lying in between start_posn and start_posn + distance. Precisely "
45  "speaking, two planes are constructed, both with normal pointing from start_posn to "
46  "end_posn. The first plane passes through start_posn; the second plane passes through "
47  "end_posn. Given a point p and time t, this function returns false_value if ANY of the "
48  "following are true: (a) t<activation_time; (b) t>=deactivation_time; (c) p is 'behind' "
49  "start_posn (ie, p lies on one side of the start_posn plane and end_posn lies on the other "
50  "side); (d) p is 'ahead' of the front (ie, p lies one one side of the front and start_posn "
51  "lies on the other side); (e) the distance between p and the front is greater than "
52  "active_length. Otherwise, the point is 'in the active zone' and the function returns "
53  "true_value.");
54  return params;
55 }
56 
57 MovingPlanarFront::MovingPlanarFront(const InputParameters & parameters)
58  : Function(parameters),
59  FunctionInterface(this),
60  _start_posn(getParam<RealVectorValue>("start_posn")),
61  _end_posn(getParam<RealVectorValue>("end_posn")),
62  _distance(getFunction("distance")),
63  _active_length(getParam<Real>("active_length")),
64  _true_value(getParam<Real>("true_value")),
65  _false_value(getParam<Real>("false_value")),
66  _activation_time(getParam<Real>("activation_time")),
67  _deactivation_time(getParam<Real>("deactivation_time")),
68  _front_normal(_end_posn - _start_posn)
69 {
70  if (_front_normal.norm() == 0)
71  mooseError("MovingPlanarFront: start_posn and end_posn must be different points");
72  _front_normal /= _front_normal.norm();
73 }
74 
75 Real
76 MovingPlanarFront::value(Real t, const Point & p) const
77 {
78  if (t < _activation_time)
79  return _false_value;
80 
81  if (t >= _deactivation_time)
82  return _false_value;
83 
84  if ((p - _start_posn) * _front_normal < 0)
85  // point is behind start posn - it'll never be active
86  return _false_value;
87 
88  const RealVectorValue current_posn = _start_posn + _distance.value(t, p) * _front_normal;
89 
90  const Real distance_ahead_of_front = (p - current_posn) * _front_normal;
91 
92  if (distance_ahead_of_front > 0)
93  return _false_value;
94 
95  if (distance_ahead_of_front < -_active_length)
96  // point is too far behind front
97  return _false_value;
98 
99  return _true_value;
100 }
MovingPlanarFront::_deactivation_time
const Real _deactivation_time
Deactivation time.
Definition: MovingPlanarFront.h:58
MovingPlanarFront::_active_length
const Real _active_length
Active length.
Definition: MovingPlanarFront.h:46
MovingPlanarFront
Defines the position of a moving front.
Definition: MovingPlanarFront.h:28
MovingPlanarFront::_front_normal
RealVectorValue _front_normal
Front unit normal.
Definition: MovingPlanarFront.h:61
validParams< MovingPlanarFront >
InputParameters validParams< MovingPlanarFront >()
Definition: MovingPlanarFront.C:16
MovingPlanarFront.h
MovingPlanarFront::_false_value
const Real _false_value
False value to return.
Definition: MovingPlanarFront.h:52
MovingPlanarFront::_start_posn
const RealVectorValue _start_posn
Initial position of front.
Definition: MovingPlanarFront.h:37
MovingPlanarFront::_true_value
const Real _true_value
True value to return.
Definition: MovingPlanarFront.h:49
registerMooseObject
registerMooseObject("PorousFlowApp", MovingPlanarFront)
MovingPlanarFront::_distance
const Function & _distance
The front's distance from start_posn (along the normal direction)
Definition: MovingPlanarFront.h:43
MovingPlanarFront::_activation_time
const Real _activation_time
Activation time.
Definition: MovingPlanarFront.h:55
MovingPlanarFront::MovingPlanarFront
MovingPlanarFront(const InputParameters &parameters)
Definition: MovingPlanarFront.C:57
MovingPlanarFront::value
virtual Real value(Real t, const Point &p) const override
Definition: MovingPlanarFront.C:76