Skip to content

New location logic - #15

Draft
orlandoisepic wants to merge 40 commits into
mainfrom
develop
Draft

orlandoisepic wants to merge 40 commits into
mainfrom
develop

Conversation

@orlandoisepic

@orlandoisepic orlandoisepic commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

New location logic

This implements the requested changes in #7 and #14 (that have first been proposed in precice/preeco-orga#70).

This means that the topology now uses the tags
from-location-name and to-location-name instead of from-patch and to-patch, respectively.
The new tags
from-location-type and to-location-type are introduced and can currently take the values surface and volume.
These tags are only relevant for the adapter-config.
The precice-config generation is left completely unchanged by this PR.

These changes also affect the generated adapter-config: its entry "location" is now filled out according to the specified location type of the exchanges and patch-names are now used exactly as specified in the topology.

Implementation Details

Unfortunately, there were a lot of changes to be made to the NodeCreator :(

  • Old methods _patch_preprocessing() and _initialize_meshes_and_patches() have been reworked into _initialize_locations() and now _initialize_meshes(). Both methods are now relatively modular and simpler than before.
    • The locations are now initialized directly as nodes. They hold references to all meshes that use/interact with them (before, they were assigned to exactly one mesh).
    • The meshes are now initialized for each participant, for each participant they interact with, for each of "extensive"/"intensive", for each of "surface"/"volume". This means that there will be even more meshes now 🤯 However, in the average topology case, nothing will change actually.
  • LocationNode (previously PatchNode) is now used consistently throughout the entire project. No more storing and manipulating locations (patches) as strings.
  • The method get_mesh_patch_map() has been renamed to get_mesh_location_map() and now uses the new LocationNode objects.
  • Other methods that need to use meshes now also use the new location-type as the meshes key and were thus updated.

The TopologyReader has also improved:

  • Its check_topology() method now checks against more edge cases and preprocesses it more.
    • If a location (former patch) has a location-type specified only once, it will be used whenever the location is mentioned. This means that it is not necessary to type "...-location-type" in every exchange.
    • It is not allowed to create a location with both "surface" and "volume" type.

The adapter config now uses the LocationNode object to create the entries.

Create a new enum for location-type and update old references to "patch"
update documentation of topology
Added info about changed topology tags
Extend preprocessing to guard against multiple location-types for the same location
and actually implement the check for "unique-exchanges", which the docstring said the method does, but never actually did.
Change all references from "patch" to "location" and added a few comments for clarity.
Consistently use LocationType as entry and not str
Update the `LocationNode` class to suit new needs.
New location logic!
This changed mainly the old `_patch_preprocessing()` (now `_initialize_locations()`) and `_initialize_meshes_and_patches()` (now `_initialize_meshes()`).

Patch names are not modified in the topology anymore, thus appear in the adapter-config as they were specified.
This allows a much cleaner method and removed a lot of unnecessary logic.
The patches (now LocationNode) are now mainly used as their object and hold references to all meshes that use/interact with them.

Meshes are now split based on type (extensive vs. intensive) and location (surface vs. volume).
This includes some logic, although it is implemented in a smarter way than before.

The method that passes the location info to the adapter-configs has been modified to include the new LocationNode as well.

The new location_type is used as a key in the `mesh_map` which is used in a few other methods; other than that, no changes.

This makes the current design a bit lighter and more modular.
Use the renamed method of NodeCreator
Use the new LocationNode object and actually adhere to the precice-adapter-schema 🫣
@orlandoisepic orlandoisepic added the breaking change A change will break backwards compatibilty label Aug 16, 2026
Fix the uniqueness check to include location-names
Remove check for duplicate exchanges. I think this may require some more adjustements and should thus be moved to a different PR
Update test to new topology format
Fix comparison logic
This updates and optimizes the mesh-creation logic. Before, if two participants exchanged intensive and extensive data, always two meshes were used per participant.
Now, if the exchanges are in different direction, i.e., extensive in one direction, intensive in the other, the same mesh is used by each participant.
it now uses _ instead of -
Update to avoid weird bug
Change it back. Apparently it was correct all along
@orlandoisepic
orlandoisepic marked this pull request as ready for review August 17, 2026 13:11

@uekerman uekerman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a quick look (only):

  • Is there any example with volume coupling already? If not, could be good to add one to also check the "type".
  • Probably beyond this PR: We should eventually check all names for consistency with the adapter schema, things like using "-name" or not
  • to-location-name -> to-location-names and turn into list (same for "from")

@orlandoisepic

Copy link
Copy Markdown
Contributor Author
  • Is there any example with volume coupling already? If not, could be good to add one to also check the "type".

I added an example plus a test

  • Probably beyond this PR: We should eventually check all names for consistency with the adapter schema, things like using "-name" or not

I agree. Dropping the "-name" would certainly make writing the topology easier and be more consistent with the adapter config.

  • to-location-name -> to-location-names and turn into list (same for "from")

I will work on it

@uekerman

Copy link
Copy Markdown
Member

Dropping the "-name" would certainly make writing the topology easier

agree

and be more consistent with the adapter config.

don't agree :)

Could you please open a separate issue (eventually) where we could collect and compare names?

update to new adapter-config
Change `from-/to-location-name` → `from-/to-location-names` (note the 's' at the end).
Updaet to allow lists in `from-/to-location-names`.
The preprocessing method is now redundant.
Move the preprocessing and validation logic to a new class.
New validation and preprocessing logic.
Update to new reader and processing.
This scenario is not correct anymore. Now it is supposed to cause an error.
This error is already checked in "preprocessing/exchange_loop"
Update the description for new tags
@orlandoisepic

Copy link
Copy Markdown
Contributor Author

The requested feature

to-location-name -> to-location-names and turn into list (same for "from")

is implemented in #18 and can be merged into this PR.

orlandoisepic and others added 3 commits September 1, 2026 05:57
Co-authored-by: Benjamin Uekermann <benjamin.uekermann@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change A change will break backwards compatibilty

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simplify location (patch) → mesh generation logic Change topology patches tag

2 participants