Skip to content

Commit

Permalink
Merge pull request OpenFAST#1703 from Reoptimize-Systems/dev
Browse files Browse the repository at this point in the history
Add tests for FAST_SFunc using Matlab action to integrate with CI
  • Loading branch information
deslaughter authored Aug 3, 2023
2 parents 83ed284 + 170616d commit 10c9e33
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 3 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/automated-dev-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ jobs:
with:
python-version: '3.9'
cache: 'pip'
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v1
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -67,6 +69,7 @@ jobs:
-DVARIABLE_TRACKING=OFF \
-DBUILD_TESTING:BOOL=ON \
-DCTEST_PLOT_ERRORS:BOOL=ON \
-DBUILD_OPENFAST_SIMULINK_API=ON \
${GITHUB_WORKSPACE}
# -DDOUBLE_PRECISION=OFF \
- name: Build all
Expand Down Expand Up @@ -175,6 +178,8 @@ jobs:
with:
python-version: '3.9'
cache: 'pip'
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v1
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down Expand Up @@ -203,6 +208,7 @@ jobs:
-DBUILD_SHARED_LIBS:BOOL=OFF \
-DBUILD_TESTING:BOOL=ON \
-DCTEST_PLOT_ERRORS:BOOL=ON \
-DBUILD_OPENFAST_SIMULINK_API=ON \
${GITHUB_WORKSPACE}
- name: Build openfast-postlib
working-directory: ${{runner.workspace}}/openfast/build
Expand Down Expand Up @@ -612,6 +618,36 @@ jobs:
!${{runner.workspace}}/openfast/build/reg_tests/glue-codes/openfast/WP_Baseline
rtest-OF-simulink:
runs-on: ubuntu-22.04
needs: build-openfast-release
steps:
- name: Cache the workspace
uses: actions/[email protected]
with:
path: ${{runner.workspace}}
key: build-openfast-release-${{ github.sha }}
- name: Install dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y libhdf5-dev libopenmpi-dev libyaml-cpp-dev libopenblas-dev libopenblas-openmp-dev
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v1
- name: Build FAST_SFunc
working-directory: ${{runner.workspace}}/openfast/build
run: |
cmake \
-DUSE_LOCAL_STATIC_LAPACK:BOOL=ON \
${GITHUB_WORKSPACE}
cmake --build . --target FAST_SFunc
- name: Run MATLAB tests and generate artifacts
uses: matlab-actions/run-tests@v1
with:
source-folder: ${{runner.workspace}}/openfast/build/glue-codes/simulink; ${{runner.workspace}}/openfast/glue-codes/simulink/examples
test-results-junit: test-results/results.xml
code-coverage-cobertura: code-coverage/coverage.xml


rtest-OF-5MW_OC4Semi_WSt_WavesWN:
runs-on: ubuntu-22.04
needs: build-openfast-release
Expand Down
7 changes: 4 additions & 3 deletions glue-codes/simulink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ set(MEX_LIBS
$<TARGET_FILE:sctypeslib>
$<TARGET_FILE:servodynlib-matlab> # MATLAB Specific
$<TARGET_FILE:subdynlib>
$<TARGET_FILE:foamfastlib>
$<TARGET_FILE:extinflowlib>
$<TARGET_FILE:ifwlib>
$<TARGET_FILE:scfastlib>
$<TARGET_FILE:foamtypeslib>
$<TARGET_FILE:extinflowtypeslib>
$<TARGET_FILE:versioninfolib>
$<TARGET_FILE:nwtclibs-matlab> # MATLAB Specific
$<TARGET_FILE:seastlib>
)

# Build the matlab shared library (mex) using the current toolchain.
Expand Down Expand Up @@ -69,7 +70,7 @@ set_target_properties(FAST_SFunc PROPERTIES
Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/matlab)
target_include_directories(FAST_SFunc PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/modules/openfast-library/src>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/modules/openfoam/src>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/modules/externalinflow/src>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/modules/supercontroller/src>
)
if(APPLE OR UNIX)
Expand Down
31 changes: 31 additions & 0 deletions glue-codes/simulink/examples/test_openfast_simulink.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
%% Test OpenFAST Simulink Interface
classdef test_openfast_simulink < matlab.unittest.TestCase

%% Test Method Block
methods (Test)

function testOpenLoopRuns(testCase)

workspace_root = getenv("GITHUB_WORKSPACE");

this_file_path = fileparts(which(mfilename()));

cd(this_file_path);

% these variables are defined in the OpenLoop model's FAST_SFunc block:
FAST_InputFileName = fullfile(workspace_root, 'reg_tests', 'r-test', 'glue-codes', 'openfast', 'AOC_WSt', 'AOC_WSt.fst');
TMax = 5; % seconds

mdl = "OpenLoop";

%simIn = Simulink.SimulationInput(mdl);
%simIn = setBlockParameter(simIn, "sldemo_househeat/Set Point", "Value", FAST_InputFileName);

assignin("base", "FAST_InputFileName", FAST_InputFileName);
assignin("base", "TMax", TMax);

sim(mdl, [0,TMax]);

end
end
end

0 comments on commit 10c9e33

Please sign in to comment.