{"action":"created","comment":{"url":"https://api.github.com/repos/idaholab/moose/pulls/comments/89868157","pull_request_review_id":10399417,"id":89868157,"diff_hunk":"@@ -0,0 +1,226 @@\n+/****************************************************************/\n+/*               DO NOT MODIFY THIS HEADER                      */\n+/* MOOSE - Multiphysics Object Oriented Simulation Environment  */\n+/*                                                              */\n+/*           (c) 2010 Battelle Energy Alliance, LLC             */\n+/*                   ALL RIGHTS RESERVED                        */\n+/*                                                              */\n+/*          Prepared by Battelle Energy Alliance, LLC           */\n+/*            Under Contract No. DE-AC07-05ID14517              */\n+/*            With the U. S. Department of Energy               */\n+/*                                                              */\n+/*            See COPYRIGHT for full restrictions               */\n+/****************************************************************/\n+\n+#include \"BicubicSplineInterpolation.h\"\n+#include \"MooseError.h\"\n+\n+int BicubicSplineInterpolation::_file_number = 0;\n+\n+BicubicSplineInterpolation::BicubicSplineInterpolation()\n+{\n+}\n+\n+BicubicSplineInterpolation::BicubicSplineInterpolation(const std::vector<Real> & x1, const std::vector<Real> & x2, const std::vector<std::vector<Real> > & y, const std::vector<Real> & yx11, const std::vector<Real> & yx1n, const std::vector<Real> & yx21, const std::vector<Real> & yx2n) :\n+    SplineInterpolationBase(),\n+    _x1(x1),\n+    _x2(x2),\n+    _y(y),\n+    _yx11(yx11),\n+    _yx1n(yx1n),\n+    _yx21(yx21),\n+    _yx2n(yx2n)\n+{\n+  errorCheck();\n+  solve();\n+}\n+\n+void\n+BicubicSplineInterpolation::setData(const std::vector<Real> & x1, const std::vector<Real> & x2, const std::vector<std::vector<Real> > & y, const std::vector<Real> & yx11, const std::vector<Real> & yx1n, const std::vector<Real> & yx21, const std::vector<Real> & yx2n)\n+{\n+  _x1 = x1;\n+  _x2 = x2;\n+  _y = y;\n+  _yx11 = yx11;\n+  _yx1n = yx1n;\n+  _yx21 = yx21;\n+  _yx2n = yx2n;\n+  errorCheck();\n+  solve();\n+}\n+\n+void\n+BicubicSplineInterpolation::errorCheck()\n+{\n+  unsigned int m = _x1.size(), n = _x2.size();\n+\n+  if (_y.size() != m)\n+    mooseError(\"y row dimension does not match the size of x1.\");\n+  else\n+    for (int i = 0; i < _y.size(); ++i)\n+      if (_y[i].size() != n)\n+        mooseError(\"y column dimension does not match the size of x2.\");\n+\n+  if (_yx11.empty())\n+    _yx11.resize(n, 1e30);\n+  else if (_yx11.size() != n)\n+    mooseError(\"The length of the vectors holding the first derivatives of y with respect to x1 must match the length of x2.\");\n+\n+  if (_yx1n.empty())\n+    _yx1n.resize(n, 1e30);\n+  else if (_yx1n.size() != n)\n+    mooseError(\"The length of the vectors holding the first derivatives of y with respect to x1 must match the length of x2.\");\n+\n+  if (_yx21.empty())\n+    _yx21.resize(m, 1e30);\n+  else if (_yx21.size() != m)\n+    mooseError(\"The length of the vectors holding the first derivatives of y with respect to x2 must match the length of x1.\");\n+\n+  if (_yx2n.empty())\n+    _yx2n.resize(m, 1e30);\n+  else if (_yx2n.size() != m)\n+    mooseError(\"The length of the vectors holding the first derivatives of y with respect to x2 must match the length of x1.\");\n+}\n+\n+void\n+BicubicSplineInterpolation::constructRowSplineSecondDerivativeTable()\n+{\n+  int m = _x1.size();\n+  _y2_rows.resize(m);\n+\n+  if (_yx21.empty())\n+    for (int j = 0; j < m; ++j)\n+      spline(_x2, _y[j], _y2_rows[j]);\n+\n+  else\n+    for (int j = 0; j < m; ++j)\n+      spline(_x2, _y[j], _y2_rows[j], _yx21[j], _yx2n[j]);\n+}\n+\n+void\n+BicubicSplineInterpolation::constructColumnSplineSecondDerivativeTable()\n+{\n+  int n = _x2.size();\n+  _y2_columns.resize(n);\n+\n+  if (_yx11.empty())\n+    for (int j = 0; j < n; ++j)\n+      spline(_x1, _y[j], _y2_columns[j]);\n+\n+  else\n+    for (int j = 0; j < n; ++j)\n+      spline(_x1, _y[j], _y2_columns[j], _yx11[j], _yx1n[j]);\n+\n+}\n+\n+void\n+BicubicSplineInterpolation::solve()\n+{\n+  constructRowSplineSecondDerivativeTable();\n+  constructColumnSplineSecondDerivativeTable();\n+}\n+\n+Real\n+BicubicSplineInterpolation::sample(Real x1, Real x2, Real yx11/* = 1e30*/, Real yx1n/* = 1e30*/)\n+{\n+  int m = _x1.size();\n+  std::vector<Real> column_spline_second_derivs(m), row_spline_eval(m);\n+\n+  // Evaluate m row-splines to get y-values for column spline construction\n+  for (int j = 0; j < m; ++j)\n+    row_spline_eval[j] = SplineInterpolationBase::sample(_x2, _y[j], _y2_rows[j], x2);\n+\n+  // Construct single column spline; get back the second derivatives wrt x1 coord on the x1 grid points\n+  spline(_x1, row_spline_eval, column_spline_second_derivs, yx11, yx1n);\n+\n+  // Evaluate newly constructed column spline\n+  return SplineInterpolationBase::sample(_x1, row_spline_eval, column_spline_second_derivs, x1);\n+}\n+\n+Real\n+BicubicSplineInterpolation::sampleDerivative(Real x1, Real x2, unsigned int deriv_var, Real yp1/* = 1e30*/, Real ypn/* = 1e30*/)\n+{\n+  // Take derivative along x1 axis\n+  if (deriv_var == 1)\n+  {\n+    int m = _x1.size();\n+    std::vector<Real> column_spline_second_derivs(m), row_spline_eval(m);\n+\n+    // Evaluate m row-splines to get y-values for column spline construction\n+    for (int j = 0; j < m; ++j)","path":"framework/src/utils/BicubicSplineInterpolation.C","position":150,"original_position":150,"commit_id":"efa1548ed6070501e4082869258d2d4ebec5608b","original_commit_id":"efa1548ed6070501e4082869258d2d4ebec5608b","user":{"login":"permcody","id":3036960,"avatar_url":"https://avatars.githubusercontent.com/u/3036960?v=3","gravatar_id":"","url":"https://api.github.com/users/permcody","html_url":"https://github.com/permcody","followers_url":"https://api.github.com/users/permcody/followers","following_url":"https://api.github.com/users/permcody/following{/other_user}","gists_url":"https://api.github.com/users/permcody/gists{/gist_id}","starred_url":"https://api.github.com/users/permcody/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/permcody/subscriptions","organizations_url":"https://api.github.com/users/permcody/orgs","repos_url":"https://api.github.com/users/permcody/repos","events_url":"https://api.github.com/users/permcody/events{/privacy}","received_events_url":"https://api.github.com/users/permcody/received_events","type":"User","site_admin":false},"body":"Sadly, there is no construct that lets you loop over a range of integers like that. People have macros and other tricks for building them, but it's more trouble than it's worth IMHO.\r\n\r\nDecltype lets you match types, so in the new C++11 way of thinking you use `auto` a lot and then to make sure you match one type against some other `auto` type, you use decltype to declare it. The downside is that it's a bit ugly.\r\n```\r\nfor (decltype(m) j = 0; ...)\r\n```","created_at":"2016-11-28T19:50:26Z","updated_at":"2016-11-28T19:50:26Z","html_url":"https://github.com/idaholab/moose/pull/8126#discussion_r89868157","pull_request_url":"https://api.github.com/repos/idaholab/moose/pulls/8126","_links":{"self":{"href":"https://api.github.com/repos/idaholab/moose/pulls/comments/89868157"},"html":{"href":"https://github.com/idaholab/moose/pull/8126#discussion_r89868157"},"pull_request":{"href":"https://api.github.com/repos/idaholab/moose/pulls/8126"}}},"pull_request":{"url":"https://api.github.com/repos/idaholab/moose/pulls/8126","id":95344268,"html_url":"https://github.com/idaholab/moose/pull/8126","diff_url":"https://github.com/idaholab/moose/pull/8126.diff","patch_url":"https://github.com/idaholab/moose/pull/8126.patch","issue_url":"https://api.github.com/repos/idaholab/moose/issues/8126","number":8126,"state":"open","locked":false,"title":"Implement bicubic spline interpolator","user":{"login":"lindsayad","id":10248304,"avatar_url":"https://avatars.githubusercontent.com/u/10248304?v=3","gravatar_id":"","url":"https://api.github.com/users/lindsayad","html_url":"https://github.com/lindsayad","followers_url":"https://api.github.com/users/lindsayad/followers","following_url":"https://api.github.com/users/lindsayad/following{/other_user}","gists_url":"https://api.github.com/users/lindsayad/gists{/gist_id}","starred_url":"https://api.github.com/users/lindsayad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lindsayad/subscriptions","organizations_url":"https://api.github.com/users/lindsayad/orgs","repos_url":"https://api.github.com/users/lindsayad/repos","events_url":"https://api.github.com/users/lindsayad/events{/privacy}","received_events_url":"https://api.github.com/users/lindsayad/received_events","type":"User","site_admin":false},"body":"- Added new class SplineInterpolationBase from which both SplineInterpolation and BicubicSplineInterpolation inherit\r\n- Added BicubicSplineFunction which takes x1, x2, and y arguments. Also optionally takes arguments which can supply first derivatives at the bounds of the spline interpolation grid\r\n- Added test which shows a bicubic spline exactly reproducing an analytical bicubic function.\r\n    - Can remove the supplied first derivative arguments which will remove the agreement between the spline and analytic functions (this is the desired behavior)\r\n\r\nAddresses #8109 \r\n\r\n### Relevant figures:\r\n\r\n- Nodal values are the solution values (corresponding to function x^3 + 2*y^3)\r\n\r\n![bicubic-spline-test-u](https://cloud.githubusercontent.com/assets/10248304/20634554/4f59f294-b307-11e6-81fb-54ab8f4acfff.png)\r\n\r\n- Nodal values are the values of the bicubic spline function (matches the solution values)\r\n\r\n![bicubic-spline-test-spline-func-value](https://cloud.githubusercontent.com/assets/10248304/20634553/4f593b6a-b307-11e6-8145-aaf2f7e8e3ce.png)\r\n\r\n- Nodal values are the values of the bicubic spline function when the first derivatives are not supplied at the boundaries of the spline interpolation. Interpolated values don't agree exactly with solution (and they shouldn't since now we are assuming natural splines)\r\n\r\n![bicubic-spline-test-spline-func-value-no-first-derivs](https://cloud.githubusercontent.com/assets/10248304/20634552/4f587c02-b307-11e6-80ec-724aef5a71db.png)\r\n\r\n\r\n","created_at":"2016-11-25T20:04:54Z","updated_at":"2016-11-28T19:50:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ebc4d0111865bf6fd43356c6bbb4425b5f48813c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/idaholab/moose/pulls/8126/commits","review_comments_url":"https://api.github.com/repos/idaholab/moose/pulls/8126/comments","review_comment_url":"https://api.github.com/repos/idaholab/moose/pulls/comments{/number}","comments_url":"https://api.github.com/repos/idaholab/moose/issues/8126/comments","statuses_url":"https://api.github.com/repos/idaholab/moose/statuses/efa1548ed6070501e4082869258d2d4ebec5608b","head":{"label":"lindsayad:bicubic_spline","ref":"bicubic_spline","sha":"efa1548ed6070501e4082869258d2d4ebec5608b","user":{"login":"lindsayad","id":10248304,"avatar_url":"https://avatars.githubusercontent.com/u/10248304?v=3","gravatar_id":"","url":"https://api.github.com/users/lindsayad","html_url":"https://github.com/lindsayad","followers_url":"https://api.github.com/users/lindsayad/followers","following_url":"https://api.github.com/users/lindsayad/following{/other_user}","gists_url":"https://api.github.com/users/lindsayad/gists{/gist_id}","starred_url":"https://api.github.com/users/lindsayad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lindsayad/subscriptions","organizations_url":"https://api.github.com/users/lindsayad/orgs","repos_url":"https://api.github.com/users/lindsayad/repos","events_url":"https://api.github.com/users/lindsayad/events{/privacy}","received_events_url":"https://api.github.com/users/lindsayad/received_events","type":"User","site_admin":false},"repo":{"id":45877148,"name":"moose","full_name":"lindsayad/moose","owner":{"login":"lindsayad","id":10248304,"avatar_url":"https://avatars.githubusercontent.com/u/10248304?v=3","gravatar_id":"","url":"https://api.github.com/users/lindsayad","html_url":"https://github.com/lindsayad","followers_url":"https://api.github.com/users/lindsayad/followers","following_url":"https://api.github.com/users/lindsayad/following{/other_user}","gists_url":"https://api.github.com/users/lindsayad/gists{/gist_id}","starred_url":"https://api.github.com/users/lindsayad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lindsayad/subscriptions","organizations_url":"https://api.github.com/users/lindsayad/orgs","repos_url":"https://api.github.com/users/lindsayad/repos","events_url":"https://api.github.com/users/lindsayad/events{/privacy}","received_events_url":"https://api.github.com/users/lindsayad/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lindsayad/moose","description":"Multiphysics Object Oriented Simulation Environment","fork":true,"url":"https://api.github.com/repos/lindsayad/moose","forks_url":"https://api.github.com/repos/lindsayad/moose/forks","keys_url":"https://api.github.com/repos/lindsayad/moose/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lindsayad/moose/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lindsayad/moose/teams","hooks_url":"https://api.github.com/repos/lindsayad/moose/hooks","issue_events_url":"https://api.github.com/repos/lindsayad/moose/issues/events{/number}","events_url":"https://api.github.com/repos/lindsayad/moose/events","assignees_url":"https://api.github.com/repos/lindsayad/moose/assignees{/user}","branches_url":"https://api.github.com/repos/lindsayad/moose/branches{/branch}","tags_url":"https://api.github.com/repos/lindsayad/moose/tags","blobs_url":"https://api.github.com/repos/lindsayad/moose/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lindsayad/moose/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lindsayad/moose/git/refs{/sha}","trees_url":"https://api.github.com/repos/lindsayad/moose/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lindsayad/moose/statuses/{sha}","languages_url":"https://api.github.com/repos/lindsayad/moose/languages","stargazers_url":"https://api.github.com/repos/lindsayad/moose/stargazers","contributors_url":"https://api.github.com/repos/lindsayad/moose/contributors","subscribers_url":"https://api.github.com/repos/lindsayad/moose/subscribers","subscription_url":"https://api.github.com/repos/lindsayad/moose/subscription","commits_url":"https://api.github.com/repos/lindsayad/moose/commits{/sha}","git_commits_url":"https://api.github.com/repos/lindsayad/moose/git/commits{/sha}","comments_url":"https://api.github.com/repos/lindsayad/moose/comments{/number}","issue_comment_url":"https://api.github.com/repos/lindsayad/moose/issues/comments{/number}","contents_url":"https://api.github.com/repos/lindsayad/moose/contents/{+path}","compare_url":"https://api.github.com/repos/lindsayad/moose/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lindsayad/moose/merges","archive_url":"https://api.github.com/repos/lindsayad/moose/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lindsayad/moose/downloads","issues_url":"https://api.github.com/repos/lindsayad/moose/issues{/number}","pulls_url":"https://api.github.com/repos/lindsayad/moose/pulls{/number}","milestones_url":"https://api.github.com/repos/lindsayad/moose/milestones{/number}","notifications_url":"https://api.github.com/repos/lindsayad/moose/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lindsayad/moose/labels{/name}","releases_url":"https://api.github.com/repos/lindsayad/moose/releases{/id}","deployments_url":"https://api.github.com/repos/lindsayad/moose/deployments","created_at":"2015-11-10T00:44:16Z","updated_at":"2016-01-11T17:39:32Z","pushed_at":"2016-11-26T00:35:28Z","git_url":"git://github.com/lindsayad/moose.git","ssh_url":"git@github.com:lindsayad/moose.git","clone_url":"https://github.com/lindsayad/moose.git","svn_url":"https://github.com/lindsayad/moose","homepage":"http://www.mooseframework.org","size":150809,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"idaholab:devel","ref":"devel","sha":"b51ef5d8f5d1fff565828938c8da0e1c1e945c69","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-11-16T10:44:16Z","pushed_at":"2016-11-28T19:16:56Z","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":168328,"stargazers_count":179,"watchers_count":179,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":303,"mirror_url":null,"open_issues_count":713,"forks":303,"open_issues":713,"watchers":179,"default_branch":"devel"}},"_links":{"self":{"href":"https://api.github.com/repos/idaholab/moose/pulls/8126"},"html":{"href":"https://github.com/idaholab/moose/pull/8126"},"issue":{"href":"https://api.github.com/repos/idaholab/moose/issues/8126"},"comments":{"href":"https://api.github.com/repos/idaholab/moose/issues/8126/comments"},"review_comments":{"href":"https://api.github.com/repos/idaholab/moose/pulls/8126/comments"},"review_comment":{"href":"https://api.github.com/repos/idaholab/moose/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/idaholab/moose/pulls/8126/commits"},"statuses":{"href":"https://api.github.com/repos/idaholab/moose/statuses/efa1548ed6070501e4082869258d2d4ebec5608b"}}}}
{"actor":{"display_login":"permcody"}}