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