Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to add contours for iso-level values of a FEM solution of a PDE on a generic 3D region; for visualization of values on the boundary, I have used ElementMeshSurfacePlot3D in the NDSolve`FEM`​ package (as in the Wolfram example of the Space Shuttle). The 3D region is an oil pump taken from CAD and imported using STL format.

I would like to insert into the 3D graphics the contour lines for some values of the temperature on the boundary.

pump

share|improve this question

You could use SliceContourPlot3D. Using the definitions of mr and uif from the page linked in the OP (and defined in user21's answer),

SliceContourPlot3D[
 uif[x, y, z], {mr}, {x, -8, 8}, {y, -5, 5}, {z, -2, 5}, 
 BoxRatios -> Automatic, Boxed -> False, Axes -> False, 
 Contours -> 20, ColorFunction -> "TemperatureMap"]

Mathematica graphics

share|improve this answer

ElementMeshSurfacePlot3D does not have an option to plot contours in Version 10. It may get one in the future. One thing you can do is use the function imsFindContour form this old, outdated package. You'll find the function in the file UnstructuredPlot.m

Then you can do something like this:

mr = BoundaryDiscretizeGraphics[
   ExampleData[{"Geometry3D", "SpaceShuttle"}]];
uif = NDSolveValue[{Inactive[Laplacian][u[x, y, z], {x, y, z}] == 1, 
    DirichletCondition[u[x, y, z] == 1, z <= -1.3]}, 
   u, {x, y, z} \[Element] mr];

Get["Imtek`UnstructuredPlot`"] // Quiet
Needs["NDSolve`FEM`"]

mesh = uif["ElementMesh"];
Show[
 ElementMeshSurfacePlot3D[uif, Boxed -> False, 
  ViewPoint -> {0, -4, 2}],
 Graphics3D[
  Polygon /@ 
     imsFindContour[mesh["Coordinates"], 
       Join @@ ElementIncidents[mesh["BoundaryElements"]], 
       uif["ValuesOnGrid"], #][[All, -1]] & /@ 
   Range[Sequence @@ MinMax[uif["ValuesOnGrid"]], 2], Boxed -> False]
 ]

enter image description here

Not perfect but maybe a starting point.

share|improve this answer
    
Would contours on a surface plot be a feature that is generally of interest to people doing FEM with Mathematica? – user21 yesterday
    
Well, that, or more generally the ability to specify a MeshFunction on a plot over a region. BTW: you can do ExampleData[{"Geometry3D", "SpaceShuttle"}, "BoundaryMeshRegion"] instead. – J. M. yesterday

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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