0
$\begingroup$

I made a finite element code and I want to show the stress distribution over the domain. The domain is shown below and I know the value of the data at the middle of each quadrilateral element.

enter image description here

I can use Graphics and assign a color to each quadrilateral depending on the intensity of the stress at each point but the visualization will not look very nice since the quadrilaterals are not small (I can make them smaller but the program will take longer time to compute the data). I want to use a function like ListContourPlot to obtain smooth contour plots for the stress distribution, something like the picture below with colors for each band:

enter image description here

Is it possible to use ListContourPlot or ListDensityPlot and visualize the data variation over the domain shown in the figure below? From reading the manual for both these functions it's not possible to define such domain (Polygon). And if I use the functions without assigning the domain I obtain something like this, which is not exactly the domain:

enter image description here

What can be done? Thank you.

$\endgroup$
  • $\begingroup$ ListContourPlot takes the option RegionFunction $\endgroup$ – Bob Hanlon Nov 28 '17 at 21:53
  • $\begingroup$ I tried to do so but I didn't obtain like this: RegionFunction -> Function[{x, y, z}, {x, y} [Element] Polygon[{{0, 0}, {96, 0}, {18, 102}, {15, 122}, {5, 122}, {5, 102}, {0, 0}}]] The result did not show the real domain,it showed the same one shown in color above. $\endgroup$ – Mr. Pi Nov 28 '17 at 23:21
1
$\begingroup$
pts = {{0, 0}, {96, 0}, {18, 102}, {15, 122}, {5, 122}, {5, 102}, {0, 
    0}};

reg = DiscretizeGraphics[Polygon[pts]];

data = Table[Sin[(x + y)/80], {y, 0, 125}, {x, 0, 100}];

Show[
 ListContourPlot[data, 
  RegionFunction -> Function[{x, y, z}, {x, y} ∈ reg]],
 Graphics[{Red, AbsolutePointSize[6], Point[pts]}]]

enter image description here

$\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.