Salome and cfMesh parametrization

From OpenFOAMWiki
Revision as of 23 April 2016 at 14:12.
The highlighted comment was edited in this revision. [diff]
Edited by author.
Last edit: 22:59, 26 April 2016

Preparation of created boundary .stl files for cfMesh[edit]

After creating geometry boundary .stl files it is time to mesh the domain. Although it is not implemented in bash script it can be added very easily, because even meshing can be done automatically now thanks to Creative Fields, Ltd. and their free cfMesh.

First we need to prepare created .stl files for meshing with cfMesh. Each .stl file represent one patch, so to create closed domain all patches have to be combined in to one “big” .stl file. One thing you have to be careful about is to set patches names in new combined .stl file.

Example is shown for Bottom.stl file in Ahmed geometry. Bottom.stl file looks like this:

 solid 
  facet normal  0.000000e+00  0.000000e+00 -1.000000e+00 
    outer loop 
      vertex -2.000000e+03 -2.000000e+03  0.000000e+00 
      vertex -2.000000e+03  2.000000e+03  0.000000e+00 
      vertex  7.000000e+03  2.000000e+03  0.000000e+00 
    endloop 
  endfacet 
  facet normal  0.000000e+00  0.000000e+00 -1.000000e+00 
    outer loop 
      vertex  7.000000e+03 -2.000000e+03  0.000000e+00 
      vertex -2.000000e+03 -2.000000e+03  0.000000e+00 
      vertex  7.000000e+03  2.000000e+03  0.000000e+00 
    endloop 
  endfacet 
 endsolid

When all .stl files are combined together, part for patch Bottom should look like this:

 ….
  endfacet 
 endsolid Inlet
 solid Bottom
  facet normal  0.000000e+00  0.000000e+00 -1.000000e+00 
    outer loop 
      vertex -2.000000e+03 -2.000000e+03  0.000000e+00 
      vertex -2.000000e+03  2.000000e+03  0.000000e+00 
      vertex  7.000000e+03  2.000000e+03  0.000000e+00 
    endloop 
  endfacet 
  facet normal  0.000000e+00  0.000000e+00 -1.000000e+00 
    outer loop 
      vertex  7.000000e+03 -2.000000e+03  0.000000e+00 
      vertex -2.000000e+03 -2.000000e+03  0.000000e+00 
      vertex  7.000000e+03  2.000000e+03  0.000000e+00 
    endloop 
  endfacet 
 endsolid Bottom
 solid Outlet
 ….

For that purpose I have written little bash script I called "stlCombine" which combines .stl files and outputs "mergedStl.stl" file. EDIT: On OSX head command with -1 option doesn't work so change that line from tail -n +2 $file | head -n -1 >> $outputPath/mergedStl.stl to tail -n +2 $file | tail -r | tail -n +1 | tail -r >> $outputPath/mergedStl.stl

 #!/bin/bash 
 # how to run it: ./stlCombine [PATH TO DIRECTORY WITH .stl FILES] [PATH TO OUTPUT DIRECTORY] 
 # example with ahmed is ./stlCombine ./ahmed/ahmed_25/constant/triSurface ./ahmed/ahmed_25
 
 # get .stl files location/path specified with running script (from example ./ahmed/ahmed_25/constant/triSurface) 
 filePath=$(cd $1 && pwd) 
 # get merged file output location/path specified with running script (from example ./ahmed/ahmed_25)
 outputPath=$(cd $2 && pwd) 
 
 # check if file mergedStl.stl exists. If it does delete it. 
 if [ -f $filesPath/mergedStl.stl ] 
 then 
     rm $filesPath/mergedStl.stl 
 fi 
 
 # remove all temporary files from input directory (where .stl files are located) 
 if [ -d "$filePath/*~" ]; then 
     rm $filePath/*~ 
 fi 
 
 # add patch name: 
   # change first and last line of every file in input location from solid to solid [.stl FILE NAME] and from endsolid to endsolid [.stl FILE NAME]
   # merge them together
 # example is from "solid" to "solid Bottom" and from "endsolid" to "endsolid Bottom" 
 for file in $filePath/*.stl 
 do 
     # get .stl file name
     fileName=`basename $file` 
     # remove .stl file extension
     patchName=`echo "$fileName" | cut -f1 -d'.'` 
     
     # append line solid [.stl FILE NAME] (eg. solid Bottom ) to file mergedStl.stl
     echo "solid $patchName" >> $outputPath/mergedStl.stl
     
     # copy all lines except first and last one from loaded .stl file and append them to mergedStl.stl
     tail -n +2 $file | head -n -1 >> $outputPath/mergedStl.stl 
     
     # append line endsolid [.stl FILE NAME] (eg. endsolid Bottom ) to file mergedStl.stl
     echo "endsolid $patchName" >> $outputPath/mergedStl.stl 
 done
    Kruno (talk)09:54, 18 July 2014

    Hi Kruno, great work, thanks for the effort.

    Could you provide a minimal working case that does what you want ? I think I can help with Salome and cfmesh, but I'd like to see the whole thing as one block instead of several parts.

    Cheers.

    Ben

      Bennn (talk)16:19, 11 August 2014

      Hi Ben, Thank you. Sorry for not responding but I wasn't aware of your message. I didn't log on to wikki and I didn't get a notification on email about your message. I just created tutorial file and I will put it online. Sorry for delay ones again.

      Best regards, Kruno

        Kruno (talk)22:59, 22 September 2014