get test functions with no support on the boundary


163
views
2
4 months ago by
I would like to create a rectangular m-by-n matrix for the heat equation (let's say) where only those test functions are considered that have no support on the boundary of the domain. (So m < n.)

Any hints on how to do this?
Community: FEniCS Project

1 Answer


4
4 months ago by

With DOLFIN master and PETSc master (>= 3.8 should work too). Works in parallel.

from dolfin import *
from petsc4py import PETSc
import numpy

mesh = UnitSquareMesh(3, 3)
V = FunctionSpace(mesh, "P", 1)
u = TrialFunction(V)
v = TestFunction(V)
a = inner(grad(u), grad(v))*dx

A = PETScMatrix()
assemble(a, tensor=A)

bc = DirichletBC(V, 0, lambda x, b: b)
bc_dofs = bc.get_boundary_values().keys()
offset = V.dofmap().ownership_range()[0]
rows = numpy.fromiter((i for i in range(*A.local_range(0))
                       if i - offset not in bc_dofs),
                      dtype=la_index_dtype())
is_rows = PETSc.IS().createGeneral(rows)
is_cols = None

# Create new submatrix
B_mat = A.mat().createSubMatrix(is_rows, is_cols)
B = PETScMatrix(B_mat)

# Reassemble into already allocated submatrix
A.mat().createSubMatrix(is_rows, is_cols, submat=B.mat())

# Test that matvec works
u = Function(V)
B*u.vector()
I've put some effort in getting the nightly PPA updated but now it seems to work. https://launchpad.net/~nschloe/+archive/ubuntu/fenics-nightly/ Thanks a bunch, Jan!
written 4 months ago by Nico Schlömer  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »