# Inactive[Grad] is lost when NDSolve parses PDE

I encountered this when trying to solve the PDE mentioned here. I've transformed the equation to the following:

With[{u = u[x, t]},
neweq = D[u, t] == Inactive[Div][{{u^2}}.Inactive[Grad][u, {x}], {x}] +


This is the formal PDE for FiniteElement method as far as I can tell, but it doesn't lead to the correct solution. After checking with GetInactivePDE, I found the Inactive[Grad][Sign[x] u, {x}]] term is simply lost in parsing stage:

(* Definition of GetInactivePDE isn't included in this post,
please find it in the link above. *)
showFormalPDE[a__] :=
Module[{state}, {state} = NDSolveProcessEquations[a];
GetInactivePDE[state["FiniteElementData"]@"PDECoefficientData",
state@"VariableData"] == 0 // Thread];

{bc, ic} = {{u[-7, t] == 0, u[7, t] == 0}, u[x, 0] == Exp[-x^2]};
showFormalPDE[{neweq, ic, bc}, u, {t, 0, 2}, {x, -7, 7}]
(* {Inactive[Div][-{{u[x]^2}} . Inactive[Grad][u[t, x], {x}], {x}] +
Derivative[1, 0][u][t, x] == 0} *)


Is this a bug? Or separate Inactive[Grad][……] term in PDE is not allowed at the moment?

Tested on v12.1.1.

Just a simpler sample reflecting the underlying issue:

eq = D[u[x, t], t] == Inactive[Grad][aaaa[x], {x}];
ic = u[x, 0] == 0;
showFormalPDE[{eq, ic}, u, {x, 0, 1}, {t, 0, 2}]
(* {Derivative[1, 0][u][t, x] == 0} *)

• There is no right definition of inactive form of equation for FEM. This is the problem. Sep 23 '20 at 14:02

No, this is not a bug. You can not have Inactive[Grad][Sign[x] u[x], {x}] you can only have Inactive[Grad][u[x], {x}] the rest needs to go into some coefficient.

• Oh, I see… but I'd argue that a warning should be generated in this case. Sep 23 '20 at 6:09
• Yes, a warning probably would be good. The problem is when I first wrote that parser I wrote it in a way that would look at the entire equation and then extract the components it recognizes. However, it does not 'subtract' what it recognizes from the argument given and in the end I have no knowledge of what did not get parsed. Trust me I would not do it this way again, but re-writing the parser would be quite a thing. Maybe something in the future. Sorry about that. Sep 23 '20 at 6:14
• It is not clear why we need inactive form of equation for FEM. And also we don't know what is inactive form in every case. Sep 23 '20 at 14:06
• @AlexTrounev Have a look at the documentation. The main point of Inactive is to prevent premature evaluation - that's necessary for a variety of reasons, have a look here, here and here. Sep 23 '20 at 15:26
• @user21 I read documentation during last several years, but I don't understand why we need inactive form at all. Is it connected with some algorithm implemented in NDSolve`? Sep 23 '20 at 15:34