Skip to content

Commit 39b2ea2

Browse files
authored
Merge pull request #59 from precice/matlab-bindings-v3.2.0
Release v3.2.0
2 parents 4f3ca84 + 4f739f3 commit 39b2ea2

File tree

20 files changed

+70
-632
lines changed

20 files changed

+70
-632
lines changed

+precice/@Participant/Participant.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ function writeData(obj,meshName,dataName,valueIndices,values)
247247
end
248248
inSize = length(valueIndices);
249249
values = preciceGateway(uint8(61),meshName,dataName,int32(inSize),valueIndices,relativeReadTime);
250-
values = reshape(values,obj.getDataDimensions(meshName,dataName),[]);
251250
end
252251

253252
% requiresGradientDataFor

+precice/@Participant/private/preciceGateway.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,8 @@ class MexFunction: public matlab::mex::Function {
304304
const TypedArray<double> relativeReadTime = inputs[5];
305305
std::vector<double> values(size[0]*dim);
306306
interface->readData(meshName,dataName,vertexIDs,relativeReadTime[0],values);
307-
outputs[0] = factory.createArray<double>({1, size[0]*dim}, values.data(), values.data()+values.size());
307+
assert(values.size() == dim*vertexIDs.size());
308+
outputs[0] = factory.createArray<double>({dim, vertexIDs.size()}, values.data(), values.data()+values.size());
308309
break;
309310
}
310311
case FunctionID::requiresGradientDataFor:
@@ -339,8 +340,8 @@ class MexFunction: public matlab::mex::Function {
339340
size_t dim = interface->getMeshDimensions(meshName);
340341
std::vector <double> positions(size[0]*dim);
341342
interface->getMeshVertexIDsAndCoordinates(meshName,ids,positions);
342-
outputs[0] = factory.createArray<int32_t>({size[0]}, ids.data(), ids.data()+ids.size());
343-
outputs[1] = factory.createArray<double>({size[0], dim}, positions.data(), positions.data()+positions.size());
343+
outputs[0] = factory.createArray<int32_t>({1, ids.size()}, ids.data(), ids.data()+ids.size());
344+
outputs[1] = factory.createArray<double>({dim, ids.size()}, positions.data(), positions.data()+positions.size());
344345
break;
345346
}
346347

.github/workflows/test.yml

