Skip to content

Conversation

BenjaminRodenberg
Copy link
Member

@BenjaminRodenberg BenjaminRodenberg commented Aug 29, 2019

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:

  • all source code that is necessary for installation of the MATLAB bindings
  • documentation, such that a user can install the MATLAB bindings
  • a solverdummy using the MATLAB bindings

Todo

Before we can merge this PR, we have to do the following things:

  • get rid of everything that is not directly connected to the MATLAB bindings (see requirements above)
  • add documentation, if it is missing (-> documentation is in good shape, more will follow in a later PR)
  • write tests for the MATLAB bindings (might also be postponed after merging, since we might need to test the MATLAB bindings using a system test on https://github.com/precice/systemtests/tree/master/Test_bindings)
  • update the Changelog
  • update the wiki as soon as PR is merged

Dominik and others added 27 commits March 7, 2019 16:30
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.
@BenjaminRodenberg BenjaminRodenberg added the enhancement A new feature, a new functionality of preCICE (from user perspective) label Aug 29, 2019
@BenjaminRodenberg BenjaminRodenberg self-assigned this Aug 29, 2019
@fsimonis fsimonis self-requested a review September 3, 2019 08:53
Copy link
Member

@fsimonis fsimonis left a 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.

Copy link
Member

@fsimonis fsimonis left a 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));
Copy link
Member

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?

Copy link
Contributor

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];
Copy link
Member

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BenjaminRodenberg
Copy link
Member Author

From my perspective unrealistic to get this done until the release. Let's postpone it to the next one.

Dominanz added a commit to Dominanz/precice that referenced this pull request Sep 12, 2019
- Switched to an enum class for the function IDs
- Undid unrelated changes
- Some minor fixes and changes
@Dominanz
Copy link
Contributor

Dominanz commented Sep 12, 2019

Do we need the legacy matlab bindings?

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
Copy link
Member Author

@BenjaminRodenberg BenjaminRodenberg left a 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)

@BenjaminRodenberg
Copy link
Member Author

I just cloned the PR branch after merging develop, built preCICE (to work with MPICH), compiled the MATLAB bindings and the solverdummy works without a problem.

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.

@BenjaminRodenberg BenjaminRodenberg changed the title WIP: Add MATLAB Bindings Add MATLAB Bindings Sep 26, 2019
@MakisH
Copy link
Member

MakisH commented Oct 8, 2019

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

@BenjaminRodenberg BenjaminRodenberg changed the base branch from develop to draft_MATLAB_bindings October 24, 2019 10:40
@BenjaminRodenberg
Copy link
Member Author

I would like to merge this PR into a new feature branch precice:draft_MATLAB_bindings on the preCICE repository, now. Some issues still remain open end will be solved by another PR, before we merge everything into precice:develop. Using this approach, we can clearly identify @Dominanz contribution to the code and let @gilbertolem add his contributions on his own fork.

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.

@fsimonis fsimonis merged commit 2a23bb1 into precice:draft_MATLAB_bindings Oct 25, 2019
BenjaminRodenberg added a commit to precice/matlab-bindings that referenced this pull request Dec 20, 2019
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature, a new functionality of preCICE (from user perspective)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants