### Transport Equation

267

views

0

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$∂

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)$−∂∂

here Dxx, Dyy and Dxy are known scalars.

Thank you very much for your help

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$∂

`c`∂`t`+`v`_{x}∂`c`∂`x`+`v`_{y}∂`c`∂`y`−∂∂`x`(`D`_{xx}∂`c`∂`x`+`D`_{xy}∂`c`∂`y`)−∂∂`y`(`D`_{yx}∂`c`∂`x`+`D`_{yy}∂`c`∂`y`)=`ƒ`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`(`D`_{xy}∂`c`∂`y`)here Dxx, Dyy and Dxy are known scalars.

Thank you very much for your help

Community: FEniCS Project

### 1 Answer

4

So what you essentially have is an anisotropic diffusion term $\nabla\cdot\left(\mathbf{D}\nabla c\right)$∇·(

Implementing such a term in FEniCS is as easy as (after integration by parts, using a CG basis)

**∇**`D``c`) with $\mathbf{D}$**a tensor of (constant) coefficients.**`D`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 = inner(D*grad(c), grad(w))*dx
A = assemble(a)
```

It works perfect, Thank you very much

written
9 months ago by
Ruben Gonzalez

Please login to add an answer/comment or follow this question.