precice / precice/python-bindings

Easily switch off preCICE

Open
#99 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Cython
Stars
30
Forks
19
PR merge metrics
No merged PRs in 30d

Description

Oftentimes, you want to run a coupled code in single-physics mode, so without preCICE. For codes like OpenFOAM or FEniCS, we would handle this in the adapter. As the Python bindings are also used in codes without adapters (e.g. Nutils) and the codes don't need compiling (Python), it would be really great if there was a simple "switch off" mechanism.

Say

import precice
precice.turn_off()
...
interface = precice.Interface("Solid", "../precice-config.xml", 0, 1)
...
vertex_ids = interface.set_mesh_vertices(mesh_id, vertices)

Then all preCICE calls should be NOPs.
This prevents us from polluting compact codes with a lot of

if(precice_used):
   interface = precice.Interface("Solid", "../precice-config.xml", 0, 1)

Is there a standard Python way how to do this? If not, could we handle it in the Python bindings?

I don't think we need this feature for other bindings as there we have longer codes and/or adapters and we compile. Do you agree?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the public precice module and the Interface entry point shown in the example. Determine how a turn_off state would affect Interface construction and subsequent calls, then verify that all preCICE calls become no-ops while single-physics Python code continues normally.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.