{"action":"created","issue":{"url":"https://api.github.com/repos/firedrakeproject/flooddrake/issues/8","repository_url":"https://api.github.com/repos/firedrakeproject/flooddrake","labels_url":"https://api.github.com/repos/firedrakeproject/flooddrake/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/firedrakeproject/flooddrake/issues/8/comments","events_url":"https://api.github.com/repos/firedrakeproject/flooddrake/issues/8/events","html_url":"https://github.com/firedrakeproject/flooddrake/issues/8","id":170163139,"number":8,"title":"Slope modification kernels have C bugs","user":{"login":"wence-","id":1126981,"avatar_url":"https://avatars.githubusercontent.com/u/1126981?v=3","gravatar_id":"","url":"https://api.github.com/users/wence-","html_url":"https://github.com/wence-","followers_url":"https://api.github.com/users/wence-/followers","following_url":"https://api.github.com/users/wence-/following{/other_user}","gists_url":"https://api.github.com/users/wence-/gists{/gist_id}","starred_url":"https://api.github.com/users/wence-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wence-/subscriptions","organizations_url":"https://api.github.com/users/wence-/orgs","repos_url":"https://api.github.com/users/wence-/repos","events_url":"https://api.github.com/users/wence-/events{/privacy}","received_events_url":"https://api.github.com/users/wence-/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-08-09T13:16:55Z","updated_at":"2016-08-10T15:32:47Z","closed_at":null,"body":"Copied, some of the code from `slope_modification.py`:\r\n\r\n```python\r\n        self.slope_modification_2d_kernel = \"\"\" double new_cell = 0, d = 1.0; const E=1e-6, UB=1e0; int j;\r\n        for(int i=0;i<vert_cell.dofs;i++){\r\n            new_cell+=vert_cell[i][0];\r\n        }\r\n        new_cell=new_cell/vert_cell.dofs;\r\n        if (new_cell<=E){\r\n            for(int i=0;i<new_vert_cell.dofs;i++){\r\n                new_vert_cell[i][0]=0;\r\n                new_vert_u_cell[i][0]=0;\r\n                new_vert_v_cell[i][0]=0;\r\n            }\r\n        }\r\n        if (new_cell>E){\r\n            float c=0;\r\n            for(int i=0;i<new_vert_cell.dofs;i++){\r\n                if (vert_cell[i][0]>E){\r\n                    new_vert_cell[i][0]=vert_cell[i][0];\r\n                    new_vert_u_cell[i][0]=vert_u_cell[i][0];\r\n                    new_vert_v_cell[i][0]=vert_v_cell[i][0];\r\n                }\r\n                if (vert_cell[i][0]<=E){\r\n                    c=c+1;\r\n                    j=i;\r\n                }\r\n            }\r\n            if (c==0){\r\n                for(int i=0;i<new_vert_cell.dofs;i++){\r\n```\r\n\r\nA few things:\r\n\r\n1. `double new_cell = 0, d = 1.0; const E=1e-6, UB=1e0; int j;`\r\nDoes not do what you think it does.  You need to specify types for `E` and `UB` otherwise they default to `int`.  I think you want:\r\n```c\r\ndouble new_cell = 0, d = 1.0;\r\nconst double E = 1e6;\r\nconst double UB = 1e0;\r\nint j\r\n```\r\n\r\n2. The counter `c` you're using in:\r\n```c\r\n        if (new_cell>E){\r\n            float c=0;\r\n            for(int i=0;i<new_vert_cell.dofs;i++){\r\n                if (vert_cell[i][0]>E){\r\n                    new_vert_cell[i][0]=vert_cell[i][0];\r\n                    new_vert_u_cell[i][0]=vert_u_cell[i][0];\r\n                    new_vert_v_cell[i][0]=vert_v_cell[i][0];\r\n                }\r\n                if (vert_cell[i][0]<=E){\r\n                    c=c+1;\r\n                    j=i;\r\n                }\r\n            }\r\n```\r\nReally ought to be declared `int`, rather than `float`.  Also, `j` appears to be unused here."},"comment":{"url":"https://api.github.com/repos/firedrakeproject/flooddrake/issues/comments/238905306","html_url":"https://github.com/firedrakeproject/flooddrake/issues/8#issuecomment-238905306","issue_url":"https://api.github.com/repos/firedrakeproject/flooddrake/issues/8","id":238905306,"user":{"login":"alsgregory","id":16209367,"avatar_url":"https://avatars.githubusercontent.com/u/16209367?v=3","gravatar_id":"","url":"https://api.github.com/users/alsgregory","html_url":"https://github.com/alsgregory","followers_url":"https://api.github.com/users/alsgregory/followers","following_url":"https://api.github.com/users/alsgregory/following{/other_user}","gists_url":"https://api.github.com/users/alsgregory/gists{/gist_id}","starred_url":"https://api.github.com/users/alsgregory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alsgregory/subscriptions","organizations_url":"https://api.github.com/users/alsgregory/orgs","repos_url":"https://api.github.com/users/alsgregory/repos","events_url":"https://api.github.com/users/alsgregory/events{/privacy}","received_events_url":"https://api.github.com/users/alsgregory/received_events","type":"User","site_admin":false},"created_at":"2016-08-10T15:32:47Z","updated_at":"2016-08-10T15:32:47Z","body":"In the new pull request update this issue is sorted."}}
{"actor":{"display_login":"alsgregory"}}