CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Meshing & Mesh Conversion (http://www.cfd-online.com/Forums/openfoam-meshing/)
-   -   BananaSplit helper for OpenFOAM blockMesh (http://www.cfd-online.com/Forums/openfoam-meshing/108336-bananasplit-helper-openfoam-blockmesh.html)

liquidspoon October 19, 2012 21:53

BananaSplit helper for OpenFOAM blockMesh
 
1 Attachment(s)
I've been using blockMesh for my simulations, but have found that even with m4 scripting, geometry definition can be tedious and error prone. I spent some time last week and put together a MATLAB program (BananaSplit) to generate blockMeshDict files. Right now, it only works for hexahedra with unity cell gradings that are aligned with the principal axes. I know this is pretty restrictive, but it's a start.

BananaSplit reads a definition file where each domain block is defined simply by two corner points, the boundary groups on the six faces (West, North, East, South, Bottom, Top), and number of cells in each direction. An example block line would look like:

Code:

block(0,0,0,1,1,1,walls,moving,walls,walls,walls,walls,10,10,1);
The handy thing about BananaSplit is that it automatically splits up neighboring blocks so that they share full faces (required by blockMesh). So, for example, a plenum with 1 inlet, a chamber, and 10 outlets can be defined by 12 blocks rather than dozens that are split along the interfaces. To use BananaSplit, simply call:

Code:

BananaSplit('input file name', 'output blockMeshDict file name');
Interior patches are automatically excluded from the output blockMeshDict, and cell counts are adjusted to match on mating faces. By default, all exterior patch groups are given the type patch in the blockMeshDict file (not wall, empty, etc.) - not a big deal to change

I hope this is helpful to other folks as well. I have attached the code, which is released under the BSD license. Please let me know if you find any bugs, or have added new functionality.

Bernhard October 20, 2012 09:58

Interesting to do this with Matlab, but it is really nice that you're sharing this with the community. Maybe it's worth putting it on the Wiki as well, to be easier found:
http://openfoamwiki.net/index.php/Main_Page

Why did you call it BananaSplit?

liquidspoon October 20, 2012 15:30

Maybe MATLAB isn't the optimal choice, since not everyone has licenses. I just used it to get some quick and dirty code working. The code could probably be tweaked to work in Octave.

I could definitely put an entry on the Wiki - I hope it helps other folks too.

It's called BananaSplit because it splits up blocks so that they share full faces (banana for no particular reason).

psk August 1, 2013 08:46

Good Day liquidspoon,

Its possible to incorporate Matlab script with blockmesh by using Banana-split?
I have set of data (xyz) in matrix format, i did small script in mat lab, I want to create blockMesh, kindly guide me.

please see the attachment for your perusal.

liquidspoon August 1, 2013 10:22

Generating blockMeshDict
 
Hi psk,

I'm not entirely sure what you want to do in blockMesh, but it looks like a triangular domain. This can be tricky because blockMesh generally works in hexahedra, and singularities or poorly quality cells can arise if you try to fit them into a triangular domain. Maybe look at Gmsh for generating triangular prism cells.

If you want to stick with blockMesh, take a look at the "WriteBlockMeshDict.m" function in the attached code from the start of the thread. It should be a nice outline for generating a valid blockMesh dict file.

liquidspoon August 1, 2013 10:55

Example domain generated with BananaSplit
 
1 Attachment(s)
By the way: Here is an example domain I generated with BananaSplit that shows when this code could be useful.

This was for a simulation of a manifold/fluid distributer with two rectangular input ports on the left side, and numerous outlet ports along the lower portion. Generating this requires a huge blockMeshDict (230 kb) since every block must be split up to only meet others on full patches. Using BananaSplit, I just worked from a short list of blocks defined by bounding corners (9 kb).

psk August 1, 2013 12:07

Thanks for your reply & Information Alex,

Sorry I am not telling briefly, that's not domain, it is flapping wing.I will tell you briefly, what i did.

My area of interest is flapping flexible wing, for that using camera to capture wing motion by frame by frame, the output is .csv file format with set of xyz data. If you see inside csv file, the 1st row gives first frame[xyz of point 1,2,3 (ie).1st frame image], 2nd row gives 2nd frame [xyz of point 1,2,3(ie).2nd frame image) similarly up to last.

I did small program in Matlab to replicate my wing. I don't how to make blockMeshDict for this problem.I am thinking by using these coordinates or script to make loop inside the blockMesh is somewhat easy to replicate the wing.( ie wing is inside the Domain)

Kindly guide me how to make blockMeshDict (its something looks like moving/dynamic mesh)

Is there any possibility to create blockMeshDict by using Matlab?

liquidspoon August 1, 2013 12:26

Hi psk,

What you are trying to do is quite a large feat, and I don't think I can just tell you how to do it (blockMesh is definitely insufficient). This sounds like a substantial research project, and I would recommend that you consult the literature on immersed boundary methods or moving mesh interfaces. Maybe you should start a separate thread specifically about your project to get better advice about where to begin.

psk August 2, 2013 02:13

Thanks Alex


All times are GMT -4. The time now is 07:55.