FEniCS / ffcx

Next generation FEniCS Form Compiler for finite element forms
https://fenicsproject.org
Other
144 stars 38 forks source link

Check for custom quadrature for each integral, not each form #622

Closed mscroggs closed 9 months ago

mscroggs commented 10 months ago

See FEniCS/dolfinx#2664

coveralls commented 10 months ago

Coverage Status

coverage: 79.732%. remained the same when pulling 2851b5713df8d6982e9ad561bd3172e2accb421c on mscroggs/dolfinx-2664 into d5a68e676365bde8dff379e2844fcc7341e7833a on main.

mscroggs commented 9 months ago

This PR does currently not work with the main branch, mwe:

import dolfinx as df
import ufl
import numpy as np
import mpi4py
import basix.ufl

msh = df.mesh.create_unit_square(mpi4py.MPI.COMM_WORLD, 10, 10)

CG2_vect = df.fem.functionspace(msh, ("Lagrange", 1))
Qe = basix.ufl.quadrature_element(msh.topology.cell_name(), value_shape=(), scheme="default", degree=1)
Quad = df.fem.functionspace(msh, Qe)

u = df.fem.Function(Quad)
v = ufl.TrialFunction(CG2_vect)

dx_m = ufl.Measure("dx",domain=msh, metadata={"quadrature_degree": 1, "quadrature_scheme": "default"}) 
ds = ufl.Measure("ds", domain=msh)

residual = u * v * dx_m
vol = df.fem.form(residual)
residual = v * ds
surf = df.fem.form(residual)

residual = u * v * dx_m + v * ds
vol_surf = df.fem.form(residual)

vol_v = df.fem.assemble_vector(vol)
sur_v = df.fem.assemble_vector(surf)

vol_surf = df.fem.assemble_vector(vol_surf)

assert np.allclose(vol_v.x.array+sur_v.x.array, vol_surf.x.array)

Same error as in FEniCS/dolfinx#2664

I've added this code to dolfinx as a test in https://github.com/FEniCS/dolfinx/pull/2870. That test should now pass with https://github.com/FEniCS/basix/pull/733 and this PR