Code Monkey home page Code Monkey logo

sopht-mpi's Introduction

SophT-MPI

CI DOI

Scalable One-stop Platform for Hydroelastic Things (SOPHT) MPI solver.

Python implementation of an elastohydrodynamic MPI solver, for resolving flow-structure interaction of 3D mixed soft/rigid bodies in viscous flows.

Installation

Below are steps of how to install sopht-mpi. We mainly use poetry to manage the project, although most of the important commands will be provided in Makefile.

  1. Clone!

First create the fork repository and clone to your local machine.

  1. Virtual python workspace: conda.

We recommend using python version above 3.10.

conda create --name sopht-mpi-env
conda activate sopht-mpi-env
conda install python==3.10
  1. Install non-python dependencies, that include MPI, hdf5-mpi and fftw. For Ubuntu you can use:
make install_non_python_modules_on_ubuntu

And for Mac-OS one can use

make install_non_python_modules_on_macos

NOTE: For cluster, optimised versions of the above modules are already installed, and as such this step can be skipped, and the internal modules should be loaded directly.

  1. Setup poetry and dependencies!
make poetry-download
make install
make pre-commit-install

Citation

We ask that any publications which use SophT-MPI cite as following:

@software{fan_kiat_chan_2023_7659153,
  author       = {Fan Kiat Chan and
                  Yashraj Bhosale},
  title        = {{Scalable One-stop Platform for Hydroelastic Things
                   (SOPHT) MPI solver}},
  month        = feb,
  year         = 2023,
  publisher    = {Zenodo},
  version      = {0.0.1},
  doi          = {10.5281/zenodo.7659153},
  url          = {https://doi.org/10.5281/zenodo.7659153}
}

sopht-mpi's People

Contributors

bhosale2 avatar fankiat avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

sopht-mpi's Issues

Allow for single rank MPI runs for easy debugging

Currently, most of the kernels can run a single rank version (often useful for debugging) except for UnboundedPoissonSolverMPI2D. This is caused by an assumption within that class that fails to cover the case when the grid is not distributed at all (i.e. grid_topology = [1, 1]).

Penalise field boundary

We need a field boundary penalisation kernel for 2D fields. I believe we do not need this for periodic boundary cases, so the implementation should then check for periodicity conditions in mpi construct before proceeding. One thing that I am not sure about in the implementation in sopht-backend kernel generator returns a kernel that operates on all sides, whereas here we need to selectively operate on each side depending on the coordinate of the block of field we are operating on. Any thoughts on how we retrofit sopht-backend implementation here would be appreciated @bhosale2 thanks.

Refactor Lamb-Oseen Vortex case

During the refactoring of examples to use the new position field convention, we missed out on this example case. I will patch this example and push a PR briefly.

Internalize get vorticity field maximum in flow simulator

I am thinking of internalizing the get max of vorticity field functionality into flow simulator itself. That way one can track diagnostics of max vorticity and the global max is taken care of within the flow simulator itself (with reduction and whatnot between ranks). What do you think @bhosale2 ? A similar idea here is the internalization of get lag grid deviation error in immersed body flow interactor.

MPI-supported IO for dumping fields for visualizations

We need to have IO tools for dumping fields for visualization and post-processing. I am planning to build on top of distArray functionality. It's something we need later on, so putting this as medium priority for now.

Update typing for pystencils

It seems that sopht-backend had an update on typing for pystencils. We need to patch our code here accordingly.

MPI Field Communicator on custom master rank

Currently, MPIFieldCommunicator() assumes rank=0 holds all the global field. We need something that allows for flexibility in setting a custom master rank. This comes as a feature useful for MPIPlotter2D() later since the lagrangian grid is allowed to be owned by a custom master rank (i.e. not rank 0).

Need for MPI logger

We need a cleaner solution than print statements in logging outputs.

An idea would be to create a MPI-logger that works the same as logging in Python from a user perspective. The MPI-logger gets initialized and depending on what mode is used, records streams from each rank or from a single rank (typically the root rank = 0) and to either sys output or a file. An example use style I envision is something like below. If the idea makes sense, I will put together the implementation soon. Please let me know what you think @bhosale2 . One thing I am not sure about the structure I'm suggesting is where do we set the logger config (levels, filename for output streams, etc). Please also let me know if you have a better suggestion. Thanks.

# mpi_logger.py
class MPILogger:
    def __init__(self, ...):
        self.logger = logging.getLogger()
        if rank == 0:
            self.verbose = True
        else:
            self.verbose = False

    def debug(self, ...):
        if self.verbose:
            self.logger.debug(msg)

    def info(self, ...):
         ...

    ...

logger = MPILogger(...)
# utils/__init__.py
from .mpi_logger import logger
# some_kernel.py
from sopht_mpi.utils import logger

def some_kernel():
    logger.info("info from some kernel")
# main.py
from sopht_mpi.utils import logger
from sopht_mpi.some_path import some_kernel

some_kernel() # this should print from some kernel
logger.info("info from main")

MPI-supported 2D flow simulator and benchmarking

We need to have a MPI-supported 2D flow simulator, with a similar style employed in SophT-Examples. Once this is done, we can do simple benchmarking for solver accuracy. @bhosale2 I'm thinking we benchmark it for two different cases (one with pure flow, and another with a rigid body). Please let me know if the list below works, and we can update the list as we go on.

Update: I am adding a flow past rod case, just to be able to test moving lagrangian grid as well as to start the process of incorporating pyelastica simulator (flow past cylinder does not need to pyelastica simulator time step, so technically only uses rigid body).

Benchmark cases

Refactor simulator and example cases

Now that we have a working version of 2d flow simulator with a few example cases, it's probably a good time to refactor the code before we move on to 3d flow simulator. In the next few days, I will include the following changes:

Please let me know if there is anything else you think would need refactoring @bhosale2

Refactor MPI utils

Currently, we have separate files with separate classes for 2D and 3D MPI utils features. This can be generalized into dimension-agnostic code, so that users will not have to worry about the dimension of the MPIConstruct they are initializing, rather it will be inferred from the grid_size prescribed by the user.

I'm still not fully sure if we will benefit from this, and will see as we go when developing the 3D simulator. I'm putting this as low priority for now.

Things that need refactoring:

  • #93
  • Dimension-agnostic MPI utils

Incorrect indexing for test cases with kernel_support = 0

Currently, some of the test cases for kernels with kernel_support = 0 are indexed with inner_index = slice((kernel_support, -kernel_support)). This would not be doing what we intend for it to do since we basically want to compare the entire field, but end up comparing nothing (with slice((0,0)) we end up with array of size [0, 0]).

renaming field_io_* -> field_*

Currently in all the test files, while the class name has been renamed to MPIFieldCommunicator, the variable used when creating an instance of the field comm. object is still named as mpi_field_io_communicator. I'll rename all of these to be consistent.

Bug in outplane field curl MPI kernel

@bhosale2 there is currently a bug in the outplane field curl, which went undetected as a consequent of a minor bug in indexing the inner cells of a vector field in the test case. The correctly indexed inner cell will give errors as shown in the figure below, which fails the test.

The good thing here is I know this error comes from the fact that in sopht_backend, the outplane field curl kernel sets the boundary to 0, and this requires some tinkering when dealing with boundaries between ranks (which I know how to deal with, similarly to penalise field boundary kernel).

image

I noticed that in the sopht_backend kernel, you have marked a TODO for one sided correction or so. Let me know if I understand this correctly, but is there plans to allow for optional correction for different sides? If this is in your plans, then I will still use this kernel in sopht-mpi. Otherwise, I will just code up my own in the current outplane field kernel. Thanks!

macos ci not passing

We recently found out that new macos was not working due to an internal issues conflicting between numba and pystencils. As a temporary fix for now I think we should remove macos in the CI until this issue is resolved on their end (either macos or numba/pystencils).

Note: For macos user who are facing the same issue due to pystencil/numba conflicts in macos (an example of error message below), this can be temporarily fixed on your end by reinstalling numba using conda install numba

E   ImportError: dlopen(/Users/runner/Library/Caches/pystencils/objectcache/mod_d84531c67f646ef86248d2be72c311f3b177830303be7d2624642eebaf44ff2e.so, 0x0002): symbol not found in flat namespace (___kmpc_barrier)

<frozen importlib._bootstrap>:241: ImportError

Support for quick visualization of 2D flow field

We need quick visualization tool for 2D flow field that adopts the matplotlib style. This will be helpful for debugging etc. I will implement a minimal version of this, meant exactly for quick debugging without needing to load files in paraview and so on.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.