Highlighting subdomains with Fenics 2019

In previous version of FEniCS, I was able to use the general Plot() function to debug my boundary condition issues. (Often times, in my applications, mistakes in my mesh generation will be at odds with the logical definitions for the domain.)

Previously, I would do this:

class subdomain_name(SubDomain):
    def inside(self, x, on_boundary):
        return (boolean_subdomain_label(x))

markers = FacetFunctionSizet(mesh, 0)
ds = ds(subdomain_data=markers)
subdomain_name().mark(markers,1)
plot(markers, interactive=True)

When I try this now, I’m met with a pile of error messages. I would post them, but it’s simply obvious to me that in the brief time I’ve been away from FEniCS, much of this has been deprecated (most notably plot() and the way ds() marks regions-- if it does at all.

This is all fine, but I was hoping there was an easy way to achieve this goal, now? I found it to be a pretty useful arrangement!

Cheers!

The plot-function you refer to was deprecated, as for most 3D visualization, Paraview is superior.
Paraview takes in either pvd or xdmf files as input.
For the problem above, saving markers as pvd function is sufficient for visualization.

Edit: You can also use VTKPlotter, see fr instance: New vtkplotter module for visualization.

Note that there have been many interface changes in the past releases, which are summarized in the Changelog.
Note that the demos have been updated reflecting these changes.

For your problem, consider the following:

from dolfin import *
import numpy as np

mesh = UnitSquareMesh(10,10)

class left_side(SubDomain):
    def inside(self, x, on_boundary):
        return np.isclose(x[0], 0) and on_boundary

markers = MeshFunction("size_t", mesh,  mesh.topology().dim()-1, 0)

left_side().mark(markers,1)


ds = ds(domain=mesh, subdomain_data=markers)
print(assemble(1*ds), assemble(1*ds(1)))

File("markers.pvd") << markers