CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Main CFD Forum (
-   -   CFD with Matlab (

mjerdem December 17, 2012 23:00

CFD with Matlab
I am planning to use Matlab for a CFD calculation; however, I have my doubts about the plotting capabilities of Matlab. IN my first program I am going to model a pipe filling a pool. I will solve for the flow in the pipe and flow in the pool in 3D with time. Is it possible to make a movie of it using Matlab or I need to get more professional plotting tools such as paraview?

cdegroot December 18, 2012 08:27

Matlab can do animation for sure. No fancy CFD visualizations but you can animate a contour plot for example.

sbaffini December 18, 2012 10:44

I would more seriously think about the computational issues of a computation in Matlab, instead of the post-processing ones. However, for 3D and/or unstructured postprocessing i usually export everything in Paraview; indeed, even if you can do something in Matlab, even plotting an unstructured mesh is a computational resources' nightmare.

cdegroot December 18, 2012 10:51

Good points. I sort of assumed he was talking about a structured code; if it is unstructured you will definitely run into difficulties doing any post processing in Matlab.

And it is good to point out too that Matlab is definitely not going to be the most efficient platform for computation. It is good for testing things out but it will be much slower and use much more memory than writing the code in C, C++, or Fortran for example.

cdegroot December 18, 2012 11:03

I should mention I wrote a little 2D CFD code in Matlab (just as a demonstration "toy") and did some animations of Rayleigh-Benard convection. It was fine for that purpose but 3D CFD may be too demanding.

Engr.RZA December 18, 2012 14:33

Yes you can write CFD code using matlab with ease of direct functions to solve equations. But for 3D contour plotting in matlab you need to put extra effort, however you can easily plot 2D contour plots in it..

sbaffini December 18, 2012 14:39

I guess i also assumed he was working within an unstructured framework (which for Matlab might not be well suited). However, for a structured approach (even if computationally demanding) the post-processing stage can be much more easier and cheap as you can manage the plane and line extractions by index.

I also have my demonstration toy in Matlab (i guess we all have it ;)), but more than a full CFD code it is just a 3D unstructured FV framework to test gradients, filters, interpolations etc. And i found myself in real troubles when trying to plot even simple things... actually, it needed more time to plot a full 3D grid than reading it. That's why i suggest paraview, it's easy, quick, runs under windows, supports a lot of formats (you may want to use an output format different from VTK). You can't ask for a better thing

All times are GMT -4. The time now is 08:26.