0
votes

Hello guys I am trying to export a mesh from MSC Patran and then plot it in Matlab. The mesh can be of arbitrary shape. I have the x, y and z coordinates of all the nodes. So far I have tried many different options and here is why they failed:

  1. Surfc() with meshgrid and griddata: I generated a grid on x-y plane with meshgrid and then used griddata to obtain the z matrix. But this plot only works when there is only 1 z value corresponding to an x-y pair. In other words, for this to work z must be of type z = f(x,y).
  2. pdegplot() : I found out that matlab can import and plot .stl files. I tried converting my coordinate matrix format and plot it with this function but it doesn't work either. Because apparently in .stl files an edge can not be shared by more than 2 elements. However my FEM files are always (i hope) shell elements. This means 3 or more elements can share the same elements.
  3. Surfc() with 3d meshgrid: I found out that meshgrid() can take 3 inputs (x,y,z) and create a 3d mesh. However this didn't work either. I used a very small mesh with about 1000 nodes and the code was trying to generate 3 matrices with 1000x1000x1000 elements. That means about 3 gb of memory for a 1000 node mesh. Whats more, surfc couldn't plot even that.
  4. Somehow importing other file formats automatically: so far I have been using patran neutral files (.out). I manually read the file and extract x,y,z data from it. Patran can also export to parasolid, iges and step file formats. I looked for direct ways of importing and plotting these in matlab but such functions don't exist as far as I have looked.
  5. Manually generating a grid: Matlab can create 3D objects (like [x,y,z] = sphere()) and Surfc() can plot these despite what I said in (1.) and the x,y,z matrices generated by sphere() are not 3 dimensional like in (3.) so I tried following this and manually generate a 3d grid from my FEM file just for testing. I found that z has repeating columns and in each column (which acts as a layer) there are n values of x and y. When I tried doing the same thing for my mesh manually, surfc() didn't work again. It plotted a really weird shape that I can't even describe.
  6. Finding a 3rd party plotting software: I tried using (light) software like gnuplot and visit but so far I am all wet. I am open to suggestions if you know any (preferably open source) software that can directly plot patran neutral files. But the software has to be capable of contour plotting also. As I am calculating a quantity for each node in Matlab and then plotting its contour on the mesh.
2
a mesh (unless completely regular) is defined not only by points, but by the connections between the points. Do you have the connectivity information, or are you handling a regular mesh? You also very determinedly describe why it doenst work, but forgot to describe your data! I can only hint from your first function that you have multiple Z for each x,y ? How?Ander Biguri
@Ander Biguri My mesh is not regular and yes I have the connectivity information. Currently my mesh is all quadratic (though it may be tri etc too). I have one matrix that gives the 4 nodes of each element (m x 4) and a matrix that gives the x,y,z coordinates of each node (n x 3). Where m is the number of elements and n is the number of nodes.Waheedullah Taj
So you can have a tetramesh?Ander Biguri
As for your next question, yes I have multiple z for each x,y. That is what I meant by arbitrary actually. But I guess i should have been clearer. Think of a plate in x-z plane. In this case the y coordinate of all the nodes is the same. And if by any chance two nodes had the same x, then that means two nodes with the same x and y, but different z.Waheedullah Taj
I see what you mean, but you are describing it wrongly. Your data is [x,y,z] even if sometimes some values are used more than once. Have a look at the suggested fucntion. I dont think there is one for quads, you will just need to write your own, I thinkAnder Biguri

2 Answers

0
votes

So you can have a tetramesh?

You seem to be working with FEM-stile meshes, thus the standard surface-plotting function wont work. For FEM-meshes of different shape (not tetra) you may need to write your own function...

0
votes

If you have the grid points and grid cell connectivities in say variables p and c, you can use the external Matlab FEA Toolbox to plot both structured and unstructured grids with for example the plotgrid command

% Cread grid struct.
grid.p = p;
grid.c = c;
grid.a = gridadj(p,c,size(p,1));   % Reconstruct grid cell adjacencies.
grid.b = gridbdr(p,c,grid.a);      % Reconstruct boundary information.
grid.s = ones(1,size(c,2));        % Set subdomain numbers to 1 for all grid cells.

% Plot grid.
plotgrid( grid )