Find a 3D function knowing the numerical gradient in discrete point (mesh)

171 Views Asked by At

I have a rectangular mesh of dimension $n,m$ and a scalar field $\theta(x,y)$ defined over the different nodes of the mesh. I want to link $\theta(x,y)$ to an initial condition level-set function $ \phi $ using this relation:

$$ \theta(x,y) = \frac{\pi}{2} + \arctan \Bigg( \frac{\frac{\partial \phi}{\partial y}}{\frac{\partial \phi}{\partial x}} \Bigg) $$

Since there are infinite functions that verify the above relation I've added another dummy constraint:

$$ \| \nabla \phi \| = 1 \implies \sqrt{(\frac{\partial \phi}{\partial x})^2 + (\frac{\partial \phi}{\partial y})^2} = 1$$ $$ \frac{\partial \phi}{\partial x} = \pm \sqrt{1-(\frac{\partial \phi}{\partial y})^2}$$

I know the scalar field $\theta(x,y)$ everywhere, and with the two relation written above, I also know the numerical value of the gradient of the function.

So right now, I would integrate the first relation to find $\phi$, but I'm completely blocked. I don't know exactly how to deal with such a discrete problem. I need the value of the function $\phi$ over the nodes of the mesh. I was thinking to integrate

$$ \int d\phi = \int \sqrt{\frac{\tan^2(\frac{\pi}{2} - \theta(x,y))}{\tan^2(\frac{\pi}{2} - \theta(x,y))+1}} \:\:dy$$

and I've tried to implement it in MATLAB without results.

Have you any idea on how to deal with such a problem?

PS: I can if needed query my MATLAB script to get more points for $\theta(x,y)$.

Thanks in advance! Enrico

1

There are 1 best solutions below

13
On

I've done few steps for your problem: the first equation is equivalent to $$\frac{\partial \phi}{\partial x}\cot(\theta(x,y))=\frac{\partial \phi}{\partial y}$$ I replaced this to second equation: $$\frac{\partial \phi}{\partial x}^2+\frac{\partial \phi}{\partial x}^2\cot^2(\theta(x,y)) = 1$$ $$\Leftrightarrow \frac{\partial \phi}{\partial x}=\pm\frac{1}{\sqrt{\cot^2(\theta(x,y))+1}}$$ Similarly for $\frac{\partial \phi}{\partial y}$, we obtain $$\frac{\partial \phi}{\partial y} = \pm\sqrt{\frac{\cot^2(\theta(x,y))}{\cot^2(\theta(x,y))+1}}$$

It is not guaranteed the existence of the function $\phi$. You can find more in https://en.wikipedia.org/wiki/Conservative_vector_field

I hope it will help.