Skip to content

Commit

Permalink
Merge pull request #26 from fredrikekre/fe/coverage
Browse files Browse the repository at this point in the history
Configure CI to upload code coverage data
  • Loading branch information
kevmoor authored Nov 8, 2024
2 parents 193acf7 + 1fd2b6d commit 25ae847
Show file tree
Hide file tree
Showing 15 changed files with 74 additions and 28 deletions.
32 changes: 23 additions & 9 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
push:
branches:
- master
tags: '*'
tags: ['*']
pull_request:
concurrency:
# Skip intermediate builds: always.
Expand All @@ -12,24 +12,38 @@ concurrency:
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
name: Julia ${{ matrix.version }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1.6'
- '1.10'
- '1'
os:
- ubuntu-latest
arch:
- x64
include:
- os: windows-latest
version: '1'
- os: macOS-latest
version: '1'
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: julia-actions/cache@v2
- name: Explicitly add OWENSOpenFAST_jll
shell: julia --color=yes --project=. {0}
run: |
using Pkg
Pkg.add(url = "https://github.com/sandialabs/OWENSOpenFAST_jll.jl")
if: ${{ matrix.version == '1.10' }}
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v4
with:
file: lcov.info
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
7 changes: 4 additions & 3 deletions .github/workflows/Documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- master
tags: '*'
tags: ['*']
pull_request:

jobs:
Expand All @@ -13,10 +13,11 @@ jobs:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: '1'
- uses: julia-actions/cache@v2
- name: Install dependencies
env:
PYTHON: ""
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
*.vtp
*.vtu
*.pdf
*.jl.cov
*.jl.*.cov
*.ech
*.vscode
*.log
/deps/openfast
*.txt
*/vtk/*
*/vtk-ADI/*
*/vtk-ADI/*
5 changes: 5 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
OWENSOpenFAST_jll = "ac0e1b5c-a850-5466-8291-e142bbb8e693"

[sources]
OWENSOpenFAST_jll = {url = "https://github.com/sandialabs/OWENSOpenFAST_jll.jl"}

[compat]
DelimitedFiles = "1"
HDF5 = "0.17"
OWENSOpenFAST_jll = "4.0.0"
julia = "1"

[extras]
Expand Down
File renamed without changes.
6 changes: 5 additions & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
OWENSOpenFAST_jll = "ac0e1b5c-a850-5466-8291-e142bbb8e693"
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"

[sources]
OWENSOpenFAST_jll = {url = "https://github.com/sandialabs/OWENSOpenFAST_jll.jl"}

[extras]
CPUSummary = "2a0fbf3d-bb9c-48f3-b0a9-814d99fd7ab9"
CPUSummary = "2a0fbf3d-bb9c-48f3-b0a9-814d99fd7ab9"
3 changes: 3 additions & 0 deletions src/OWENSOpenFASTWrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ module OWENSOpenFASTWrappers
import Libdl
using LinearAlgebra # for aerodyn cross-product

using OWENSOpenFAST_jll: libaerodyn_inflow_c_binding, libhydrodyn_c_binding,
libifw_c_binding, libmoordyn_c_binding, turbsim

const path = splitdir(@__FILE__)[1]
OFWpath = path

Expand Down
11 changes: 9 additions & 2 deletions src/aerodyn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ Does some pre-initializing of the ADI library to setup arrays for each turbine
"""
function adiPreInit(adilib_filename, numTurbines,transposeDCM,;adi_debug=0)
if isnothing(adilib_filename)
adilib_filename="$path/../deps/openfast/build/modules/aerodyn/libaerodyn_inflow_c_binding"
# adilib_filename="$path/../deps/openfast/build/modules/aerodyn/libaerodyn_inflow_c_binding"
adilib_filename = libaerodyn_inflow_c_binding
end
# Set the error level
global adi_abort_error_level = 4

try
# TODO: No need to explicitly dlopen the library and look up the symbols. It is more
# ideomatic to just reference symbols directly in the ccall, e.g.
# ```julia
# ccall((:ADI_C_PreInit, libaerodyn_inflow_c_binding), Cint, ...)
# ```
println("Opening AeroDyn-Inflow library at: $adilib_filename")
global adilib = Libdl.dlopen(adilib_filename) # Open the library explicitly.
global adi_active = true
Expand Down Expand Up @@ -792,7 +798,8 @@ function setupTurb(adi_lib,ad_input_file,ifw_input_file,adi_rootname,bld_x,bld_z
)

if isnothing(adi_lib)
adi_lib = "$path/../deps/openfast/build/modules/aerodyn/libaerodyn_inflow_c_binding"
# adi_lib = "$path/../deps/openfast/build/modules/aerodyn/libaerodyn_inflow_c_binding"
adi_lib = libaerodyn_inflow_c_binding
end

# load library and set number of turbines
Expand Down
5 changes: 4 additions & 1 deletion src/hydrodyn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ function HD_Init(;hdlib_filename=nothing, output_root_name="./HD", hd_input_file
init_node_pos=zeros(6), interp_order=1, t_initial=0.0, dt=0.01, t_max=60.0)

if isnothing(hdlib_filename)
hdlib_filename="$path/../deps/openfast/build/modules/hydrodyn/libhydrodyn_c_binding"
# hdlib_filename="$path/../deps/openfast/build/modules/hydrodyn/libhydrodyn_c_binding"
hdlib_filename = libhydrodyn_c_binding
end

global hd_abort_error_level = 4
Expand Down Expand Up @@ -355,6 +356,8 @@ function HD_Init(;hdlib_filename=nothing, output_root_name="./HD", hd_input_file
channel_names = string(repeat(" ", 20 * 4000))
channel_units = string(repeat(" ", 20 * 4000))

# TODO: No need to explicitly dlopen the library and look up the symbols. It is more
# ideomatic to just reference symbols directly in the ccall.
global hdlib = Libdl.dlopen(hdlib_filename) # Open the library explicitly.
global hd_active = true

Expand Down
7 changes: 5 additions & 2 deletions src/inflowwind.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ calls inflow wind init
* `none`:
"""
function ifwinit(;inflowlib_filename="$path/../deps/openfast/build/modules/inflowwind/libifw_c_binding",HWindSpeed=10.125,turbsim_filename="$path/test.bts")
function ifwinit(;inflowlib_filename=libifw_c_binding,HWindSpeed=10.125,turbsim_filename="$path/test.bts")
if isnothing(inflowlib_filename)
inflowlib_filename="$path/../deps/openfast/build/modules/inflowwind/libifw_c_binding"
# inflowlib_filename="$path/../deps/openfast/build/modules/inflowwind/libifw_c_binding"
inflowlib_filename = libifw_c_binding
end
# Where the input is manipulated
HWindSpeed_str = " $(round(HWindSpeed,digits=1)) HWindSpeed - Horizontal windspeed (m/s)"
Expand Down Expand Up @@ -158,6 +159,8 @@ function ifwinit(;inflowlib_filename="$path/../deps/openfast/build/modules/inflo


# try
# TODO: No need to explicitly dlopen the library and look up the symbols. It is more
# ideomatic to just reference symbols directly in the ccall.
println("Attempting to access inflow wind at: $inflowlib_filename")
global inflowlib = Libdl.dlopen(inflowlib_filename) # Open the library explicitly.
sym_init = Libdl.dlsym(inflowlib, :IfW_C_Init) # Get a symbol for the function to call.
Expand Down
5 changes: 4 additions & 1 deletion src/moordyn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def_fairlead_pts = [[20.434, 35.393, -14.],
function MD_Init(;mdlib_filename=nothing, md_input_file="none", WtrDens=1025, WtrDpth=200, init_ptfm_pos=zeros(6), gravity=9.80665, dt=0.01, interp_order=1)

if isnothing(mdlib_filename)
mdlib_filename="$path/../deps/openfast/build/modules/moordyn/libmoordyn_c_binding"
# mdlib_filename="$path/../deps/openfast/build/modules/moordyn/libmoordyn_c_binding"
mdlib_filename = libmoordyn_c_binding
end

global md_abort_error_level = 4
Expand Down Expand Up @@ -83,6 +84,8 @@ function MD_Init(;mdlib_filename=nothing, md_input_file="none", WtrDens=1025, Wt
channel_names = string(repeat(" ", 20 * 4000))
channel_units = string(repeat(" ", 20 * 4000))

# TODO: No need to explicitly dlopen the library and look up the symbols. It is more
# ideomatic to just reference symbols directly in the ccall.
global mdlib = Libdl.dlopen(mdlib_filename) # Open the library explicitly.
global md_active = true
global md_sym_init = Libdl.dlsym(mdlib, :MD_C_Init) # Get a symbol for the function to call.
Expand Down
2 changes: 1 addition & 1 deletion test/HAWT_verification/HAWTverify_aerodyn_output_files.jl
Original file line number Diff line number Diff line change
Expand Up @@ -689,4 +689,4 @@ for (ihead,header_name) in enumerate(headerNames1)
PyPlot.legend()
# PyPlot.xlim([0.4,0.5])
PyPlot.savefig("$(path)/$header_name.pdf",transparent = true)
end
end
4 changes: 2 additions & 2 deletions test/hydrodyn_run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using Test
cd(path)

# hdlib_filename = "$path/../deps/bin/libhydrodyn_c_binding" #change this to match your local path of the HydroDyn DLL
hdlib_filename = "$path/../deps/openfast/build/modules/hydrodyn/libhydrodyn_c_binding" #change this to match your local path of the HydroDyn DLL
# hdlib_filename = "$path/../deps/openfast/build/modules/hydrodyn/libhydrodyn_c_binding" #change this to match your local path of the HydroDyn DLL
ptfm_motions_filename = "$path/data/OpenFAST_DisplacementTimeseries.dat"
output_root_name = "$path/data/hd_wrapper_test"
PotFile = "$path/data/potential_flow_data/marin_semi"
Expand All @@ -32,7 +32,7 @@ out_vals_ts = zeros(Cfloat,length(ts), 1)
forces = zeros(Cfloat,6)
out_vals = zeros(Cfloat,43)
# Run HydroDyn
OWENSOpenFASTWrappers.HD_Init(;hdlib_filename, output_root_name, hd_input_file, ss_input_file, PotFile, t_initial, dt, t_max)
OWENSOpenFASTWrappers.HD_Init(; output_root_name, hd_input_file, ss_input_file, PotFile, t_initial, dt, t_max)

# Time step zero
OWENSOpenFASTWrappers.HD_CalcOutput(t_initial, ptfm_pos_ts[1,:], ptfm_vel_ts[1,:], ptfm_acc_ts[1,:], forces, out_vals)
Expand Down
6 changes: 3 additions & 3 deletions test/ifw_run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ using Test
# openfast/build/modules/inflowwind is where the dynamic library will be
# Move the dynamic library to VAWTHydro.jl/bin or a custom location if you specify the path in the call
turbsim_filename = "$path/data/ifw/test.bts"
inflowlib_filename = "$path/../deps/openfast/build/modules/inflowwind/libifw_c_binding"
OWENSOpenFASTWrappers.ifwinit(;inflowlib_filename,turbsim_filename)
# inflowlib_filename = "$path/../deps/openfast/build/modules/inflowwind/libifw_c_binding"
OWENSOpenFASTWrappers.ifwinit(; turbsim_filename)
velocity = OWENSOpenFASTWrappers.ifwcalcoutput([0.0,0.0,100.0],0.1)
println(velocity)
OWENSOpenFASTWrappers.ifwend()
@test isapprox(velocity,[15.636677, -0.3423329, 0.24170564];atol=1e-4)
@test isapprox(velocity,[15.636677, -0.3423329, 0.24170564];atol=1e-4)
5 changes: 3 additions & 2 deletions test/moordyn_run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using Test

cd(path)

md_lib_filename = "$path/../deps/openfast/build/modules/moordyn/libmoordyn_c_binding" #change this to match your local path of the MoorDyn DLL
# md_lib_filename = "$path/../deps/openfast/build/modules/moordyn/libmoordyn_c_binding" #change this to match your local path of the MoorDyn DLL
ptfm_motions_filename = "$path/data/OpenFAST_DisplacementTimeseries.dat"
# md_input_file = "$path/NRELOffshrBsline5MW_OC4DeepCwindSemi_MoorDynv2.dat"
md_input_file = "$path/data/moordyn_test.dat"
Expand All @@ -32,7 +32,8 @@ forces = Vector{Float32}(undef, 6)
line_tensions = Vector{Float32}(undef, 6)

## Run MoorDyn
OWENSOpenFASTWrappers.MD_Init(;mdlib_filename=md_lib_filename, init_ptfm_pos=ptfm_pos_ts[1,:], interp_order=interp_order)
# OWENSOpenFASTWrappers.MD_Init(;mdlib_filename=md_lib_filename, init_ptfm_pos=ptfm_pos_ts[1,:], interp_order=interp_order)
OWENSOpenFASTWrappers.MD_Init(; init_ptfm_pos=ptfm_pos_ts[1,:], interp_order=interp_order)

# Time step zero
forces[:], line_tensions[:] = OWENSOpenFASTWrappers.MD_CalcOutput(t_initial, ptfm_pos_ts[1,:], ptfm_vel_ts[1,:], ptfm_acc_ts[1,:], forces, line_tensions)
Expand Down

0 comments on commit 25ae847

Please sign in to comment.