# Maxwell related question

**URL:** <https://community.freefem.org/t/maxwell-related-question/548>\
**Category:** General Discussion\
**Created:** [August 24, 2020, 8:54am UTC](https://community.freefem.org/t/maxwell-related-question/548 "2020-08-24T08:54:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fotios.kasolis](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fotios.kasolis/32/18_2.png) [@fotios.kasolis](https://community.freefem.org/u/fotios.kasolis)\
**Post date:** [August 24, 2020, 8:54am UTC](https://community.freefem.org/t/maxwell-related-question/548/1 "2020-08-24T08:54:06Z")

</div>

Dear all,

I am trying to understand a bit more of FreeFEM’s type deduction strategy in the following case. If `u` is a `P1` function, then `grad(u)` is an `NE0` function, say in `E1`. If such a `P1` function is known from solving a Dirichlet-Laplace problem and its gradient needs to be used as the right hand side (rhs) of a vectorial problem that is tested against `NE0` functions, then which of the following ways is the way to go?  
(1) first interpolate, then plug-in as rhs

```auto
E1 [jx, jy, jz] = -k*grad(u); // k is subdomain-wise constant of type func
varf RHS([Ax, Ay, Az], [Wx, Wy, Wz]) = int3d(T)( [Jx, Jy, Jz]' * [Wx, Wy, Wz] )

```

(2) just include the gradient as part of the rhs, that is,

```auto
varf RHS([Ax, Ay, Az], [Wx, Wy, Wz]) = int3d(T)( -k * grad(u)' * [Wx, Wy, Wz] )

```

Using the notation here, in the [magnetostatics module](https://modules.freefem.org/modules/magnetostatic/) the rhs is defined as in `E1`, but there it is clearer, since the current is a function of the space variables. Can someone please explain what is the space of `k` and `grad(u)` during the assembly in the second case (check the test space and project/interpolate there or? a link in documentation also works)? Further, in the same magnetostatics example, is there a reason for not defining `Mu` as a `P0` function, since it naturally is a `P0` member (and this will keep the module more transparent)?

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [August 24, 2020, 9:34am UTC](https://community.freefem.org/t/maxwell-related-question/548/2 "2020-08-24T09:34:55Z")

</div>

As long as your [qforder](https://doc.freefem.org/references/quadrature-formulae.html) is high enough, both formulation will be equivalent numerically.
