examples.levelSet.distanceFunction.interiorΒΆ
Here we solve the level set equation in two dimension for an interior region. The equation is given by:
\[\begin{split}\abs{\nabla \phi} &= 1 \\
\phi &= 0 \;\; \text{at} \begin{cases}
\text{$x = \left( d, L - d \right)$ for $d \le y \le L - d$} \\
\text{$y = \left( d, L - d \right)$ for $d \le x \le L - d$}
\end{cases}\end{split}\]
Do the tests:
>>> var.calcDistanceFunction(order=1)
>>> dX = dx / 2.
>>> dY = dy / 2.
>>> mm = dX * dY / numerix.sqrt(dX**2 + dY**2)
>>> def evalCell(phix, phiy, dx, dy):
... aa = dy**2 + dx**2
... bb = -2 * ( phix * dy**2 + phiy * dx**2)
... cc = dy**2 * phix**2 + dx**2 * phiy**2 - dx**2 * dy**2
... sqr = numerix.sqrt(bb**2 - 4. * aa * cc)
... return ((-bb - sqr) / 2. / aa, (-bb + sqr) / 2. / aa)
>>> v1 = evalCell(dY, dX, dx, dy)[1]
>>> v2 = max(-dY*3, -dX*3)
>>> values = numerix.array(( v1, dY, dY, dY, v1,
... dX, -mm, -dY, -mm, dX,
... dX, -dX, -v1, -dX, dX,
... dX, -mm, -dY, -mm, dX,
... v1, dY, dY, dY, v1 ))
>>> print(var.allclose(values, atol = 1e-10))
1
Last updated on Nov 20, 2024.
Created using Sphinx 7.1.2.