{"action":"created","comment":{"url":"https://api.github.com/repos/simphony/simphony-openfoam/pulls/comments/27661126","id":27661126,"diff_hunk":"@@ -0,0 +1,292 @@\n+\"\"\" test foam native interface\n+\n+This module contains the unitary tests for the\n+OpenFoam native interface functionalities\n+\n+\"\"\"\n+\n+import unittest\n+from simphony.cuds.mesh import Mesh, Face, Point, Cell\n+from simphony.core.cuba import CUBA\n+from simphony.core.data_container import DataContainer\n+import simphonyfoaminterface as foamface\n+from foam_controlwrapper.foam_files import FoamFiles\n+from collections import OrderedDict\n+import os\n+import shutil\n+\n+\n+class FoamInterfaceTestCase(unittest.TestCase):\n+    \"\"\"Test case for OpenFOAM native interface\"\"\"\n+    def setUp(self):\n+        self.name = 'mesh1'\n+        self.test_dir = 'test'\n+        self.path = os.path.join(self.test_dir, self.name)\n+        self.time = '0'\n+        self.mesh = Mesh(self.name)\n+\n+        self.points = [\n+            Point(\n+                (0.0, 0.0, 0.0)),\n+            Point(\n+                (1.0, 0.0, 0.0)),\n+            Point(\n+                (1.0, 1.0, 0.0)),\n+            Point(\n+                (0.0, 1.0, 0.0)),\n+            Point(\n+                (0.0, 0.0, 1.0)),\n+            Point(\n+                (1.0, 0.0, 1.0)),\n+            Point(\n+                (1.0, 1.0, 1.0)),\n+            Point(\n+                (0.0, 1.0, 1.0))\n+        ]\n+\n+        puids = [self.mesh.add_point(point) for point in self.points]\n+\n+        self.faces = [\n+            Face([puids[0], puids[3], puids[7], puids[4]],\n+                 data=DataContainer({CUBA.LABEL: 0})),\n+            Face([puids[1], puids[2], puids[6], puids[5]],\n+                 data=DataContainer({CUBA.LABEL: 1})),\n+            Face([puids[0], puids[1], puids[5], puids[4]],\n+                 data=DataContainer({CUBA.LABEL: 2})),\n+            Face([puids[3], puids[2], puids[6], puids[7]],\n+                 data=DataContainer({CUBA.LABEL: 3})),\n+            Face([puids[0], puids[1], puids[2], puids[3]],\n+                 data=DataContainer({CUBA.LABEL: 4})),\n+            Face([puids[4], puids[5], puids[6], puids[7]],\n+                 data=DataContainer({CUBA.LABEL: 5}))\n+\n+        ]\n+\n+        [self.mesh.add_face(face) for face in self.faces]\n+\n+        self.cells = [\n+            Cell(puids)\n+        ]\n+\n+        self.puids = puids\n+\n+        [self.mesh.add_cell(cell) for cell in self.cells]\n+\n+        self._uuidToFoamLabel = {}\n+        self._foamCellLabelToUuid = {}\n+        self._foamFaceLabelToUuid = {}\n+        self._foamEdgeLabelToUuid = {}\n+        self._foamPointLabelToUuid = {}\n+        # generate uuid mapping\n+        label = 0\n+        for point in self.mesh.iter_points():\n+            uid = point.uid\n+            self._uuidToFoamLabel[uid] = label\n+            self._foamPointLabelToUuid[label] = uid\n+            label += 1\n+\n+        label = 0\n+        for edge in self.mesh.iter_edges():\n+            uid = edge.uid\n+            self._uuidToFoamLabel[uid] = label\n+            self._foamEdgeLabelToUuid[label] = uid\n+            label += 1\n+\n+        label = 0\n+        for face in self.mesh.iter_faces():\n+            uid = face.uid\n+            self._uuidToFoamLabel[uid] = label\n+            self._foamFaceLabelToUuid[label] = uid\n+            label += 1\n+\n+        label = 0\n+        for cell in self.mesh.iter_cells():\n+            uid = cell.uid\n+            self._uuidToFoamLabel[uid] = label\n+            self._foamCellLabelToUuid[label] = uid\n+            label += 1\n+\n+        # find out boundary patches\n+        patchNameFacesMap = OrderedDict()\n+        self.facePoints = []\n+        for face in self.mesh.iter_faces():\n+            if CUBA.LABEL in face.data:\n+                boundary = 'boundary' + str(face.data[CUBA.LABEL])\n+                if boundary not in patchNameFacesMap:\n+                    patchNameFacesMap[boundary] = []\n+                patchNameFacesMap[boundary].append(\n+                    self._uuidToFoamLabel[face.uid])\n+\n+            # make compressed list of faces points\n+            self.facePoints.append(len(face.points))\n+            for puid in face.points:\n+                self.facePoints.append(self._uuidToFoamLabel[puid])\n+\n+        # make points coordinate list\n+        self.pointCoordinates = []\n+        for point in self.mesh.iter_points():\n+            for coord in point.coordinates:\n+                self.pointCoordinates.append(coord)\n+\n+        # make compressed list of cells points\n+        self.cellPoints = []\n+        for cell in self.mesh.iter_cells():\n+            self.cellPoints.append(len(cell.points))\n+            for puid in cell.points:\n+                self.cellPoints.append(self._uuidToFoamLabel[puid])\n+\n+        # make patch information\n+        self.patchNames = []\n+        self.patchFaces = []\n+        for patchName in patchNameFacesMap:\n+            self.patchNames.append(patchName)\n+            self.patchFaces.append(len(patchNameFacesMap[patchName]))\n+            for face in patchNameFacesMap[patchName]:\n+                self.patchFaces.append(face)\n+\n+        if not self.patchNames:\n+            error_str = 'Could not initialize with mesh  {}. '\n+            error_str += 'Mesh has not boundary face definitions.'\n+            raise ValueError(error_str.format(self.mesh.name))\n+\n+        # this to have controlDict file for mesh definition\n+        FoamFiles().write_default_files(self.path, 'simpleFoam',\n+                                        self.time, False)\n+\n+        foamface.init(self.name, os.path.abspath(os.path.join(self.path,\n+                                                              os.pardir)))\n+\n+    def tearDown(self):\n+        if os.path.exists(self.test_dir):\n+            shutil.rmtree(self.test_dir)\n+\n+    def test_add_mesh(self):\n+        \"\"\"Test addMesh method\n+\n+        \"\"\"\n+\n+        foamface.addMesh(self.name, self.pointCoordinates,\n+                         self.cellPoints, self.facePoints,\n+                         self.patchNames, self.patchFaces)\n+\n+    def test_write_mesh(self):\n+        \"\"\"Test writeMesh method\n+\n+        \"\"\"\n+\n+        foamface.addMesh(self.name, self.pointCoordinates,\n+                         self.cellPoints, self.facePoints,\n+                         self.patchNames, self.patchFaces)\n+        foamface.writeMesh(self.name)\n+\n+    def test_get_point_coordinates(self):\n+        \"\"\"Test getPointCoordinates method\n+\n+        \"\"\"\n+\n+        foamface.addMesh(self.name, self.pointCoordinates,\n+                         self.cellPoints, self.facePoints,\n+                         self.patchNames, self.patchFaces)\n+        for point in self.points:\n+            coords = foamface.getPointCoordinates(\n+                self.name,\n+                self._uuidToFoamLabel[point.uid])\n+            self.assertEqual(point.coordinates, tuple(coords))","path":"foam_controlwrapper/tests/test_foam_interface.py","position":194,"original_position":194,"commit_id":"27b352d12be79178ba62b5a47862a58309ab2e24","original_commit_id":"27b352d12be79178ba62b5a47862a58309ab2e24","user":{"login":"itziakos","id":403930,"avatar_url":"https://avatars.githubusercontent.com/u/403930?v=3","gravatar_id":"","url":"https://api.github.com/users/itziakos","html_url":"https://github.com/itziakos","followers_url":"https://api.github.com/users/itziakos/followers","following_url":"https://api.github.com/users/itziakos/following{/other_user}","gists_url":"https://api.github.com/users/itziakos/gists{/gist_id}","starred_url":"https://api.github.com/users/itziakos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itziakos/subscriptions","organizations_url":"https://api.github.com/users/itziakos/orgs","repos_url":"https://api.github.com/users/itziakos/repos","events_url":"https://api.github.com/users/itziakos/events{/privacy}","received_events_url":"https://api.github.com/users/itziakos/received_events","type":"User","site_admin":false},"body":"oops wrong file, please, ingnore my comment ","created_at":"2015-04-02T14:23:15Z","updated_at":"2015-04-02T14:23:15Z","html_url":"https://github.com/simphony/simphony-openfoam/pull/10#discussion_r27661126","pull_request_url":"https://api.github.com/repos/simphony/simphony-openfoam/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/simphony/simphony-openfoam/pulls/comments/27661126"},"html":{"href":"https://github.com/simphony/simphony-openfoam/pull/10#discussion_r27661126"},"pull_request":{"href":"https://api.github.com/repos/simphony/simphony-openfoam/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/simphony/simphony-openfoam/pulls/10","id":31236453,"html_url":"https://github.com/simphony/simphony-openfoam/pull/10","diff_url":"https://github.com/simphony/simphony-openfoam/pull/10.diff","patch_url":"https://github.com/simphony/simphony-openfoam/pull/10.patch","issue_url":"https://api.github.com/repos/simphony/simphony-openfoam/issues/10","number":10,"state":"open","locked":false,"title":"Feature openfoammesh numerola","user":{"login":"khiltunen","id":8565707,"avatar_url":"https://avatars.githubusercontent.com/u/8565707?v=3","gravatar_id":"","url":"https://api.github.com/users/khiltunen","html_url":"https://github.com/khiltunen","followers_url":"https://api.github.com/users/khiltunen/followers","following_url":"https://api.github.com/users/khiltunen/following{/other_user}","gists_url":"https://api.github.com/users/khiltunen/gists{/gist_id}","starred_url":"https://api.github.com/users/khiltunen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khiltunen/subscriptions","organizations_url":"https://api.github.com/users/khiltunen/orgs","repos_url":"https://api.github.com/users/khiltunen/repos","events_url":"https://api.github.com/users/khiltunen/events{/privacy}","received_events_url":"https://api.github.com/users/khiltunen/received_events","type":"User","site_admin":false},"body":"This PR implements the missing methods to FoamControlWrapper: add_mesh, get_mesh, delete_mesh and iter_meshes. Interface library for mesh transfer using OpenFoam's objectRegistry is included. Data transfer and control files are implemented taking advantage of PyFoam. Unittests and two working examples to one and two-phase (vof) poiseuille flow are included and a converter example to transfering OpenFoam's mesh to H5CUDS -file.","created_at":"2015-03-16T11:50:44Z","updated_at":"2015-04-02T14:23:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"940649d4e2e0666327d44445de4e79afa1f57a3e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/simphony/simphony-openfoam/pulls/10/commits","review_comments_url":"https://api.github.com/repos/simphony/simphony-openfoam/pulls/10/comments","review_comment_url":"https://api.github.com/repos/simphony/simphony-openfoam/pulls/comments{/number}","comments_url":"https://api.github.com/repos/simphony/simphony-openfoam/issues/10/comments","statuses_url":"https://api.github.com/repos/simphony/simphony-openfoam/statuses/27b352d12be79178ba62b5a47862a58309ab2e24","head":{"label":"simphony:feature-openfoammesh-numerola","ref":"feature-openfoammesh-numerola","sha":"27b352d12be79178ba62b5a47862a58309ab2e24","user":{"login":"simphony","id":8048249,"avatar_url":"https://avatars.githubusercontent.com/u/8048249?v=3","gravatar_id":"","url":"https://api.github.com/users/simphony","html_url":"https://github.com/simphony","followers_url":"https://api.github.com/users/simphony/followers","following_url":"https://api.github.com/users/simphony/following{/other_user}","gists_url":"https://api.github.com/users/simphony/gists{/gist_id}","starred_url":"https://api.github.com/users/simphony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simphony/subscriptions","organizations_url":"https://api.github.com/users/simphony/orgs","repos_url":"https://api.github.com/users/simphony/repos","events_url":"https://api.github.com/users/simphony/events{/privacy}","received_events_url":"https://api.github.com/users/simphony/received_events","type":"Organization","site_admin":false},"repo":{"id":28183758,"name":"simphony-openfoam","full_name":"simphony/simphony-openfoam","owner":{"login":"simphony","id":8048249,"avatar_url":"https://avatars.githubusercontent.com/u/8048249?v=3","gravatar_id":"","url":"https://api.github.com/users/simphony","html_url":"https://github.com/simphony","followers_url":"https://api.github.com/users/simphony/followers","following_url":"https://api.github.com/users/simphony/following{/other_user}","gists_url":"https://api.github.com/users/simphony/gists{/gist_id}","starred_url":"https://api.github.com/users/simphony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simphony/subscriptions","organizations_url":"https://api.github.com/users/simphony/orgs","repos_url":"https://api.github.com/users/simphony/repos","events_url":"https://api.github.com/users/simphony/events{/privacy}","received_events_url":"https://api.github.com/users/simphony/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/simphony/simphony-openfoam","description":"","fork":false,"url":"https://api.github.com/repos/simphony/simphony-openfoam","forks_url":"https://api.github.com/repos/simphony/simphony-openfoam/forks","keys_url":"https://api.github.com/repos/simphony/simphony-openfoam/keys{/key_id}","collaborators_url":"https://api.github.com/repos/simphony/simphony-openfoam/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/simphony/simphony-openfoam/teams","hooks_url":"https://api.github.com/repos/simphony/simphony-openfoam/hooks","issue_events_url":"https://api.github.com/repos/simphony/simphony-openfoam/issues/events{/number}","events_url":"https://api.github.com/repos/simphony/simphony-openfoam/events","assignees_url":"https://api.github.com/repos/simphony/simphony-openfoam/assignees{/user}","branches_url":"https://api.github.com/repos/simphony/simphony-openfoam/branches{/branch}","tags_url":"https://api.github.com/repos/simphony/simphony-openfoam/tags","blobs_url":"https://api.github.com/repos/simphony/simphony-openfoam/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/simphony/simphony-openfoam/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/simphony/simphony-openfoam/git/refs{/sha}","trees_url":"https://api.github.com/repos/simphony/simphony-openfoam/git/trees{/sha}","statuses_url":"https://api.github.com/repos/simphony/simphony-openfoam/statuses/{sha}","languages_url":"https://api.github.com/repos/simphony/simphony-openfoam/languages","stargazers_url":"https://api.github.com/repos/simphony/simphony-openfoam/stargazers","contributors_url":"https://api.github.com/repos/simphony/simphony-openfoam/contributors","subscribers_url":"https://api.github.com/repos/simphony/simphony-openfoam/subscribers","subscription_url":"https://api.github.com/repos/simphony/simphony-openfoam/subscription","commits_url":"https://api.github.com/repos/simphony/simphony-openfoam/commits{/sha}","git_commits_url":"https://api.github.com/repos/simphony/simphony-openfoam/git/commits{/sha}","comments_url":"https://api.github.com/repos/simphony/simphony-openfoam/comments{/number}","issue_comment_url":"https://api.github.com/repos/simphony/simphony-openfoam/issues/comments{/number}","contents_url":"https://api.github.com/repos/simphony/simphony-openfoam/contents/{+path}","compare_url":"https://api.github.com/repos/simphony/simphony-openfoam/compare/{base}...{head}","merges_url":"https://api.github.com/repos/simphony/simphony-openfoam/merges","archive_url":"https://api.github.com/repos/simphony/simphony-openfoam/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/simphony/simphony-openfoam/downloads","issues_url":"https://api.github.com/repos/simphony/simphony-openfoam/issues{/number}","pulls_url":"https://api.github.com/repos/simphony/simphony-openfoam/pulls{/number}","milestones_url":"https://api.github.com/repos/simphony/simphony-openfoam/milestones{/number}","notifications_url":"https://api.github.com/repos/simphony/simphony-openfoam/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/simphony/simphony-openfoam/labels{/name}","releases_url":"https://api.github.com/repos/simphony/simphony-openfoam/releases{/id}","created_at":"2014-12-18T13:03:28Z","updated_at":"2015-04-01T17:11:22Z","pushed_at":"2015-04-02T12:52:36Z","git_url":"git://github.com/simphony/simphony-openfoam.git","ssh_url":"git@github.com:simphony/simphony-openfoam.git","clone_url":"https://github.com/simphony/simphony-openfoam.git","svn_url":"https://github.com/simphony/simphony-openfoam","homepage":null,"size":18156,"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":6,"forks":0,"open_issues":6,"watchers":0,"default_branch":"master"}},"base":{"label":"simphony:master","ref":"master","sha":"114cb38a83c6a6ced49cd41f5c840a27c2e9e9d1","user":{"login":"simphony","id":8048249,"avatar_url":"https://avatars.githubusercontent.com/u/8048249?v=3","gravatar_id":"","url":"https://api.github.com/users/simphony","html_url":"https://github.com/simphony","followers_url":"https://api.github.com/users/simphony/followers","following_url":"https://api.github.com/users/simphony/following{/other_user}","gists_url":"https://api.github.com/users/simphony/gists{/gist_id}","starred_url":"https://api.github.com/users/simphony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simphony/subscriptions","organizations_url":"https://api.github.com/users/simphony/orgs","repos_url":"https://api.github.com/users/simphony/repos","events_url":"https://api.github.com/users/simphony/events{/privacy}","received_events_url":"https://api.github.com/users/simphony/received_events","type":"Organization","site_admin":false},"repo":{"id":28183758,"name":"simphony-openfoam","full_name":"simphony/simphony-openfoam","owner":{"login":"simphony","id":8048249,"avatar_url":"https://avatars.githubusercontent.com/u/8048249?v=3","gravatar_id":"","url":"https://api.github.com/users/simphony","html_url":"https://github.com/simphony","followers_url":"https://api.github.com/users/simphony/followers","following_url":"https://api.github.com/users/simphony/following{/other_user}","gists_url":"https://api.github.com/users/simphony/gists{/gist_id}","starred_url":"https://api.github.com/users/simphony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simphony/subscriptions","organizations_url":"https://api.github.com/users/simphony/orgs","repos_url":"https://api.github.com/users/simphony/repos","events_url":"https://api.github.com/users/simphony/events{/privacy}","received_events_url":"https://api.github.com/users/simphony/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/simphony/simphony-openfoam","description":"","fork":false,"url":"https://api.github.com/repos/simphony/simphony-openfoam","forks_url":"https://api.github.com/repos/simphony/simphony-openfoam/forks","keys_url":"https://api.github.com/repos/simphony/simphony-openfoam/keys{/key_id}","collaborators_url":"https://api.github.com/repos/simphony/simphony-openfoam/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/simphony/simphony-openfoam/teams","hooks_url":"https://api.github.com/repos/simphony/simphony-openfoam/hooks","issue_events_url":"https://api.github.com/repos/simphony/simphony-openfoam/issues/events{/number}","events_url":"https://api.github.com/repos/simphony/simphony-openfoam/events","assignees_url":"https://api.github.com/repos/simphony/simphony-openfoam/assignees{/user}","branches_url":"https://api.github.com/repos/simphony/simphony-openfoam/branches{/branch}","tags_url":"https://api.github.com/repos/simphony/simphony-openfoam/tags","blobs_url":"https://api.github.com/repos/simphony/simphony-openfoam/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/simphony/simphony-openfoam/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/simphony/simphony-openfoam/git/refs{/sha}","trees_url":"https://api.github.com/repos/simphony/simphony-openfoam/git/trees{/sha}","statuses_url":"https://api.github.com/repos/simphony/simphony-openfoam/statuses/{sha}","languages_url":"https://api.github.com/repos/simphony/simphony-openfoam/languages","stargazers_url":"https://api.github.com/repos/simphony/simphony-openfoam/stargazers","contributors_url":"https://api.github.com/repos/simphony/simphony-openfoam/contributors","subscribers_url":"https://api.github.com/repos/simphony/simphony-openfoam/subscribers","subscription_url":"https://api.github.com/repos/simphony/simphony-openfoam/subscription","commits_url":"https://api.github.com/repos/simphony/simphony-openfoam/commits{/sha}","git_commits_url":"https://api.github.com/repos/simphony/simphony-openfoam/git/commits{/sha}","comments_url":"https://api.github.com/repos/simphony/simphony-openfoam/comments{/number}","issue_comment_url":"https://api.github.com/repos/simphony/simphony-openfoam/issues/comments{/number}","contents_url":"https://api.github.com/repos/simphony/simphony-openfoam/contents/{+path}","compare_url":"https://api.github.com/repos/simphony/simphony-openfoam/compare/{base}...{head}","merges_url":"https://api.github.com/repos/simphony/simphony-openfoam/merges","archive_url":"https://api.github.com/repos/simphony/simphony-openfoam/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/simphony/simphony-openfoam/downloads","issues_url":"https://api.github.com/repos/simphony/simphony-openfoam/issues{/number}","pulls_url":"https://api.github.com/repos/simphony/simphony-openfoam/pulls{/number}","milestones_url":"https://api.github.com/repos/simphony/simphony-openfoam/milestones{/number}","notifications_url":"https://api.github.com/repos/simphony/simphony-openfoam/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/simphony/simphony-openfoam/labels{/name}","releases_url":"https://api.github.com/repos/simphony/simphony-openfoam/releases{/id}","created_at":"2014-12-18T13:03:28Z","updated_at":"2015-04-01T17:11:22Z","pushed_at":"2015-04-02T12:52:36Z","git_url":"git://github.com/simphony/simphony-openfoam.git","ssh_url":"git@github.com:simphony/simphony-openfoam.git","clone_url":"https://github.com/simphony/simphony-openfoam.git","svn_url":"https://github.com/simphony/simphony-openfoam","homepage":null,"size":18156,"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":6,"forks":0,"open_issues":6,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/simphony/simphony-openfoam/pulls/10"},"html":{"href":"https://github.com/simphony/simphony-openfoam/pull/10"},"issue":{"href":"https://api.github.com/repos/simphony/simphony-openfoam/issues/10"},"comments":{"href":"https://api.github.com/repos/simphony/simphony-openfoam/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/simphony/simphony-openfoam/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/simphony/simphony-openfoam/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/simphony/simphony-openfoam/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/simphony/simphony-openfoam/statuses/27b352d12be79178ba62b5a47862a58309ab2e24"}}}}