# An engineer's pipe flow

(Difference between revisions)
 Revision as of 14:26, 1 February 2008Traumflug (Talk | contribs) (Added chapter 2.)← Previous diff Revision as of 14:39, 1 February 2008Traumflug (Talk | contribs) (internal links)Next diff → Line 40: Line 40: tr -d '\r' < doppelbogen.stl | \ tr -d '\r' < doppelbogen.stl | \ - stl2gts | transform --normalize | \ + [[stl2gts]] | transform --normalize | \ - transform --scale 1.0001 > doppelbogen.gts + [[transform]] --scale 1.0001 > doppelbogen.gts

## Revision as of 14:39, 1 February 2008

Velocity results of our example

All these oceans with their tides and ships cuising in it are impressive, aren't they? Did you notice how stiff and probably refreshing the breeze around MS Tangaroa is?

Well, as an ordinary mechanical engineer I often have much less impressive things to work out. Like water taps, curved pipes or some sort of flow meter. These small-sized internal flows are, what this tutorial is about. I'll take an example on a simple pipe with two bows in it.

In this tutorial I'll explain how to get more or less arbitrary geometry of internal flows into the Gerris flow solver and how to compute the fluid's behavior there. I'll discuss on what's all this fuss with the Reynolds Number is and how it translates to simple engineering tasks. Finally, I'll do some basic measures in the results and will compare against what a textbook on hydraulics considers as the correct solution.

## Computer Aided Design

Undoubtly, different engineers have different tastes about what a good software package for doing CAD is. So, I'll keep this part short and will explain how the result should look, only.

The few steps mentioned here sound simple, but can be a lot of work, of course:

1. Create a model of where in your design the fluid flows.
2. Create a cube of arbitrary size to cover this fluid model.
3. Substract the modeled fluid flow from this cube.
4. Make sure the inlet and outlet of this flow reaches the cube's sides.

The result might look like this:

• All of the cube's edges should be of equal size (or it wouldn't be a cube).
• It's only one inlet or outlet per cube side allowed.
• Avoid trapped volumes as it's a waste of computing time.

If you have this, save the geometry in STL format. For the sample scripts in this tutorial I'll use `doppelbogen.stl` as the file name.

## From CAD geometry to Gerris geometry

This step is pretty straightforward as it's mostly a single step to resize the geometry to fit Gerris' fluid domain and to convert from STL to GTS format. Gerris comes along with all the tools needed.

The only caveat is, you have to make the cube slightly larger than the fluid domain as many CAD applications write triangualted data pretty exact, but not exact enough to be unambiguous. Small errors at the 15th digit behind the decimal point are common.

The `transform` tool has a handy `--normalize` option which does resizing and relocating in one step. All put together, a single shell line to do the conversion and transformation looks like this:

``` ```

``` tr -d '\r' < doppelbogen.stl | \ stl2gts | transform --normalize | \ transform --scale 1.0001 > doppelbogen.gts ```

The commands in detail:

• `tr -d '\r'` is put in to convert DOS line endings to Unix line endings, e.g. if your CAD runs on Windows. It doesn't hurt if the STL already has Unix line endings. If you ever happen to use a traditional Macintosh text editor, use a `tr '\r' '\n'` instead.
• `stl2gts` does, as the name already hints, the conversion from STL format to GTS format.
• `transform --normalize` handily makes the geometry fit into the minimal Gerris fluid domain, a single GfsBox.
• `transform --scale 1.0001` oversizes the cube slightly (see above).

Depending on your CAD, an additional `-i` option in one of the `transform` commands might be needed to switch the triangles "inside out". The fastest way to find out wether this option is needed or not is to just proceed without it and to re-do this step in case you run into calculation errors later. I'll refer to this when explaining how to calculate the flow.

As all commands read from standard input and write to standard output, there's no need for intermediate files.

The result of this step is a file with the name `doppelbogen.gts`.