2
$\begingroup$

I am trying to solve:

Needs["NDSolve`FEM`"];
reg = ImplicitRegion[x^2 + y^2 <= 1, {x, y}];
mesh = ToElementMesh[reg]

s = NDSolveValue[{Derivative[0, 2][f][x, y] + 
  Derivative[2, 0][f][x, y] == 0, 
DirichletCondition[f[x, y] == Sin[x y], True]}, 
  f, {x, y} \[Element] mesh];

Test Function

      g[x_, y_] := Evaluate[s[x, y]];
      g[0.1, 0.2]

      out: 0.0193817

     sol2 = NDSolveValue[{D[u[t, x, y], t] == 
     D[u[t, x, y], x, x] + g[x, y].Grad[u[t, x, y], {x, y}], 
     u[0, x, y] == 0, DirichletCondition[u[t, x, y] == 0, True]}, 
     u, {t, 0, 30}, {x, y} \[Element] reg]

getting error as: PDE parsing error of or Inconsistent equation dimensions, I am missing mathematica syntax, how to include interpolating solution into NDSolveValue?

$\endgroup$
1
  • $\begingroup$ It will be much easier to help you if you post all the code that is necessary to reproduce the issue. Next, using I as the name of the dependent variable is a bad idea, as I is Sqrt[-1] $\endgroup$
    – user21
    Commented Apr 20, 2016 at 6:28

1 Answer 1

2
$\begingroup$

Grad (g) returns a vector - but your PDE is scalar. Here is an example where I sum over the squares g and take the sqrt (which is a scalar):

Needs["NDSolve`FEM`"];
reg = ImplicitRegion[x^2 + y^2 <= 1, {x, y}];
mesh = ToElementMesh[reg];
(*RegionPlot[reg]*)

s = NDSolveValue[{Derivative[0, 2][f][x, y] + 
      Derivative[2, 0][f][x, y] == 0, 
    DirichletCondition[f[x, y] == Sin[x y], True]}, 
   f, {x, y} \[Element] mesh];
g[x_, y_] := Evaluate[Grad[s[x, y], {x, y}]];
sol2 = NDSolveValue[{D[u[t, x, y], t] == 
    D[u[t, x, y], x, x] + 0.5*Sqrt[Total[g[x, y]^2]], u[0, x, y] == 0,
    DirichletCondition[u[t, x, y] == 0, True]}, 
  u, {t, 0, 30}, {x, y} \[Element] mesh]

A version with Dot:

Needs["NDSolve`FEM`"];
reg = ImplicitRegion[x^2 + y^2 <= 1, {x, y}];
mesh = ToElementMesh[reg];
(*RegionPlot[reg]*)

s = NDSolveValue[{Derivative[0, 2][f][x, y] + 
      Derivative[2, 0][f][x, y] == 0, 
    DirichletCondition[f[x, y] == Sin[x y], True]}, 
   f, {x, y} \[Element] mesh];
g[x_, y_] := Evaluate[0.5*Grad[s[x, y], {x, y}]];
sol2 = NDSolveValue[{D[u[t, x, y], t] == 
    D[u[t, x, y], x, x] + g[x, y].Grad[u[t, x, y], {x, y}], 
   u[0, x, y] == 0, DirichletCondition[u[t, x, y] == 0, True]}, 
  u, {t, 0, 30}, {x, y} \[Element] mesh]

This gives a message that the PDE is convection dominated an the result may not be stable.

$\endgroup$
4
  • $\begingroup$ @Matica, same issue. Grad returns a vector but you PDE is scalar. What is the PDE you want to model? $\endgroup$
    – user21
    Commented Apr 21, 2016 at 20:21
  • $\begingroup$ @Matica, g[x, y].Grad[u[t, x, y], {x,y}] works. The 0.5* should go inside the Evaluate. $\endgroup$
    – user21
    Commented Apr 21, 2016 at 21:11
  • $\begingroup$ @Matica, see the update. $\endgroup$
    – user21
    Commented Apr 21, 2016 at 21:27
  • 1
    $\begingroup$ Better make it a question. $\endgroup$
    – user21
    Commented Apr 26, 2016 at 0:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.