### Transport Equation

267
views
0
9 months ago by
Hi there,

I have the equation
$\frac{\partial c}{\partial t}+v_x\frac{\partial c}{\partial x}+v_y\frac{\partial c}{\partial y}-\frac{\partial}{\partial x}\left(D_{xx}\frac{\partial c}{\partial x}+D_{xy}\frac{\partial c}{\partial y}\right)-\frac{\partial}{\partial y}\left(D_{yx}\frac{\partial c}{\partial x}+D_{yy}\frac{\partial c}{\partial y}\right)=f$ct +vxcx +vycy x (Dxxcx +Dxycy )y (Dyxcx +Dyycy )=ƒ

I understand the time stepping and the advection part. but how could I program diffusion part? especially the
$-\frac{\partial}{\partial x}\left(D_{xy}\frac{\partial c}{\partial y}\right)$x (Dxycy )
here Dxx, Dyy and Dxy are known scalars.

Thank you very much for your help

Community: FEniCS Project

4
9 months ago by
So what you essentially have is an anisotropic diffusion term   $\nabla\cdot\left(\mathbf{D}\nabla c\right)$·(Dc) with  $\mathbf{D}$D a tensor of (constant) coefficients.
Implementing such a term in FEniCS is as easy as (after integration by parts, using a CG basis)

from dolfin import *

mesh = UnitSquareMesh(2,2)

# Tensor with (isotropic) diffusion coefficients
D = Constant([[1.,1.],[1., 1.]])

V = FunctionSpace(mesh,'CG', 1)
c = TrialFunction(V)
w = TestFunction(V)

A = assemble(a)​