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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## latest

- 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)
Expand Down
21 changes: 17 additions & 4 deletions micro_manager/micro_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,23 @@ def initialize(self) -> None:
self._micro_sims[i].initialize()
else: # Case where the initialize() method returns data
if self._is_adaptivity_on:
# Check for missing data
expected, provided = set(self._adaptivity_micro_data_names), set(
initial_micro_output.keys()
)
if missing := expected - provided:
raise Exception(
"The initialize() method needs to return data which is required for the adaptivity calculation. "
f'Of the expected data {", ".join(expected)}, the following is missing: {", ".join(missing)}'
)
Comment thread
IshaanDesai marked this conversation as resolved.
elif extra := provided - set(
self._adaptivity_macro_data_names
+ self._adaptivity_micro_data_names
):
self._logger.log_warning_rank_zero(
f'The initialize() method of the Micro simulation returns extra initial data which isn\'t used by the adaptivity: {", ".join(extra)}'
)

for name in initial_micro_output.keys():
initial_micro_data[name] = [0] * self._local_number_of_sims
# Save initial data from first micro simulation as we anyway have it
Expand All @@ -753,10 +770,6 @@ def initialize(self) -> None:
self._data_for_adaptivity[name][
first_id
] = initial_micro_output[name]
else:
raise Exception(
"The initialize() method needs to return data which is required for the adaptivity calculation."
)

# Gather initial data from the rest of the micro simulations
if sim_requires_init_data:
Expand Down
Loading