|
| 1 | +# OpenVSP Geometry |
| 2 | + |
| 3 | +In this example, we import an aircraft model created in OpenVSP into the FLOWUnsteady environment. The `aircraft.vsp3` file used here is available in the folder [`examples/aircraft-vsp/`](https://github.com/byuflowlab/FLOWUnsteady/tree/master/examples) in the FLOWUnsteady GitHub repo. |
| 4 | + |
| 5 | +After creating the aircraft geometry in OpenVSP, we write out a DegenGeom file using the tab Analysis > DegenGeom as shown below. This creates a CSV file that contains all the components of the aircraft geometry. |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +Let's import the geometry into Julia using the [`FLOWUnsteady.read_degengeom`](@ref) function and inspect it. |
| 10 | +```@example inspect |
| 11 | +import FLOWUnsteady as uns |
| 12 | +
|
| 13 | +geom_path = joinpath(uns.examples_path, "aircraft-vsp", "aircraft.csv") |
| 14 | +comp = uns.read_degengeom(geom_path); |
| 15 | +
|
| 16 | +for i in 1:length(comp) |
| 17 | + println("$i. $(comp[i].name)") |
| 18 | +end |
| 19 | +``` |
| 20 | + |
| 21 | +Now that we have a good idea about the index of the components in the geometry, we can use them in FLOWUnsteady using the function [`FLOWUnsteady.import_vsp`](@ref). The following example script imports the OpenVSP geometry, creates FLOWUnsteady data structures and writes it out to a vtk file. The geometry can be used with the FLOWUnsteady solver by following one of the previous examples. |
| 22 | + |
| 23 | +```julia |
| 24 | +#=############################################################################## |
| 25 | +# DESCRIPTION |
| 26 | + Import of OpenVSP geometry into FLOWUnsteady |
| 27 | +
|
| 28 | +# AUTHORSHIP |
| 29 | + * Author : Cibin Joseph |
| 30 | + * Email : cibinjoseph92@gmail.com |
| 31 | + * Created : Aug 2023 |
| 32 | + * Last updated : Aug 2023 |
| 33 | + * License : MIT |
| 34 | +=############################################################################### |
| 35 | + |
| 36 | +import FLOWUnsteady as uns |
| 37 | + |
| 38 | +run_name = "aircraft-vsp" # Name of this simulation |
| 39 | +save_path = run_name # Where to save this simulation |
| 40 | + |
| 41 | +# Path to DegenGeom file |
| 42 | +geom_path = joinpath(uns.examples_path, "aircraft-vsp", "aircraft.csv") |
| 43 | + |
| 44 | +Vinf(X, t) = [1.0, 0.0, 0.0] # Freestream function |
| 45 | + |
| 46 | +# ----------------- 1) VEHICLE DEFINITION -------------------------------------- |
| 47 | +println("Importing geometry...") |
| 48 | + |
| 49 | +# Import VSP Components from DegenGeom file |
| 50 | +comp = uns.read_degengeom(geom_path); |
| 51 | + |
| 52 | +fuselage = uns.import_vsp(comp[1]) |
| 53 | +wingL = uns.import_vsp(comp[2]) |
| 54 | +wingR = uns.import_vsp(comp[2]; flip_y=true) |
| 55 | +basefuse = uns.import_vsp(comp[4]) |
| 56 | +horstabL = uns.import_vsp(comp[5]) |
| 57 | +horstabR = uns.import_vsp(comp[5]; flip_y=true) |
| 58 | +verstab = uns.import_vsp(comp[7]) |
| 59 | + |
| 60 | +println("Generating vehicle...") |
| 61 | + |
| 62 | +# Generate vehicle |
| 63 | +system = uns.vlm.WingSystem() # System of all FLOWVLM objects |
| 64 | +uns.vlm.addwing(system, "WingL", wingL) |
| 65 | +uns.vlm.addwing(system, "WingR", wingR) |
| 66 | +uns.vlm.addwing(system, "HorStabL", horstabL) |
| 67 | +uns.vlm.addwing(system, "HorStabR", horstabR) |
| 68 | +uns.vlm.addwing(system, "VerStab", verstab) |
| 69 | + |
| 70 | +fuse_grid = uns.gt.MultiGrid(3) |
| 71 | +uns.gt.addgrid(fuse_grid, "Fuselage", fuselage) |
| 72 | + |
| 73 | +basefuse_grid = uns.gt.MultiGrid(3) |
| 74 | +uns.gt.addgrid(basefuse_grid, "BaseFuse", basefuse) |
| 75 | + |
| 76 | +grids = [fuse_grid, basefuse_grid] |
| 77 | + |
| 78 | +vlm_system = system # System solved through VLM solver |
| 79 | +wake_system = system # System that will shed a VPM wake |
| 80 | + |
| 81 | +vehicle = uns.VLMVehicle( system; |
| 82 | + vlm_system=vlm_system, |
| 83 | + wake_system=wake_system, |
| 84 | + grids=grids |
| 85 | + ); |
| 86 | + |
| 87 | +# ----------------- EXPORT GEOMETRY -------------------------------------------- |
| 88 | +if isdir(save_path); rm(save_path, recursive=true, force=true); end |
| 89 | +mkdir(save_path) |
| 90 | + |
| 91 | +uns.vlm.setVinf(system, Vinf) |
| 92 | +str = uns.save_vtk(vehicle, run_name; path=save_path) |
| 93 | + |
| 94 | +# Open up geometry in ParaView |
| 95 | +str = joinpath(save_path, str) |
| 96 | +run(`paraview -data=$(str)`) |
| 97 | +``` |
| 98 | + |
| 99 | + |
0 commit comments