How to split the weak form by subdomains?

Got it

# This code is based on the FEniCSx' subdomains tutorial
# https://github.com/jorgensd/dolfinx-tutorial.git
# with a Creative Commons Attribution 4.0 International License,
# and FEniCS Tutorial @ Sorbonne
# https://github.com/jorgensd/FEniCS23-tutorial
# with a MIT License, both by Jørgen S. Dokken.
#
# It was modified to portray the idea of subdomains in a
# weak form. Authorship and copyright should remain with the
# original author.
from dolfinx import fem
from dolfinx import mesh
from dolfinx import plot as dlfplt
import dolfinx.fem.petsc as petsc
from dolfinx import default_scalar_type as num_type
import numpy as np
from mpi4py import MPI
import ufl
import pyvista

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

geo_x, geo_y = ufl.SpatialCoordinate(msh)
kappa = ufl.conditional(
    ufl.le(geo_x, 0.5), num_type(1), num_type(0.1))

V = fem.functionspace(msh, ("Lagrange", 1))
u, v = ufl.TrialFunction(V), ufl.TestFunction(V)
a = ufl.inner(kappa * ufl.grad(u), ufl.grad(v)) * ufl.dx
L = fem.Constant(msh, num_type(1)) * v * ufl.dx
# x = SpatialCoordinate(msh)
dofs = fem.locate_dofs_geometrical(
    V, lambda x: np.isclose(x[0], 0))
bcs = [fem.dirichletbc(num_type(1), dofs, V)]

problem = petsc.LinearProblem(
    a, L, bcs=bcs,
    petsc_options={"ksp_type": "preonly", "pc_type": "lu"})
uh = problem.solve()

num_cells_local = msh.topology.index_map(
    msh.topology.dim).size_local
topology, cell_types, vtk_geo = dlfplt.vtk_mesh(
    msh, msh.topology.dim,
    np.arange(num_cells_local, dtype=np.int32))

p2 = pyvista.Plotter(window_size=[800, 800])
grid_uh = pyvista.UnstructuredGrid(*dlfplt.vtk_mesh(V))
grid_uh.point_data["u"] = uh.x.array.real
grid_uh.set_active_scalars("u")
p2.add_mesh(grid_uh, show_edges=True)
p2.show()