LCOV - code coverage report
Current view: top level - src/functions - MovingPlanarFront.C (source / functions) Hit Total Coverage
Test: porous_flow Test Coverage Lines: 47 47 100.0 %
Date: 2017-11-20 12:14:45 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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
      12           2 : validParams<MovingPlanarFront>()
      13             : {
      14           2 :   InputParameters params = validParams<Function>();
      15           6 :   params.addRequiredParam<RealVectorValue>("start_posn", "Initial position of the front");
      16           6 :   params.addRequiredParam<RealVectorValue>("end_posn", "Final position of the front");
      17           6 :   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           2 :       "should ensure that distance is positive");
      22           6 :   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           2 :       "the point and the front position <= active_length.");
      28           6 :   params.addParam<Real>("true_value", 1.0, "Return this value if a point is in the active zone.");
      29           6 :   params.addParam<Real>(
      30           2 :       "false_value", 0.0, "Return this value if a point is not in the active zone.");
      31           8 :   params.addParam<Real>("activation_time",
      32           4 :                         std::numeric_limits<Real>::lowest(),
      33           2 :                         "This function will return false_value when t < activation_time");
      34           8 :   params.addParam<Real>("deactivation_time",
      35           4 :                         std::numeric_limits<Real>::max(),
      36           2 :                         "This function will return false_value when t >= deactivation_time");
      37           4 :   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           2 :                              "The front's distance from start_posn is defined by distance");
      40           2 :   return params;
      41             : }
      42             : 
      43           2 : MovingPlanarFront::MovingPlanarFront(const InputParameters & parameters)
      44             :   : Function(parameters),
      45             :     FunctionInterface(this),
      46           4 :     _start_posn(getParam<RealVectorValue>("start_posn")),
      47           4 :     _end_posn(getParam<RealVectorValue>("end_posn")),
      48           4 :     _distance(getFunction("distance")),
      49           6 :     _active_length(getParam<Real>("active_length")),
      50           6 :     _true_value(getParam<Real>("true_value")),
      51           6 :     _false_value(getParam<Real>("false_value")),
      52           6 :     _activation_time(getParam<Real>("activation_time")),
      53           6 :     _deactivation_time(getParam<Real>("deactivation_time")),
      54          18 :     _front_normal(_end_posn - _start_posn)
      55             : {
      56           2 :   if (_front_normal.size() == 0)
      57           1 :     mooseError("MovingPlanarFront: start_posn and end_posn must be different points");
      58             :   _front_normal /= _front_normal.size();
      59           1 : }
      60             : 
      61             : Real
      62       10240 : MovingPlanarFront::value(Real t, const Point & p)
      63             : {
      64       10240 :   if (t < _activation_time)
      65         512 :     return _false_value;
      66             : 
      67        9728 :   if (t >= _deactivation_time)
      68        1536 :     return _false_value;
      69             : 
      70        8192 :   if ((p - _start_posn) * _front_normal < 0)
      71             :     // point is behind start posn - it'll never be active
      72         256 :     return _false_value;
      73             : 
      74        7936 :   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        7936 :   if (distance_ahead_of_front > 0)
      79        5592 :     return _false_value;
      80             : 
      81        2344 :   if (distance_ahead_of_front < -_active_length)
      82             :     // point is too far behind front
      83         210 :     return _false_value;
      84             : 
      85        2134 :   return _true_value;
      86        2499 : }

Generated by: LCOV version 1.11