# Periodic conditions 3D gmsh

**URL:** <https://fenicsproject.discourse.group/t/periodic-conditions-3d-gmsh/5906>\
**Category:** variational formulation\
**Created:** [May 29, 2021, 2:00pm UTC](https://fenicsproject.discourse.group/t/periodic-conditions-3d-gmsh/5906 "2021-05-29T14:00:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TherealSova](https://avatars.discourse-cdn.com/v4/letter/t/74df32/32.png) [@TherealSova](https://fenicsproject.discourse.group/u/TherealSova)\
**Post date:** [May 29, 2021, 2:00pm UTC](https://fenicsproject.discourse.group/t/periodic-conditions-3d-gmsh/5906/1 "2021-05-29T14:00:01Z")

</div>

Good day! I have tube channel:

 ![image](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/e/e0e944a2921c3d52f91f0ac11f03622256abc821.png)  
I import my mesh from gmsh.

```auto
import numpy as np
import meshio
msh = meshio.read("gmsh/3D_channel.msh")
def create_mesh(mesh, cell_type, prune_z=False):
    cells = mesh.get_cells_type(cell_type)
    cell_data = mesh.get_cell_data("gmsh:physical", cell_type)
    out_mesh = meshio.Mesh(points=mesh.points, cells={cell_type: cells}, cell_data={"name_to_read":[cell_data]})
    if prune_z:
        out_mesh.prune_z_0()
    return out_mesh

tetra_mesh = create_mesh(msh, "tetra", prune_z=True)
meshio.write("mesh.xdmf", tetra_mesh)

triangle_mesh = create_mesh(msh, "triangle", prune_z=True)
meshio.write("facet_mesh.xdmf", triangle_mesh)

from dolfin import * 

mesh = Mesh()
with XDMFFile("mesh.xdmf") as infile:
    infile.read(mesh)

V = VectorFunctionSpace(mesh, 'P', 2)
Q = FunctionSpace(mesh, 'P', 1)

dim = mesh.topology().dim()
print('Dim:',dim)

mvc = MeshValueCollection("size_t", mesh, dim-1) 
with XDMFFile("facet_mesh.xdmf") as infile:
    infile.read(mvc, "name_to_read")
facet_domains = cpp.mesh.MeshFunctionSizet(mesh, mvc)

```

How i can realize periodic conditions wia `facet_domains `? Numbers domains for periodic contitions are 6 and 7. Thanks for you answer.

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [May 29, 2021, 6:56pm UTC](https://fenicsproject.discourse.group/t/periodic-conditions-3d-gmsh/5906/2 "2021-05-29T18:56:41Z")

</div>

In dolfin, you need to be able to describe the mapping geometrically, as shown in: [Bitbucket](https://bitbucket.org/fenics-project/dolfin/src/b55804ecca7d010ff976967af869571b56364975/python/demo/documented/periodic/demo_periodic.py?at=master#demo_periodic.py-6,50:51,64,86)

In dolfinx, I have made a package that relies on `MeshTags` (an integer marking one boundary, as obtained from GMSH) and a geometrical mapping (mapping to the other surface): [dolfinx\_mpc/demo\_periodic3d.py at master · jorgensd/dolfinx\_mpc · GitHub](https://github.com/jorgensd/dolfinx_mpc/blob/master/python/demos/demo_periodic3d.py#L80).
