www.mooseframework.org
MovingPlanarFront.C
Go to the documentation of this file.
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 "MovingPlanarFront.h"
9 
10 template <>
11 InputParameters
13 {
14  InputParameters params = validParams<Function>();
15  params.addRequiredParam<RealVectorValue>("start_posn", "Initial position of the front");
16  params.addRequiredParam<RealVectorValue>("end_posn", "Final position of the front");
17  params.addRequiredParam<FunctionName>(
18  "distance",
19  "The front is an infinite plane with normal pointing from start_posn to "
20  "end_posn. The front's distance from start_posn is defined by distance. You "
21  "should ensure that distance is positive");
22  params.addRequiredParam<Real>(
23  "active_length",
24  "This function will return true_value at a point if: (a) t >= "
25  "activation_time; (b) t < deactivation_time; (c) the point lies in the "
26  "domain between start_posn and the front position; (d) the distance between "
27  "the point and the front position <= active_length.");
28  params.addParam<Real>("true_value", 1.0, "Return this value if a point is in the active zone.");
29  params.addParam<Real>(
30  "false_value", 0.0, "Return this value if a point is not in the active zone.");
31  params.addParam<Real>("activation_time",
32  std::numeric_limits<Real>::lowest(),
33  "This function will return false_value when t < activation_time");
34  params.addParam<Real>("deactivation_time",
35  std::numeric_limits<Real>::max(),
36  "This function will return false_value when t >= deactivation_time");
37  params.addClassDescription("This function defines the position of a moving front. The front is "
38  "an infinite plane with normal pointing from start_posn to end_posn. "
39  "The front's distance from start_posn is defined by distance");
40  return params;
41 }
42 
43 MovingPlanarFront::MovingPlanarFront(const InputParameters & parameters)
44  : Function(parameters),
45  FunctionInterface(this),
46  _start_posn(getParam<RealVectorValue>("start_posn")),
47  _end_posn(getParam<RealVectorValue>("end_posn")),
48  _distance(getFunction("distance")),
49  _active_length(getParam<Real>("active_length")),
50  _true_value(getParam<Real>("true_value")),
51  _false_value(getParam<Real>("false_value")),
52  _activation_time(getParam<Real>("activation_time")),
53  _deactivation_time(getParam<Real>("deactivation_time")),
54  _front_normal(_end_posn - _start_posn)
55 {
56  if (_front_normal.size() == 0)
57  mooseError("MovingPlanarFront: start_posn and end_posn must be different points");
58  _front_normal /= _front_normal.size();
59 }
60 
61 Real
62 MovingPlanarFront::value(Real t, const Point & p)
63 {
64  if (t < _activation_time)
65  return _false_value;
66 
67  if (t >= _deactivation_time)
68  return _false_value;
69 
70  if ((p - _start_posn) * _front_normal < 0)
71  // point is behind start posn - it'll never be active
72  return _false_value;
73 
74  const RealVectorValue current_posn = _start_posn + _distance.value(t, p) * _front_normal;
75 
76  const Real distance_ahead_of_front = (p - current_posn) * _front_normal;
77 
78  if (distance_ahead_of_front > 0)
79  return _false_value;
80 
81  if (distance_ahead_of_front < -_active_length)
82  // point is too far behind front
83  return _false_value;
84 
85  return _true_value;
86 }
const Real _activation_time
activation time
MovingPlanarFront(const InputParameters &parameters)
InputParameters validParams< MovingPlanarFront >()
const Real _deactivation_time
deactivation time
const RealVectorValue _start_posn
Initial position of front.
virtual Real value(Real t, const Point &p) override
const Real _false_value
false value to return
Function & _distance
The front&#39;s distance from start_posn (along the normal direction)
const Real _true_value
true value to return
const Real _active_length
active length
RealVectorValue _front_normal
front unit normal