Use 2D solution as initial guess in 3D - transformation 2D to 3D

I have 2D solution of scalar potential in cylindrical coordinates and want to use it as initial solution guess in 3D (rotational symmetrical problem)

I am trying this:

def scalar_2D_to_3D(gfu_2D, mesh_2D, gfu_3D):
    x3, y3, z3 = x, y, z
    # radial coordinate for rotation around x-axis
    r3 = sqrt(y3*y3 + z3*z3)
    f = gfu_2D(CoordinateTrafo(CF((x,r3)), mesh_2D.Materials(".*")))
    gfu_3D.Set(f)

but my code crashes on gfu_3D.Set(f) without any error message.

Is there a way how to transform 2D gfu to 3D?

This looks fine. Can you post mwe of crash?
Best Christopher

There was a bug in NGSolve in the find element of point functions. Should be fixed with this commit:

I started a nightly build so new version should be up in ~1 hour installable with pip prerelease:

pip install --upgrade --pre ngsolve

best
Christopher

Thank you Christopher. Now it works like a charm.

My 3D solution is found in the first iteration on rotated 2D mesh when I use transformed 2D solution as initial guess, so I see big speed up.

1 Like