How to plot discontinuities with scatteredInterpolant in 3D?

3 visualizaciones (últimos 30 días)
Hector Palacios
Hector Palacios el 22 de Feb. de 2016
Comentada: Hector Palacios el 23 de Feb. de 2016
This is the problem, I have scattered data of a fiber composite. This is a problem of "material discontinuity", this means the values of stress along the interface between materials are discontinuous. So, in the interface I have the values of stress for each material, this means that interface data has two values for plotting rather than one.
When i'm going to interpolate the data, the command scatteredInterpolant automatically averages the two values and eliminates duplicate points instead considering a discontinuity.
I also want to integrate, so if the discontinuity is not well represented, the integral value will be wrong.
Any help? In 2D is too easy to plot discontinuities, so maybe there's a way.
Thank you very much in advance.

Respuestas (1)

Mike Garrity
Mike Garrity el 22 de Feb. de 2016
If you have some way of identifying which side of the discontinuity a location is on, then I would set up two scatteredinterpolants. Split your data into two sets to seed the two scatteredinterpolants. Then, when you're integrating, switch from using one to the other as you cross the boundary.
As for plotting, I'd probably need more details. For example, if you wanted to display the results as a surface, then you'd probably want to either:
  • Create one surface from each scatteredinterpolant, using nans for values which are on the other side of the discontinuity.
  • Create a single mesh which holds values calculated from both scatteredinterpolants, but squeeze a row of nans along the discontinuity.
  3 comentarios
Mike Garrity
Mike Garrity el 23 de Feb. de 2016
I would probably do something like this.
Here's some sample data where vp changes suddenly when you cross a circular boundary.
npts = 400;
radius = 1.5;
xp = 2*randn(npts,1);
yp = 2*randn(npts,1);
mask = sqrt(xp.^2 + yp.^2) > radius;
vp = zeros(npts,1);
vp(mask) = cos(xp(mask)) .* cos(yp(mask));
vp(~mask) = sin(xp(~mask)) .* sin(yp(~mask));
We'll create a 2D mesh that covers part of it.
[xg,yg] = meshgrid(linspace(-pi,pi,150));
Now let's try filling out that mesh with a single scatteredInterpolant.
F = scatteredInterpolant(xp,yp,vp);
zg = F(xg,yg);
surf(xg,yg,zg,'EdgeColor','none')
camlight
view(-15.1,62)
Notice that things are a bit raggedy where we cross that circle.
Now let's try with two scatteredInterpolants, one for each domain.
clf
F1 = scatteredInterpolant(xp(mask),yp(mask),vp(mask));
F2 = scatteredInterpolant(xp(~mask),yp(~mask),vp(~mask));
We'll need two 2D arrays to hold the values, initialized to NaN, and a mask to identify which grid elements are on which side of the circle:
gmask = sqrt(xg(:).^2 + yg(:).^2) > radius;
vg1 = nan(size(xg));
vg2 = nan(size(xg));
Now we can fill in the values using the two scatteredInterpolants.
vg1(gmask) = F1(xg(gmask),yg(gmask));
vg2(~gmask) = F2(xg(~gmask),yg(~gmask));
And plot the results.
surf(xg,yg,vg1,'EdgeColor','none')
hold on
surf(xg,yg,vg2,'EdgeColor','none')
hold off
camlight
view(-15.1,62)
You can see how each of the two surfaces comes up to the edge of the circle much more cleanly, although it is a little easier to see if we color the two domains differently.
It's not perfect, of course. If you look closely, you'll see little squared off edges along the circle. That's coming from the resolution of our 2D grid.
Hector Palacios
Hector Palacios el 23 de Feb. de 2016
Thank you very much. So NaN is the solution for plotting holes. It works perfect!
I hope not ask for much, but can that result be integrated?

Iniciar sesión para comentar.

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by