Skip to content

Commit

Permalink
Merge pull request #89 from cibinjoseph/vsp
Browse files Browse the repository at this point in the history
OpenVSP geometry import feature
  • Loading branch information
EdoAlvarezR authored Nov 16, 2023
2 parents a829829 + 32ebeee commit 9d9027a
Show file tree
Hide file tree
Showing 19 changed files with 25,859 additions and 17 deletions.
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FLOWUnsteady"
uuid = "b491798d-ac6e-455f-a27c-49c10bb0a666"
authors = ["Eduardo J. Alvarez <[email protected]> and contributors"]
version = "3.2.1"
version = "3.3.0"

[deps]
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
Expand All @@ -17,13 +17,14 @@ FLOWVPM = "6e19019d-7c31-4940-9d16-c3f15dfe6020"
FLOWVLM = "1a3ff0be-0410-4572-aa62-b496bdd1f33b"
FLOWNoise = "d27480ee-285d-533b-ae3d-5018956ae0bc"
BPM = "f91b385c-3ede-44c9-92c8-2a04f762ef2f"
VSPGeom = "9b3f6a95-fce2-4bc5-94a2-f99b39986ea6"

[compat]
julia = "1.6"
GeometricTools = "2.1.6"
FLOWVPM = "3.0.1"
FLOWVLM = "2.1.2"
FLOWNoise = "2.3.1"
FLOWNoise = "2.3.2"
BPM = "2.0.1"

[extras]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ over long distances with minimal numerical dissipation.
The rVPM uses particles to discretize the Navier-Stokes equations, with the
particles representing radial basis functions that construct a continuous
vorticity/velocity field. The basis functions become the LES filter, providing a
variable filter width and spatial adaption as the particles are convected and
variable filter width and spatial adaptation as the particles are convected and
stretched by the velocity field. The local evolution of the filter width
provides an extra degree of freedom to reinforce conservations laws, which makes
provides an extra degree of freedom to reinforce conservation laws, which makes
the reformulated VPM numerically stable (overcoming the numerical issues that
plague the classic VPM).

