cb-geo / mpm

CB-Geo High-Performance Material Point Method
https://www.cb-geo.com/research/mpm
Other
244 stars 82 forks source link

Build and install of a shared `libmpm` library #723

Open lgiraldi opened 2 years ago

lgiraldi commented 2 years ago

Describe the feature Split the current mpm CMake target into a mpm executable and a libmpm shared library.

For the context, we are planning to build a data analysis tool for simulation results while reusing mpm particles and grid functionalities as much as possible. Therefore, we would greatly appreciate to link our software to such "libmpm" shared library.

Describe alternatives

Additional context

I already have a minimal example up and running for a single shared library, I can provide a PR.

kks32 commented 2 years ago

Hi @lgiraldi Thanks. We use to have a libmpm shared library build and even had a toggle option. https://github.com/cb-geo/mpm/commit/05823df418bbd50e99c8321db12bc66e88f2aca0#diff-1e7de1ae2d059d21e1dd75d5812d5a34b0222cef273b7c3a2af62eb747f9d20a

There was some performance reason why we don't do it anymore....digging through the history of CMakelists.txt might provide a better insight on why we don't do that anymore. lib will reduce compile times, but there was some other issue that stopped us from continuing to do this...I can look into this further...if you can find out in the commit histories that would be greatly appreciated too.

Happy to help integrate your data analysis tool. If you can provide a little more detail, maybe using HDF5 files could be a viable option?

lgiraldi commented 2 years ago

Thanks for the quick reply. I could find the issue #662 and the PR #664 related to the commit you were mentioning. Taking these comments into account, another alternative would be to make the executable not depending on the shared library with something like

add_executable(mpm ${mpm_SOURCE_DIR}/src/main.cc ${mpm_src} ${mpm_vtk})
if(MPM_BUILD_LIB)
  add_library(lmpm SHARED ${mpm_src} ${mpm_vtk})
endif()

Otherwise, would using a static library solve #662 ? Sorry for the ingenuous question, I am no MPI expert.

Regarding our tool, it is related to a research project whose goal is to update the simulation state using external data sources (data assimilation) for an experimental process. For some technical reasons, we would like to play with the simulation state from the FE mesh and not from the particles (so we can't use HDF5 directly). At the moment, our plan is to reuse mpm capabilities for going from the particles to the mesh back and forth in order to simplify our implementation.

I am willing to give you more details about my research through another private channel.