# “Problem” and “varf” format

**URL:** https://community.freefem.org/t/problem-and-varf-format/4002
**Category:** General Discussion
**Created:** [July 11, 2025, 1:59pm UTC](https://community.freefem.org/t/problem-and-varf-format/4002 "2025-07-11T13:59:41Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Dainy-Jia](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/dainy-jia/32/3322_2.png) [@Dainy-Jia](https://community.freefem.org/u/Dainy-Jia)
#### Post date: [July 11, 2025, 1:59pm UTC](https://community.freefem.org/t/problem-and-varf-format/4002/1 "2025-07-11T13:59:41Z")

</div>

Hi, everyone!  
I have a three-dimensional model：

```auto
E+u\times B-(1/Rm)* \curl B=g in \Omega
(\partial B)/(\partial t)+\curl E=0 in \Omega

```

The boundary condition is

```auto
B\cdot n=0, E\times n=0 On \partial Omega

```

here, u represents the velocity field, E represents the electric field, and B represents the magnetic field.  
The discrete format of this model is

```auto
(E_h^n,F)+(u_h^n \times B_h^{n-1},F )-(B_h^n,\curl F)=(g,F),
(1/\tau)*(B_h^n-B_h^{n-1},C)+(\curl E_h^n,C)=0.

```

In the code, I do the decoupling operation, which involves the exact solution with respect to the values of u. I used two types of code to solve these two models, but the convergence order obtained using “Problem” was correct, while it was incorrect when changed to “varf”.

> Blockquote  
> [solver\_EB\_3D.edp](https://community.freefem.org/uploads/short-url/kXTMJhzpiHWaQnpr59Kai8NPwiC.edp) (6.2 KB)  
> [solver\_EB3D\_save.edp](https://community.freefem.org/uploads/short-url/76zNcrL42u7MtN5QE3N94wBaMum.edp) (6.3 KB)

---

<div class="post-metadata">

### Author: ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)
#### Post date: [July 12, 2025, 2:45pm UTC](https://community.freefem.org/t/problem-and-varf-format/4002/2 "2025-07-12T14:45:12Z")

</div>

Hi,  
In your right-hand side you miss the boundary values for B. You can include them by

```auto
     real[int] bon = a2(0,WhPh);
     b=b+bon;

```

When you set` [E1[], B1[]] = sol`, the dof are not in the correct order. A correct way is

```auto
    WhPh [Q1,Q2,Q3,Z1,Z2,Z3];
     Q1[]=sol;
    [E1,E2,E3]=[Q1,Q2,Q3];[B1,B2,B3]=[Z1,Z2,Z3];

```

Another difference is that in one file you have `[u1,u2,u3]=(Et(0.)+1.)*u1Exact;` and in the other `[u1,u2,u3]=(Et(tnext)+1.)*u1Exact;`  
full file with the corrections (not the last one with Et(0.) or Et(tnext))  
[solver\_EB3D\_save.edp](https://community.freefem.org/uploads/short-url/ik0hfgmKMSIKqV1TDjumgN3nyLI.edp) (6.5 KB)

---

<div class="post-metadata">

### Author: ![Dainy-Jia](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/dainy-jia/32/3322_2.png) [@Dainy-Jia](https://community.freefem.org/u/Dainy-Jia)
#### Post date: [July 13, 2025, 10:34am UTC](https://community.freefem.org/t/problem-and-varf-format/4002/3 "2025-07-13T10:34:06Z")

</div>

Thank you very much for your reply!  
Based on the code you returned, I have been able to successfully run the correct result. Since the velocity u, the electric field E and the magnetic field B are solved in coupling, I need to define to combine the space ‘Uh’

```auto
  fespace Uh(Th,[P1,P1,P1], Edge03d, RT03d);
  Uh [Q1,Q2,Q3,Z1,Z2,Z3,N1,N2,N3];
...
real[int] sol = A^-1 * b;
      Q1[]=sol;
    [u1,u2,u3]=[Q1,Q2,Q3];[E1,E2,E3]=[Z1,Z2,Z3]; [B1,B2,B3]=[N1,N2,N3];

```

However, defining ‘Uh’ this way will result in an error. Do you have any good methods？  
Looking forward to your reply！

---

<div class="post-metadata">

### Author: ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)
#### Post date: [July 13, 2025, 12:46pm UTC](https://community.freefem.org/t/problem-and-varf-format/4002/4 "2025-07-13T12:46:16Z")

</div>

You can simply set  
`fespace Uh(Th, [P1,P1,P1,Edge03d, RT03d]);`  
The important thing is to put `Q1[]=sol` where `[Q1,...]` is declared in the space `Uh` involved in the matrix and rhs definitions `matrix A1 = a1(Uh,Uh);` `real[int] b = rhs(0, Uh);` so that the degrees of freedom are correctly interpreted.

---

<div class="post-metadata">

### Author: ![Dainy-Jia](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/dainy-jia/32/3322_2.png) [@Dainy-Jia](https://community.freefem.org/u/Dainy-Jia)
#### Post date: [July 13, 2025, 1:54pm UTC](https://community.freefem.org/t/problem-and-varf-format/4002/5 "2025-07-13T13:54:45Z")

</div>

Thank you for your suggestion. I can run it correctly now！