Expand Down
6 changes: 4 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ makedocs(
"examples/vahana-vehicle.md",
"examples/vahana-maneuver.md",
"examples/vahana-monitor.md",
"examples/vahana-run.md",
"examples/vahana-run.md"
],
"examples/openvsp-aircraft.md"
],
"Visualization" => "visualization.md",
"Theory" => [
Expand All @@ -69,7 +70,8 @@ makedocs(
"(1) Vehicle Definition" => [
"api/flowunsteady-vehicle-types.md",
"api/flowunsteady-vehicle-components.md",
"api/flowunsteady-vehicle-asm.md"
"api/flowunsteady-vehicle-asm.md",
"api/flowunsteady-openvsp.md"
],
"api/flowunsteady-maneuver.md",
"api/flowunsteady-simulation.md",
Expand Down
6 changes: 6 additions & 0 deletions docs/src/api/flowunsteady-openvsp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# [Importing OpenVSP geometry](@id openvsp_import)

```@docs
FLOWUnsteady.read_degengeom
FLOWUnsteady.import_vsp
```
Binary file added docs/src/examples/assets/DegenGeom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/examples/assets/aircraft-paraview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 99 additions & 0 deletions docs/src/examples/openvsp-aircraft.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# OpenVSP Geometry

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.

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.

![DegenGeom](assets/DegenGeom.png)

Let's import the geometry into Julia using the [`FLOWUnsteady.read_degengeom`](@ref) function and inspect it.
```@example inspect
import FLOWUnsteady as uns
geom_path = joinpath(uns.examples_path, "aircraft-vsp", "aircraft.csv")
comp = uns.read_degengeom(geom_path);
for i in 1:length(comp)
println("$i. $(comp[i].name)")
end
```

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.

```julia
#=##############################################################################
# DESCRIPTION
Import of OpenVSP geometry into FLOWUnsteady
# AUTHORSHIP
* Author : Cibin Joseph
* Email : [email protected]
* Created : Aug 2023
* Last updated : Aug 2023
* License : MIT
=###############################################################################

import FLOWUnsteady as uns

run_name = "aircraft-vsp" # Name of this simulation
save_path = run_name # Where to save this simulation

# Path to DegenGeom file
geom_path = joinpath(uns.examples_path, "aircraft-vsp", "aircraft.csv")

Vinf(X, t) = [1.0, 0.0, 0.0] # Freestream function

# ----------------- 1) VEHICLE DEFINITION --------------------------------------
println("Importing geometry...")

# Import VSP Components from DegenGeom file
comp = uns.read_degengeom(geom_path);

fuselage = uns.import_vsp(comp[1])
wingL = uns.import_vsp(comp[2])
wingR = uns.import_vsp(comp[2]; flip_y=true)
basefuse = uns.import_vsp(comp[4])
horstabL = uns.import_vsp(comp[5])
horstabR = uns.import_vsp(comp[5]; flip_y=true)
verstab = uns.import_vsp(comp[7])

println("Generating vehicle...")

# Generate vehicle
system = uns.vlm.WingSystem() # System of all FLOWVLM objects
uns.vlm.addwing(system, "WingL", wingL)
uns.vlm.addwing(system, "WingR", wingR)
uns.vlm.addwing(system, "HorStabL", horstabL)
uns.vlm.addwing(system, "HorStabR", horstabR)
uns.vlm.addwing(system, "VerStab", verstab)

fuse_grid = uns.gt.MultiGrid(3)
uns.gt.addgrid(fuse_grid, "Fuselage", fuselage)

basefuse_grid = uns.gt.MultiGrid(3)
uns.gt.addgrid(basefuse_grid, "BaseFuse", basefuse)

grids = [fuse_grid, basefuse_grid]

vlm_system = system # System solved through VLM solver
wake_system = system # System that will shed a VPM wake

vehicle = uns.VLMVehicle( system;
vlm_system=vlm_system,
wake_system=wake_system,
grids=grids
);

# ----------------- EXPORT GEOMETRY --------------------------------------------
if isdir(save_path); rm(save_path, recursive=true, force=true); end
mkdir(save_path)

uns.vlm.setVinf(system, Vinf)
str = uns.save_vtk(vehicle, run_name; path=save_path)

# Open up geometry in ParaView
str = joinpath(save_path, str)
run(`paraview -data=$(str)`)
```

![Paraview](assets/aircraft-paraview.png)
4 changes: 2 additions & 2 deletions docs/src/examples/rotorhover-aero.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ vpm_SFS = vpm.SFS_none # VPM LES subfilter-scale model
# vpm_SFS = vpm.DynamicSFS(vpm.Estr_fmm, vpm.pseudo3level_positive;
# alpha=0.999, rlxf=0.005, minC=0, maxC=1
# clippings=[vpm.clipping_backscatter],
# controls=[control_sigmasensor],
# controls=[vpm.control_sigmasensor],
# )

# NOTE: In most practical situations, open rotors operate at a Reynolds number
Expand Down Expand Up @@ -419,7 +419,7 @@ uns.run_simulation(simulation, nsteps;
omit_shedding=omit_shedding,
extra_runtime_function=runtime_function,
# ----- RESTART OPTIONS -----------------
restart_file=restart_file,
restart_vpmfile=restart_file,
# ----- OUTPUT OPTIONS ------------------
save_path=save_path,
run_name=run_name,
Expand Down
1 change: 1 addition & 0 deletions docs/src/examples/rotorhover-quasisteady.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ simply changing the following parameter in
[the aero solution](@ref rotorhoveraero):
```julia
VehicleType = uns.QVLMVehicle
n = 50 # <---- For some reason PSU-WOPWOP breaks with less blade elements
```
and this parameter when [calling PSU-WOPWOP](@ref rotorhovernoise):
```julia
Expand Down
1 change: 1 addition & 0 deletions docs/src/generate_examples_rotorhover.jl
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ open(joinpath(output_path, output_name*"-quasisteady.md"), "w") do fout
[the aero solution](@ref rotorhoveraero):
```julia
VehicleType = uns.QVLMVehicle
n = 50 # <---- For some reason PSU-WOPWOP breaks with less blade elements
```
and this parameter when [calling PSU-WOPWOP](@ref rotorhovernoise):
```julia
Expand Down
4 changes: 2 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ over long distances with minimal numerical dissipation.
The rVPM uses particles to discretize the Navier-Stokes equations, with the
particles representing radial basis functions that construct a continuous
vorticity/velocity field. The basis functions become the LES filter, providing a
variable filter width and spatial adaption as the particles are convected and
variable filter width and spatial adaptation as the particles are convected and
stretched by the velocity field. The local evolution of the filter width
provides an extra degree of freedom to reinforce conservations laws, which makes
provides an extra degree of freedom to reinforce conservation laws, which makes
the reformulated VPM numerically stable (overcoming the numerical issues that
plague the classic VPM).

Expand Down
7 changes: 3 additions & 4 deletions docs/src/installation/general.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,8 @@ If you run into any issues, please try the following:
* Mac users, take a look at this thread: [LINK](https://github.com/byuflowlab/FLOWUnsteady/issues/26)
* Instructions for BYU Fulton supercomputer: [LINK](https://nbviewer.jupyter.org/url/edoalvar2.groups.et.byu.net/LabNotebook/202108/FLOWVPMSuperComputer.ipynb)

If issues persist, please check the resolved issues in [the FLOWExaFMM repo](https://github.com/byuflowlab/FLOWExaFMM.jl/issues)
and feel free to open a new issue.

If issues persist, please check the resolved issues in [the FLOWExaFMM repo](https://github.com/byuflowlab/FLOWExaFMM.jl/issues?q=), the discussion forum in [the FLOWUnsteady repo](https://github.com/byuflowlab/FLOWUnsteady/discussions?discussions_q=),
and feel free to open a new issue or discussion for help.

## Other Packages
Run the following commands in the Julia REPL to add some dependencies that are not
Expand All @@ -205,7 +204,7 @@ import Pkg
url = "https://github.com/byuflowlab/"

packages = (("AirfoilPrep.jl", "v2.1.2"), ("FLOWVLM", "v2.1.2"),
("BPM.jl", "v2.0.1"), ("FLOWNoise", "v2.3.1"))
("BPM.jl", "v2.0.1"), ("FLOWNoise", "v2.3.2"), ("VSPGeom.jl", nothing))

Pkg.add([ Pkg.PackageSpec(; url=url*name, rev=v) for (name, v) in packages ])
```
Expand Down
66 changes: 66 additions & 0 deletions examples/aircraft-vsp/aircraft-vsp.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#=##############################################################################
# DESCRIPTION
Import of OpenVSP geometry into FLOWUnsteady
# AUTHORSHIP
* Author : Cibin Joseph
* Email : [email protected]
* Created : Aug 2023
* Last updated : Aug 2023
* License : MIT
=###############################################################################

import FLOWUnsteady as uns

run_name = "aircraft-vsp" # Name of this simulation
save_path = run_name # Where to save this simulation


Vinf(X, t) = [1.0, 0.0, 0.0] # Freestream function

# ----------------- 1) VEHICLE DEFINITION --------------------------------------
println("Importing geometry...")

comp = uns.read_degengeom("aircraft.csv")

fuselage = uns.import_vsp(comp[1])
wingL = uns.import_vsp(comp[2])
wingR = uns.import_vsp(comp[2]; flip_y=true)
basefuse = uns.import_vsp(comp[4])
horstabL = uns.import_vsp(comp[5])
horstabR = uns.import_vsp(comp[5]; flip_y=true)
verstab = uns.import_vsp(comp[7])

println("Generating vehicle...")

# Generate vehicle
system = uns.vlm.WingSystem() # System of all FLOWVLM objects
uns.vlm.addwing(system, "WingL", wingL)
uns.vlm.addwing(system, "WingR", wingR)
uns.vlm.addwing(system, "HorStabL", horstabL)
uns.vlm.addwing(system, "HorStabR", horstabR)
uns.vlm.addwing(system, "VerStab", verstab)

fuse_grid = uns.gt.MultiGrid(3)
uns.gt.addgrid(fuse_grid, "Fuselage", fuselage)

basefuse_grid = uns.gt.MultiGrid(3)
uns.gt.addgrid(basefuse_grid, "BaseFuse", basefuse)

grids = [fuse_grid, basefuse_grid]

vlm_system = system # System solved through VLM solver
wake_system = system # System that will shed a VPM wake

vehicle = uns.VLMVehicle( system;
vlm_system=vlm_system,
wake_system=wake_system,
grids=grids
)

# ----------------- 2) GEOMETRY EXPORT -----------------------------------------
rm(save_path, recursive=true, force=true)
mkdir(save_path)

uns.vlm.setVinf(system, Vinf)
uns.save_vtk(vehicle, run_name; path=save_path)
Loading

0 comments on commit 9d9027a

Please sign in to comment.