Create and assemble form into scalar in DOLFINX

Hi, I want to calculate the fowllowing integral,

Screenshot from 2024-01-15 15-37-49

by assembleing the form

element = create_element("Lagrange", "interval", 1)
E  = Coefficient(element)
energy = E * E * dx

and I creat the form as fowllows:

auto el = std::make_shared<Form<T>>(fem::create_form<T>(*form_Poisson_1D_Q1_el, {V}, {{"E", E_}}, {}, {}));

but it reports the error:

terminate called after throwing an instance of 'std::runtime_error'
  what():  Wrong number of argument spaces for Form.
Aborted (core dumped)

Now I have two questions:

1 What is wrong in my code, how can I create the form?

2 .Can I compute the intergral by just using dolfinx::fem::assemble_scalar(*el), is there anything else to take care?

Thanks very much!

Not adhering to Read before posting: How do I get my question answered?, for starters :wink:

Have a look at:

But as mentioned in the previous reply, without following the guidelines for posting on the forum dramatically decreases the chances of getting help with your question.