CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Meshing & Mesh Conversion

[blockMesh] BananaSplit helper for OpenFOAM blockMesh

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By liquidspoon

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 19, 2012, 21:53
Default BananaSplit helper for OpenFOAM blockMesh
  #1
Member
 
Alex
Join Date: Jun 2011
Posts: 33
Rep Power: 14
liquidspoon is on a distinguished road
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.
Attached Files
File Type: zip BananaSplit.zip (32.5 KB, 355 views)
ancolli and Astrodan like this.

Last edited by liquidspoon; October 21, 2012 at 10:46.
liquidspoon is offline   Reply With Quote

Old   October 20, 2012, 09:58
Default
  #2
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21
Bernhard is on a distinguished road
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?
Bernhard is offline   Reply With Quote

Old   October 20, 2012, 15:30
Default
  #3
Member
 
Alex
Join Date: Jun 2011
Posts: 33
Rep Power: 14
liquidspoon is on a distinguished road
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).
liquidspoon is offline   Reply With Quote

Old   August 1, 2013, 08:46
Default
  #4
psk
Member
 
david
Join Date: Jun 2013
Location: Montreal, Canada
Posts: 62
Rep Power: 11
psk is an unknown quantity at this point
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.
__________________
Million Thanks,
David

"Small Dream is a Crime"

Last edited by psk; August 12, 2013 at 02:33.
psk is offline   Reply With Quote

Old   August 1, 2013, 10:22
Default Generating blockMeshDict
  #5
Member
 
Alex
Join Date: Jun 2011
Posts: 33
Rep Power: 14
liquidspoon is on a distinguished road
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 is offline   Reply With Quote

Old   August 1, 2013, 10:55
Default Example domain generated with BananaSplit
  #6
Member
 
Alex
Join Date: Jun 2011
Posts: 33
Rep Power: 14
liquidspoon is on a distinguished road
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).
Attached Images
File Type: png VolumeStreamLines-sm.png (56.5 KB, 318 views)
liquidspoon is offline   Reply With Quote

Old   August 1, 2013, 12:07
Default
  #7
psk
Member
 
david
Join Date: Jun 2013
Location: Montreal, Canada
Posts: 62
Rep Power: 11
psk is an unknown quantity at this point
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?
__________________
Million Thanks,
David

"Small Dream is a Crime"
psk is offline   Reply With Quote

Old   August 1, 2013, 12:26
Default
  #8
Member
 
Alex
Join Date: Jun 2011
Posts: 33
Rep Power: 14
liquidspoon is on a distinguished road
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.
liquidspoon is offline   Reply With Quote

Old   August 2, 2013, 02:13
Default
  #9
psk
Member
 
david
Join Date: Jun 2013
Location: Montreal, Canada
Posts: 62
Rep Power: 11
psk is an unknown quantity at this point
Thanks Alex
__________________
Million Thanks,
David

"Small Dream is a Crime"
psk is offline   Reply With Quote

Old   October 9, 2014, 00:38
Smile BananaSplit
  #10
New Member
 
Zhenquan Li
Join Date: Oct 2012
Location: Australia
Posts: 6
Rep Power: 13
jali is on a distinguished road
Thanks Alex for the sharing the files.

I would like to know if you have a program in Matlab which writes out mesh files (boundary, neighbour, owner, points, faces) in OpenFOAM from a mesh generated in Matlab. I understand this is a BIG job. I have adaptive mesh refinement criteria implemented in Matlab and have achieved positive results for the accuracy verification. My refined meshes are not in structured blocks so cannot use BananaSplit .
jali is offline   Reply With Quote

Old   October 11, 2014, 11:55
Default
  #11
Member
 
Alex
Join Date: Jun 2011
Posts: 33
Rep Power: 14
liquidspoon is on a distinguished road
Unfortunately I don't have a code that writes out the full mesh definition in the OpenFOAM format. The BananaSplit code just generates a valid blockMeshDict file.

It would be a bit tedious, but not terribly difficult to write your own code to generate an OpenFOAM mesh (list all the points, the face orderings, the cells, the face-owners, and face-neighbors, and boundaries). Alternatively you could try generating your mesh in a simpler file format (e.g. gmsh: http://people.sc.fsu.edu/~jburkardt/...h/t13_data.msh) and using one of the built-in OpenFOAM converters.
liquidspoon is offline   Reply With Quote

Reply

Tags
blockmesh, meshing


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[OpenFOAM.org] blockMesh issue on openfoam6 startup - ubuntu 16.04 bjdarrer OpenFOAM Installation 7 August 25, 2020 19:15
Is Playstation 3 cluster suitable for CFD work hsieh OpenFOAM 9 August 16, 2015 14:53
[blockMesh] External flow around cube with blockMesh Woody8 OpenFOAM Meshing & Mesh Conversion 0 March 31, 2015 14:54
[blockMesh] set of xyz data in blockMesh psk OpenFOAM Meshing & Mesh Conversion 12 August 27, 2013 08:37
Blockmesh cavity error message tonitoney OpenFOAM Installation 2 March 17, 2008 11:59


All times are GMT -4. The time now is 21:46.