Integral calculation

\sigma = 5.8e7 \\ E = [Ex,Ey,Ez] = [0,0,1] \\ J = [Jx,Jy,Jz] = \sigma E \\ R = \frac{1}{{\int {\frac{{J \cdot J}}{\sigma }} d\Omega }} \\

I have recently started using NGSolve.

I would like to do the above integral calculations in NGSolve. However, I do not know how to do it.

sigma = 5.8e7
mu = 4*pi*1e-7
E = CoefficientFunction([0,0,1])
J = sigma*E
R_denominator = LinearForm(fes)
R_denominator += J*J/sigma *dx
R = 1/R_denominator

I have tried with the above code, but I get an error.
TypeError: unsupported operand type(s) for /: ‘int’ and ‘ngsolve.comp.LinearForm’

Can someone please provide a solution?

R = 1/Integrate(J*J/sigma*dx, mesh)

should work.

Thank you for telling me about it. However I got ZeroDivisionError: float division by zero.
The integral formula is not wrong, so is there a problem with E or J?
I’ll go back and look at the documentation.

Thanks anyway.

Ah yes, you define a vector valued CF with a tuple, not a list. for more historic reasons a list defines a domain wise cf

E = CoefficientFunction((0,0,1))