3
$\begingroup$

Bug introduced in 11.1 or earlier, fixed in 11.3 or earlier.


The following PDE

pde = I Cos[x y] D[u[x, y], x] + Laplacian[u[x, y], {x, y}] == 0;

Is happily solved by

NDSolve[{pde, 
  DirichletCondition[u[x, y] == Cos[x y], True]}, u, {x, 0, 1}, {y, 0,
   1}]

However, if I set up the advection coefficient using interpolation, things go askew:

Needs["NDSolve`FEM`"]
R = ImplicitRegion[0 <= x <= 1 && 0 <= y <= 1, {x, y}];
mesh = ToElementMesh[R]; 
coords = mesh["Coordinates"]; 
CosA = ElementMeshInterpolation[{mesh}, 
   Table[{xi, yi} = coords[[i]]; 
    Cos[xi yi], {i, 1, Length[coords]}]];
pde = I CosA[x, y] D[u[x, y], x] + Laplacian[u[x, y], {x, y}] == 0;
NDSolve[{pde, 
  DirichletCondition[u[x, y] == Cos[x y], True]}, u, {x, 0, 1}, {y, 0,
   1}]

Mathematica issues the complaint CompiledFunction::cfex --

CompiledFunction: Could not complete external evaluation at instruction 10; proceeding with uncompiled evaluation.

Though the answer is ultimately obtained, the behavior is curious to me. (Also, I need the speedup that comes with compiling.)

Note that the problem is not due to interpolation alone, e.g. one can drop the I,

pde = CosA[x, y] D[u[x, y], x] + Laplacian[u[x, y], {x, y}] == 0;

and compilation works. The issue, as far as I can tell, involves the special imaginary-interpolated combination. Two questions:

  1. Why this behavior?
  2. Is there a workaround?
$\endgroup$
  • $\begingroup$ I cannot reproduce the error with Mathematica version 12.0. Please restart you kernel. Maybe there was some definition lingering around in some symbol. $\endgroup$ – Henrik Schumacher Jun 12 at 12:01
  • 1
    $\begingroup$ What version are you using? This works fine in 11.3 and 12.0. $\endgroup$ – user21 Jun 12 at 12:13
  • $\begingroup$ @user21 and Henrick Shumacher, I'm using 11.1.1.0. I'll upgrade and report back. $\endgroup$ – Will.Mo Jun 12 at 13:38
  • $\begingroup$ @HenrikSchumacher thanks for the code edit. $\endgroup$ – Will.Mo Jun 12 at 13:43
  • $\begingroup$ Did you get a chance to test this? $\endgroup$ – user21 Jun 14 at 5:21
3
$\begingroup$

The problem is solved by upgrading to Mathematica 12.0.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.