precice / matlab-bindings

MATLAB language bindings for preCICE
https://www.precice.org
GNU Lesser General Public License v3.0
5 stars 3 forks source link

Port MATLAB bindings to new interface introduced in MATLAB R2019a #2

Open BenjaminRodenberg opened 5 years ago

BenjaminRodenberg commented 5 years ago

In precice/precice#102 we want to implement/implemented a MATLAB API for preCICE. However, this API is based on functionality from MATLAB R2018b and before. R2019a introduces a more comfortable interface for the generation of a MATLAB interface to a C++ Library.

Dominanz commented 5 years ago

Some details on that from my side:

In the course of coupling a MATLAB solver with preCICE for my thesis, I am writing MATLAB bindings for precice based on the C++ MEX API introduced in R2018a. I do this in my fork. This works fine, but involves explicitly writing wrapper functions and classes for the preCICE functionalities. Hence, it is a lot of code that needs to be written and maintained.

R2019a (which was released less than a month ago) introduced the clibgen package to import C++ libraries into MATLAB in a very comfortable way, more or less without writing any code. The process basically consists of two major steps:

  1. Call clibgen.generateLibraryDefinition to create a definition file from the library headers and <libname>.so file. This file must then be manually reviewed to complete the information that can't be automatically determined by clibgen.
  2. Call clibgen.build on the definition file to import the library. This will create a folder containing a new <customName>.so file. From then, functions and classes in there can be accessed as clib.<customName>.<libname>.*.

This process is really simple. Also, it makes the original bindings pretty much dispensable (for anyone with access to R2019a). However, as far as I figured it out up to now, there are a few shortcomings that must be dealt with, e.g.:

These issues should be solved. Afterwards, clibgen can replace the MATLAB binding.