Allow micro simulations to pass local data for adaptivity calculation only#231
Open
AdityaGupta716 wants to merge 5 commits intoprecice:developfrom
Open
Allow micro simulations to pass local data for adaptivity calculation only#231AdityaGupta716 wants to merge 5 commits intoprecice:developfrom
AdityaGupta716 wants to merge 5 commits intoprecice:developfrom
Conversation
bf75590 to
64c7120
Compare
… 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
64c7120 to
95f45a3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #25
Micro simulations can now return data from
solve()(and optionallyinitialize()) 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_datakey toadaptivity_settingsin the Micro Manager JSON config:The micro simulation's
solve()method includes the local data key in its returned dict:Changes
micro_manager/config.py: reads optionallocal_datafromadaptivity_settings, exposes it viaget_local_data_for_adaptivity()micro_manager/micro_manager.py: initializes local data arrays, collects local data fromsolve(),initialize(), and lazy initialization paths, strips local data keys from output before writing to preCICEtests/unit/test_micro_manager.py: new test verifying local data is collected for adaptivity but absent from preCICE write outputtests/unit/micro-manager-config-local-adaptivity-data.json: test config withlocal_datadocs/configuration.md: new parameter documented in table and example config updateddocs/adaptivity.md: new "Local data for adaptivity" section with usage exampleCHANGELOG.md: entry added under[Unreleased]