How-to: Generate a 2D Boolean Mask for bounce-back domains

Hello, this is my first post in this forum and I want to share an easy tecnique that I am using for generating a Boolean Mask for bounce-back domains.
The boolean mask is described in the documentation: Bounce-back domain from boolean mask

First of all you need a picture of your domain:
The image should be rotated 90 degrees clockwise in respect to the desired final geometry.
The white region is the allowed region to the fluid, the black region is the forbidden one.
I created mine with Inkscape[/url], so it is a [url=]SVG vectorial image that can be resized without a loos of quality.

Then using the “convert” tool from the ImageMagick suite[/url] you shall convert the image to the [url=]Netpbm format:

convert geometry.svg -compress none geometry.pbm

The “-compress none” option is the trick of this how-to.
Now you shall delete the first two lines of the pbm file and you are done.

I wrote a really simple bash script to generate the dat file:

#! /bin/bash
convert "$1" -compress none "$1"".pbm"
lines="`wc "$1"".pbm" | awk '{ print $1 }'`"
let 'lines = lines - 2'
tail -n $lines "$1"".pbm" > geometry.dat

This is an example of the result:

Hello Gildo, thanks for sharing. If you are interested, you are welcome to post your howto in the community wiki

Hello Gildo,

It’s my first participation here. I need to draw a porous media. And I think your method can be very interesting for me.

Can you send the picture to me? I can’t see it.

Thank you for sharing.

Best regards,