quinta-feira, 22 de agosto de 2013

Merging Meshes from Salomé to be Used on Openfoam

This post took me a while. The main problem in here is due to mesh conversion between Salomé and Openfoam. Depending on your geometry, when you convert Salomé's unv file to Openfoam it appear some inner parts that are pretty annoying to get rid off.

If the mesh is pure unstructured you can do it easily. Just create and export. But if you have some structured mesh within a mesh, these inner parts come to play. One of my goals is to observe the velocity profile behavior and if you have an unstructured grid this won't be good, mainly because you won't have an even spaced velocity vector.

So, because of this issue, I had to redesign my straight stabilizer in order to have a hybrid grid. I had divided him into three main meshes and he is going to follow basically the same divisions stated at http://chasingaftermystuff.blogspot.com/2013/04/creating-spiral-drilling-stabilizer_12.html.
Follows the mesh from inner wall:
Zooming close to SmSpa we can see that this part is made with triangles and tetrahedrons. This is the only part on this straight stabilizer that is unstructured.
I won't publish the script capable of doing this because, by now, you should be able to do the same, but if you want the full script I can send you with no charge. : ) . Just leave a comment.

Ok.

As we saw we have mainly 3 parts (Slick, SmSpa and Stb) to complete the the whole we must mirror SmSpa and Slick. So, in the end we have 5 parts in total. It is easier to merge them with Openfoam. For each part we need to create an Openfoam case.

It is going to be like this:




As you can see, we have the all 5 parts, 3 original and 2 mirrored (MSlick and MSmSpa). Every part has an interface. The Slick part has one entrance, the Inlet, and two interfaces between Slick and SmSpa, the interface that belongs to Slick and one that belongs to SmSpa,

Showing the interface.


After exporting all your meshes to unv format and putting everything on the respective cases we must merge and stitch them.

Let us take the case where we must connect the Slick part to SmSpa. Go to the Slick folder and type:

    $ mergeMeshes ../Slick/ ../SmSpa/
    $ stitchMesh Slick_Interface_SmSpa SmSpa_Interface_Slick

On the mergeMeshes you need to input the case folders. Mines are /Slick/ and /SmSpa/. On stitchMesh is going to be the name of your interfaces. I named mine as Slick_Interface_SmSpa (belongs to Slick) SmSpa_Interface_Slick (belongs to SmSpa). You will see you had created two new folders inside of the case. These folders are going to be created according to you controlDict write Interval. If you write interval is 0.001, your first folder is going to be 0.001 and the second, 0.002. Go to the second folder and check your boundary file. If your stitchMesh went smooth you are supposed to have 6 patches but 2 of them with 0 faces. If this is the fact. Perfect. Erase these patches and correct the first number that begins the ( ). It should be 6. Now, type 4. Like this:


Copy the content of the second folder into the folder constant/polyMesh. The idea is to substitute the previous content.

By now you merged the Slick and SmSpa. Erase the folders created through stitchMesh and mergMeshes. Now we need to merge the rest. 

I've found that Openfoam has some problems to stitch more meshes ... I like to be practical, so, a workaround for this is just change to another folder. We need to merge the mesh that we just created into Stb. Go to Stb/ folder and repeat the same process.

Cheers!!!