Skip to content

Commit

Permalink
Add test (fails on main)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgensd committed Dec 2, 2024
1 parent ffcdf10 commit e5194c3
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion python/test/unit/fem/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from mpi4py import MPI

import numpy as np
import pytest

import basix
Expand All @@ -16,7 +17,7 @@
from dolfinx.fem import extract_function_spaces, form, functionspace
from dolfinx.fem.forms import form_cpp_class
from dolfinx.mesh import create_unit_square
from ufl import TestFunction, TrialFunction, dx, inner
from ufl import Measure, SpatialCoordinate, TestFunction, TrialFunction, dx, inner


def test_extract_forms():
Expand Down Expand Up @@ -109,3 +110,24 @@ def test_incorrect_element():
mesh._cpp_object,
)
dolfinx.fem.Form(f, ufcx_form, code)


def test_multiple_measures_one_subdomain_data():
comm = MPI.COMM_WORLD
mesh = dolfinx.mesh.create_unit_interval(comm, 10)
x = SpatialCoordinate(mesh)
num_cells_local = mesh.topology.index_map(mesh.topology.dim).size_local
ct = dolfinx.mesh.meshtags(
mesh,
mesh.topology.dim,
np.arange(num_cells_local, dtype=np.int32),
np.arange(num_cells_local, dtype=np.int32),
)

dx = Measure("dx", domain=mesh, subdomain_data=ct)
dx_stand = Measure("dx", domain=mesh)

J = dolfinx.fem.form(x[0] ** 2 * dx + x[0] * dx_stand)
J_local = dolfinx.fem.assemble_scalar(J)
J_global = comm.allreduce(J_local, op=MPI.SUM)
assert np.isclose(J_global, 1 / 3 + 1 / 2)

0 comments on commit e5194c3

Please sign in to comment.