plane interpolation in CFD data
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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?
I appreciate your help!
Best Regards, Stephan Heidrich
0 Commenti
Risposte (1)
Mike Garrity
il 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.
load tetmesh
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.
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.
Vedere anche
Categorie
Scopri di più su Computational Fluid Dynamics (CFD) in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!