Restiction on mesh

I want to compute the solution in a particular subdomain and I imported mesh from gmsh. please find attached fenics code and error.

import numpy as N
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

import meshio
msh = meshio.read("subbygmsh.msh")
triangle_mesh = create_mesh(msh, "triangle", True)
line_mesh = create_mesh(msh, "line", True)
meshio.write("mesh1.xdmf", triangle_mesh)
meshio.write("mf1.xdmf", line_mesh) 

from dolfin import*
mesh=Mesh()
mvc = MeshValueCollection("size_t", mesh, mesh.topology().dim())
with XDMFFile("mesh1.xdmf") as infile:
   infile.read(mesh)
   infile.read(mvc, "name_to_read")

cf = cpp.mesh.MeshFunctionSizet(mesh, mvc)

dx= Measure("dx", domain=mesh, subdomain_data=cf)

mvc = MeshValueCollection("size_t", mesh, mesh.topology().dim()-1)
with XDMFFile("mf1.xdmf") as infile:
    infile.read(mvc, "name_to_read")   
mf = cpp.mesh.MeshFunctionSizet(mesh, mvc)    
ds= Measure("ds", domain=mesh, subdomain_data=mf)

restiction=Restriction(mesh, 1)

and error is NameError: name ‘Restriction’ is not defined

As the error clearly states, Restriction is not defined in the dolfin package. Could you please clearify where you have gotten this function from. There is a function for creating “sub-meshes”, namely MeshView, as for instance used here: Bitbucket

1 Like

Thank you for your replay,

Here you can find the restriction function

https://fenicsproject.org/olddocs/dolfin/1.5.0/python/programmers-reference/cpp/mesh/Restriction.html

You are looking at a very outdated documentation, for FEniCS 1.5.0 [released 2015-01-12]

Latest C++ documentation can be found here: DOLFIN: Class Index

1 Like