CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Meshing & Mesh Conversion (https://www.cfd-online.com/Forums/openfoam-meshing/)
-   -   [snappyHexMesh] snappyHexMesh Boundary Conditions (https://www.cfd-online.com/Forums/openfoam-meshing/89822-snappyhexmesh-boundary-conditions.html)

Cyberholmes June 23, 2011 00:07

snappyHexMesh Boundary Conditions
 
I have just managed to successfully use snappyHexMesh to mesh a geometry I made in Blender. What I'm now wondering is how I go about assigning boundary conditions to the boundaries in this mesh.

For example, I have a protrusion in my geometry that needs to have a velocity boundary condition set on the boundary at its end. How do I specify that surface?

Thank you.

Cyberholmes June 24, 2011 11:08

Can anyone shed a little light on this?

lovecraft22 June 25, 2011 03:14

I think you have to assign a different name to the protrusion and then assign the boundary condition you need to that region.

Cyberholmes June 26, 2011 01:51

What I don't know is how to assign a name to that region with snappyHexMesh. snappyHexMesh creates a meshing on its own, and it has hundreds of thousands of cells that have random names. I don't know how to specify a region out of that.

wyldckat June 26, 2011 05:19

Greetings to all!

@Cyberholmes: you've got two possible methods:
  1. Pre-define the surfaces in the STL and then associate those names to patches in snappyHexMeshDict. The usual method is to use an ASCII STL (text mode, not binary) and define solids by their names. Edit the motorBike STL example with a text editor, to see what I mean: mesh/snappyHexMesh/motorBike/constant/triSurface/motorBike.stl
  2. Or use createPatch for creating patches after the mesh is complete. An example dictionary is here: applications/utilities/mesh/manipulation/createPatch/createPatchDict
    You can find practical examples on the tutorials, simply by running this command on the tutorials folder:
    Code:

    find . -name createPatchDict
    Visit those cases and see how the Allrun scripts use createPatch and respective dictionary. Keep a look out for the command(s) before createPatch, which will define the face sets to be used by createPatch.
The rest is up to your detective skills ;)

Best regards,
Bruno

Cyberholmes June 26, 2011 13:00

Thank you so much! You don't know how much of a help you've been!

lovecraft22 June 26, 2011 14:22

Quote:

Originally Posted by wyldckat (Post 313605)
Greetings to all!

Pre-define the surfaces in the STL and then associate those names to patches in snappyHexMeshDict. The usual method is to use an ASCII STL (text mode, not binary) and define solids by their names. Edit the motorBike STL example with a text editor, to see what I mean: mesh/snappyHexMesh/motorBike/constant/triSurface/motorBike.stl

How can you do that? By editing the stl text file by hand?

wyldckat June 26, 2011 17:10

Hi lovecraft22,
Quote:

Originally Posted by lovecraft22 (Post 313647)
How can you do that? By editing the stl text file by hand?

It honestly depends on the source of your STL. Examples:
  • Some STL exporters in CAD like applications, can export selected surfaces onto a single STL file, whether ASCII or binary. They export the selection onto a single STL file.
    What we can do is a little bit of text hacking on ASCII STLs, by renaming the solid name and ending that solid with the respective name (see motorBike.stl).
    Then, after each STL has been properly fixed, manually or with a script, we can concatenate the various STL files into a single one.
    With a lot of patience, this can also be achieved with ParaView, by selecting triangles, extracting them and export the extraction to a separate STL file... but this requires a gigantic load of patience and the triangles must already be sized exactly as you want them. Keep in mind that ParaView is not a 3D CAD tool by trade!
  • Or you can use a proper geometry editing tool that can export the STL with the desired surface names. I honestly can't remember with 100% certainty of any geometry editor that does this, but I believe that MeshLab might do this. The other possibilities I can remember are Blender and SALOME. FreeCAD possibly can do this as well.
If you confirm which editor does this, feel free to tell us as well ;)

Best regards,
Bruno

mturcios777 June 27, 2011 18:19

There is a script that allows you to define boundaries in Blender and have it exported to STL. It is mentioned in the thread:

http://www.cfd-online.com/Forums/ope...cii-stlbs.html

I've used it and it works quite well.

flowris June 28, 2011 10:36

This one also shows how to define patches:
tutorials/incompressible/pimpleDyMFoam/wingMotion

The Allrun file shows you what to do.

Hillie July 10, 2017 21:05

Dear Foamers,

I know that this thread is old, but I wanted to add my solution, since I still had to Google for a good couple of hours to figure out how to name the surfaces, and this might help some people.

As has been discussed in this thread you can put in multiple stl files into SHM or name the patches after the meshing. Naming surfaces in the stl didn't work for me. I have tried splitting them in Salome, but my geometry is quite complex, and so i had a huge amount of separate faces which didn't make that solution that great.

The solution that worked for me is the following:
Mesh the part in SHM.

Them use Toposet to make faceSet of the faces of interest.
Below are my actions in for toposet.
i.e I make a box around the faces of interest and then refine by just selecting the faces with a certain normal.

Code:

actions
(
    {
        name    setname;
        type    faceSet;
        action  new;
        source  boxToFace;
        sourceInfo
        {
            box  (-0.15 0 -0.081)(-0.145 0.0346751670140271 -0.0805);
        }
    }
    { 
        name    setname;
        type    faceSet;
        action  subset;
        source  normalToFace;
        sourceInfo
        {
            normal (0.243182556589797 0.00832132403345907 0.94);
            cos 0.01;
        }

      }
);

After generating this topoSet you can use createPatch to enerate the patch.

Code:

pointSync false;

patches
(
    {
        // Name of new patch
        name patchname;

        // Type of new patch
        patchInfo
        {
            type patch;
        }

        // How to construct: either from 'patches' or 'set'
        constructFrom set;

        // If constructFrom = patches : names of patches. Wildcards allowed.
        set setname;
    }
 
);

When running createPatch it complained that my faceSet contained a number of internal faces. After removing those by hand (There were 3 in my case) createPatch ran beautifully.

I hope this helps some people.


All times are GMT -4. The time now is 17:56.