Defining local functions on partitioned subdomains in parallel

I am setting up a course on multiscale methods to teach next semester. I am hoping to use fenics as the tool to construct operators.

I would like to be able to define functions only on local subdomains - is there a neat way to do this? I couldn’t see an example

For example if I run my code in parallel, I will have a domain decomposition. On an individual processor, I would like to define and solve problems on degrees of freedom which “belong” to that processor (including an overlap).

Currently if I define a function, fenics / petsc handle it, constructing a global function, stored locally, plus appropriate parallel communicators.

Best

Tim Dodwell

Another way of asking this, is if I am using PETSc4py and I have something like

# Build Structured Grid
da = PETSc.DMDA().create([nx, ny, nz], dof=3, stencil_type=1, stencil_width = overlap)
da.setUniformCoordinates(xmax=Lx, ymax=Ly, zmax=Lz)
da.setMatType(PETSc.Mat.Type.IS)

Can I then construct a PETSc matrix using the “da” with Fenics

A = da.createMatrix()

# assemble a with fenics

# Extract local matrix 

r, _ = A.getLGMap()
is_A = PETSc.IS().createGeneral(r.indices)
A_aij = A.convertISToAIJ()
A_aij_local = A_mpiaij.createSubMatrices(is_A)[0]