Implementing source term

Hello everybody,

i am not really sure how to implement the source term of my problem. The problem is the RHS and it know about the issues with the regularity. It looks like the following:

(\sigma(\theta)\nabla \varphi) * \nabla \varphi.

$$ \sigma(\theta)$$ is the heat conductivity for an isotropic material. First of all i could just say it is a constant but my problem is the quadratic term after it.

Thank you and greetings

I want something like Expression(…). Or?

  • if you solve a system of equations and φ is a TrialFunction in the system, then its straight forward with

    sigma = Expression(....)
    S = dot(sigma * grad(phi), grad(phi) )
    

    then you have a nonlinear system of equations, which can be solved with the Newton method

  • If φ is just a normal Function (for example implementing the picard itation for nonlinear systems → φ is the value from the previous iteration), then I don’t think there is a super straight forward way (at least I dont know one). I previously used project for something similar, however discarded the whole code in order to use newton method, as my Picard iteration did not converge.

    V_phi = FunctionSpace(mesh, 'P', 1)
    S = project( dot(sigma*grad(phi), grad(phi)), V_phi)
    

I hope this kind of helps :slight_smile:

Thank you!
Greetings