About MHD equations

Hello, everyone.

I want to solev MHD equations in freefem++, but I really can not deal with the boundary condition of magnetic B, especially the condition

B·n = 0


B·n = Be·n

Be is the analytic solution and n is the normal for boundary.
The MHD equations as follows, where time J = [0,T],

Another question: In three dimensions, I define the mesh

mesh3 Th = cube(N,N,N);

But when N > 10, the output: out of memory. Are there somes methods to this?

You can do as

The penalty formulation (3) will work if the boundary is made of flat pieces. Otherwise you have to lump it, see Boundary condition - #6 by fb77

For B·n = Be·n in boundary of three dimensions \Omega, is it okay for me to enter like this?

+ int2d(Th, 1, 2, 3, 4, 5, 6)(1e10*( Bx*N.x + By*N.y + Bz*N.z )*( wx*N.x + wy*N.y + wz*N.z ) )
- int2d(Th, 1, 2, 3, 4, 5, 6) (1.e10*( Bxe*N.x + Bye*N.y + Bze*N.z )*( wx*N.x + wy*N.y + wz*N.z ) )

Is there need any other statements for magnetics B, like

+ on(1, 2, 3, 4, 5, 6)(.......)

Yes it looks good (if your domain has flat boundaries as I said, like a cube for example). There is no need of anything else.

For completeness I explain why the variational formulation corresponds to your required boundary condition.