diff --git a/modules/phase_field/include/postprocessors/FindValueOnLine.h b/modules/phase_field/include/postprocessors/FindValueOnLine.h index d9c0b5dec805..19fcb0e880ac 100644 --- a/modules/phase_field/include/postprocessors/FindValueOnLine.h +++ b/modules/phase_field/include/postprocessors/FindValueOnLine.h @@ -17,7 +17,11 @@ template<> InputParameters validParams(); /** - * Finds a secific value along a line through a bisection search/ + * Find a specific target value along a sampling line. The variable values along + * the line should change monotonically. The target value is searched using a + * bisection algorithm. + * The Postprocessor reports the distance from the start_point along the line + * between start_point and end_point. */ class FindValueOnLine : public GeneralPostprocessor, public Coupleable { @@ -45,6 +49,9 @@ class FindValueOnLine : public GeneralPostprocessor, public Coupleable /// search depth const unsigned int _depth; + /// tolerance for comparison to the target value + const Real _tol; + /// coupled variable MooseVariable * _coupled_var; diff --git a/modules/phase_field/src/postprocessors/FindValueOnLine.C b/modules/phase_field/src/postprocessors/FindValueOnLine.C index d7e10baa0f4b..11c1d07ad7e7 100644 --- a/modules/phase_field/src/postprocessors/FindValueOnLine.C +++ b/modules/phase_field/src/postprocessors/FindValueOnLine.C @@ -12,10 +12,12 @@ template<> InputParameters validParams() { InputParameters params = validParams(); - params.addParam("start_point", "Start point of the sample line."); - params.addParam("end_point", "End point of the sample line."); + params.addClassDescription("Find a specific target value along a sampling line. The variable values along the line should change monotonically. The target value is searched using a bisection algorithm."); + params.addParam("start_point", "Start point of the sampling line."); + params.addParam("end_point", "End point of the sampling line."); params.addParam("target", "Target value to locate."); - params.addParam("depth", "Number of bisections to perform."); + params.addParam("depth", 30, "Maximum number of bisections to perform."); + params.addParam("tol", 1e-10, "Stop search if a value within a symmetric interval of this with around the target is found."); params.addCoupledVar("v", "Variable to inspect"); return params; } @@ -28,6 +30,7 @@ FindValueOnLine::FindValueOnLine(const InputParameters & parameters) : _length((_end_point - _start_point).norm()), _target(getParam("target")), _depth(getParam("depth")), + _tol(getParam("tol") / 2.0), _coupled_var(getVar("v", 0)), _position(0.0), _mesh(_subproblem.mesh()), @@ -60,6 +63,10 @@ FindValueOnLine::execute() // sample value Real value = getValueAtPoint(p); + // have we hit the target value yet? + if (value > _target - _tol && value < _target + _tol) + break; + // bisect if ( (left >= _target && _target >= value) || (left <= _target && _target <= value)) @@ -103,7 +110,7 @@ FindValueOnLine::getValueAtPoint(const Point & p) else { // there is no element - mooseError("No element found."); + mooseError("No element found at the current search point. Please make sure the sampling line stays inside the mesh completely."); } }