Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/build-openmpi-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build OpenMPI cache

on:
push:
branches:
- main
- develop
pull_request:
branches:
- "*"
workflow_dispatch:

jobs:
build_cache:
name: Build and cache OpenMPI 5
runs-on: ubuntu-latest
container: precice/precice:nightly
steps:
- name: Install build dependencies
run: |
apt-get -qq update
apt-get -qq install wget build-essential

- name: Load Cache OpenMPI 5
id: ompi-cache-load
uses: actions/cache/restore@v5
with:
path: ~/openmpi
key: openmpi-5.0.5-${{ runner.os }}-build

- name: Build OpenMPI 5
if: steps.ompi-cache-load.outputs.cache-hit != 'true'
run: |
wget https://download.open-mpi.org/release/open-mpi/v5.0/openmpi-5.0.5.tar.gz
tar -xzf openmpi-5.0.5.tar.gz
cd openmpi-5.0.5
mkdir -p ~/openmpi
./configure --prefix=$HOME/openmpi
make -j$(nproc)
make install

- name: Save OpenMPI 5 to cache
if: steps.ompi-cache-load.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
with:
path: ~/openmpi
key: openmpi-5.0.5-${{ runner.os }}-build

- name: Verify OpenMPI installation
run: |
if [ ! -d ~/openmpi ]; then
echo "::error::OpenMPI cache directory not found"
exit 1
fi
cp -r ~/openmpi/* /usr/local/
ldconfig
mpiexec --version
38 changes: 11 additions & 27 deletions .github/workflows/check-coverage.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,42 @@
name: Check test coverage

on:
push:
branches:
- main
- develop
pull_request:
branches:
- "*"
workflow_run:
workflows: [Build OpenMPI cache]
types:
- completed

jobs:
coverage:
name: Run test coverage check
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
container: precice/precice:nightly
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
path: micro-manager
ref: ${{ github.event.workflow_run.head_sha }}

- name: Install dependencies
run: |
apt-get -qq update
apt-get -qq install python3-dev python3-venv git pkg-config
apt-get -qq install wget build-essential

- name: Load Cache OpenMPI 5
id: ompi-cache-load
uses: actions/cache/restore@v5
with:
path: ~/openmpi
key: openmpi-v5-${{ runner.os }}-build

- name: Build OpenMPI 5
if: steps.ompi-cache-load.outputs.cache-hit != 'true'
run: |
wget https://download.open-mpi.org/release/open-mpi/v5.0/openmpi-5.0.5.tar.gz
tar -xzf openmpi-5.0.5.tar.gz
cd openmpi-5.0.5
mkdir -p ~/openmpi
./configure --prefix=$HOME/openmpi
make -j$(nproc)
make install

- name: Save OpenMPI 5 to cache
if: steps.ompi-cache-load.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
with:
path: ~/openmpi
key: openmpi-v5-${{ runner.os }}-build
key: openmpi-5.0.5-${{ runner.os }}-build

- name: Configure OpenMPI
run: |
if [ ! -d ~/openmpi ]; then
echo "::error::OpenMPI cache not found. The cache workflow may have failed."
exit 1
fi
cp -r ~/openmpi/* /usr/local/
ldconfig
which mpiexec
Expand Down
22 changes: 13 additions & 9 deletions .github/workflows/run-adaptivity-tests-parallel.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
name: Test adaptivity functionality in parallel
on:
push:
branches:
- main
- develop
pull_request:
branches:
- "*"
workflow_run:
workflows: [Build OpenMPI cache]
types:
- completed
jobs:
integration_tests:
name: Integration tests
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
container: precice/precice:nightly
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
path: micro-manager
ref: ${{ github.event.workflow_run.head_sha }}

- name: Install sudo for MPI
working-directory: micro-manager
Expand Down Expand Up @@ -51,24 +50,29 @@ jobs:

unit_tests:
name: Unit tests
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
container: precice/precice:nightly
steps:
- name: Checkout Repository
uses: actions/checkout@v6
with:
path: micro-manager
ref: ${{ github.event.workflow_run.head_sha }}

- name: Load Cache OpenMPI 5
id: ompi-cache-load
uses: actions/cache/restore@v5
with:
path: ~/openmpi
key: openmpi-v5-${{ runner.os }}-build
# If this fails, cache gets built in run-unit-tests
key: openmpi-5.0.5-${{ runner.os }}-build

- name: Configure OpenMPI
run: |
if [ ! -d ~/openmpi ]; then
echo "::error::OpenMPI cache not found. The cache workflow may have failed."
exit 1
fi
cp -r ~/openmpi/* /usr/local/
ldconfig
which mpiexec
Expand Down
46 changes: 18 additions & 28 deletions .github/workflows/run-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,38 @@
name: Run unit tests for user-side functions
on:
push:
branches:
- main
- develop
pull_request:
branches:
- "*"
workflow_run:
workflows: [Build OpenMPI cache]
types:
- completed
jobs:
unit_tests:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
container: precice/precice:nightly
steps:
- uses: actions/checkout@v6
with:
path: micro-manager
ref: ${{ github.event.workflow_run.head_sha }}

- name: Install dependencies
run: |
apt-get -qq update
apt-get -qq install python3-dev python3-venv git pkg-config
apt-get -qq install wget build-essential

- name: Load Cache OpenMPI 5
id: ompi-cache-load
uses: actions/cache/restore@v5
with:
path: ~/openmpi
key: openmpi-v5-${{ runner.os }}-build

- name: Build OpenMPI 5
if: steps.ompi-cache-load.outputs.cache-hit != 'true'
run: |
wget https://download.open-mpi.org/release/open-mpi/v5.0/openmpi-5.0.5.tar.gz
tar -xzf openmpi-5.0.5.tar.gz
cd openmpi-5.0.5
mkdir -p ~/openmpi
./configure --prefix=$HOME/openmpi
make -j$(nproc)
make install

- name: Save OpenMPI 5 to cache
if: steps.ompi-cache.outputs.cache-hit != 'true'
id: ompi-cache-store
uses: actions/cache/save@v5
with:
path: ~/openmpi
key: openmpi-v5-${{ runner.os }}-build
key: openmpi-5.0.5-${{ runner.os }}-build

- name: Configure OpenMPI
run: |
if [ ! -d ~/openmpi ]; then
echo "::error::OpenMPI cache not found. The cache workflow may have failed."
exit 1
fi
cp -r ~/openmpi/* /usr/local/
ldconfig
which mpiexec
Expand All @@ -71,6 +54,13 @@ jobs:
cd tests/unit
python3 -m unittest test_micro_manager.py

- name: Run model adaptivity unit tests
working-directory: micro-manager
run: |
. .venv/bin/activate
cd tests/unit
python3 -m unittest test_model_adaptivity.py

- name: Install Micro Manager and run tasking unit test
working-directory: micro-manager
env:
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Micro Manager changelog

## v0.10.0

- Fixed load balancing for case where number of sims to send and recv are not the same [#276](https://github.com/precice/micro-manager/pull/276)
- Fixed CI OpenMPI cache miss by centralizing the MPI build into a dedicated workflow [#263](https://github.com/precice/micro-manager/pull/263)
- Fixed naming of variables tracking active simulations in the `MicroManager` [#273](https://github.com/precice/micro-manager/pull/273)
- Improved load balancing of inactive simulations by tracking a small amount of time [#272](https://github.com/precice/micro-manager/pull/272)
- Added the exported field `model_resolution` when using model adaptivity [#271](https://github.com/precice/micro-manager/pull/271)
- Fixed model adaptivity active simulation mask generation for 0 local simulations [#270](https://github.com/precice/micro-manager/pull/270)
- Allow `initialize()` to return data that is not used by the adaptivity [#261](https://github.com/precice/micro-manager/pull/261)
- Fixed `MicroSimulation` initialization requiring positional parameters [#255](https://github.com/precice/micro-manager/pull/255)
- Fixed model adaptivity convergence at resolution boundaries to prevent infinite loops for out-of-range switching requests [#252](https://github.com/precice/micro-manager/pull/252)
- Add function `set_global_id` to the dummies and the example in the integration test [#247](https://github.com/precice/micro-manager/pull/247)

## v0.9.0

- Refactored `DomainDecomposer` class and added a new variant of non-uniform decomposition [#243](https://github.com/precice/micro-manager/pull/243)
Expand Down
30 changes: 27 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,28 @@ summary: Provide a JSON file to configure the Micro Manager.

{% note %} In the preCICE XML configuration the Micro Manager is a participant with the name `Micro-Manager`. {% endnote %}

The Micro Manager is configured with a JSON file. Several parameters can be set.
The Micro Manager is configured with a [JSON](https://en.wikipedia.org/wiki/JSON#Syntax) file. Several parameters can be set, in different sections. For example:

```json
{
"micro_file_name": "python/micro.py",
"coupling_params": {
"precice_config_file_name": "precice-config.xml",
"macro_mesh_name": "Macro-Mesh",
"read_data_names": ["Macro-Scalar", "Macro-Vector"],
"write_data_names": ["Micro-Scalar", "Micro-Vector"]
},
"simulation_params": {
"micro_dt": 1.0,
"macro_domain_bounds": [0.0, 1.0, 0.0, 1.0, 0.0, 1.0]
}
}
```

## Micro Manager Configuration

These parameters are in the outer section.

| Parameter | Description | Default |
|----------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|
| `micro_file_name` | Path to the file containing the Python importable micro simulation class. If the file is not in the working directory, give the relative path from the directory where the Micro Manager is executed. | - |
Expand All @@ -25,6 +43,8 @@ Apart from the base settings, there are three main sections in the configuration

## Coupling Parameters

These parameters are in the section `coupling_params`.

| Parameter | Description |
|----------------------------|--------------------------------------------------------------------------------|
| `precice_config_file_name` | Path to the preCICE XML configuration file from the current working directory. |
Expand All @@ -34,6 +54,8 @@ Apart from the base settings, there are three main sections in the configuration

## Simulation Parameters

These parameters are in the section `simulation_params`.

| Parameter | Description | Default |
| --- | --- | --- |
| `macro_domain_bounds` | Minimum and maximum bounds of the macro-domain, having the format `[xmin, xmax, ymin, ymax, zmin, zmax]` in 3D and `[xmin, xmax, ymin, ymax]` in 2D. | - |
Expand All @@ -50,6 +72,8 @@ Non-uniform domain decomposition is based on a geometric progression.

## Diagnostics

These parameters are in the section `diagnostics`.

| Parameter | Description | Default |
|------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|---------|
| `data_from_micro_sims` | Dictionary with the names of the data from the micro simulation to be written to VTK files as keys and `"scalar"` or `"vector"` as values. | - |
Expand Down Expand Up @@ -117,7 +141,7 @@ To turn on model adaptivity, set `"model_adaptivity": true` in `simulation_param

| Parameter | Description |
|----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `micro_file_names` | List of paths to the files containing the Python importable micro simulation classes. If the files are not in the working directory, give the relative path from the directory where the Micro Manager is executed. Requires a minimum of 2 files. |
| `micro_file_names` | List of paths to the files containing the Python importable micro simulation classes, in order of decreasing model fidelity. If the files are not in the working directory, give the relative path from the directory where the Micro Manager is executed. Requires a minimum of 2 files. |
| `switching_function` | Path to the file containing the Python importable switching function. If the file is not in the working directory, give the relative path from the directory where the Micro Manager is executed. |
| `micro_stateless` | List of boolean values, whether the respective micro simulation model is stateless and can use model instancing. |

Expand Down Expand Up @@ -161,7 +185,7 @@ The Micro Manager uses the output functionality of preCICE, hence these data set
## Load balancing

Load balancing can be activated by setting `load_balancing` to true.
It balances based on either the elapsed time required to solve the prior iteration `type="time""` or the number of active simulations `type=active`.
It balances based on either the elapsed time required to solve the prior iteration `type="time"` or the number of active simulations `type="active"`.
One Initial load balancing step is performed, prior to any computation (assuming equal workload for time based load balancing or the current active counts for `active` load balancing.).
Subsequently, in the following iteration another load balancing step is performed based. (This is mainly for the time based balancing to use the just acquired timings.)
Afterwards balancing is performed `every_n_time_windows`.
Expand Down
15 changes: 15 additions & 0 deletions docs/micro-simulation-convert-to-library.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,21 @@ class MicroSimulation: # Name is fixed
It will be called with frequency set by configuration option `simulation_params: micro_output_n`
This function is *optional*.
"""

def set_global_id(self, sim_id):
"""
Reset the global ID of the micro simulation.

Parameters
----------
sim_id : int
New global ID of the simulation instance.
"""

def get_global_id(self):
"""
Return the global ID of the simulation.
"""
```

A dummy code of a sample MicroSimulation class can be found in the [examples/python-dummy/micro_dummy.py](https://github.com/precice/micro-manager/blob/develop/examples/python-dummy/micro_dummy.py) directory.
Expand Down
2 changes: 2 additions & 0 deletions docs/model-adaptivity.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,5 @@ The output is expected to be an integer and is interpreted in the following mann
| 0 | No resolution change |
| -1 | Increase model fidelity by one (go back one in list) |
| 1 | Decrease model fidelity by one (go one ahead in list) |

If the switching function requests a change beyond the available resolution range, the request is ignored and does not trigger another model-adaptivity iteration.
Comment thread
IshaanDesai marked this conversation as resolved.
Loading