Lines changed: 34 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -13,81 +13,54 @@ jobs:
1313
test-solverdummies:
1414
name: Test MATLAB solverdummmies
1515
runs-on: ubuntu-latest
16-
# container: precice/precice:develop # does not work somehow because of sudo
17-
# see e.g. https://github.com/precice/matlab-bindings/actions/runs/4366307887/jobs/7636136347
16+
container:
17+
image: precice/precice:nightly
1818
strategy:
1919
fail-fast: true
2020
matrix:
2121
include:
22-
- release: latest
22+
# - release: latest # R2024b segfaults; 24.2.0.2863752 (R2024b) Update 5
23+
- release: R2024a
2324
- release: R2023b
24-
- release: R2023a
25-
- release: R2022b
26-
- release: R2022a
27-
- release: R2021b
25+
# - release: R2023a # throws an error: symbol lookup error: /usr/lib/x86_64-linux-gnu/libpython3.12.so: undefined symbol: XML_SetReparseDeferralEnabled
26+
# - release: R2022b
27+
# - release: R2022a
28+
# - release: R2021b
2829
# - release: R2021a # throws an error: https://github.com/precice/matlab-bindings/pull/42
2930
steps:
30-
31-
- name: install precice
32-
uses: precice/setup-precice-action@main
33-
with:
34-
precice-version: 'v3.1.0'
35-
36-
- name: Set up MATLAB
37-
uses: matlab-actions/setup-matlab@v1
38-
with:
39-
release: ${{ matrix.release }}
40-
41-
- name: Check out repository
42-
uses: actions/checkout@v3
43-
44-
- name: Run compilation script
45-
uses: matlab-actions/run-command@v1
46-
with:
47-
command: compile_matlab_bindings_for_precice
48-
49-
- name: Run Solverdummies
50-
shell: bash
31+
- name: Install Dependencies
5132
run: |
52-
export LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libstdc++.so.6:/usr/lib/x86_64-linux-gnu/libgfortran.so.5"
53-
matlab -sd "./solverdummy" -batch "addpath('../'); solverdummy precice-config.xml SolverOne;" & matlab -sd "./solverdummy" -batch "addpath('../'); solverdummy precice-config.xml SolverTwo;"
54-
55-
test-tutorial:
56-
name: Test MATLAB Tutorials
57-
runs-on: ubuntu-latest
58-
strategy:
59-
fail-fast: true
60-
matrix:
61-
include:
62-
- release: latest
63-
- release: R2023b
64-
- release: R2023a
65-
- release: R2022b
66-
- release: R2022a
67-
- release: R2021b
68-
# - release: R2021a
69-
steps:
70-
71-
- name: install precice
72-
uses: precice/setup-precice-action@main
73-
with:
74-
precice-version: 'develop'
75-
33+
apt-get -qq update
34+
apt-get -qq install wget
35+
rm -rf /var/lib/apt/lists/*
7636
- name: Set up MATLAB
77-
uses: matlab-actions/setup-matlab@v1
37+
uses: matlab-actions/setup-matlab@v2
7838
with:
7939
release: ${{ matrix.release }}
80-
8140
- name: Check out repository
8241
uses: actions/checkout@v3
83-
8442
- name: Run compilation script
85-
uses: matlab-actions/run-command@v1
43+
uses: matlab-actions/run-command@v2
8644
with:
8745
command: compile_matlab_bindings_for_precice
88-
89-
- name: Run Tutorials
46+
#- name: Run Solverdummies
47+
# uses: matlab-actions/run-command@v2
48+
# env:
49+
# LD_PRELOAD: /usr/lib/x86_64-linux-gnu/libstdc++.so.6:/usr/lib/x86_64-linux-gnu/libgfortran.so.5
50+
# with:
51+
# startup-options: -sd examples/solverdummy
52+
# command: addpath('../..'),
53+
# # not possible to run following two commands in parallel
54+
# solverdummy precice-config.xml SolverOne
55+
# solverdummy precice-config.xml SolverTwo
56+
# workaround from https://github.com/matlab-actions/run-command/issues/53
57+
- name: Get run-matlab-command
9058
run: |
91-
export LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libstdc++.so.6:/usr/lib/x86_64-linux-gnu/libgfortran.so.5"
92-
matlab -sd "./tutorial/implicit" -batch "addpath('../../'); Solver_I;" & matlab -sd "./tutorial/implicit" -batch "addpath('../../'); Solver_U;"
93-
59+
wget -O /usr/local/bin/run-matlab-command https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/glnxa64/run-matlab-command
60+
chmod +x /usr/local/bin/run-matlab-command
61+
- name: Run Solverdummies
62+
working-directory: examples/solverdummy
63+
env:
64+
LD_PRELOAD: /usr/lib/x86_64-linux-gnu/libstdc++.so.6:/usr/lib/x86_64-linux-gnu/libgfortran.so.5
65+
run: |
66+
run-matlab-command "addpath('../..'), solverdummy precice-config.xml SolverOne" & run-matlab-command "addpath('../..'), solverdummy precice-config.xml SolverTwo"

Contents.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
% MATLAB-bindings for coupling library preCICE
2-
% Version 3.1.0 (R2023b, R2023a, R2022b, R2022a, R2021b) 12-Apr-2024
2+
% Version 3.2.0 (R2024a, R2023b) 03-Apr-2025
33
%
44
% Files
55
% getVersionInformation -

README.md

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ Note that the first two digits of the version number of the bindings indicate th
66

77
## Requirements
88

9-
MATLAB R2018a or later is required. The bindings are actively tested on versions R2023b, R2023a, R2022b, R2022a, and R2021b.
9+
MATLAB R2018a or later is required. The bindings are actively tested on versions R2024a and R2023b.
10+
11+
⚠️Note that we currently observe problems in our CI pipeline for MATLAB R2024b and R2022b and older. If you are any active user of any of these versions, we would appreciate your feedback under [this issue](https://github.com/precice/matlab-bindings/issues/58)⚠️
1012

1113
## Restrictions
1214

13-
- An issue causes MATLAB to crash upon SolverInterface initialization if precice was compiled with openmpi. This issue can be resolved by installing openmpi from source using the option `-disable-dlopen`. For reference, see e.g. [here](https://stackoverflow.com/questions/26901663/error-when-running-openmpi-based-library). Alternatively, the user can switch to a different MPI implementation, e.g. MPICH (other implementations were not tested). Note that for [using a different MPI implementation](https://precice.org/installation-source-advanced.html#mpi---build-precice-using-non-default-mpi-implementation) one has to specify the alternative implementation while building preCICE. For more information on this issue, please refer to https://github.com/precice/matlab-bindings/issues/19.
14-
- Currently, only one instance of the `SolverInterface` class can exist at the same time in a single MATLAB instance. If the user wishes to couple multiple participants based on MATLAB, he is supposed to start them in different MATLAB instances. If, for some reason, the user needs multiple instances of `SolverInterface`, he should use the OOP variant (Multiple instances of `SolverInterfaceOOP` can exist at the same time).
15-
- There is a known bug, if the `SolverInterface` destructor is called. For a possible workaround refer to https://github.com/precice/precice/issues/378. This issue is tracked in https://github.com/precice/matlab-bindings/issues/28.
15+
- An issue causes MATLAB to crash upon Participant initialization if preCICE was compiled with OpenMPI. This issue can be resolved by installing OpenMPI from source using the option `-disable-dlopen`. For reference, see e.g. [here](https://stackoverflow.com/questions/26901663/error-when-running-openmpi-based-library). Alternatively, the user can switch to a different MPI implementation, e.g. MPICH (other implementations were not tested). Note that for [using a different MPI implementation](https://precice.org/installation-source-advanced.html#mpi---build-precice-using-non-default-mpi-implementation) one has to specify the alternative implementation while building preCICE. For more information on this issue, please refer to https://github.com/precice/matlab-bindings/issues/19.
16+
- Currently, only one instance of the `Participant` class can exist at the same time in a single MATLAB instance. If the user wishes to couple multiple participants based on MATLAB, he is supposed to start them in different MATLAB instances. If, for some reason, the user needs multiple instances of `Participant`, he should use the OOP variant (Multiple instances of `ParticipantOOP` can exist at the same time).
17+
- There is a known bug, if the `Participant` destructor is called. For a possible workaround refer to https://github.com/precice/precice/issues/378. This issue is tracked in https://github.com/precice/matlab-bindings/issues/28.
1618

1719
## Compilation
1820

@@ -34,7 +36,7 @@ To use the bindings, you have to add this folder (e.g. `/home/user/matlab-bindin
3436

3537
## Usage
3638

37-
The API introduces a MATLAB wrapper class for the `SolverInterface` class and a namespace for the preCICE constants. They are accessible in MATLAB as `precice.SolverInterface` and `precice.constants` respectively.
39+
The API introduces a MATLAB wrapper class for the `Participant` class and a namespace for the preCICE constants. They are accessible in MATLAB as `precice.Participant` and `precice.constants` respectively.
3840

3941
The function syntax is mostly identical to the syntax of the C++ API. The following things should be noted:
4042

@@ -47,21 +49,26 @@ The function syntax is mostly identical to the syntax of the C++ API. The follow
4749
As an example, the C++ API function
4850

4951
```bash
50-
readBlockScalarData(int dataID, int size, const int *valueIndices, double *values)
52+
void readData(
53+
::precice::string_view meshName,
54+
::precice::string_view dataName,
55+
::precice::span<const VertexID> ids,
56+
double relativeReadTime,
57+
::precice::span<double> values) const
5158
```
5259

5360
is found in the MATLAB bindings as
5461

5562
```bash
56-
values = readBlockScalarData(dataID, valueIndices)
63+
values = readData(meshName, dataName, ids, relativeReadTime)
5764
```
5865

5966
## Out of process variant
6067

61-
The C++ MEX API supports [out of process execution](https://de.mathworks.com/help/matlab/matlab_external/out-of-process-execution-of-c-mex-functions.html) of MEX functions. This feature is implemented in the class `precice.SolverInterfaceOOP`. This class works exactly like `precice.SolverInterface`. Internally, however, the gateway function that calls the preCICE routines is run on a `mexHost` object.
68+
The C++ MEX API supports [out of process execution](https://de.mathworks.com/help/matlab/matlab_external/out-of-process-execution-of-c-mex-functions.html) of MEX functions. This feature is implemented in the class `precice.ParticipantOOP`. This class works exactly like `precice.Participant`. Internally, however, the gateway function that calls the preCICE routines is run on a `mexHost` object.
6269
This has the following advantages:
6370

64-
- Multiple instances of `SolverInterfaceOOP` can exist at the same time.
71+
- Multiple instances of `ParticipantOOP` can exist at the same time.
6572
- If the gateway function crashes, then MATLAB will not crash. Only the mexHost object will crash.
6673
However, using the OOP variant is **significantly** slower than the normal in process
6774

@@ -70,8 +77,8 @@ However, using the OOP variant is **significantly** slower than the normal in pr
7077
## `libprecice.so` cannot be found
7178

7279
```bash
73-
Invalid MEX-file 'SOMEPATH/matlab-bindings/+precice/@SolverInterface/private/preciceGateway.mexa64':
74-
libprecice.so.2: cannot open shared object file: No such file or directory.
80+
Invalid MEX-file 'SOMEPATH/matlab-bindings/+precice/@Participant/private/preciceGateway.mexa64':
81+
libprecice.so.3: cannot open shared object file: No such file or directory
7582
```
7683

7784
Tells you that the MATLAB bindings cannot find the C++ library preCICE. Make sure that you [installed preCICE correctly](https://precice.org/installation-source-installation.html#testing-your-installation).
@@ -85,19 +92,27 @@ $ pkg-config --cflags --libs libprecice
8592

8693
If everything until this point looks good and you are still facing problems and you installed preCICE to a custom location using `CMAKE_INSTALL_PREFIX`, MATLAB might not be able to find `libprecice.so`, since it is not discoverable. Please add the location of `libprecice.so` (see `pkg-config --libs-only-L libprecice`, without the `-L`) to your `LD_LIBRARY_PATH`. For further instructions refer to the [MATLAB documentation](https://de.mathworks.com/help/matlab/matlab_external/set-run-time-library-path-on-linux-systems.html).
8794

88-
## version \`GLIBCXX_3.4.26' not found
95+
## version `GLIBCXX_X.X.XX` not found
8996

9097
```bash
91-
Invalid MEX-file 'SOMEPATH/matlab-bindings/+precice/@SolverInterface/private/preciceGateway.mexa64':
98+
Invalid MEX-file 'SOMEPATH/matlab-bindings/+precice/@Participant/private/preciceGateway.mexa64':
9299
/usr/local/MATLAB/R2021a/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6:
93100
version `GLIBCXX_3.4.26' not found (required by /lib/x86_64-linux-gnu/libprecice.so.2)
94101
```
95102
96-
Matlab ships with a version of `libstdc++.so.6` that may be too old. This version does not find the preCICE C++ library. By using the system-provided version of `libstdc++.so.6`, you can fix the error.
103+
MATLAB ships with a version of `libstdc++.so.6` that may be too old. This version does not find the preCICE C++ library.
104+
105+
So far, this problem was encountered with Ubuntu Version `20.04.04 LTS`, GNU C++ `10.5.0`, on MATLAB versions `R2020b (Update 8)`, `R2021a`, `R2021b (Update 7)`. See https://github.com/precice/matlab-bindings/issues/53 for more details.
106+
107+
There are two possible solutions:
108+
109+
### (recommended) Update your MATLAB installation
110+
111+
This problem does not appear, for example, for MATLAB R2023b (Update 7). For information on how to update MATLAB, please refer to the MATLAB documentation.
97112
98-
So far, this problem was encountered with Ubuntu Version `20.04.04 LTS`, GNU C++ `9.4.0`, on matlab versions `R2020b`, `R2021a`, `R2021b`.
113+
### Set `LD_PRELOAD` to use the system-provided `libstdc++.so.6`
99114
100-
To solve this error start matlab with the following command:
115+
Please start MATLAB with the following command:
101116
102117
```shell
103118
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 matlab
File renamed without changes.

tutorial/README.md

Lines changed: 0 additions & 83 deletions
This file was deleted.

0 commit comments

Comments
 (0)