Next time, please provide the full error message as well,
Traceback (most recent call last):
File "/root/shared/mwe234.py", line 46, in <module>
a, L = fem.form(k), fem.form(L)
File "/usr/local/dolfinx-real/lib/python3.10/dist-packages/dolfinx/fem/forms.py", line 176, in form
return _create_form(form)
File "/usr/local/dolfinx-real/lib/python3.10/dist-packages/dolfinx/fem/forms.py", line 171, in _create_form
return _form(form)
File "/usr/local/dolfinx-real/lib/python3.10/dist-packages/dolfinx/fem/forms.py", line 165, in _form
return formcls(ufcx_form, V, coeffs, constants, subdomains, mesh, module.ffi, code)
File "/usr/local/dolfinx-real/lib/python3.10/dist-packages/dolfinx/fem/forms.py", line 51, in __init__
super().__init__(ffi.cast("uintptr_t", ffi.addressof(self._ufcx_form)),
TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
1. dolfinx.cpp.fem.Form_float64(spaces: List[dolfinx::fem::FunctionSpace], integrals: Dict[dolfinx::fem::IntegralType, Tuple[List[Tuple[int, object]], dolfinx.cpp.mesh.MeshTags_int32]], coefficients: List[dolfinx.cpp.fem.Function_float64], constants: List[dolfinx.cpp.fem.Constant_float64], need_permutation_data: bool, mesh: dolfinx.cpp.mesh.Mesh = None)
2. dolfinx.cpp.fem.Form_float64(form: int, spaces: List[dolfinx::fem::FunctionSpace], coefficients: List[dolfinx.cpp.fem.Function_float64], constants: List[dolfinx.cpp.fem.Constant_float64], subdomains: Dict[dolfinx::fem::IntegralType, dolfinx.cpp.mesh.MeshTags_int32], mesh: dolfinx.cpp.mesh.Mesh)
Invoked with: <cdata 'uintptr_t' 140175546442848>, [<dolfinx.cpp.fem.FunctionSpace object at 0x7f7d375b53b0>, <dolfinx.cpp.fem.FunctionSpace object at 0x7f7d375b53b0>], [], [], {<IntegralType.cell: 0>: <dolfinx.mesh.MeshTagsMetaClass object at 0x7f7d373722a0>, <IntegralType.exterior_facet: 1>: None, <IntegralType.interior_facet: 2>: None, <IntegralType.vertex: 3>: None}, <dolfinx.mesh.Mesh object at 0x7f7d39d81800>
This says that the input to the form constructor is wrong. This is because of the way you have defined your meshtag/subdomain marker.
subdomain_indices = np.where(Xnp>0.5)[0].astype(np.int32)
subdomain_values = np.full_like(subdomain_indices, 999, dtype=np.int32)
subdomain = mesh.meshtags(domain, 2, subdomain_indices, subdomain_values)
dx_999 = ufl.Measure('dx', domain=domain, subdomain_data=subdomain,subdomain_id=999)
k = ufl.inner(sigma(_v), epsilon(_dv)) * dx_999
Runs, as we require that the indices and values in a mesh-tag object, that is passed to C++ uses int32
.
However, I would like to note that by assembling the matrix on only a part of the domain, the matrix contains rows with only zeros.