def test_basic_interior_facet_assembly(): ghost_mode = dolfinx.cpp.mesh.GhostMode.none if (dolfinx.MPI.size(dolfinx.MPI.comm_world) > 1): ghost_mode = dolfinx.cpp.mesh.GhostMode.shared_facet mesh = dolfinx.RectangleMesh( dolfinx.MPI.comm_world, [numpy.array([0.0, 0.0, 0.0]), numpy.array([1.0, 1.0, 0.0])], [5, 5], cell_type=dolfinx.cpp.mesh.CellType.triangle, ghost_mode=ghost_mode) V = function.FunctionSpace(mesh, ("DG", 1)) u, v = ufl.TrialFunction(V), ufl.TestFunction(V) a = ufl.inner(ufl.avg(u), ufl.avg(v)) * ufl.dS A = dolfinx.fem.assemble_matrix(a) A.assemble() assert isinstance(A, PETSc.Mat) L = ufl.conj(ufl.avg(v)) * ufl.dS b = dolfinx.fem.assemble_vector(L) b.assemble() assert isinstance(b, PETSc.Vec)
uh.vector.setArray(vec.array) uh.name = tag return uh def write(filename, mesh, u): from dolfinx.io import XDMFFile with XDMFFile(MPI.COMM_WORLD, filename, "w", encoding=XDMFFile.Encoding.HDF5) as xdmffile: xdmffile.write_mesh(mesh) xdmffile.write_function(u) cell_type = dolfinx.cpp.mesh.CellType.quadrilateral Nx = 2 Ny = 1 mesh = dolfinx.RectangleMesh(MPI.COMM_WORLD, [numpy.array([0,0,0]), numpy.array([1,1,0])], [Nx, Ny], cell_type=cell_type) cells = numpy.arange(Nx*Ny) V = dolfinx.FunctionSpace(mesh, ("Lagrange", 1)) u = ufl.TrialFunction(V) v = ufl.TestFunction(V) f = dolfinx.Function(V) def rhs(x): return sin(pi*x[0])*sin(pi*x[1]) f.interpolate(rhs) a_eqn = inner(grad(u), grad(v)) L_eqn = inner(f, v) a = a_eqn*ufl.dx(metadata={"quadrature_rule": "runtime"}) L = L_eqn*ufl.dx(metadata={"quadrature_rule": "runtime"})