# Code from Poisson subdomain problem tutorial not working

**URL:** <https://fenicsproject.discourse.group/t/code-from-poisson-subdomain-problem-tutorial-not-working/3265>\
**Category:** Uncategorized\
**Created:** [May 20, 2020, 4:57pm UTC](https://fenicsproject.discourse.group/t/code-from-poisson-subdomain-problem-tutorial-not-working/3265 "2020-05-20T16:57:03Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![epsilonD3LT4](https://avatars.discourse-cdn.com/v4/letter/e/dc4da7/32.png) [@epsilonD3LT4](https://fenicsproject.discourse.group/u/epsilonD3LT4)\
**Post date:** [May 31, 2020, 2:55pm UTC](https://fenicsproject.discourse.group/t/code-from-poisson-subdomain-problem-tutorial-not-working/3265/10 "2020-05-31T14:55:01Z")

</div>

The problem from the tutorial was that the way of separating out the CellBlock file into line and triangular elements (looks like it’s creating a sub-dictionary?) did not work. I replaced

```
mesh_of_triangles = meshio.Mesh(points=points[:, :2],
                                cells={'triangle': cells['triangle']},
                                cell_data={'triangle': 
                                    {'subdomain': 
                                        cell_data['triangle']
                                        ['gmsh:physical']}},
                                field_data=field_data) 

meshio.write("poisson_subdomain_triangle.xdmf", mesh_of_triangles )

mesh_of_lines = meshio.Mesh(points=points[:, :2],
                                cells={'line': cells['line']},
                                cell_data={'line': {'subdomain':
                                    cell_data['triangle']
                                    ['gmsh:physical']}},
                                field_data=field_data) 

```

with (from the post [here](https://fenicsproject.discourse.group/t/transitioning-from-mesh-xml-to-mesh-xdmf-from-dolfin-convert-to-meshio/412/109))

```
line_cells = []
for cell in mesh.cells:
    if cell.type == "triangle":
        triangle_cells = cell.data
    elif cell.type == "line":
        if len(line_cells) == 0:
            line_cells = cell.data
        else:
            line_cells = np.vstack([line_cells, cell.data])

line_data = []
for key in mesh.cell_data_dict["gmsh:physical"].keys():
    if key == "line":
        if len(line_data) == 0:
            line_data = mesh.cell_data_dict["gmsh:physical"][key]
        else:
            line_data = np.vstack([line_data, mesh.cell_data_dict["gmsh:physical"][key]])
    elif key == "triangle":
        triangle_data = mesh.cell_data_dict["gmsh:physical"][key]

triangle_mesh = meshio.Mesh(points=mesh.points, cells={"triangle": triangle_cells})
line_mesh =meshio.Mesh(points=mesh.points,
                           cells=[("line", line_cells)],
                           cell_data={"name_to_read":[line_data]})

```

which seems to overcome the problem I originally encountered. However, now I get a different error, which I think warrants its own thread.

---

_[View the full topic](https://fenicsproject.discourse.group/t/code-from-poisson-subdomain-problem-tutorial-not-working/3265)._
