Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support to read and write multiple data fields #31

Open
steffenger opened this issue Mar 5, 2025 · 1 comment · May be fixed by #34
Open

Support to read and write multiple data fields #31

steffenger opened this issue Mar 5, 2025 · 1 comment · May be fixed by #34
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@steffenger
Copy link

This issue was already adressed for the fenics-adapter precice/fenics-adapter#65. Allow the user to initialise the adapter also with dictionaries of different data or functionspaces could be a good solution, as described by @IshaanDesai in precice/fenics-adapter#65 (comment).

@BenjaminRodenberg BenjaminRodenberg added this to the v0.1.0 milestone Mar 6, 2025
@BenjaminRodenberg BenjaminRodenberg added the enhancement New feature or request label Mar 6, 2025
@BenjaminRodenberg
Copy link
Member

BenjaminRodenberg commented Mar 6, 2025

I already described a possible solution here.

Let's try to start working on this issue by drafting how the configuration would look like. Based on the configuration for the partitioned heat conduction example I would suggest to change the configuration to the following:

{
  "participant_name": "Dirichlet",
  "precice_config_file_name": "../precice-config.xml",
  "interfaces": {
    "Dirichlet-Mesh": {
      "write_data": ["Heat-Flux"],
      "read_data": ["Temperature"],
    },
    # potentially more meshes
  }
}

I think we will still need the information about the part about the coupling interface here -- even if the user also provides the labels in the adapter code. Otherwise the information which data "lives" on which mesh would be lost.

We would need to extend the API of the adapter to accept a label indicating the data we want to read or write and the corresponding mesh. We would get the following API calls for the Dirichlet participant:

...
precice.initialize(coupling_subdomain={'Dirichlet-Mesh': coupling_boundary}, 
                   read_function_spaces={'Temperature': V},
                   write_objects={'Heat-Flux': f_N_function})
...
coupling_expression = precice.create_coupling_expression('Dirichlet-Mesh', 'Temperature')
...
read_data = precice.read_data('Dirichlet-Mesh', 'Temperature', dt)
# or: read_data = precice.read_data(coupling_expression.mesh_name, coupling_expression.data_name, dt)
precice.update_coupling_expression(coupling_expression, read_data)
...
precice.write_data('Dirichlet-Mesh', 'Heat-Flux', flux_x)

Some comments:

  • We can only create_coupling_expression if we know for which read_function_space, i.e. must provide 'Temperature'.
  • For read_data and write_data providing Dirichlet-Mesh and Temperature/Heat-Flux is not strictly necessary in this case. But imagine we have Temperature1 and Temperature2 or Temperature on Dirichlet-Mesh1 and on Dirichlet-Mesh2.
  • update_coupling_expression should be able to get all the required information from coupling_expression

Note: There is definitely a possibility for some redesign to simplify the user interface, e.g. by calling directly coupling_expression.read_data(dt). Thinking about point sources we could also introduce a point_source = precice.create_coupling_point_sources('Dirichlet-Mesh', 'Temperature'). But I think this is bringing us quite far away from the original issue. Let's implement the feature first and then try to come up with an improved interface (if necessary) later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants