Integral Of A Function Over Boundaries

I am looking for a command to calculate the integral of a solved function over a boundary. I tried

T_int   = 1/V_tot * assemble_scalar(T_fluc *  n[0] * ds(1))

where V_tot is the volume, T_fluc the solved function, n[0] the normal vector in x direction and ds(1) a specific boundary. In the legacy Fenics, this was possible using the function “assemble(…)”. However, when I try to compute the integral, I get the following error message:

TypeError: pack_constants(): incompatible function arguments. The following argument types are supported:
    1. (arg0: dolfinx::fem::Form<double>) -> numpy.ndarray[numpy.float64]
    2. (arg0: dolfinx::fem::Expression<double>) -> numpy.ndarray[numpy.float64]
    3. (arg0: dolfinx::fem::Form<float>) -> numpy.ndarray[numpy.float32]
    4. (arg0: dolfinx::fem::Expression<float>) -> numpy.ndarray[numpy.float32]
    5. (arg0: dolfinx::fem::Form<std::complex<double> >) -> numpy.ndarray[numpy.complex128]
    6. (arg0: dolfinx::fem::Expression<std::complex<double> >) -> numpy.ndarray[numpy.complex128]

I am using dolfinx_mpc:v0.4.1.

Thank you for your help!

As you can see in: A known analytical solution — FEniCSx tutorial
You need to wrap the ufl-form in dolfinx.fem.form prior to inserting it in assemle_scalar.

1 Like

Thank you for your fast answer!