CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Meshing & Mesh Conversion (
-   -   HexBlocker a GUI for blockMeshDict, alpha release (

nsf March 17, 2013 14:30

HexBlocker a GUI for blockMeshDict, alpha release
3 Attachment(s)
Hi Foamers!

I've been developing a GUI for blockMesh and I think it's ready for an early alpha release (under GPL). For now it goes under the name of hexBlocker. It's written in C++ and is based on Qt and VTK. I've attached a couple of screenshots. As of now hexBlocker has the following features and limitations
  • Reading and writing blockMeshDict files. It uses it's own import/export functions and hence doesn't support parameters nor coded blocks.
  • There's a “revert action” (ctrl-R) that rereads the blockMeshDict from a file. This makes it easy to simultaneously edit via a text-generator.
  • Create hexagonal blocks(wedges are not supported) from two points or through extruding a patch.
  • Set boundary conditions by selecting patches.
  • Move vertices and setting their position,
  • Setting the number of cells on each parallel (or dependent) edge. Grading is not yet supported but is one of the top things on the todo-list.

If you'd like to try it out you'll need to clone it with git and compile. Don't worry there's a script included. If you can compile OpenFOAM and ParaView then you have all the required dependencies. Listed below are the packages I needed on a more or less clean install of Ubuntu 12.04.


sudo apt-get install git cmake qt4-dev-tools libqt4-dev libxt-dev
To install open up a terminal and go to some directory where you want it.

git clone git://
cd hexBlocker

The script will download and compile vtk-5.10.0 and then proceed to compiling hexBlocker. I really recommend that you review the script before running it. It should work for Ubuntu 12.04 but I take no responsibility if this causes your computer to crash, the international bank system to collapse or wastes your time.

Bear in mind that this is a spare time project. The intention was for me to learn some C++ outside OpenFOAM nevertheless I think hexBlocker might evolve to something useful. If you'd like to chip in just send me an PM or email.

HexBlocker is not not endorsed by, approved by nor affiliated with anyone but me. OpenFOAM(R) is a trademark of OpenCFD.

haakon March 18, 2013 07:40

Wow, this looks really nice. This is a really useful tool, because you can make a lot of different high-quality meshes with blockMesh, but it's not very user-friendly. However, I get a build error:


[ 48%] Building CXX object CMakeFiles/HexBlocker.dir/HexPatch.cpp.o
/home/haakon/Downloads/hexBlocker/src/HexBlock.cpp: In member function ‘void HexBlock::initPatches()’:
/home/haakon/Downloads/hexBlocker/src/HexBlock.cpp:382:32: error: taking address of temporary array
/home/haakon/Downloads/hexBlocker/src/HexBlock.cpp:384:32: error: taking address of temporary array
/home/haakon/Downloads/hexBlocker/src/HexBlock.cpp:386:32: error: taking address of temporary array
/home/haakon/Downloads/hexBlocker/src/HexBlock.cpp:388:32: error: taking address of temporary array
/home/haakon/Downloads/hexBlocker/src/HexBlock.cpp:390:32: error: taking address of temporary array
/home/haakon/Downloads/hexBlocker/src/HexBlock.cpp:392:32: error: taking address of temporary array
make[2]: *** [CMakeFiles/HexBlocker.dir/HexBlock.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/HexBlocker.dir/all] Error 2
make: *** [all] Error 2
error in make for hexBlocker

I have not yet looked into it myself, but I thought you wanted to know. The system is Linux mint 14, which is the same codebase as Ubuntu 12.10.

nsf March 18, 2013 13:59


Thank you for trying out the code!

I would seem that newer gcc version don't like the way I was calling the initPatches function. I've pushed a change which I think fixes that issue. I would appreciate if you could pull it and try to recompile. Since my only machine with 12.10 is an old Asus eee. I suspect it will take one day or more to compile vtk on that one.

I was doing


Which is not supported and perhaps is not good practice. So instead of sending an temporary array I just changed the code to use four ints.


Please let me know if you have any other issues!



Edit: I just noted Håkon already had submited a patch on gitHub. I noticed it after I submited the same fix. Thanks again Håkon!

By the way, I found a bug which caused extrude patch to misbehave. I've submitted a fix and also added the possibility to load a blockMeshDict from the commandline.

nsf April 10, 2013 15:40

New features
1 Attachment(s)
Hi all,

Just wanted to let you know that I've implemented a couple of new features.
  • It's now possible to set grading on edges.
  • There's a calculator button which calculates the cell sizes on the edge. It uses the tool by Markus Hartinger which he posted here:
  • It's possible to delete blocks.
  • It's possible to change the visibility of block, patches and edges.

I have no experience with packaging, if anybody would like to chip in please send a pm or reply to this thread.


Pekka April 15, 2013 14:36

1 Attachment(s)
Cool !

Thanks for your efforts developing very useful tool. Unfortunately I cannot compile it, pls. find the attached log file, maybe it helps find reason for the error.


nsf April 15, 2013 15:13

Possible fix commited
Hi Pekka!

Thanks for trying out the program and the comment!.
I've built and tested hexBlocker with qt-2.8.1 I see from the log file that you are using qt-4.7.4.

The first error you're getting is


/home/Pekka/OpenFOAM/Pekka-1.6-ext/applications/hexBlocker/src/GradingCalculatorDialog.cpp: In constructor ‘GradingCalculatorDialog::GradingCalculatorDialog(QWidget*)’:
/home/Pekka/OpenFOAM/Pekka-1.6-ext/applications/hexBlocker/src/GradingCalculatorDialog.cpp:38: error: no matching function for call to ‘QDoubleValidator::QDoubleValidator(double, double, int)’
/home/Pekka/OpenFOAM/OpenFOAM-1.6-ext/ThirdParty/packages/qt-everywhere-opensource-src-4.7.4/platforms/linux64GccDPOpt/include/QtGui/qvalidator.h:174: note: candidates are: QDoubleValidator::QDoubleValidator(const QDoubleValidator&)
/home/Pekka/OpenFOAM/OpenFOAM-1.6-ext/ThirdParty/packages/qt-everywhere-opensource-src-4.7.4/platforms/linux64GccDPOpt/include/QtGui/qvalidator.h:169: note:                QDoubleValidator::QDoubleValidator(double, double, int, QObject*, const char*)
/home/Pekka/OpenFOAM/OpenFOAM-1.6-ext/ThirdParty/packages/qt-everywhere-opensource-src-4.7.4/platforms/linux64GccDPOpt/include/QtGui/qvalidator.h:168: note:                QDoubleValidator::QDoubleValidator(QObject*, const char*)
/home/Pekka/OpenFOAM/OpenFOAM-1.6-ext/ThirdParty/packages/qt-everywhere-opensource-src-4.7.4/platforms/linux64GccDPOpt/include/QtGui/qvalidator.h:145: note:                QDoubleValidator::QDoubleValidator(double, double, int, QObject*)
/home/Pekka/OpenFOAM/OpenFOAM-1.6-ext/ThirdParty/packages/qt-everywhere-opensource-src-4.7.4/platforms/linux64GccDPOpt/include/QtGui/qvalidator.h:144: note:                QDoubleValidator::QDoubleValidator(QObject*)

It would seem that the constructor I'm using doesn't exists in qt-4.7.4. From what I can find QDoubleValidator also needs an reference to it's parent in qt-4.7. I've added that and commited and pushed. Since I don't have an older version of qt here it gets difficult to test that this fixes all issues with qt-4.7. Could you please try again and see if that fixes everything? Just run


git pull
from the hexBlocker directory. Then you can rerun the (or just the relevant part of the script.)

If you'd like to chip in I recommend installing qt-creator. And then just go to open project and select the file CMakeLists.txt. Qtcreator will ask you to run cmake (which you'll need to install). It will also prompt you for extra variables. Add


startingWithCFD April 16, 2013 05:13

Looks like a great tool! But unfortunately I am stuck in the installation process.
Please pardon my low linux skills.

For those of you using OpenSUSE 12.3 and being as ignorant as I was, here are some minor changes that helped me.

1) Some package names mentioned in README-install.txt are different
libqt4-dev ---> libqt4-devel
zlib1g-dev ---> zlib-devel
libreadline-dev ---> readline-devel
libncurses-dev ---> ncurses-devel
libxt-dev ---> libXt-devel

