Skip to content

Allow micro simulations to pass local data for adaptivity calculation only#231

Open
AdityaGupta716 wants to merge 5 commits intoprecice:developfrom
AdityaGupta716:feature/adaptivity-local-data
Open

Allow micro simulations to pass local data for adaptivity calculation only#231
AdityaGupta716 wants to merge 5 commits intoprecice:developfrom
AdityaGupta716:feature/adaptivity-local-data

Conversation

@AdityaGupta716
Copy link
Copy Markdown
Contributor

Summary

Closes #25

Micro simulations can now return data from solve() (and optionally initialize()) that is used only for the adaptivity similarity distance calculation and is never sent to the macro simulation via preCICE.

This is useful when a micro simulation has internal state data (e.g. a phase indicator, convergence metric, or any other state variable) that characterizes similarity between simulations but should not be communicated to the macro side.

Usage

Add a local_data key to adaptivity_settings in the Micro Manager JSON config:

"adaptivity_settings": {
    "type": "local",
    "data": ["Macro-Scalar-Data"],
    "local_data": {"internal-state": "scalar"},
    ...
}

The micro simulation's solve() method includes the local data key in its returned dict:

def solve(self, macro_data, dt):
    return {
        "Micro-Scalar-Data": ...,   # sent to macro simulation as usual
        "internal-state": 42.0,     # used only for adaptivity, never sent to macro
    }

Changes

  • micro_manager/config.py: reads optional local_data from adaptivity_settings, exposes it via get_local_data_for_adaptivity()
  • micro_manager/micro_manager.py: initializes local data arrays, collects local data from solve(), initialize(), and lazy initialization paths, strips local data keys from output before writing to preCICE
  • tests/unit/test_micro_manager.py: new test verifying local data is collected for adaptivity but absent from preCICE write output
  • tests/unit/micro-manager-config-local-adaptivity-data.json: test config with local_data
  • docs/configuration.md: new parameter documented in table and example config updated
  • docs/adaptivity.md: new "Local data for adaptivity" section with usage example
  • CHANGELOG.md: entry added under [Unreleased]

@AdityaGupta716 AdityaGupta716 force-pushed the feature/adaptivity-local-data branch from bf75590 to 64c7120 Compare March 1, 2026 22:21
… only

Closes precice#25

Micro simulations can now return data from their solve() method that is
used exclusively for the adaptivity similarity distance calculation and
is never written to the macro simulation via preCICE.

To use this feature, add a 'local_data' key to 'adaptivity_settings' in
the Micro Manager JSON config:

    "adaptivity_settings": {
        ...
        "local_data": {"My-Internal-State": "scalar"}
    }

The micro simulation's solve() method can then include this key in its
returned dict. The Micro Manager will collect it for adaptivity but strip
it from the output before writing to preCICE.

Changes:
- config.py: read and expose 'local_data' from adaptivity_settings
- micro_manager.py: initialize and collect local adaptivity data arrays,
  strip local data keys from solve() output before preCICE write
- tests: new test config and test case verifying local data is collected
  for adaptivity but absent from preCICE write output
@AdityaGupta716 AdityaGupta716 force-pushed the feature/adaptivity-local-data branch from 64c7120 to 95f45a3 Compare March 1, 2026 22:24
@MakisH MakisH added the GSoC Contributed in the context of the Google Summer of Code label Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GSoC Contributed in the context of the Google Summer of Code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow micro simulations to pass data to be used only in the adaptivity calculation

2 participants