7
$\begingroup$

Trying to help out in the question, Finite Elements 3D, I came across this behavior of SliceContourPlot3D:

op = -Laplacian[u[x, y, z], {x, y, z}] - 2;
uif = NDSolveValue[{op == 0, DirichletCondition[u[x, y, z] == 0, True}, 
   u, {x, y, z} ∈ Ball[{0, 0, 0}]];

SliceContourPlot3D[
 uif[x, y, z], "CenterPlanes", {x, y, z} ∈ MeshRegion@uif["ElementMesh"], 
 ColorFunction -> "Rainbow"]

Mathematica graphics

The range of colors does not go all the way down to violet/indigo. I expected the range of colors to be something like this:

With[{sel = Positive[uif["Grid"].{0.3, -0.4, -1}]},
 With[{pts = Pick[uif["Grid"], sel]},
  Graphics3D[
   GraphicsComplex[
    pts,
    {Point[Range@Length@pts, 
      VertexColors -> (ColorData["Rainbow"] /@ Rescale[Pick[uif["ValuesOnGrid"], sel]])
      ]}
    ]]
  ]]

Mathematica graphics

Is this a bug in SliceContourPlot3D? (Perhaps it's due to extrapolation from sampling outside the domain?) Is there a way to get it to rescale the colors the way I expected?

I'm using V10.3.0, Mac OSX.

$\endgroup$
1
  • 1
    $\begingroup$ Looks that SliceContourPlot3D is a function of Mathematica 10.3.0. To me it is not working. I'm using 10.0.0. $\endgroup$
    – Stratus
    Dec 20, 2015 at 19:54

2 Answers 2

4
$\begingroup$

It seems SliceContourPlot3D makes an initial sample, that is not quite right - i.e. outside of the region. Using

op = -Laplacian[u[x, y, z], {x, y, z}] - 2;
uif = NDSolveValue[{op == 0, 
    DirichletCondition[u[x, y, z] == 0, True]}, 
   u, {x, y, z} \[Element] Ball[{0, 0, 0}], 
   "ExtrapolationHandler" -> {(Indeterminate &),
              "WarningMessage" -> False}];

SliceContourPlot3D[
 uif[x, y, z], "CenterPlanes", {x, y, z} \[Element] 
  MeshRegion@uif["ElementMesh"], ColorFunction -> "Rainbow"]

enter image description here

On a related note, I am wondering if for FEM this ExtrapolationHandler should be the default - what do you think?

$\endgroup$
1
  • $\begingroup$ I almost always use this extrapolation handler, because in my uses of interpolation, extrapolation is usually inappropriate. Not sure if turning off the warning message by default is the best choice or not. Plotters suppress such warnings automatically, it seems. Sometimes, it might be good to be warned. $\endgroup$
    – Michael E2
    Dec 20, 2015 at 22:13
4
$\begingroup$
mesh = BoundaryDiscretizeRegion[Ball[{0, 0, 0}]];
alpha = 0.;
op = -Laplacian[u[x, y, z], {x, y, z}] - 2
Subscript[\[CapitalGamma], 
   D] = {DirichletCondition[u[x, y, z] == 0, True]};
uif = NDSolveValue[{op == 0, Subscript[\[CapitalGamma], D]}, 
  u, {x, y, z} \[Element] mesh]
sol2 = Plot[uif[x, 0, 0], {x, -1, 1}]
SliceContourPlot3D[
 uif[x, y, z], "CenterCutSphere", {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, 
 AxesLabel -> Automatic, ColorFunction -> "BrightBands", 
 PlotLegends -> Automatic]

enter image description here

$\endgroup$

Your Answer

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

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