2) In change
MOC=$(which moc-qt4) ---> MOC=$(which moc)
UIC=$(which uic-qt4) ---> UIC=$(which uic)

No problems occured during the compilation of vtk.
However, I tried running bin/HexBlocker but I got the message


./bin/HexBlocker: error while loading shared libraries: cannot open shared object file: No such file or directory
What do I need to change to detect the fresh compiled library? Thanks in advance.

nsf April 16, 2013 13:09


Thank you for the note about the required packages! I'll add them to the README-file.

I'll also improve the install script. I've made the following changes:

MOC=$(which moc-qt4 moc | head -n1)
UIC=$(which uic-qt4 uic | head -n1)

This way it will take moc-qt4 if it finds one. Else it will take moc. Hopefully it finds qt on OpenSUSE as well.

As for the third point. Are you sure that vtk compiled? Is the missing library present? What does

find -name
tell you? (run it from the install dir).

If the library is present then cmake probably hasn't done it's job or something else went wrong. Maybe you moved the executable after compilation? The location of the vtk libraries used by HexBlocker are relative to the executable. You may move the entire install directory but you can't move HexBlocker with respect to the vtk folder.

If the library is present you can try to set LD_LIBRARY_PATH or LD_PRELOAD with the absolute path to the vtk libraries.


