diff --git a/.github/workflows/automated-dev-tests.yml b/.github/workflows/automated-dev-tests.yml index aa613778cc..c2c1fd8024 100644 --- a/.github/workflows/automated-dev-tests.yml +++ b/.github/workflows/automated-dev-tests.yml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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/cache@v3.0.4 + 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 diff --git a/glue-codes/simulink/CMakeLists.txt b/glue-codes/simulink/CMakeLists.txt index 1da4052938..b84ee0d80d 100644 --- a/glue-codes/simulink/CMakeLists.txt +++ b/glue-codes/simulink/CMakeLists.txt @@ -33,12 +33,13 @@ set(MEX_LIBS $ $ # MATLAB Specific $ - $ + $ $ $ - $ + $ $ $ # MATLAB Specific + $ ) # Build the matlab shared library (mex) using the current toolchain. @@ -69,7 +70,7 @@ set_target_properties(FAST_SFunc PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/matlab) target_include_directories(FAST_SFunc PUBLIC $ - $ + $ $ ) if(APPLE OR UNIX) diff --git a/glue-codes/simulink/examples/test_openfast_simulink.m b/glue-codes/simulink/examples/test_openfast_simulink.m new file mode 100644 index 0000000000..0686b125bd --- /dev/null +++ b/glue-codes/simulink/examples/test_openfast_simulink.m @@ -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