Hi

I've been using the signed distance function (Eikonal equation) for some
time
in various turbulence models. This equation is very stiff so in my approach
I
have found it necessary to add a stabilization term. I also solve a simpler
linear Poisson problem first to get a good initial guess for the nonlinear
Newton solver. Otherwise it's pretty straightforward. You could probably use
the
NonlinearVariational etc classes to wrap this up nicely, but I haven't done
that.
The code I use is basically (copy and pasted from
http://bazaar.launchpad.net/~cbc.rans/cbc.rans/mikael/view/head:/cbc/rans/turbsolvers/Eikonal.py):

V = FunctionSpace(mesh, 'CG', 1)
v = TestFunction(V)
u = TrialFunction(V)
f = Constant(1.0)
y = Function(V)

# Initialization problem to get good initial guess for nonlinear problem:
F1 = inner(grad(u), grad(v))*dx - f*v*dx
a1, L1 = lhs(F1), rhs(F1)
A1, b1 = assemble_system(a1, L1)
# Apply boundary conditions: DirichletBC = 0 on the boundary
for bc in bcs: bc.apply(A1, b1)
solve(A1, y.vector(), b1)

# Stabilized Eikonal equation
eps = Constant(0.01)
F = sqrt(inner(grad(y), grad(y)))*v*dx  -  f*v*dx + eps*inner(grad(y),
grad(v))*dx

J = derivative(F, y, u)
etc
Solve with Newton iterations

This works for me for a range of geometries. Hope it is helpful.

Best regards

Mikael

On 8 August 2011 22:31, Johan Hake <[email protected]> wrote:

> Hello!
>
> Has anyone in the FEniCS comunity used FEniCS to solve for the signed
> distance
> function?
>
>  http://en.wikipedia.org/wiki/Signed_distance
>
> This functions gives the distance to the boundary for any given point
> inside
> the domain. I would like to compute this for the vertices of a mesh. It
> looks
> like it is a nontrivial problem and I wonder if any of you have put your
> teeth
> into this one.
>
> Johan
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dolfin
> Post to     : [email protected]
> Unsubscribe : https://launchpad.net/~dolfin
> More help   : https://help.launchpad.net/ListHelp
>
_______________________________________________
Mailing list: https://launchpad.net/~dolfin
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~dolfin
More help   : https://help.launchpad.net/ListHelp

Reply via email to