This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Advection diffusion coefficient

0 votes

Hi,

I just found the advection-diffusion example on github and in the UFL-File

u = TrialFunction(scalar)
v  = TestFunction(scalar)
u0 = Coefficient(scalar)
b  = Coefficient(vector)
f  = Coefficient(scalar)

c = 0.005
k = 0.05

a = u*v*dx + 0.5*k*(dot(b, grad(u)*v)*dx + c*dot(grad(u), grad(v))*dx)
L = u0*v*dx - 0.5*k*(dot(b, grad(u0)*v)*dx + c*dot( grad(u0), grad(v))*dx) \
    + k*f*v*dx

I don't understand what c and k should represent and why they are set as variable, but the other factors (0.5 in the equation of a and L) are not.
Is there any difference?

I was wondering if they were something like the diffusion coefficient and if the diffusion coefficient could be set to an manually by Defining it with D = Coefficient(scalar)?

I hope you have some Ideas, what I want to realize and how this could be done.

Thanks

asked Jul 19, 2016 by Pama328 FEniCS Novice (480 points)
edited Jul 20, 2016 by Pama328

1 Answer

0 votes
 
Best answer

Hello,

You may find more knowledge in Chapter 31 of Fenics Book. From what it looks like, (0.5) used in linear and bilinear form comes from some time discretization scheme. In Fenics Book, they use Crank Nicolson with 'theta = 0.5'.

Here, 'c' and 'k' may just be variables which if written directly in the form will complicate it or they may be specific parameters related to the problem, but it is unlikely that they would define them like that in the UFL.

answered Jul 21, 2016 by Chaitanya_Raj_Goyal FEniCS User (4,150 points)
selected Jul 23, 2016 by Pama328

Thanks, the reference to the Fenics book helped a lot.

After reading this chapter I guess that c could be the diffusion coefficient and k could be the time intervall delta t which is necessary for time stepping. Would you agree?

And if I'm not mistaken it should also work if I set them manually in the cpp code after declaring it in the UFL-File via

c = Coefficient(scalar)
k = Coefficient(scalar)

?

I cannot comment on the first assumption because I have not studied the problem but take a look at bottom of page 59 here:

https://hplgit.github.io/fenics-tutorial/doc/pub/fenics-tutorial-4print.pdf

Your second assumption is correct.

Hope this solves your problem.

Thanks, that also helped a lot.

Besides;

c = Coefficient(scalar)

worked, but

k = Coefficient(scalar)

didn't.

For some reasons (I don't know exactly why) k had to be defined as

k = Constant(cell)

Do you know why?

...