Enosh, a structured grid generator (V)

Here is Enosh version 1.0.

It’s been a long time. Finally my little 2D mesh generator is ready and I think it’s good to go. (A few buttons may not work, sorry. Smooth function is not released right now, I am still working on it. Only straight line can be defined. I will add more line types in the future.) Please download it in the download page. Extract the .tar.gz file anywhere on your 64 bits linux, follow the instructions and run “./enosh”. Any comments and feedback are welcome!

Enosh, a structured grid generator (IV)


I have made significant improvement on the mesh export. The manual building up of OpenFOAM mesh now turns up really fast. I got a feeling that it could possibly beat even OpenFOAM’s native blockMesh generator. In my test of a \(3,200,000\) mesh (for flow around a square cylinder). The building process took \(90.51\)s in total. Here are more details:

...... [1] Done assembling the points. ( 7.09000s)
...... [2] Done assembling all cells & intnl cntrs. ( 40.62000s)
...... [3] Done treatment of cntrs and init o&nbs. ( 27.74000s)
...... [4] Done assembling boundary cntrs and info. ( 9.77000s)
...... [5] Done assembling faces. ( 1.29000s)
...... [6] Done assembling owners on frontAndBack. ( 0.23000s)
...... [7] Done face orientation correction. ( 3.77000s)

This is a very exciting progress. As in the old days, I have to wait for 10 minutes for just a \(24,000\) grid sized mesh. So the speed now scales roughly around \(O(N)\), which is way better than \(O(N \log N)\) or \(O(N^2)\).

The renumber (e.g., using Cuthill–McKee algorithm) is needed, but it is not a big deal at this moment.

As for a smaller mesh, using the same blocks as before (8 blocks around the square), \(240,000\) mesh size, it took:

...... [1] Done assembling the points. ( 0.53000s)
...... [2] Done assembling all cells & intnl cntrs. ( 2.60000s)
...... [3] Done treatment of cntrs and init o&nbs. ( 1.81000s)
...... [4] Done assembling boundary cntrs and info. ( 0.91000s)
...... [5] Done assembling faces. ( 0.10000s)
...... [6] Done assembling owners on frontAndBack. ( 0.01000s)
...... [7] Done face orientation correction. ( 0.28000s)

Enosh, a structured grid generator (III)

Updates:

Finally, I got the boundary file output working. Now it is able to export to the OpenFOAM mesh format. But I still need to do some optimization (hopefully to make it back to log-complexity with hash tables, thanks to C++11). Currently it takes too much time to build an OpenFOAM mesh manually.

Also I have tested the code on a clean ubuntu 64 environment with virtualbox, it seems to me anyone who wants to use it needs vtk and Qt installed. Using synaptic package manager, search vtk and install the vtk-dev, libqvtk-dev packages.

Here is a screenshot of a multi-block mesh simulation:Name:  Screenshot from 2014-02-28 15:17:40.jpg<br /><br /> Views: 46<br /><br /> Size:  63.1 KB

And the input mesh config file:

Code:

// ------------------------------------------------------------------------- //
// //
// ENOSH, a multi-block structured mesh generator //
// Copyright 2014 Daniel Wei //
// //
// Mesh Configuration File //
// ------------------------------------------------------------------------- //

// --------------------
// Description: A square cylinder mesh
// --------------------

// --------------------
// Geometry: NODES
// Format: NODE $NEWID $POINT
// --------------------
NODE 1 (-5, -5, 0);
NODE 2 (-0.5, -5, 0);
NODE 3 (0.5, -5, 0);
NODE 4 (5, -5, 0);
NODE 5 (-5, -0.5, 0);
NODE 6 (-0.5, -0.5, 0);
NODE 7 (0.5, -0.5, 0);
NODE 8 (5, -0.5, 0);
NODE 9 (-5, 0.5, 0);
NODE 10 (-0.5, 0.5, 0);
NODE 11 (0.5, 0.5, 0);
NODE 12 (5, 0.5, 0);
NODE 13 (-5, 5, 0);
NODE 14 (-0.5, 5, 0);
NODE 15 (0.5, 5, 0);
NODE 16 (5, 5, 0);

