{"action":"created","comment":{"url":"https://api.github.com/repos/libMesh/libmesh/pulls/comments/237965351","pull_request_review_id":180401797,"id":237965351,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNzk2NTM1MQ==","diff_hunk":"@@ -78,16 +78,15 @@ double __libmesh_nlopt_objective(unsigned n,\n     {\n       if (solver->gradient_object != nullptr)\n         {\n-          solver->gradient_object->gradient(\n-                                            *(sys.current_local_solution), *(sys.rhs), sys);\n+          solver->gradient_object->gradient(*(sys.current_local_solution), *(sys.rhs), sys);\n \n           // we've filled up sys.rhs with the gradient data, now copy it\n           // to the nlopt data structure\n           libmesh_assert(sys.rhs->size() == n);\n \n           std::vector<double> grad;\n           sys.rhs->localize_to_one(grad);\n-          for (unsigned i=0; i<n; ++i)\n+          for (auto i : IntRange<dof_id_type>(0, n))","path":"src/solvers/nlopt_optimization_solver.C","position":44,"original_position":44,"commit_id":"3f617539ae5e29c4a1b5e9243df68760c310b8b4","original_commit_id":"3f617539ae5e29c4a1b5e9243df68760c310b8b4","user":{"login":"jwpeterson","id":1775907,"node_id":"MDQ6VXNlcjE3NzU5MDc=","avatar_url":"https://avatars0.githubusercontent.com/u/1775907?v=4","gravatar_id":"","url":"https://api.github.com/users/jwpeterson","html_url":"https://github.com/jwpeterson","followers_url":"https://api.github.com/users/jwpeterson/followers","following_url":"https://api.github.com/users/jwpeterson/following{/other_user}","gists_url":"https://api.github.com/users/jwpeterson/gists{/gist_id}","starred_url":"https://api.github.com/users/jwpeterson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwpeterson/subscriptions","organizations_url":"https://api.github.com/users/jwpeterson/orgs","repos_url":"https://api.github.com/users/jwpeterson/repos","events_url":"https://api.github.com/users/jwpeterson/events{/privacy}","received_events_url":"https://api.github.com/users/jwpeterson/received_events","type":"User","site_admin":false},"body":"So here we are somewhat constrained by the [nlopt interface](https://nlopt.readthedocs.io/en/latest/NLopt_Reference/#objective-function) itself which is expecting an `unsigned int`.\r\n```\r\ndouble f(unsigned n, const double* x, double* grad, void* f_data);\r\n```\r\nThat probably means that we should `static_assert` that we aren't using the nlopt code when `sizeof(dof_id_type) != 4`...\r\n","created_at":"2018-11-30T18:55:42Z","updated_at":"2018-11-30T18:55:43Z","html_url":"https://github.com/libMesh/libmesh/pull/1959#discussion_r237965351","pull_request_url":"https://api.github.com/repos/libMesh/libmesh/pulls/1959","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/libMesh/libmesh/pulls/comments/237965351"},"html":{"href":"https://github.com/libMesh/libmesh/pull/1959#discussion_r237965351"},"pull_request":{"href":"https://api.github.com/repos/libMesh/libmesh/pulls/1959"}},"in_reply_to_id":237942585},"pull_request":{"url":"https://api.github.com/repos/libMesh/libmesh/pulls/1959","id":234791793,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM0NzkxNzkz","html_url":"https://github.com/libMesh/libmesh/pull/1959","diff_url":"https://github.com/libMesh/libmesh/pull/1959.diff","patch_url":"https://github.com/libMesh/libmesh/pull/1959.patch","issue_url":"https://api.github.com/repos/libMesh/libmesh/issues/1959","number":1959,"state":"open","locked":false,"title":"Add index_range() helper function.","user":{"login":"jwpeterson","id":1775907,"node_id":"MDQ6VXNlcjE3NzU5MDc=","avatar_url":"https://avatars0.githubusercontent.com/u/1775907?v=4","gravatar_id":"","url":"https://api.github.com/users/jwpeterson","html_url":"https://github.com/jwpeterson","followers_url":"https://api.github.com/users/jwpeterson/followers","following_url":"https://api.github.com/users/jwpeterson/following{/other_user}","gists_url":"https://api.github.com/users/jwpeterson/gists{/gist_id}","starred_url":"https://api.github.com/users/jwpeterson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwpeterson/subscriptions","organizations_url":"https://api.github.com/users/jwpeterson/orgs","repos_url":"https://api.github.com/users/jwpeterson/repos","events_url":"https://api.github.com/users/jwpeterson/events{/privacy}","received_events_url":"https://api.github.com/users/jwpeterson/received_events","type":"User","site_admin":false},"body":"This helper allows us to rewrite loops over `std::vectors` in which indices are required in such a way that:\r\n\r\n1. No explicit index type is used at the call site.\r\n1. We avoid repeated calls to `vector::size()` in the loop termination test (although it's not clear if that's really much of an optimization...)\r\n\r\nSo, for example, a typical for-loop could be rewritten as:\r\n```diff\r\n-      for (unsigned int s = 0; s != sysnames.size(); ++s)\r\n+      for (auto s : index_range(sysnames))\r\n```\r\nNote that the underlying index type is `std::size_t` as that is the type returned by `vector::size()`. It is still possible to do explicit signed integer iteration by constructing an `IntRange<int>` on the fly, and I have also done that in a few cases in this patch. I still need to test how well compilers are able to vectorize `IntRange<int>` loops... if it doesn't seem to work, I'll revert to non range-based loops instead in those cases.  \r\n\r\nAs you might imagine, we have many places in the library where we can use this helper, I've only fixed about 10% of them in this initial PR. I'm planning to keep all these small commits on this branch just in case I've broken something and need to go back and bisect.\r\n\r\n\r\n","created_at":"2018-11-29T21:27:07Z","updated_at":"2018-11-30T18:55:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fc24a02976b618310a5f274ad51f9653fba1c7a3","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/libMesh/libmesh/pulls/1959/commits","review_comments_url":"https://api.github.com/repos/libMesh/libmesh/pulls/1959/comments","review_comment_url":"https://api.github.com/repos/libMesh/libmesh/pulls/comments{/number}","comments_url":"https://api.github.com/repos/libMesh/libmesh/issues/1959/comments","statuses_url":"https://api.github.com/repos/libMesh/libmesh/statuses/3f617539ae5e29c4a1b5e9243df68760c310b8b4","head":{"label":"jwpeterson:intrange","ref":"intrange","sha":"3f617539ae5e29c4a1b5e9243df68760c310b8b4","user":{"login":"jwpeterson","id":1775907,"node_id":"MDQ6VXNlcjE3NzU5MDc=","avatar_url":"https://avatars0.githubusercontent.com/u/1775907?v=4","gravatar_id":"","url":"https://api.github.com/users/jwpeterson","html_url":"https://github.com/jwpeterson","followers_url":"https://api.github.com/users/jwpeterson/followers","following_url":"https://api.github.com/users/jwpeterson/following{/other_user}","gists_url":"https://api.github.com/users/jwpeterson/gists{/gist_id}","starred_url":"https://api.github.com/users/jwpeterson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwpeterson/subscriptions","organizations_url":"https://api.github.com/users/jwpeterson/orgs","repos_url":"https://api.github.com/users/jwpeterson/repos","events_url":"https://api.github.com/users/jwpeterson/events{/privacy}","received_events_url":"https://api.github.com/users/jwpeterson/received_events","type":"User","site_admin":false},"repo":{"id":7152212,"node_id":"MDEwOlJlcG9zaXRvcnk3MTUyMjEy","name":"libmesh","full_name":"jwpeterson/libmesh","private":false,"owner":{"login":"jwpeterson","id":1775907,"node_id":"MDQ6VXNlcjE3NzU5MDc=","avatar_url":"https://avatars0.githubusercontent.com/u/1775907?v=4","gravatar_id":"","url":"https://api.github.com/users/jwpeterson","html_url":"https://github.com/jwpeterson","followers_url":"https://api.github.com/users/jwpeterson/followers","following_url":"https://api.github.com/users/jwpeterson/following{/other_user}","gists_url":"https://api.github.com/users/jwpeterson/gists{/gist_id}","starred_url":"https://api.github.com/users/jwpeterson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwpeterson/subscriptions","organizations_url":"https://api.github.com/users/jwpeterson/orgs","repos_url":"https://api.github.com/users/jwpeterson/repos","events_url":"https://api.github.com/users/jwpeterson/events{/privacy}","received_events_url":"https://api.github.com/users/jwpeterson/received_events","type":"User","site_admin":false},"html_url":"https://github.com/jwpeterson/libmesh","description":"libMesh github repository","fork":true,"url":"https://api.github.com/repos/jwpeterson/libmesh","forks_url":"https://api.github.com/repos/jwpeterson/libmesh/forks","keys_url":"https://api.github.com/repos/jwpeterson/libmesh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jwpeterson/libmesh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jwpeterson/libmesh/teams","hooks_url":"https://api.github.com/repos/jwpeterson/libmesh/hooks","issue_events_url":"https://api.github.com/repos/jwpeterson/libmesh/issues/events{/number}","events_url":"https://api.github.com/repos/jwpeterson/libmesh/events","assignees_url":"https://api.github.com/repos/jwpeterson/libmesh/assignees{/user}","branches_url":"https://api.github.com/repos/jwpeterson/libmesh/branches{/branch}","tags_url":"https://api.github.com/repos/jwpeterson/libmesh/tags","blobs_url":"https://api.github.com/repos/jwpeterson/libmesh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jwpeterson/libmesh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jwpeterson/libmesh/git/refs{/sha}","trees_url":"https://api.github.com/repos/jwpeterson/libmesh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jwpeterson/libmesh/statuses/{sha}","languages_url":"https://api.github.com/repos/jwpeterson/libmesh/languages","stargazers_url":"https://api.github.com/repos/jwpeterson/libmesh/stargazers","contributors_url":"https://api.github.com/repos/jwpeterson/libmesh/contributors","subscribers_url":"https://api.github.com/repos/jwpeterson/libmesh/subscribers","subscription_url":"https://api.github.com/repos/jwpeterson/libmesh/subscription","commits_url":"https://api.github.com/repos/jwpeterson/libmesh/commits{/sha}","git_commits_url":"https://api.github.com/repos/jwpeterson/libmesh/git/commits{/sha}","comments_url":"https://api.github.com/repos/jwpeterson/libmesh/comments{/number}","issue_comment_url":"https://api.github.com/repos/jwpeterson/libmesh/issues/comments{/number}","contents_url":"https://api.github.com/repos/jwpeterson/libmesh/contents/{+path}","compare_url":"https://api.github.com/repos/jwpeterson/libmesh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jwpeterson/libmesh/merges","archive_url":"https://api.github.com/repos/jwpeterson/libmesh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jwpeterson/libmesh/downloads","issues_url":"https://api.github.com/repos/jwpeterson/libmesh/issues{/number}","pulls_url":"https://api.github.com/repos/jwpeterson/libmesh/pulls{/number}","milestones_url":"https://api.github.com/repos/jwpeterson/libmesh/milestones{/number}","notifications_url":"https://api.github.com/repos/jwpeterson/libmesh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jwpeterson/libmesh/labels{/name}","releases_url":"https://api.github.com/repos/jwpeterson/libmesh/releases{/id}","deployments_url":"https://api.github.com/repos/jwpeterson/libmesh/deployments","created_at":"2012-12-13T17:22:45Z","updated_at":"2018-11-29T20:34:04Z","pushed_at":"2018-11-30T15:14:13Z","git_url":"git://github.com/jwpeterson/libmesh.git","ssh_url":"git@github.com:jwpeterson/libmesh.git","clone_url":"https://github.com/jwpeterson/libmesh.git","svn_url":"https://github.com/jwpeterson/libmesh","homepage":"http://libmesh.sourceforge.net","size":122402,"stargazers_count":1,"watchers_count":1,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"lgpl-2.1","name":"GNU Lesser General Public License v2.1","spdx_id":"LGPL-2.1","url":"https://api.github.com/licenses/lgpl-2.1","node_id":"MDc6TGljZW5zZTEx"},"forks":1,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"libMesh:master","ref":"master","sha":"4229bbf138a32d3d566f7bb505132632fdb6b8dd","user":{"login":"libMesh","id":2366757,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzNjY3NTc=","avatar_url":"https://avatars1.githubusercontent.com/u/2366757?v=4","gravatar_id":"","url":"https://api.github.com/users/libMesh","html_url":"https://github.com/libMesh","followers_url":"https://api.github.com/users/libMesh/followers","following_url":"https://api.github.com/users/libMesh/following{/other_user}","gists_url":"https://api.github.com/users/libMesh/gists{/gist_id}","starred_url":"https://api.github.com/users/libMesh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libMesh/subscriptions","organizations_url":"https://api.github.com/users/libMesh/orgs","repos_url":"https://api.github.com/users/libMesh/repos","events_url":"https://api.github.com/users/libMesh/events{/privacy}","received_events_url":"https://api.github.com/users/libMesh/received_events","type":"Organization","site_admin":false},"repo":{"id":5850234,"node_id":"MDEwOlJlcG9zaXRvcnk1ODUwMjM0","name":"libmesh","full_name":"libMesh/libmesh","private":false,"owner":{"login":"libMesh","id":2366757,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzNjY3NTc=","avatar_url":"https://avatars1.githubusercontent.com/u/2366757?v=4","gravatar_id":"","url":"https://api.github.com/users/libMesh","html_url":"https://github.com/libMesh","followers_url":"https://api.github.com/users/libMesh/followers","following_url":"https://api.github.com/users/libMesh/following{/other_user}","gists_url":"https://api.github.com/users/libMesh/gists{/gist_id}","starred_url":"https://api.github.com/users/libMesh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libMesh/subscriptions","organizations_url":"https://api.github.com/users/libMesh/orgs","repos_url":"https://api.github.com/users/libMesh/repos","events_url":"https://api.github.com/users/libMesh/events{/privacy}","received_events_url":"https://api.github.com/users/libMesh/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/libMesh/libmesh","description":"libMesh github repository","fork":false,"url":"https://api.github.com/repos/libMesh/libmesh","forks_url":"https://api.github.com/repos/libMesh/libmesh/forks","keys_url":"https://api.github.com/repos/libMesh/libmesh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/libMesh/libmesh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/libMesh/libmesh/teams","hooks_url":"https://api.github.com/repos/libMesh/libmesh/hooks","issue_events_url":"https://api.github.com/repos/libMesh/libmesh/issues/events{/number}","events_url":"https://api.github.com/repos/libMesh/libmesh/events","assignees_url":"https://api.github.com/repos/libMesh/libmesh/assignees{/user}","branches_url":"https://api.github.com/repos/libMesh/libmesh/branches{/branch}","tags_url":"https://api.github.com/repos/libMesh/libmesh/tags","blobs_url":"https://api.github.com/repos/libMesh/libmesh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/libMesh/libmesh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/libMesh/libmesh/git/refs{/sha}","trees_url":"https://api.github.com/repos/libMesh/libmesh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/libMesh/libmesh/statuses/{sha}","languages_url":"https://api.github.com/repos/libMesh/libmesh/languages","stargazers_url":"https://api.github.com/repos/libMesh/libmesh/stargazers","contributors_url":"https://api.github.com/repos/libMesh/libmesh/contributors","subscribers_url":"https://api.github.com/repos/libMesh/libmesh/subscribers","subscription_url":"https://api.github.com/repos/libMesh/libmesh/subscription","commits_url":"https://api.github.com/repos/libMesh/libmesh/commits{/sha}","git_commits_url":"https://api.github.com/repos/libMesh/libmesh/git/commits{/sha}","comments_url":"https://api.github.com/repos/libMesh/libmesh/comments{/number}","issue_comment_url":"https://api.github.com/repos/libMesh/libmesh/issues/comments{/number}","contents_url":"https://api.github.com/repos/libMesh/libmesh/contents/{+path}","compare_url":"https://api.github.com/repos/libMesh/libmesh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/libMesh/libmesh/merges","archive_url":"https://api.github.com/repos/libMesh/libmesh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/libMesh/libmesh/downloads","issues_url":"https://api.github.com/repos/libMesh/libmesh/issues{/number}","pulls_url":"https://api.github.com/repos/libMesh/libmesh/pulls{/number}","milestones_url":"https://api.github.com/repos/libMesh/libmesh/milestones{/number}","notifications_url":"https://api.github.com/repos/libMesh/libmesh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/libMesh/libmesh/labels{/name}","releases_url":"https://api.github.com/repos/libMesh/libmesh/releases{/id}","deployments_url":"https://api.github.com/repos/libMesh/libmesh/deployments","created_at":"2012-09-18T02:12:18Z","updated_at":"2018-11-30T17:41:05Z","pushed_at":"2018-11-30T18:28:30Z","git_url":"git://github.com/libMesh/libmesh.git","ssh_url":"git@github.com:libMesh/libmesh.git","clone_url":"https://github.com/libMesh/libmesh.git","svn_url":"https://github.com/libMesh/libmesh","homepage":"http://libmesh.github.io","size":122212,"stargazers_count":254,"watchers_count":254,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":166,"mirror_url":null,"archived":false,"open_issues_count":153,"license":{"key":"lgpl-2.1","name":"GNU Lesser General Public License v2.1","spdx_id":"LGPL-2.1","url":"https://api.github.com/licenses/lgpl-2.1","node_id":"MDc6TGljZW5zZTEx"},"forks":166,"open_issues":153,"watchers":254,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/libMesh/libmesh/pulls/1959"},"html":{"href":"https://github.com/libMesh/libmesh/pull/1959"},"issue":{"href":"https://api.github.com/repos/libMesh/libmesh/issues/1959"},"comments":{"href":"https://api.github.com/repos/libMesh/libmesh/issues/1959/comments"},"review_comments":{"href":"https://api.github.com/repos/libMesh/libmesh/pulls/1959/comments"},"review_comment":{"href":"https://api.github.com/repos/libMesh/libmesh/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/libMesh/libmesh/pulls/1959/commits"},"statuses":{"href":"https://api.github.com/repos/libMesh/libmesh/statuses/3f617539ae5e29c4a1b5e9243df68760c310b8b4"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"jwpeterson"}}