forked from FloatingArrayDesign/MoorDyn
-
Notifications
You must be signed in to change notification settings - Fork 2
96 lines (85 loc) · 3.55 KB
/
matlab.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Test MATLAB MEX
on:
push:
branches: [ $default-branch, master, wrappers_test ]
pull_request:
branches:
- "**"
env:
BUILD_TYPE: Release
LD_LIBRARY_PATH: ${{github.workspace}}/install/lib:${{github.workspace}}/install/lib64
DYLD_LIBRARY_PATH: ${{github.workspace}}/install/lib
jobs:
test:
name: Test MATLAB MEX
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# MATLAB requires an old version of Windows
os: [ubuntu-latest, macos-latest, windows-2019]
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Create install folder
run: |
mkdir -p ${{github.workspace}}/install
- name: Configure CMake (Linux)
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install -DEXTERNAL_EIGEN:BOOL=OFF -DPYTHON_WRAPPER:BOOL=OFF -DFORTRAN_WRAPPER:BOOL=OFF -DRUST_WRAPPER:BOOL=OFF -DMATLAB_WRAPPER:BOOL=OFF -DUSE_VTK=OFF -DBUILD_TESTING=OFF
- name: Build
id: build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Install
run: cmake --install ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Add the installed DLL to the PATH
run: echo "${{github.workspace}}/install/bin" >> "$GITHUB_PATH"
if: runner.os == 'Windows'
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2
- name: Compile and run
uses: matlab-actions/run-command@v2
with:
command: |
mex('-setup', '-v', 'C');
cd('wrappers/matlab/');
fnames = struct2table(dir('*.cpp')).name;
for i = 1:length(fnames)
fname = cell2mat(fnames(i));
mex('-v', fname, '-I./', '-I${{github.workspace}}/install/include/moordyn', '-L${{github.workspace}}/install/lib', '-L${{github.workspace}}/install/lib64', '-lmoordyn');
end
% Run the same minimal test we have on matlab_bindings.m.in
system = MoorDynM_Create('../../tests/Mooring/lines.txt');
%% 3 coupled points x 3 components per point = 9 DoF
x = zeros(9,1);
dx = zeros(9,1);
%% Get the initial positions from the system itself
for i=1:3
%% 4 = first fairlead id
point = MoorDynM_GetPoint(system, i + 3);
x(1 + 3 * (i - 1):3 * i) = MoorDynM_GetPointPos(point);
end
%% Setup the initial condition
MoorDynM_Init(system, x, dx);
%% Make the points move at 0.5 m/s to the positive x direction
for i=1:3
dx(1 + 3 * (i - 1)) = 0.5;
end
t = 0.0;
dt = 0.5;
[t, f] = MoorDynM_Step(system, x, dx, t, dt);
%% Print the position and tension of the line nodes
n_lines = MoorDynM_GetNumberLines(system);
for line_id=1:n_lines
line_id
line = MoorDynM_GetLine(system, line_id);
n_nodes = MoorDynM_GetLineNumberNodes(line);
for node_id=1:n_nodes
node_id
pos = MoorDynM_GetLineNodePos(line, node_id - 1);
pos
ten = MoorDynM_GetLineNodeTen(line, node_id - 1);
ten
end
end
%% Alright, time to finish!
MoorDynM_Close(system);