I have imported all packages from dolfin using " from dolfin import *"

But this code snippet gives the error below. please can you help me

Update Other Spaces

        self.ScalarErrorSpace = FunctionSpace(self.mesh, "DG", int(self.k + 2))
        self.VectorErrorSpace = VectorFunctionSpace(self.mesh, "DG", int(self.k + 1))
        self.ScalarRHSSpace = FunctionSpace(self.mesh, "DG", int(self.k + 1))
        self.VectorRHSSpace = VectorFunctionSpace(self.mesh, "DG", int(self.k + 1))
        self.LocalSpace = FunctionSpace(self.mesh, "DG", 0)
        # Update Mesh Elements
        boundaries = FacetFunction('size_t', self.mesh)
        Gamma_D1 = DirichletBoundary_top()
        Gamma_D1.mark(boundaries, 2)        
        Gamma_D2 = DirichletBoundary_bottom()
        Gamma_D2.mark(boundaries, 4)
        Gamma_N1 = NeumannBoundary_left()
        Gamma_N1.mark(boundaries, 1)
        Gamma_N2 = NeumannBoundary_right()
        Gamma_N2.mark(boundaries, 3)

boundaries = FacetFunction(‘size_t’, self.mesh)
NameError: name ‘FacetFunction’ is not defined

FacetFunction is deprecated. See here:

1 Like

boundaries = MeshFunction(“size_t”, self.mesh, mesh.topology().dim()-1, 0)

AttributeError: module ‘dolfin.mesh’ has no attribute ‘topology’
I tried it i got this error.
I am very new to fenics.

Without minimal working example, it’s hard to see what is the problem. Maybe adding self before mesh would help?

I agree with this comment. from dolfin import * imports the mesh module (dolfin.mesh), which is different from the self.mesh class variable.

If you are new to fenics it is recommended to use DOLFINx, see The new DOLFINx solver is now recommended over DOLFIN

This solved the problem thanks.