From 619b22d1186d559e369ea17b6da6c911e6dc0a97 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Thu, 21 Sep 2023 09:24:38 -0400 Subject: [PATCH 1/5] Add CONTRIBUTING.md --- CONTRIBUTING.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..2d13846b --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,11 @@ +# Contributing to the Micro Manager + +Contributions to the Micro Manager are most welcome! Please have a look at the page [contributing to preCICE](https://precice.org/community-contribute-to-precice.html) and also this page for more details. + +## Automatic checks + +We check every contribution with a few GitHub Actions workflows that report at the bottom of each pull request. For example, we have an Action to check if the contributed code is formatting correctly according to [autopep8](https://pypi.org/project/autopep8/). + +## Changelog + +We maintain a `CHANGELOG.md` where all major changes and contributions are entered. From fcd2b29462c68c6bd97d5f8c7e351dd1067ce5f0 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Sat, 14 Oct 2023 18:51:30 -0400 Subject: [PATCH 2/5] Clean up adaptivity tests and some renaming (#67) * Clean up adaptivity tests * Rename long variables in micro_manager.py --- .github/workflows/run-adaptivity-test.yml | 2 +- micro_manager/micro_manager.py | 8 ++++---- tests/unit/test_adaptivity_serial.py | 18 ------------------ 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/.github/workflows/run-adaptivity-test.yml b/.github/workflows/run-adaptivity-test.yml index 1ffb3e61..e66dc318 100644 --- a/.github/workflows/run-adaptivity-test.yml +++ b/.github/workflows/run-adaptivity-test.yml @@ -1,4 +1,4 @@ -name: Test for functions in classes AdaptivityCalculator, LocalAdaptivityCalculator, GlobalAdaptivityCalculator +name: Test adaptivity functionality on: push: branches: diff --git a/micro_manager/micro_manager.py b/micro_manager/micro_manager.py index 452599b5..53340c79 100644 --- a/micro_manager/micro_manager.py +++ b/micro_manager/micro_manager.py @@ -116,7 +116,7 @@ def __init__(self, config_file: str) -> None: if name in self._write_data_names: self._adaptivity_micro_data_names[name] = is_data_vector - self._is_adaptivity_required_in_every_implicit_iteration = self._config.is_adaptivity_required_in_every_implicit_iteration() + self._adaptivity_in_every_implicit_step = self._config.is_adaptivity_required_in_every_implicit_iteration() self._micro_sims_active_steps = None # ************** @@ -282,7 +282,7 @@ def solve(self) -> None: n_checkpoint = n if self._is_adaptivity_on: - if not self._is_adaptivity_required_in_every_implicit_iteration: + if not self._adaptivity_in_every_implicit_step: similarity_dists, is_sim_active, sim_is_associated_to = self._adaptivity_controller.compute_adaptivity( self._dt, self._micro_sims, similarity_dists, is_sim_active, sim_is_associated_to, self._data_for_adaptivity) @@ -304,7 +304,7 @@ def solve(self) -> None: micro_sims_input = self._read_data_from_precice() if self._is_adaptivity_on: - if self._is_adaptivity_required_in_every_implicit_iteration: + if self._adaptivity_in_every_implicit_step: similarity_dists, is_sim_active, sim_is_associated_to = self._adaptivity_controller.compute_adaptivity( self._dt, self._micro_sims, similarity_dists, is_sim_active, sim_is_associated_to, self._data_for_adaptivity) @@ -339,7 +339,7 @@ def solve(self) -> None: # If adaptivity is computed only once per time window, the states of sims need to be reset too if self._is_adaptivity_on: - if not self._is_adaptivity_required_in_every_implicit_iteration: + if not self._adaptivity_in_every_implicit_step: similarity_dists = np.copy(similarity_dists_cp) is_sim_active = np.copy(is_sim_active_cp) sim_is_associated_to = np.copy(sim_is_associated_to_cp) diff --git a/tests/unit/test_adaptivity_serial.py b/tests/unit/test_adaptivity_serial.py index 9aaa7227..29ca8338 100644 --- a/tests/unit/test_adaptivity_serial.py +++ b/tests/unit/test_adaptivity_serial.py @@ -102,13 +102,6 @@ def test_update_active_sims(self): is_sim_active = np.array([True, True, True, True, True]) # Activate all micro sims before calling functionality - class MicroSimulation(): - pass - - dummy_micro_sims = [] - for _ in range(self._number_of_sims): - dummy_micro_sims.append(MicroSimulation()) - is_sim_active = adaptivity_controller._update_active_sims( self._similarity_dists, is_sim_active) @@ -153,17 +146,6 @@ def test_associate_active_to_inactive(self): is_sim_active = np.array([True, False, False, True, False]) expected_sim_is_associated_to = np.array([-2, 0, 0, -2, 3]) - class MicroSimulation(): - def __init__(self, global_id): - self._global_id = global_id - - def get_global_id(self): - return self._global_id - - dummy_micro_sims = [] - for i in range(self._number_of_sims): - dummy_micro_sims.append(MicroSimulation(i)) - sim_is_associated_to = np.array([-2, -2, -2, -2, -2]) sim_is_associated_to = adaptivity_controller._associate_inactive_to_active( From f45efbd0f3b051cadcd2a464e587023788521262 Mon Sep 17 00:00:00 2001 From: Marcin Rogowski Date: Mon, 30 Oct 2023 00:13:03 +0300 Subject: [PATCH 3/5] README clarification + fix typo (#69) * Fix typo * Add --config parameter to the run-micro-manager.py execution command * Add assertion to check if a rank has no vertices --------- Co-authored-by: Ishaan Desai --- examples/README.md | 22 ++++++++++++++++++---- micro_manager/micro_manager.py | 2 ++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/examples/README.md b/examples/README.md index 904104fc..7aea421b 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,18 +1,25 @@ # Solverdummies -The `solverdummies` are minimal working examples for using the preCICE Micro Manager with different languages. At the moment, there are examples for Python, and C++. They can be coupled with any other solver, for example the `macro-dummy.py` in this directory. +The `solverdummies` are minimal working examples for using the preCICE Micro Manager with different languages. At the moment, there are examples for Python, and C++. They can be coupled with any other solver, for example the `macro_dummy.py` in this directory. ## Python To run the Python solverdummies, run the following commands in the `examples/` directory in **two different terminals**: ```bash -python macro-dummy.py -python python-dummy/run_micro_manager.py +python macro_dummy.py +python python-dummy/run_micro_manager.py --config micro-manager-config.json ``` Note that running `micro_manager micro-manager-config.json` from the terminal will not work, as the path in the configuration file is relative to the current working directory. See [#36](https://github.com/precice/micro-manager/issues/36) for more information. +To run the Python solverdummies with adaptivity run the following commands in the `examples/` directory in **two different terminals**: + +```bash +python macro_dummy.py +python python-dummy/run_micro_manager.py --config micro-manager-adaptivity-config.json +``` + ## C++ The C++ solverdummies have to be compiled first using [`pybind11`](https://pybind11.readthedocs.io/en/stable/index.html). To do so, install `pybind11` using `pip`: @@ -42,7 +49,14 @@ Then, run the following commands in the `examples/` directory, in **two differen ```bash python macro_dummy.py -python cpp-dummy/run_micro_manager.py +python cpp-dummy/run_micro_manager.py --config micro-manager-config.json +``` + +To run the C++ solverdummies with adaptivity run the following commands in the `examples/` directory in **two different terminals**: + +```bash +python macro_dummy.py +python cpp-dummy/run_micro_manager.py --config micro-manager-adaptivity-config.json ``` When changing the C++ solverdummy to your own solver, make sure to change the `PYBIND11_MODULE` in `micro_cpp_dummy.cpp` to the name that you want to compile to. diff --git a/micro_manager/micro_manager.py b/micro_manager/micro_manager.py index 53340c79..3b9ec38e 100644 --- a/micro_manager/micro_manager.py +++ b/micro_manager/micro_manager.py @@ -149,6 +149,8 @@ def initialize(self) -> None: self._mesh_vertex_ids, mesh_vertex_coords = self._participant.get_mesh_vertex_ids_and_coordinates( self._macro_mesh_name) + assert (mesh_vertex_coords.size != 0), "Macro mesh has no vertices." + self._local_number_of_sims, _ = mesh_vertex_coords.shape self._logger.info("Number of local micro simulations = {}".format(self._local_number_of_sims)) From 2e3c2a4c77732f56a957abbad9e4d0cb64029725 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 7 Nov 2023 17:39:48 +0100 Subject: [PATCH 4/5] Add JOSS DOI badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index af8f6b4f..f2a2a85f 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ Upload Python Package +[![DOI](https://joss.theoj.org/papers/10.21105/joss.05842/status.svg)](https://doi.org/10.21105/joss.05842) + A tool to facilitate solving two-scale (macro-micro) coupled problems using the coupling library [preCICE](https://www.precice.org/). The main documentation is rendered on the [preCICE website](https://precice.org/tooling-micro-manager-overview.html). From 6c08889c658c889d6ab5d0867802522585abcee5 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 7 Nov 2023 17:43:16 +0100 Subject: [PATCH 5/5] Remove reference to old conference paper and add CITATION.cff file --- CITATION.cff | 46 ++++++++++++++++++++++++++++++++++++++++++++++ README.md | 2 -- 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 CITATION.cff diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 00000000..e6afa280 --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,46 @@ +cff-version: "1.2.0" +authors: +- family-names: Desai + given-names: Ishaan + orcid: "https://orcid.org/0000-0002-2552-7509" +- family-names: Scheurer + given-names: Erik + orcid: "https://orcid.org/0009-0000-9396-2994" +- family-names: Bringedal + given-names: Carina + orcid: "https://orcid.org/0000-0003-0495-2634" +- family-names: Uekermann + given-names: Benjamin + orcid: "https://orcid.org/0000-0002-1314-9969" +doi: 10.18419/darus-3764 +message: If you use this software, please cite our article in the + Journal of Open Source Software. +preferred-citation: + authors: + - family-names: Desai + given-names: Ishaan + orcid: "https://orcid.org/0000-0002-2552-7509" + - family-names: Scheurer + given-names: Erik + orcid: "https://orcid.org/0009-0000-9396-2994" + - family-names: Bringedal + given-names: Carina + orcid: "https://orcid.org/0000-0003-0495-2634" + - family-names: Uekermann + given-names: Benjamin + orcid: "https://orcid.org/0000-0002-1314-9969" + date-published: 2023-11-07 + doi: 10.21105/joss.05842 + issn: 2475-9066 + issue: 91 + journal: Journal of Open Source Software + publisher: + name: Open Journals + start: 5842 + title: "Micro Manager: a Python package for adaptive and flexible + two-scale coupling" + type: article + url: "https://joss.theoj.org/papers/10.21105/joss.05842" + volume: 8 +title: "Micro Manager: a Python package for adaptive and flexible + two-scale coupling" diff --git a/README.md b/README.md index f2a2a85f..aedda6eb 100644 --- a/README.md +++ b/README.md @@ -19,5 +19,3 @@ A tool to facilitate solving two-scale (macro-micro) coupled problems using the The main documentation is rendered on the [preCICE website](https://precice.org/tooling-micro-manager-overview.html). Please report any [issues](https://github.com/precice/micro-manager/issues) and give us feedback through [one of our community channels](https://precice.org/community-channels.html). - -The concept and initial design of the Micro Manager is described in *Desai, Ishaan, & Bringedal, Carina & Uekermann, Benjamin. A flexible software approach to simulate two-scale coupled problems. ECCOMAS Congress 2022. [10.23967/eccomas.2022.037](https://doi.org/10.23967/eccomas.2022.037)*.