{"action":"created","comment":{"url":"https://api.github.com/repos/idaholab/moose/pulls/comments/62051701","id":62051701,"diff_hunk":"@@ -0,0 +1,114 @@\n+/****************************************************************/\n+/* MOOSE - Multiphysics Object Oriented Simulation Environment  */\n+/*                                                              */\n+/*          All contents are licensed under LGPL V2.1           */\n+/*             See LICENSE for full restrictions                */\n+/****************************************************************/\n+\n+#include \"FindValueOnLine.h\"\n+#include \"MooseMesh.h\"\n+\n+template<>\n+InputParameters validParams<FindValueOnLine>()\n+{\n+  InputParameters params = validParams<GeneralPostprocessor>();\n+  params.addParam<Point>(\"start_point\", \"Start point of the sample line.\");\n+  params.addParam<Point>(\"end_point\", \"End point of the sample line.\");\n+  params.addParam<Real>(\"target\", \"Target value to locate.\");\n+  params.addParam<unsigned int>(\"depth\", \"Number of bisections to perform.\");\n+  params.addCoupledVar(\"v\", \"Variable to inspect\");\n+  return params;\n+}\n+\n+FindValueOnLine::FindValueOnLine(const InputParameters & parameters) :\n+    GeneralPostprocessor(parameters),\n+    Coupleable(this, false),\n+    _start_point(getParam<Point>(\"start_point\")),\n+    _end_point(getParam<Point>(\"end_point\")),\n+    _length((_end_point - _start_point).norm()),\n+    _target(getParam<Real>(\"target\")),\n+    _depth(getParam<unsigned int>(\"depth\")),\n+    _coupled_var(getVar(\"v\", 0)),\n+    _position(0.0),\n+    _mesh(_subproblem.mesh()),\n+    _point_vec(1)\n+{\n+}\n+\n+void\n+FindValueOnLine::initialize()\n+{\n+  // We do this here just in case it's been destroyed and recreated becaue of mesh adaptivity.\n+  _pl = _mesh.getMesh().sub_point_locator();\n+}\n+\n+void\n+FindValueOnLine::execute()\n+{\n+  Real s;\n+  Real s_left = 0.0;\n+  Real left = getValueAtPoint(_start_point);\n+  Real s_right = 1.0;\n+  Real right = getValueAtPoint(_end_point);\n+\n+  for (unsigned i = 0; i < _depth; ++i)\n+  {\n+    // find midpoint\n+    s = (s_left + s_right) / 2.0;\n+    Point p = s * (_end_point - _start_point) + _start_point;\n+\n+    // sample value\n+    Real value = getValueAtPoint(p);\n+\n+    // bisect\n+    if (   (left >= _target && _target >= value)\n+        || (left <= _target && _target <= value))\n+    {\n+      // to the left\n+      s_right = s;\n+      right = value;\n+    }\n+    else\n+    {\n+      // to the right\n+      s_left = s;\n+      left = value;\n+    }","path":"modules/phase_field/src/postprocessors/FindValueOnLine.C","position":76,"original_position":76,"commit_id":"1e4b59b3b77c2f521711ec12add4a2725e9cf8b1","original_commit_id":"1e4b59b3b77c2f521711ec12add4a2725e9cf8b1","user":{"login":"dschwen","id":202302,"avatar_url":"https://avatars.githubusercontent.com/u/202302?v=3","gravatar_id":"","url":"https://api.github.com/users/dschwen","html_url":"https://github.com/dschwen","followers_url":"https://api.github.com/users/dschwen/followers","following_url":"https://api.github.com/users/dschwen/following{/other_user}","gists_url":"https://api.github.com/users/dschwen/gists{/gist_id}","starred_url":"https://api.github.com/users/dschwen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dschwen/subscriptions","organizations_url":"https://api.github.com/users/dschwen/orgs","repos_url":"https://api.github.com/users/dschwen/repos","events_url":"https://api.github.com/users/dschwen/events{/privacy}","received_events_url":"https://api.github.com/users/dschwen/received_events","type":"User","site_admin":false},"body":"Yeah, thanks for the comments. I had planned to add an abs/rel tolerance in\na followup PR. I'm not sure that a non-fuzzy equal is going to give any\nreal world speedup.\n\nOn Wed, May 4, 2016 at 9:26 AM Cody Permann <notifications@github.com>\nwrote:\n\n> In modules/phase_field/src/postprocessors/FindValueOnLine.C\n> <https://github.com/idaholab/moose/pull/6891#discussion_r62047812>:\n>\n> > +    Real value = getValueAtPoint(p);\n> > +\n> > +    // bisect\n> > +    if (   (left >= _target && _target >= value)\n> > +        || (left <= _target && _target <= value))\n> > +    {\n> > +      // to the left\n> > +      s_right = s;\n> > +      right = value;\n> > +    }\n> > +    else\n> > +    {\n> > +      // to the right\n> > +      s_left = s;\n> > +      left = value;\n> > +    }\n>\n> Agreed, it looks like this code doesn't exit until the bounds close in.\n> There's might be a fair amount of extra work occurring since you aren't\n> exiting when you find the value.\n>\n> —\n> You are receiving this because you authored the thread.\n> Reply to this email directly or view it on GitHub\n> <https://github.com/idaholab/moose/pull/6891/files/1e4b59b3b77c2f521711ec12add4a2725e9cf8b1#r62047812>\n>\n","created_at":"2016-05-04T14:45:16Z","updated_at":"2016-05-04T14:45:16Z","html_url":"https://github.com/idaholab/moose/pull/6891#discussion_r62051701","pull_request_url":"https://api.github.com/repos/idaholab/moose/pulls/6891","_links":{"self":{"href":"https://api.github.com/repos/idaholab/moose/pulls/comments/62051701"},"html":{"href":"https://github.com/idaholab/moose/pull/6891#discussion_r62051701"},"pull_request":{"href":"https://api.github.com/repos/idaholab/moose/pulls/6891"}}},"pull_request":{"url":"https://api.github.com/repos/idaholab/moose/pulls/6891","id":68798169,"html_url":"https://github.com/idaholab/moose/pull/6891","diff_url":"https://github.com/idaholab/moose/pull/6891.diff","patch_url":"https://github.com/idaholab/moose/pull/6891.patch","issue_url":"https://api.github.com/repos/idaholab/moose/issues/6891","number":6891,"state":"open","locked":false,"title":"Add find value by bisection","user":{"login":"dschwen","id":202302,"avatar_url":"https://avatars.githubusercontent.com/u/202302?v=3","gravatar_id":"","url":"https://api.github.com/users/dschwen","html_url":"https://github.com/dschwen","followers_url":"https://api.github.com/users/dschwen/followers","following_url":"https://api.github.com/users/dschwen/following{/other_user}","gists_url":"https://api.github.com/users/dschwen/gists{/gist_id}","starred_url":"https://api.github.com/users/dschwen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dschwen/subscriptions","organizations_url":"https://api.github.com/users/dschwen/orgs","repos_url":"https://api.github.com/users/dschwen/repos","events_url":"https://api.github.com/users/dschwen/events{/privacy}","received_events_url":"https://api.github.com/users/dschwen/received_events","type":"User","site_admin":false},"body":"Adds bisection search along line postprocessor to find the location of a specific variable value. Useful for locating an interface in phase field.\r\n\r\nCloses #6389 ","created_at":"2016-05-04T00:53:12Z","updated_at":"2016-05-04T14:45:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1be7117dc9ff9f8e5e4262da2e9db200c7303698","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/idaholab/moose/pulls/6891/commits","review_comments_url":"https://api.github.com/repos/idaholab/moose/pulls/6891/comments","review_comment_url":"https://api.github.com/repos/idaholab/moose/pulls/comments{/number}","comments_url":"https://api.github.com/repos/idaholab/moose/issues/6891/comments","statuses_url":"https://api.github.com/repos/idaholab/moose/statuses/1e4b59b3b77c2f521711ec12add4a2725e9cf8b1","head":{"label":"dschwen:bisect_6389","ref":"bisect_6389","sha":"1e4b59b3b77c2f521711ec12add4a2725e9cf8b1","user":{"login":"dschwen","id":202302,"avatar_url":"https://avatars.githubusercontent.com/u/202302?v=3","gravatar_id":"","url":"https://api.github.com/users/dschwen","html_url":"https://github.com/dschwen","followers_url":"https://api.github.com/users/dschwen/followers","following_url":"https://api.github.com/users/dschwen/following{/other_user}","gists_url":"https://api.github.com/users/dschwen/gists{/gist_id}","starred_url":"https://api.github.com/users/dschwen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dschwen/subscriptions","organizations_url":"https://api.github.com/users/dschwen/orgs","repos_url":"https://api.github.com/users/dschwen/repos","events_url":"https://api.github.com/users/dschwen/events{/privacy}","received_events_url":"https://api.github.com/users/dschwen/received_events","type":"User","site_admin":false},"repo":{"id":17870930,"name":"moose","full_name":"dschwen/moose","owner":{"login":"dschwen","id":202302,"avatar_url":"https://avatars.githubusercontent.com/u/202302?v=3","gravatar_id":"","url":"https://api.github.com/users/dschwen","html_url":"https://github.com/dschwen","followers_url":"https://api.github.com/users/dschwen/followers","following_url":"https://api.github.com/users/dschwen/following{/other_user}","gists_url":"https://api.github.com/users/dschwen/gists{/gist_id}","starred_url":"https://api.github.com/users/dschwen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dschwen/subscriptions","organizations_url":"https://api.github.com/users/dschwen/orgs","repos_url":"https://api.github.com/users/dschwen/repos","events_url":"https://api.github.com/users/dschwen/events{/privacy}","received_events_url":"https://api.github.com/users/dschwen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dschwen/moose","description":"Multiphysics Object Oriented Simulation Environment","fork":true,"url":"https://api.github.com/repos/dschwen/moose","forks_url":"https://api.github.com/repos/dschwen/moose/forks","keys_url":"https://api.github.com/repos/dschwen/moose/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dschwen/moose/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dschwen/moose/teams","hooks_url":"https://api.github.com/repos/dschwen/moose/hooks","issue_events_url":"https://api.github.com/repos/dschwen/moose/issues/events{/number}","events_url":"https://api.github.com/repos/dschwen/moose/events","assignees_url":"https://api.github.com/repos/dschwen/moose/assignees{/user}","branches_url":"https://api.github.com/repos/dschwen/moose/branches{/branch}","tags_url":"https://api.github.com/repos/dschwen/moose/tags","blobs_url":"https://api.github.com/repos/dschwen/moose/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dschwen/moose/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dschwen/moose/git/refs{/sha}","trees_url":"https://api.github.com/repos/dschwen/moose/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dschwen/moose/statuses/{sha}","languages_url":"https://api.github.com/repos/dschwen/moose/languages","stargazers_url":"https://api.github.com/repos/dschwen/moose/stargazers","contributors_url":"https://api.github.com/repos/dschwen/moose/contributors","subscribers_url":"https://api.github.com/repos/dschwen/moose/subscribers","subscription_url":"https://api.github.com/repos/dschwen/moose/subscription","commits_url":"https://api.github.com/repos/dschwen/moose/commits{/sha}","git_commits_url":"https://api.github.com/repos/dschwen/moose/git/commits{/sha}","comments_url":"https://api.github.com/repos/dschwen/moose/comments{/number}","issue_comment_url":"https://api.github.com/repos/dschwen/moose/issues/comments{/number}","contents_url":"https://api.github.com/repos/dschwen/moose/contents/{+path}","compare_url":"https://api.github.com/repos/dschwen/moose/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dschwen/moose/merges","archive_url":"https://api.github.com/repos/dschwen/moose/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dschwen/moose/downloads","issues_url":"https://api.github.com/repos/dschwen/moose/issues{/number}","pulls_url":"https://api.github.com/repos/dschwen/moose/pulls{/number}","milestones_url":"https://api.github.com/repos/dschwen/moose/milestones{/number}","notifications_url":"https://api.github.com/repos/dschwen/moose/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dschwen/moose/labels{/name}","releases_url":"https://api.github.com/repos/dschwen/moose/releases{/id}","deployments_url":"https://api.github.com/repos/dschwen/moose/deployments","created_at":"2014-03-18T15:25:39Z","updated_at":"2016-01-12T23:31:50Z","pushed_at":"2016-05-04T04:01:08Z","git_url":"git://github.com/dschwen/moose.git","ssh_url":"git@github.com:dschwen/moose.git","clone_url":"https://github.com/dschwen/moose.git","svn_url":"https://github.com/dschwen/moose","homepage":null,"size":131222,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"devel"}},"base":{"label":"idaholab:devel","ref":"devel","sha":"88c4a56758380058eca75d00d5f991c3e643c27d","user":{"login":"idaholab","id":3855370,"avatar_url":"https://avatars.githubusercontent.com/u/3855370?v=3","gravatar_id":"","url":"https://api.github.com/users/idaholab","html_url":"https://github.com/idaholab","followers_url":"https://api.github.com/users/idaholab/followers","following_url":"https://api.github.com/users/idaholab/following{/other_user}","gists_url":"https://api.github.com/users/idaholab/gists{/gist_id}","starred_url":"https://api.github.com/users/idaholab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idaholab/subscriptions","organizations_url":"https://api.github.com/users/idaholab/orgs","repos_url":"https://api.github.com/users/idaholab/repos","events_url":"https://api.github.com/users/idaholab/events{/privacy}","received_events_url":"https://api.github.com/users/idaholab/received_events","type":"Organization","site_admin":false},"repo":{"id":16851223,"name":"moose","full_name":"idaholab/moose","owner":{"login":"idaholab","id":3855370,"avatar_url":"https://avatars.githubusercontent.com/u/3855370?v=3","gravatar_id":"","url":"https://api.github.com/users/idaholab","html_url":"https://github.com/idaholab","followers_url":"https://api.github.com/users/idaholab/followers","following_url":"https://api.github.com/users/idaholab/following{/other_user}","gists_url":"https://api.github.com/users/idaholab/gists{/gist_id}","starred_url":"https://api.github.com/users/idaholab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idaholab/subscriptions","organizations_url":"https://api.github.com/users/idaholab/orgs","repos_url":"https://api.github.com/users/idaholab/repos","events_url":"https://api.github.com/users/idaholab/events{/privacy}","received_events_url":"https://api.github.com/users/idaholab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/idaholab/moose","description":"Multiphysics Object Oriented Simulation Environment","fork":false,"url":"https://api.github.com/repos/idaholab/moose","forks_url":"https://api.github.com/repos/idaholab/moose/forks","keys_url":"https://api.github.com/repos/idaholab/moose/keys{/key_id}","collaborators_url":"https://api.github.com/repos/idaholab/moose/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/idaholab/moose/teams","hooks_url":"https://api.github.com/repos/idaholab/moose/hooks","issue_events_url":"https://api.github.com/repos/idaholab/moose/issues/events{/number}","events_url":"https://api.github.com/repos/idaholab/moose/events","assignees_url":"https://api.github.com/repos/idaholab/moose/assignees{/user}","branches_url":"https://api.github.com/repos/idaholab/moose/branches{/branch}","tags_url":"https://api.github.com/repos/idaholab/moose/tags","blobs_url":"https://api.github.com/repos/idaholab/moose/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/idaholab/moose/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/idaholab/moose/git/refs{/sha}","trees_url":"https://api.github.com/repos/idaholab/moose/git/trees{/sha}","statuses_url":"https://api.github.com/repos/idaholab/moose/statuses/{sha}","languages_url":"https://api.github.com/repos/idaholab/moose/languages","stargazers_url":"https://api.github.com/repos/idaholab/moose/stargazers","contributors_url":"https://api.github.com/repos/idaholab/moose/contributors","subscribers_url":"https://api.github.com/repos/idaholab/moose/subscribers","subscription_url":"https://api.github.com/repos/idaholab/moose/subscription","commits_url":"https://api.github.com/repos/idaholab/moose/commits{/sha}","git_commits_url":"https://api.github.com/repos/idaholab/moose/git/commits{/sha}","comments_url":"https://api.github.com/repos/idaholab/moose/comments{/number}","issue_comment_url":"https://api.github.com/repos/idaholab/moose/issues/comments{/number}","contents_url":"https://api.github.com/repos/idaholab/moose/contents/{+path}","compare_url":"https://api.github.com/repos/idaholab/moose/compare/{base}...{head}","merges_url":"https://api.github.com/repos/idaholab/moose/merges","archive_url":"https://api.github.com/repos/idaholab/moose/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/idaholab/moose/downloads","issues_url":"https://api.github.com/repos/idaholab/moose/issues{/number}","pulls_url":"https://api.github.com/repos/idaholab/moose/pulls{/number}","milestones_url":"https://api.github.com/repos/idaholab/moose/milestones{/number}","notifications_url":"https://api.github.com/repos/idaholab/moose/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/idaholab/moose/labels{/name}","releases_url":"https://api.github.com/repos/idaholab/moose/releases{/id}","deployments_url":"https://api.github.com/repos/idaholab/moose/deployments","created_at":"2014-02-14T22:26:15Z","updated_at":"2016-05-01T13:38:12Z","pushed_at":"2016-05-04T14:35:26Z","git_url":"git://github.com/idaholab/moose.git","ssh_url":"git@github.com:idaholab/moose.git","clone_url":"https://github.com/idaholab/moose.git","svn_url":"https://github.com/idaholab/moose","homepage":"http://www.mooseframework.org","size":143615,"stargazers_count":150,"watchers_count":150,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":235,"mirror_url":null,"open_issues_count":603,"forks":235,"open_issues":603,"watchers":150,"default_branch":"devel"}},"_links":{"self":{"href":"https://api.github.com/repos/idaholab/moose/pulls/6891"},"html":{"href":"https://github.com/idaholab/moose/pull/6891"},"issue":{"href":"https://api.github.com/repos/idaholab/moose/issues/6891"},"comments":{"href":"https://api.github.com/repos/idaholab/moose/issues/6891/comments"},"review_comments":{"href":"https://api.github.com/repos/idaholab/moose/pulls/6891/comments"},"review_comment":{"href":"https://api.github.com/repos/idaholab/moose/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/idaholab/moose/pulls/6891/commits"},"statuses":{"href":"https://api.github.com/repos/idaholab/moose/statuses/1e4b59b3b77c2f521711ec12add4a2725e9cf8b1"}}}}