treverhines / RBF

Python package containing the tools necessary for radial basis function (RBF) applications
MIT License
220 stars 51 forks source link

How to compute anisotropic diffusion operator ? #28

Closed RomanLF closed 1 year ago

RomanLF commented 2 years ago

Hello Mister Hines,

I am still working with RBF-FD thanks to your package. I read on the issues posted here how to compute a pressure field given some velocities. In this pressure Poisson equation, the right handside was computed with the use of weight matrices :

Wx = weight_matrix(nodes, nodes, n, [1, 0, 0], phi=phi, order=order)
Wy = weight_matrix(nodes, nodes, n, [0, 1, 0], phi=phi, order=order)
Wz = weight_matrix(nodes, nodes, n, [0, 0, 1], phi=phi, order=order)
Wxx = weight_matrix(nodes, nodes, n, [2, 0, 0], phi=phi, order=order)
Wyy = weight_matrix(nodes, nodes, n, [0, 2, 0], phi=phi, order=order)
Wzz = weight_matrix(nodes, nodes, n, [0, 0, 2], phi=phi, order=order)
bx = -rho*(u*Wx.dot(u) + v*Wy.dot(u) + w*Wz.dot(u)) + mu*(Wxx.dot(u) + Wyy.dot(u) + Wzz.dot(u))
by = -rho*(u*Wx.dot(v) + v*Wy.dot(v) + w*Wz.dot(v)) + mu*(Wxx.dot(v) + Wyy.dot(v) + Wzz.dot(v))
bz = -rho*(u*Wx.dot(w) + v*Wy.dot(w) + w*Wz.dot(w)) + mu*(Wxx.dot(w) + Wyy.dot(w) + Wzz.dot(w))
rhs = Wx.dot(bx) + Wy.dot(by) + Wz.dot(bz)

My question is the following :

$$ \mathbf{W} = \partial_j (Dj \partial{j}) $$

For example in dimension 3, building $W : (n{interior}, n)$ a weight matrix build on some interior nodes (not affected by boundary conditions), with $n{interior}$ number of interior points and $n$ the total number of points, so that,

$$ W u = \partial_x (D_x \partial_x u) + \partial_y (D_y \partial_y u) + \partial_z (D_z \partial_z u) $$

With $D_x$, $D_y$, $Dz$ of dimensions $(n{interior},1)$ each, and $u$ a scalar variable of dimension $(n,1)$ defined on whole domain.

In this example I cannot use the method showed in the example to compute the RHS because I don't have access to variable $u$ to make the writings work with dimensions of matrices.

Do you have any hint about how to build an anisotropic diffusion operator in that case ?

Kind regards, Roman

treverhines commented 2 years ago

Hi Roman. I am glad to hear you are still finding this package useful.

I am a bit confused by your notation here. $D_j$ is a spatially dependent diffusion coefficient, right? It is possible to create a weight matrix for what you want. You would need to expand your equation using the product rule, and pass the spatially dependent coefficients (either $D_i$ or $\partial_i D_i$) into weight_matrix with the coeffs argument. It may be helpful to look at examples here https://rbf.readthedocs.io/en/latest/fd.html where I use the coeffs argument to apply free boundary conditions.

RomanLF commented 1 year ago

Hello Trever,

Thank for your answer and your very instructive example. i forgot to answer here but thank you a lot.

Roman