Line data Source code
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 : 12 : registerMooseObject("PorousFlowApp", MovingPlanarFront); 13 : 14 : InputParameters 15 43 : MovingPlanarFront::validParams() 16 : { 17 43 : InputParameters params = Function::validParams(); 18 86 : params.addRequiredParam<RealVectorValue>("start_posn", "Initial position of the front"); 19 86 : params.addRequiredParam<RealVectorValue>("end_posn", "Final position of the front"); 20 86 : 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 86 : params.addParam<Real>( 26 : "active_length", 27 86 : std::numeric_limits<Real>::max(), 28 : "Points greater than active_length behind the front will return false_value"); 29 86 : params.addParam<Real>("true_value", 1.0, "Return this value if a point is in the active zone."); 30 86 : params.addParam<Real>( 31 86 : "false_value", 0.0, "Return this value if a point is not in the active zone."); 32 86 : params.addParam<Real>("activation_time", 33 86 : std::numeric_limits<Real>::lowest(), 34 : "This function will return false_value when t < activation_time"); 35 86 : params.addParam<Real>("deactivation_time", 36 86 : std::numeric_limits<Real>::max(), 37 : "This function will return false_value when t >= deactivation_time"); 38 43 : params.addClassDescription( 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 43 : return params; 54 0 : } 55 : 56 24 : MovingPlanarFront::MovingPlanarFront(const InputParameters & parameters) 57 : : Function(parameters), 58 : FunctionInterface(this), 59 24 : _start_posn(getParam<RealVectorValue>("start_posn")), 60 48 : _end_posn(getParam<RealVectorValue>("end_posn")), 61 24 : _distance(getFunction("distance")), 62 48 : _active_length(getParam<Real>("active_length")), 63 48 : _true_value(getParam<Real>("true_value")), 64 48 : _false_value(getParam<Real>("false_value")), 65 48 : _activation_time(getParam<Real>("activation_time")), 66 48 : _deactivation_time(getParam<Real>("deactivation_time")), 67 24 : _front_normal(_end_posn - _start_posn) 68 : { 69 24 : if (_front_normal.norm() == 0) 70 2 : mooseError("MovingPlanarFront: start_posn and end_posn must be different points"); 71 22 : _front_normal /= _front_normal.norm(); 72 22 : } 73 : 74 : Real 75 92672 : MovingPlanarFront::value(Real t, const Point & p) const 76 : { 77 92672 : if (t < _activation_time) 78 4608 : return _false_value; 79 : 80 88064 : if (t >= _deactivation_time) 81 13824 : return _false_value; 82 : 83 74240 : if ((p - _start_posn) * _front_normal < 0) 84 : // point is behind start posn - it'll never be active 85 2320 : return _false_value; 86 : 87 71920 : 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 71920 : if (distance_ahead_of_front > 0) 92 50684 : return _false_value; 93 : 94 21236 : if (distance_ahead_of_front < -_active_length) 95 : // point is too far behind front 96 1890 : return _false_value; 97 : 98 19346 : return _true_value; 99 : }