0
$\begingroup$

I have obtained solution to a 3D FEA problem and would like to plot it on the mesh. The geometry has holes in it. For example, if u[x,y,z] is an interpolation function, obtained from a FEA solution, then is there an equivalent command to contourplot and contourplot3D such that i can plot the solution on the mesh. If i directly use the commands contourplot and contourplot3D, then the plot does not show the holes in the mesh (or geometry).

Contourplot3D[U[x,y,z],{x,y,z}\[Element]mesh]

However, this function does not work because you cannot give a mesh as the domain data. I would also like to know how could i plot a 2D contour at a surface. For example something like this,

Block[{z=0.1},Contourplot2D[U[x,y,z],{x,y,z}\[Element]mesh]]

Is there any alternative to this plotting function? I would appreciate any help in this regard.

$\endgroup$
  • 3
    $\begingroup$ provide a sample code with specific problem. $\endgroup$ – Navid Rajil Mar 22 '18 at 21:33
  • $\begingroup$ @NavidRajil I have updated the question, thanks. $\endgroup$ – KVK318 Mar 23 '18 at 14:50
  • 1
    $\begingroup$ @KVK318, typically this means that you should give a complete copy and past-able code to reproduce the issue you want to illustrate. Next time. $\endgroup$ – user21 Mar 23 '18 at 15:24
  • $\begingroup$ @user21 I am sorry about that, I will do that next time. $\endgroup$ – KVK318 Mar 25 '18 at 0:24
4
$\begingroup$

How about:

Needs["NDSolve`FEM`"]
r = RegionDifference[Cuboid[{-2, -2, -2}, {2, 2, 2}], Ball[]];
mesh = ToElementMesh[r];
mesh["Wireframe"]

enter image description here

SliceContourPlot3D[x^3 + y^2 - z^2, Element[{x, y, z}, mesh]]

enter image description here

Or:

SliceContourPlot3D[x^3 + y^2 - z^2, MeshRegion[mesh], 
 Element[{x, y, z}, mesh]]

enter image description here

$\endgroup$
  • $\begingroup$ @user21Thanks. This function works but i would also like to plot the solution over the entire domain instead of slices. I have updated my question top explain better what i am trying to do. $\endgroup$ – KVK318 Mar 23 '18 at 14:52
  • $\begingroup$ @user21Thanks. I just figured out that the SliceContourPlot3D solves one of my problems which is I can plot a contour on a slice which is equivalent to ContourPlot in 2D. However, i would also like to plot the solution over the entire domain instead of slices. $\endgroup$ – KVK318 Mar 23 '18 at 15:05
  • $\begingroup$ @KVK318, see update. Also have a look at the documentation of SliceContourPlot3D $\endgroup$ – user21 Mar 23 '18 at 15:23
  • $\begingroup$ @user21Thanks, this is exactly what i was looking for. $\endgroup$ – KVK318 Mar 25 '18 at 0:26

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.