-
-
Notifications
You must be signed in to change notification settings - Fork 197
Add MATLAB Bindings #494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MATLAB Bindings #494
Conversation
Note: Bindings not finished, currently only those required for solverdummy are implemented.
Added bindings for three more functions. Fixed a minimal typo in solverdummy.
The MATLAB bindings now support both character arrays and strings for inputs where the C++ API requires strings.
Changed the write functions in SolverInterface (and the functions called by them) to take a const double* (resp. const double&) instead of a double* (resp. double) for the value argument. The purpose of these functions is to copy the contents of the buffer provided as value argument to the other solver. Hence, the access to the write buffer is read-only, consequently it can be const.
…elop This includes the const-correctness which is valuable for continuing the MATLAB bindings
…elop Adds the remaining changes for const correctness.
The compiling script now uses pkgconfig to determine necessary flags and matlabs `mfilename` to determine the path, making it portable. The dokumenation was extended. Many API functions were added, though several are still missing.
For writeBlockScalarData, the user may now specify to transpose the output if desired, which is helpful if the code is geared to work with column vectors (manual transposing causes unnecessary memory overhead). Fixed bugs in Constants class and mesh quad functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the legacy matlab bindings?
Once the new matlab interface is released, we end up with a total of 3 matlab bindings.
I cannot test nor review the .m
files.
src/precice/bindings/matlab/+precice/@Constants/private/preciceGateway.cpp
Outdated
Show resolved
Hide resolved
src/precice/bindings/matlab/+precice/@Constants/private/preciceGateway.cpp
Show resolved
Hide resolved
src/precice/bindings/matlab/+precice/@Constants/private/preciceGateway.cpp
Outdated
Show resolved
Hide resolved
src/precice/bindings/matlab/+precice/@Constants/private/preciceGateway.cpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is solid but needs to be polished a bit.
Also, these bindings are not compiled into preCICE and therefore should not be in the src
directory.
It is time that we tackle this issue and move such bindings into something like extra/bindings/
.
Alternatively we could put them into a separate repository.
int meshID = interface.getMeshID(meshName); | ||
int dimensions = interface.getDimensions(); | ||
mexPrintf(meshName.c_str()); | ||
std::vector<std::vector<double>> vertices(N, std::vector<double>(dimensions, 0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should populate the dimensions somehow.
std::generate
and some random distribution maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand what you mean by this.
bool valid=false; | ||
// define the functionID | ||
const TypedArray<uint8_t> functionIDArray = inputs[0]; | ||
int functionID = functionIDArray[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we merge these two calls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment above.
src/precice/bindings/matlab/+precice/@SolverInterface/private/preciceGateway.cpp
Show resolved
Hide resolved
From my perspective unrealistic to get this done until the release. Let's postpone it to the next one. |
- Switched to an enum class for the function IDs - Undid unrelated changes - Some minor fixes and changes
They are not meant to be bindings. The solverdummy is rather a minimal example showing how bindings would look like in the old C MEX API. If users are forced to use a pre-R2018a release of MATLAB, they might be interested in this. However, we could also just exclude them from the PR. |
- Switched to an enum class for the function IDs - Undid unrelated changes - Some minor fixes and changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we entirely remove tools/solverdummies/matlab-legacy
from the PR? Merging something that is already called legacy does not look right. edit: I renamed them and decided to keep them for the reasons @Dominanz is giving in #494 (comment)
That's good news. As soon as @fsimonis has aproved the PR, we can merge it. There are some comments in his review that we should either directly address in this PR or at least transfer to issues, such that we do not forget. |
This pull request has been mentioned on preCICE. There might be relevant details there: https://precice.discourse.group/t/i-was-asked-to-try-a-pull-request-how-can-i-do-that/38/2 |
I would like to merge this PR into a new feature branch From my point of view the following issues still remain open:
@fsimonis do you agree? If yes, you can just merge this PR from my point of view. |
Moved from https://github.com/precice/precice/tree/draft_MATLAB_bindings. Main contributions contained in this PR: * precice/precice#494 * precice/precice#580 Co-authored-by: Dominik <volland@ma.tum.de> Co-authored-by: Gilberto Lem <35875991+gilbertolem@users.noreply.github.com>
Closes #102.
This branch currently contains all the changes by @Dominanz that were necessary for his thesis. One particularly useful contribution for preCICE are the MATLAB bindings that have been developed by @Dominanz. We want to merge @Dominanz implementation of the MATLAB bindings into https://github.com/precice/precice within this PR.
I would suggest to release the MATLAB bindings as soon as possible in order to be able to provide them to our users. However, I would suggest to explicitly declare them as experimental since I expect that we will need to make some experiences until we arrive at the final version of the Interface.
Requirements
We require the following components for the MATLAB bindings:
Todo
Before we can merge this PR, we have to do the following things: