1D problem arbitrarily oriented

Hello everyone,

I’m trying to solve the advection-diffusion problem in a 1D domain which is arbitrarily oriented. My first approach is as follows:

  • To begin I take the 1D advection-diffusion example found here https://github.com/gregvw/FEniCS-examples/blob/master/advdiff.py

  • Then I rotate the line lying on the x axis such that the nodes are separated the same length and they have x, y and z coordinates different from 0, lets think about it as the diagonal of a cube.

  • The rotated coordinates are saved in a xml file and loaded via mesh = Mesh(‘grid.xml’)

  • Finally I Solve the problem, but I’m getting different results. The results are different because in the weak form we have
    a = uvdx + dtinner(grad(v),difgrad(u))dx + dtinner(v,grad(adv*u)[0])*dx

where it is considered only the derivative in the x direction with grad(adv*u)[0]

How could I consider something like du/ds instead of du/dx only?

I already try with inner(v,grad(adv*u))*dx but I get the error “shapes do not match: Argument id=140085557493832 and Grad id=140085596126728”

Thank you very much for your time and suggestions!

Hi, note that for a line in 3d which is aligned with x axis grad(u)[0] is equivalent to dot(grad(u), t) where t=Constant((1, 0, 0)) is the tangent vector of the line.