plane interpolation in CFD data

4 views (last 30 days)
Stephan He on 31 Mar 2016
Commented: Stephan He on 2 Apr 2016
Hello everyone,
for a project I need to interpolate different surfaces from CFD data. The surfaces are assumed to be rectangular and free to be placed. Since the CFD data comes as scattered data points I need to interpolate the data from the 3d CFD information to get the best precision.
My problem now is that I need to somehow reduce the distance of data points to be used for interpolation.
The reason therefore is that I want interpolated points surrounded by nan- data points to be nan even though there might be other points in further distance that allow to interpolate at this point.
As example I want to show you one case which should give you somewhat of a clue I am talking about.  In the first and second plot you can see a hopper connected to two tanks and the outlet.
I want to get the boundary conditions of the 6 red surfaces. That means that for example the XY plan at the outlet should have a lot of NaN data points with just some data points interpolated within the circle defined by the outlet diameter.
But for now with
surfaces{i}(j+3,:) = griddata(data{1}, data{2}, data{3}, data{handles.indexSelected(j)} ,surfaces{i}(1,:),surfaces{i}(2,:),surfaces{i}(3,:),'linear');
I get the inner part of the outlet (red circle) plus the interpolated points resulting from the diagonal between outlet tube and the tanks: Is there a possibility to adapt the griddata function to suite my needs?
Best Regards, Stephan Heidrich

Mike Garrity on 1 Apr 2016
So here's one fairly simple approach.
First we need a model. I'll use this one because it ships with MATLAB.
trep = TriRep(tet, X);
[tri, Xb] = freeBoundary(trep);
hsurf = trisurf(tri, Xb(:,1), Xb(:,2), Xb(:,3), ...
'FaceColor',[0 .447 .741]); Now we need some scatter data. I'll just make up some random points and use a trig function to turn them into the values I want to color by:
npts = 1000;
x = randn(npts,1) * 10;
y = randn(npts,1) * 10;
z = rand(npts,1) * 70;
v = cos(x/3) .* cos(y/3) .* cos(z/3);
hold on
hscatter = scatter3(x,y,z,32,v,'.');
caxis([-1 1])
hold off In your case the points that are outside the model should have nan for the v, but I'll skip that here.
Now we'll create a scatteredInterpolant and use that to interpolate onto the vertices of the model:
F = scatteredInterpolant(x,y,z,v);
verts = hsurf.Vertices;
hsurf.FaceVertexCData = F(verts(:,1),verts(:,2),verts(:,3));
hsurf.FaceColor = 'interp';
delete(hscatter) A couple of things to watch out for. Because your samples are all on one side of the model, all of the vertices in the model are going to be extrapolating. Extrapolated values can get wonky pretty quickly. This means that you're going to be very sensitive to the interpolation method you're using. The scatteredInterpolant approach provides a couple of options, and hopefully one of those will work well for you. If not, you may have to explore some of MATLAB's other interpolation techniques.
Stephan He on 2 Apr 2016
Hello Mike,
thank you for your reply. But unfortunatly i dont see how this answers my question. My status quo uses the griddata function which uses the scatteredInterpolant function and allows me to interpolate at different points in one go.
I think my problem is rather a mathematical one. I would need an interpolation method that would take all close datapoints into consideration (for now its unimportant whether linear, nearest, natural or whatever). therefor i would need an interpolation that allows me to interpolate within a defined frame seen from the interpolation point.
so lets say it interpolates from all points that are within a box of 2x6x6mm around the interpolation point.
I guess I could write some function that would give me the desired outcome but I highly doubt that my version would be perfomant enough.
If it is still not clear enough feel free to ask ;)