Main ContribExamples/2DsHM

From OpenFOAMWiki

snappyHexMesh is a 3D meshing tool and does not offer the possibility of setting different refinement levels in each of the three coordinate directions. As a result, it is not possible to create quasi-3D meshes to be used for 2D OF simulations. sHM might still implement 1 cell in the z-direction away from surfaces and outside of the refinement regions but you will still end up with several cells in the z-direction. This example shows you how to get rid of these unwanted cells in the z-direction and is based on the wingMotion_snappyHexMesh tutorial. In a nutshell, it takes one of the side planes of the 3D mesh, extrudes it in the z direction with extrudeMesh, and extracts the patches with autoPatch. Some minor editing work on the dictionaries is required and is described as well.

Steps 5 to 7 at the end are optional and show how you can separate the geometry in sections using the faceSet and createPatch tools.

Here we go:

  Step 1. run blockMesh 
  Step 2. run snappyHexMesh -overwrite
  Step 3. run extrudeMesh

(extrudeProperties dictionary) The extrudeMesh tool is used on boundary front by a positive distance, the sign of the outward normal to this boundary. I used delta_z = 1.0 from the original z = 0.1 plane. One should also set parameter nLayers = 1 to make sure only one cell is extruded in the z-direction. The extrudeProperties dictionary is provided and should reside in the constant directory. It will create 3 patches, originalPatch (the original front patch in plane z = 0.1), otherSide (extruded front patch now in plane z=1.1), and sides. The last one, sides, consists of the extrusions of the bounding curves of the original front. Therefore it includes the extrusions of inlet, exit, top, bottom and airfoil. These will be separated next.

  Step 4. run autoPatch 90

The number 90 is the feature angle to search for and the actual angle between the parts of sides and the other two patches. You will get 7 additional patches named auto0 to auto6. The original three patches from the extrusion process now have 0 faces in them in the constant/polyMesh/boundary file and the total boundary number is 10 right after the file header. Edit the constant/polyMesh/boundary file, remove the sections pertaining to the original 3 extrusion boundaries, and adjust the total number of boundaries to 7. You might want to rename the boundaries from auto* to more meaningful names such as inlet, exit, airfoil, etc. The final boundary file from that step is provided for reference (final boundary file without a flap).

The following 3 steps are optional. Use them if you want to divide the airfoil in parts (slats, flaps, whatever...):

  Step 5. run faceSet

(faceSetDict) This step is required to extract the faces from the airfoil patch and put them in a new face set, f0, in order to separate the flap in the next step. Here we use options "action new" and patchToFace. These are commented in the provided faceSetDict file which should reside in the system folder.

  Step 6. run faceSet

Now we want to extract the flap part from the existing face set f0, so we use options "action subset" and boxToFace where the specified box should enclose the face centres of the flap part of the airfoil. I picked the last delta-x = 0.4 therefore my box extends from x = 0.6 to x = 1 (yeah I know, that's a ridiculously huge flap ). faceSet will now use the existing set f0 after creating a backup to f0_old. After the command finishes f0 will only have flap faces in it.

  Step 7. run createPatch

(createPatchDict) This is the last step where we create the flap patch from face set f0. You'll need the createPatchDict file which should reside in the system folder. We need to use options "constructFrom set" and "set f0" in the patchInfo section. Note that createPatch will also adjust the entire mesh and remove any boundaries that might end up with 0 faces in them. The final mesh will be in folder 1/polyMesh. You can have it written directly in constant/polyMesh by using the -overwrite flag. The final boundary file with the flap is provided for reference (final boundary file with a flap)

Valid versions: OF version 17.png

--Ziad 20:14, 1 November 2010 (CET)