# 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,
showFormalPDE[a__] :=
Module[{state}, {state} = NDSolveProcessEquations[a];
GetInactivePDE[state["FiniteElementData"]@"PDECoefficientData",

{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.
• @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