LD_LIBRARY_PATH=/absolute/path/to/vtk/lib/vtk-5.10 HexBlocker
You would use LD_PRELOAD with the same syntax but you would have to set all libraries that can be found.

If the library isn't present then VTK did not compile. You'll have to investigate that.

I'll go on a two week vacation now so I'll be "afk". I might have time to answer a question or two but don't count on it. I'll be back the 2nd of May.



startingWithCFD April 16, 2013 13:25

Are you still there?? I hope I caught you before leaving! :-D

The find command returns:

I did not move anything. I will check the rest tomorrow.
Thanks for the answer!

Pekka April 16, 2013 15:06

1 Attachment(s)
Hi Nicolas !

Thanks for your quick reply. Now it compile by using "" and I can tested it. I tried also build project with QT Creator 2.4.1 and found the following type of problem:


nsf April 16, 2013 16:01


I'm backing the bags so be out soon but I'm still here.

I can't be sure what the problem is. Are you using an older version of cmake?

You could try to compare the output of

ldd bin/HexBlocker | grep
Is the path correct? If not try setting LD_LIBRARY_PATH.


nsf April 16, 2013 16:08

Hi Pekka,

I'm also using qtcreator 2.4.1 so that shouldn't be the problem. If you go to help->about Qtcreator. What Qt-version is it using?

From the documentation I see that "setPlaceholderText()" was introduced in Qt4.7. Most likely your qt-creator has not found the custom compiled qt you are using when you compile HexBlocker. It's probably possible to "point" QtCreator to a custom compilation of Qt. I don't know how though.


startingWithCFD April 17, 2013 03:15

Ok, I updated my LD_LIBRARY_PATH variable by adding the following line to ~/.bashrc:


export LD_LIBRARY_PATH=/home/username/OpenFOAM/hexBlocker/vtk/lib/vtk-5.10:$LD_LIBRARY_PATH
Now the executable works! Thanks for the help!
I will provide feedback about the program as soon as I get a bit more familiar with it.

lksz June 11, 2013 09:11

Use Ubuntu 12.04 LTS and during the installation process after the command:


I got:


/bin/bash^M: bad interpreter:    no such file or director
It can be easily fixed by:



nsf June 11, 2013 17:18


Originally Posted by lksz (Post 433382)
Use Ubuntu 12.04 LTS and during the installation process after the command:


I got:


/bin/bash^M: bad interpreter:    no such file or director
It can be easily fixed by:



Hi, lksz and congratulations on your first post!

I played around with some settings with git and it borked end of line characters.

I've fixed it in the latest commit (hopefully). Your welcome to try it out.


nsf June 11, 2013 17:22

New Features
Hi all,

I've implemented a couple of more features.

It's now possible to create arcs on edges. HexBlocker will read and write arc and line but will ignore polyLines, simpleSpline and polySpline.

