Importing Matlab File and Meshing

  • 191 Views
  • Last Post 09 November 2018
  • Topic Is Solved
Abdullah posted this 01 November 2018

I need help on importing Matlab file (.mat) of a binary image to Ansys, then I need to mesh that geometry  and exported as stl or obj file to use it in OpenFOAM.

Can you help me, please.

Order By: Standard | Newest | Votes
rwoolhou posted this 02 November 2018

You need some geometry for SpaceClaim, although you could read in an image file and trace over it (check what you can read in). Why would you then switch to FOAM as you've got Fluent in the install? 

peteroznewman posted this 02 November 2018

Abdullah,

Please describe the binary image in more detail. Is that a 2D image or a 3D image? Can you put a screen snapshot of that image in your reply? Some members have matlab, so if you put the .mat file inside a .zip file, you can use the Attach button to attach the .zip file after you Post your reply. Note that the .zip file must be < 120 MB for the attach to work.

Regards,
Peter

Abdullah posted this 02 November 2018

Hi Peter,

It is a binary image of porous media so it consist of two regions, pores and solids. It is a small size image of thin layer (256 x256 x 3) I have attached It to this reply so you can try to imported to ANSYS, and please help me how you can do it?

 

Attached Files

peteroznewman posted this 03 November 2018

Hi Abdullah,

I opened your file in matlab and looked at the three layers; they are all identical and look like this:

I assume the black regions are air and the white regions are solid. Do you need to mesh the air or the solid? What do you want to do, just extrude that to some length? What are the true dimensions of the image. All I know is there are 256 pixels.  What is the pixel pitch in mm? Do you want to exclude any of the tiny pores? I would advise that because it will create a large number of elements and slow down the computation.

I imported a PNG image of one layer of your file into SpaceClaim, then used the Spline tool to trace curves around one of the black pores, then extruded a solid. Is this what you want to do?

What is your overall simulation goal? Do you even need to create this geometry?  If this is a small sample of a larger body, then the porosity can be calculated and used as a property of a solid block. This would be computationally much more efficient and a lot less work building the model.

Regards,
Peter

Abdullah posted this 03 November 2018

Hi Peter,

I will answer your question in the same order you mentioned.

1. Consider black is solid and white is air. I want to mesh the Air which is the white volume in my case.

2.  It is a small sample of large body and the length is 0.0005 m in x and y. I have selected 3 identical layers because I am interested in 2D case so I selected same x and y direction and thin layer in z. I did that because openfoam deals with 3D geometry and I can apply empty boundary condition in z direction to solve it in 2D.

3.Yes, I want to exclude small solids that do not affect the results.

4. My goal is as follows, I have a sample of porous media, I have selected a small thin identical layer to solve the diffusion equation in that sample. I am doing my simulation in OpenFOAM, but I could not import that file to it and do the mesh. So, I want to use Ansys to import that Matlab (.mat) file, create a geometry and then mesh it, then save it as ansys file or any file format that openFoam can read. Then do my simulation.

Regards,

Abdullah

peteroznewman posted this 05 November 2018

Hi Abdullah,

Thank you for that information.

You can get started with SpaceClaim, insert the image, create a block of air, trace around the black solids and cut those shapes out of your air. Reply if you get stuck, but do read the ANSYS Help and view a few SpaceClaim tutorials that are on this site first.

Good luck,
Peter

Abdullah posted this 07 November 2018

Hi Peter,

I really got stuck, I new to ANSYS.

How can I import the matlab (.mat) file to ANSYS ? can you please explain the steps of how to import matlab file then creating the geometry and the mesh ?

Thank you,

Abdullah

peteroznewman posted this 08 November 2018

Hi Abdullah,

In matlab, create a variable that is just one slice, not three so you have a 256x256 variable.  Save that variable as a PNG file. Check that you can view the image with the Windows image viewing software.

In SpaceClaim, go to the Assemblies tab and click on the File Add button to add the PNG file to SpaceClaim. You will have to read the ANSYS Help file to figure out how to scale it to the right dimension. I didn't do that in my example.

Then in the Design tab, you can pick the spline tool to trace around the black solids that you can Pull to cut holes in the Air.

Good luck,
Peter

Abdullah posted this 09 November 2018

Hi Peter,

THANK YOU !!

I could generate the geometry now, I was trying to do this for along time but I was stuck on my research. I really appreciate your help !!!

wish you all the best.

Abdullah

peteroznewman posted this 09 November 2018

Hi Abdullah,

That's great!

You can show your appreciation by clicking Like below the posts that are helpful, and clicking Is Solution on the post that answered your question so that other students facing a similar issue can find help in this discussion.

Best regards,
Peter

Close