# How to solve the following problem?

I want to solve the following problem with FreeFEM++.

{\rm given }{\bf \vec B}{\rm (}{\bf \vec r}){\rm :such }\vec \nabla \cdot {\bf \vec B} = 0 \\ {\rm find }F{\rm (}{\bf \vec r}),G{\rm (}{\bf \vec r}):{\rm such }\vec \nabla F \times \vec \nabla G = {\bf \vec B} \\

How can I derive the weak form of this equation to solve with FreeFEM++?

This is a well-known problem on differential forms, which is difficult.
There is no easy way of solving it globally. One can solve it by abstract differential geometry arguments in the neighboorhood of a point x where B(x) is nonzero.
Solving it with FreeFem++ looks out of reach since it is nonlinear in the couple F,G.

An analogous 2d problem is: given a non-vanishing vector field B, find two scalar functions f,g such that f*grad(g)=B.
The formal solution is: consider the integral lines of B^\perp.
Take g constant on each of these integral lines, the constant changing when changing the integral line. Then grad g is perpendicular to these integral lines, thus grad g is proportional to B. It follows the existence of f.

All this is related to the Frobenius Theorem

1 Like

Nevertheless I can propose you a solution, assuming that B_3>0 everywhere.

It is enough to satisfy
B.\nabla F=0, (1)
B.\nabla G=0, (2)
and
(\partial_1 F)(\partial_2 G)-(\partial_2 F)(\partial_1 G)=B_3 on the plane x_3=0. (3)

Then if you interpret x_3 as a time, (1) and (2) are advection equations on F
and G, that you can solve (divide by B_3) using convect, see FreeFEM-documentation.pdf p.61, provided you give initial data
F_0, G_0 on the plane x_3=0.
These initial data need to be chosen such that (3) holds.
You can take for example G_0=x_2.
Then (3) is just (\partial_1 F_0)=B_3, which is easily solved to get some F_0(x_1,x_2).
Once you have F_0,G_0, you can solve the advection equations.
Francois.

1 Like