You can select a patch and optionally a radius and HexBlocker will calculate the third arc point for you.

Just update with git clone or follow the steps in the first post.


Entropete June 24, 2013 05:59

blockMeshDict format
Hi Nicolas

As a newcomer to OpenFoam (and returning to CFD after many years) I've found your GUI very useful - initially for debugging meshes and then for creating them. Many thanks for your efforts.

I have just one little request: when writing the blockMeshDict file, it would be help readability and text editing if a CR or LF (as appropriate) were inserted after each hex () declaration. On my system (Ubuntu 12.04, OF 2.2) all the blocks are on one line.


nsf June 24, 2013 12:18

Hi Peter and welcome to the forums!

Thank you for trying out the code and giving feed back.

I'v committed and pushed a change which adds line breaks between blocks.

Recently I've been busy with other spare time projects so there has been little activity. My plan is to add support for splines and lines. After that I'll look in to splitting blocks. I'll just have to find the time. There is summer time in Sweden so there are other activities with higher priorities right now =)

Let me know if you encounter other issues.



Ps to update just run


git pull

And everything should be recompiled.

Entropete July 5, 2013 10:04


Many thanks for that little change - it makes it a lot easier to use a text editor alongside the GUI.

Enjoy your Swedish summer and don't spend too much time at the computer!

I know it's an Alpha release, but I hope you won't mind if I report a few bugs and observations about the program's behaviour, in case you haven't found them yourself. (all these relate to the latest version with OF 2.2 and Ubuntu 12.04).

1. Edges on the slave block don't move to the correct position after patches are merged. Work around: save and reload file.
2. Simplegrading values of less than 1 often get overwritten as 0. I haven't yet worked out when this behaviour occurs.
3. On one occasion, the program reordered the vertices in a file that I had started in a text editor. I haven't had a repeat, but I haven't been trying to recreate it.
4. Occasional crashes (but very rare).

Problems that aren't strictly bugs
1. Extruding adjacent patches to create adjacent blocks creates duplicate vertices even if the patches are extruded by the same distance. This creates non-empty internal patches (i.e. baffles) that are tricky to remove. If it is possible to code it easily, it would be great to be able to extrude a multiple selection of patches at one go to avoid this problem.
2. No delete vertices tool (this might help solve the first problem), but would also need vertices to be renumbered throughout.
3. Manually entered comments are lost when saving from hexBlocker.

And to finish on a positive note:
Things that are brilliant!
1. Being able to select all the dependent edges in one go and change the mesh size and grading for all of them.
2. Defining boundary conditions for multiple patches by clicking on them - no more trying to think inside the box!


nsf July 5, 2013 12:39

Hi Peter, thanks for the feedback, I do appreciate it!

I was aware of bugs 1 and 4. I can't recreate number 4 it could be a race condition where the code starts a rerender and then starts a second rerender before the first completes. If you find a way to recreate the crashes please let me know. The first was introduced when I enabled arcs I haven't found the time to work on it. The fix should be easy.

Bug 2 is interesting. I haven't seen it before, does it get replaced in the GUI or in the blockMeshDict or both?

If you can find a way to repeat bug 3 I'm interested. I'll keep an eye out for it. There is no intentional reordering of vertices, the Ids are only changed when merging patches. It could perhaps be related to bug 1.

Semi bug 1: I've noticed this as well when I coded the extrude algorithm. I can't really get my head around how one would extrude them simultaneously. One would have to search all other patches that also extruded and check if they share a vertice. And then I'm not sure how to continue.

Semi bug2: This is intentional, the idea is to simplify block creation by eliminating the need to manually create (or delete) patches, edges and vertices. The code should do this for you.

Semibug3: Well, currently the entire file is rewritten and comments are filtered out. I think it would take quite a bit of coding to be able to save all comments. Also polyLines, simpleSplines and polySplines will be overridden.

I could create a table of vertices, where there position is edited manually. This would provide a work around for semibugs 1:3. No real need to work simultaneously with a text editor

If you have ideas and wan't to help out I'm willing to help and explain what the code does. I've put some effort in keeping the code well documented so others could chip in.

And thanks for the positive feedback! I'm glad you find hexBlocker use full!


All times are GMT -4. The time now is 10:02.