CFD

Generating boundary points to use for simple mesh generation

In a recent assignment for AA543: Computational Fluid Dynamics at the University of Washington, we were asked to generate an O-type mesh around a NACA 0012 airfoil using Thompson’s grid generation method.

FORTRAN code that can generate multiple NACA airfoil geometries was provided, as well as a .dat file with an index of X, Y values that correlate to points on the boundary of the airfoil. This was a setup that made it simple to integrate with meshing code.

Subsequent to this assignment, I wanted to apply these learnings to a more freeform object. This topic describes one method to generate points based on a high contrast black/white line image using FORTRAN, Excel, and Solidworks.

Step 1: Find suitable image

I’ve been wanting to take a trip to Bonaire so I found a simple map image to use.

bonaire

Step 2: Open in Solidworks

Rather than describing the steps in their entirety here, I’ve copied a link to an article that explains how to open an image into a Solidworks Sketch and use the AutoTrace add-in to automatically convert the image lines to sketch lines.

https://grabcad.com/tutorials/tutorial-tip-using-autotrace-in-solidworks 

Step 3: Generating points

This step can be a little tedious. It depends on how smooth your original image is. If it is a smooth continuous shape then Solidworks will generate a continuous line around your image. This makes adding points much simpler. In my case, the image has a lot of different geometries and so Solidworks created it as a set of a lot of different lines and splines.

 

As mentioned previously, if you have multiple segments created with the autotrace tool, you’ll need to create reference points carefully. Be sure to create all the points you want in order around the shape, as the order is important in the creation of associated nodes and numbering.

Once reference points have been created, create a new sketch, and use the Convert Entities tool to convert the reference points to points in the new sketch. All you should now have are points in the new sketch.

Now exit the sketch, and go to the Macro function in the Tools menu. In this step we will export the points in our sketch to an Excel file for cleanup.

Step 3: Export point data to Excel

This step is based off the tutorial here (https://grabcad.com/tutorials/tutorial-how-to-export-points-from-solidworks-to-a-excel-file) however some modifications were made to the macro file as the file in the tutorial does not work for recent versions of Solidworks well.

  1. Download the attached .swp (macro) file.
  2. Select the sketch you have created with the points
  3. Tools -> Macro -> Edit, and navigate to the file you just downloaded
  4. Click the play button to run the macro which will open an excel file and populate it with the point map.

Step 4: Cleanup Excel file and Export

  1. If your shape was a 2D shape, delete the column with Z data.
  2. Delete the row that lists X, Y variable names
  3. Add a column before the X, Y columns with node data, 1 through final count.

A few notes here to be careful with.

  • Plot the points to ensure that they are sequenced correctly. Sometimes Solidworks will mixup point direction in particular segments, which can mess with a grid approach that requires ordered points. Plotting the points allows you to check and fix any errors.
  • Additionally, if you’re planning to use FORTRAN to generate a structured grid mesh (as I was in the AA543 homework), be particularly conscious on where you plan to start and end your points to ensure that they work with the mesh generation logic. In my case I was required to shift some points around to suit.

Example of how the Excel file should look prior to export.

Point-4

Now the data can be exported for use in the program of your choice. I chose to export as tab separated text file which FORTRAN can easily parse for input.

Conclusion

And that’s it! Now you have point data for an image that you can use in CFD/mesh code. Example of a structured mesh approach for the image of Bonaire I started with. Point data file for this geoemetry linked below for those interested.