// --------------------
// Geometry: Edges and Their Dimensions
// Format: EDGE $NODE1ID-$NODE2ID [$DIMENSION] [$DELTA1] [$DELTA2] [$SMOOTHERBCTYPE] [$CAEBD]
// The order of node IDs is NOT important!
// Any bdName:bdType for the internal lines will be ignored
// --------------------
EDGE 1-2 50 0 0 0 bottom:symmetryPlane
EDGE 2-3 10 0 0 0 bottom:symmetryPlane
EDGE 3-4 50 0 0 0 bottom:symmetryPlane
EDGE 5-6 50 0 0 0 bdName:bdType
EDGE 6-7 10 0 0 0 cyl:wall
EDGE 7-8 50 0 0 0 bdName:bdType
EDGE 9-10 50 0 0 0 bdName:bdType
EDGE 10-11 10 0 0 0 cyl:wall
EDGE 11-12 50 0 0 0 bdName:bdType
EDGE 13-14 50 0 0 0 top:symmetryPlane
EDGE 14-15 10 0 0 0 top:symmetryPlane
EDGE 15-16 50 0 0 0 top:symmetryPlane
EDGE 1-5 50 0 0 0 inlet:patch
EDGE 5-9 10 0 0 0 inlet:patch
EDGE 9-13 50 0 0 0 inlet:patch
EDGE 2-6 50 0 0 0 bdName:bdType
EDGE 6-10 10 0 0 0 cyl:wall
EDGE 10-14 50 0 0 0 bdName:bdType
EDGE 3-7 50 0 0 0 bdName:bdType
EDGE 7-11 10 0 0 0 cyl:wall
EDGE 11-15 50 0 0 0 bdName:bdType
EDGE 4-8 50 0 0 0 outlet:patch
EDGE 8-12 10 0 0 0 outlet:patch
EDGE 12-16 50 0 0 0 outlet:patch

// --------------------
// Geometry: Blocks
// Format: BLOCK $NEWID ($IDLIST1 $IDLIST2 $IDLIST3 $IDLIST4)
// Note: The order of these IDLISTs IS important!
// --------------------
BLOCK 1 (1-2 2-6 6-5 5-1);
BLOCK 2 (2-3 3-7 7-6 6-2);
BLOCK 3 (3-4 4-8 8-7 7-3);
BLOCK 4 (5-6 6-10 10-9 9-5);
BLOCK 6 (7-8 8-12 12-11 11-7);
BLOCK 7 (9-10 10-14 14-13 13-9);
BLOCK 8 (10-11 11-15 15-14 14-10);
BLOCK 9 (11-12 12-16 16-15 15-11);

Enosh, a structured grid generator (II)

Spent four days in figuring out how to construct an OpenFOAM polyMesh manually, it is more complicated than I thought, the difficult part is how to construct a multi-block mesh. One of the annoying issues in a multi-block polymesh construction is how to handle its internal lines/surfaces, where two lines become one. And then the points indices and the face indices all have to change accordingly. There may be many approaches to address this, but I, after many days’ thought, decided to use a brutal force search and match approach. In a double precision, I hope it won’t have any problem. 
Name:  test2.jpg<br />
Views: 185<br />
Size:  98.5 KB

This issue, of cause, is just a tip of the iceberg. You have also to consider the face orientation, owner and neighbour cell ordering, etc. More than that, the cell ordering seems to be critical for CFD simulation. I am not sure at this moment should I use CuthillMcKee algorithm or not. I got lots of questions…

Again, there is an interesting phenomenon, everything could be very easy, but once you want to make it (such as your method or your code) general, it will become complicated.

Today, the mesh exporter to OpenFOAM format start working. I need to get rid of some bugs and think about the boundary patches issue in the next step. When the boundary export is finished, I will release it. So for 2D cases, it is apparently a good alternative to OpenFOAM’s native blockMesh utility.

Enosh, a structured grid generator (I)

Trust me, I’ve read more than 20 structured mesh generator codes already in the last year. Interestingly, none of them satisfy me. So I decided to make it my own. I’ve been working on this small mesh generator for quite a while. It worked before for a single block mesh smoothing. But starting from last month, as I was thinking about how to make it “multi-block”, I decided to rewrite the whole code. Because it is quite different from C++ point of view to design classes for a single block or to design classes for multi-blocks. For the ease and the power and the flexibility of visualization, I chose qt and vtk to handle the graphic things. Talk to vtk is quite popular these days. But I am also slightly worrying about the portability in the future release. (Any ideas?)

The following screenshots show a simple TFI horseshoe mesh and its input file:
Name:  Screenshot from 2014-02-07 15:57:59.jpg<br />
Views: 203<br />
Size:  100.3 KB
Name:  Screenshot from 2014-02-07 16:17:53.jpg<br />
Views: 194<br />
Size:  27.4 KB
I am making it neater and more powerful every week. The things I like most about this little program are: a clean syntax of the input file (very close to what you have learnt from blockmeshDict, but it is more powerful, and it is specifically designed for mesh smoothing), eps/png export (we all know how pleasant to have “publication quality” figures), a good-looking qt widget. Also in the near future, I hope it could be an alternative to the OpenFOAM blockmesh utility with easier syntax and a nice mesh viewer.

I am aiming high. Here are a few things that cross my mind, they are on my to-do list. Will do it in the next few months hopefully.

1. OpenFOAM mesh export; (I had one before in my another mesh generator, so should be okay)
2. Multi-blocks capability, which is essential;
3. Multi-block smoothing (with bc control);