0

I am stuck with this problem for the last two days and haven't found a solution so far. I have a data in the following format:

x1, y1, val1
..  ..  ..
..  ..  ..
xn, yn, valn

The values val1, ..., valn are the field quantities I obtain after simulation on a geometry as below.

enter image description here

Only the grey region is the domain of interest whereas the one in blue/dark blue is not (including the inverted L shaped blue region in the interior). Thus the x and y coordinates of the data are scattered/irregular and with large gaps due to the hole in my original geometry. Is there a way to get a filled contour plot for this data? Trying the following in Matlab gives me triangulation with triangles outside the original polygon. Also, it fills the holes which is not what I want.

x = data(:,1);
y = data(:,2);
z = data(:,3);

%
dt = delaunayTriangulation(x,y) ;
tri = dt.ConnectivityList ;
xi = dt.Points(:,1) ;
yi = dt.Points(:,2) ;
F = scatteredInterpolant(x,y,z);
zI = F(xi,yi) ;
trisurf(tri,xi,yi,zI) 

Another possibility was to import the data in ParaView and do filtering as Table-to-Points--> Delaunay Triangulation 2D. But this has the same problems as Matlab. The holes are not analytical to mask the unwanted interpolated regions with NaNs by using some mathematical expression.

user1234
  • 95
  • 1
  • 1
  • 8
  • How do you define a hole? I mean, everything is a hole no? you just have random points – Ander Biguri Aug 03 '18 at 14:12
  • 1
    Otherwise, your question is very similar to this recently asked one: https://stackoverflow.com/questions/51670744/how-to-calculate-a-triangular-interpolation-from-values-in-coordinates-in-matlab . Coincidence? – Ander Biguri Aug 03 '18 at 14:21
  • Also similar to [this](https://stackoverflow.com/q/43030227/52738). – gnovice Aug 03 '18 at 14:30
  • The data points come from solving a pde (lets say Poisson equation) on a physical domain that has holes. The output i have is however only at discrete points in the domain. The other questions you refer to don’t seem go have concave geometry thus enabling a correct triangulation. – user1234 Aug 03 '18 at 14:56
  • @user1234 every space between your poitns can be interpreted as a hole. If you do not have the geometry of the boundary, you can not to what you want. I already told you to please describe your holes. – Ander Biguri Aug 03 '18 at 15:07
  • BTW, you know about PDEtoolbox? https://uk.mathworks.com/products/pde.html – Ander Biguri Aug 03 '18 at 15:35
  • By holes, I mean the regions where I don't have any data at all as it does not belong to my computational domain (added figure to explain this). I do have access to the geometry. But from what you are saying, the only way is to first interpolate the data and then find if the interpolated point is inside the region of interest, if not mark it as nan. I am guessing this will be expensive, no? – user1234 Aug 03 '18 at 15:40
  • If I had the p e t representation for the field quantities, i could have used the pdeinterpolant in pdetoolbox. Is that what you meant? – user1234 Aug 03 '18 at 15:42

1 Answers1

1

Paraview seems to have the solution for this. Although I did not use finite elements to solve the pde, I could generate a finite element mesh inside GMsh for my geometry with holes. I then import both my CSV data file and the GMsh mesh file (in .vtk format) in ParaView. Resampling my field data with Dataset filter with the results of the Delaunay2D as the input gives me the contour only on the original geometry.

user1234
  • 95
  • 1
  • 1
  • 8