Correct expansion for 2D anisotropic diffusion I am trying to model a diffusion phenomenon with anisotropic and heterogeneous diffusion.
$$\nabla \cdot (D\nabla c)$$
where
$$D = \begin{bmatrix} D_{xx}(x,y)&D_{xy}(x,y)\\ D_{yx}(x,y)&D_{yy}(x,y) \end{bmatrix}$$
and $D_{xy} = D_{yx}$. From Wikipedia, I get
$$\nabla \cdot (D\nabla c) = \nabla \cdot[D(x,y)] \nabla c(x,y) + \mbox{tr} \left( D(x,y) \nabla \nabla ^T c(x,y) \right)$$
If I am correct, then
$$\mbox{tr} \left( D(x,y)\nabla \nabla ^Tc(x,y) \right) = D_{xx}\frac{\partial^2 c}{\partial x^2}+D_{yy}\frac{\partial^2 c}{\partial y^2}$$
but I am unsure how to expand the first term. Perhaps,
$$\left( \frac{\partial c}{\partial x} \hat i + \frac{\partial c}{\partial y} \hat j \right) (\nabla D_{xx}+2\nabla D_{xy}+\nabla D_{yy})$$
where $\nabla (\cdot) = \left(\frac{\partial (\cdot)}{\partial x} \hat i+\frac{\partial (\cdot)}{\partial y} \hat j \right)$
completely FOIL'd out?
Any help would be appreciated, as I am trying to use this for implementing a model. I also apologize for my notation.
 A: The expansion of the divergence is explained in this post, where intrinsic expressions are given. We might want to expand the divergence explicitly, noting that
\begin{aligned}
\nabla\cdot(D\nabla c) &= (D_{xx}c_{,x} + D_{xy}c_{,y})_{,x} + (D_{xy}c_{,x} + D_{yy}c_{,y})_{,y} \\
&= D_{xx,x}c_{,x} + D_{xy,x}c_{,y} + D_{xy,y}c_{,x} + D_{yy,y}c_{,y} \\
&\quad + D_{xx}c_{,xx} + 2\, D_{xy}c_{,xy} + D_{yy}c_{,yy} .
\end{aligned}
where we have used differential rules, the symmetry property $D_{yx}=D_{xy}$, and the definition $\nabla c = [c_{,x}, c_{,y}]^T$ of the gradient (indices after the comma denote partial differentiation). In other words, we get $$
\nabla\cdot(D\nabla c) = (\nabla\cdot D) \cdot \nabla c + D : \nabla \nabla c 
\tag{*}
$$
as was found in the related post, where $$
\nabla\cdot D = \begin{bmatrix}
D_{xx,x}+D_{xy,y}\\
D_{xy,x}+D_{yy,y}
\end{bmatrix}, \qquad 
\nabla \nabla c = \begin{bmatrix}
c_{,xx} & c_{,xy}\\
c_{,xy} & c_{,yy}
\end{bmatrix},
$$
and the colon denotes the Frobenius inner product (which is analogous to the vector dot product). In Eq. (*), the first term corresponds to the first line of the expanded expression above, and the second term corresponds to the second line.
Note: in this answer, $\nabla$ is viewed as the gradient operator, not as a vector of scalar differential operators.
