Skip to content

Simplify error handling (remove error-deferred workaround) #364

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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

MakisH
Copy link
Member

@MakisH MakisH commented Apr 2, 2025

Currently, we have a workaround to force OpenFOAM to stop when encountering an error in the configuration phase. This is not needed anymore since OpenFOAM v2012, which introduces an additional option errors for the function object, which if set to strict, acts as we would expect in this scenario. See related OpenFOAM issue.

The errors option is now in OpenFOAM long enough that we can assume we will not trouble too many users.

This PR:

  • Documents the option
  • Removes the error-deferred option from Utilities.C
  • Replaces all instances of error-deferred with error
  • Replaces the FataErrorInFunction in Utilities.C with a FatalError (the FatalErrorInFunction did not seem to work in some cases, and it does not seem appropriate for a central logging function)
  • Replaces a few explicit calls to FatalErrorInFunction with calls to the adapterInfo function, clarifying the respective error messages, if needed.

Ideally, I would go as far as to rename adapterInfo to adapterLog, but this would touch too many files and potentially frustrate some users that maintain their own forks.

I have tested the following:

Reviewers: Filter out the whitespace changes. I indented-out a large part of Adapter.C because I removed a try-catch construct.

TODO list:

  • I updated the documentation in docs/
  • I added a changelog entry in changelog-entries/ (create directory if missing)

@MakisH MakisH added the dev Not directly affecting users, but helping future development label Apr 2, 2025
@MakisH MakisH requested review from fsimonis, davidscn and vidulejs April 2, 2025 12:34
@MakisH MakisH self-assigned this Apr 2, 2025
@MakisH MakisH marked this pull request as ready for review April 7, 2025 11:14
@MakisH
Copy link
Member Author

MakisH commented Apr 7, 2025

The system tests now pass: https://github.com/precice/openfoam-adapter/actions/runs/14307651426/job/40095066009?pr=364

Now only waiting for review.

Copy link
Member

@davidscn davidscn left a comment

Choose a reason for hiding this comment

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

Looks good, I didn't try to run it myself.

@@ -365,6 +366,8 @@ This directs the solver to use the `preciceAdapterFunctionObject` function objec
which is part of the `libpreciceAdapterFunctionObject.so` shared library.
The name `preCICE_Adapter` can be arbitrary. It is important that the library is loaded outside the `functions` dictionary when you want to use the custom boundary conditions that we provide with the FF module.

The `errors strict` option is optional and [available since OpenFOAM v2012](https://www.openfoam.com/news/main-news/openfoam-v20-12/post-processing#post-processing-function-object-error-handling). Since the adapter is necessary to do a coupled simulation, this option instructs OpenFOAM to stop in case it faces issues with loading the adapter. For OpenFOAM versions that don't support this, remove the option.
Copy link
Member

Choose a reason for hiding this comment

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

So, if not set, my OpenFOAM solver will just keep going, yes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct, same as when OpenFOAM cannot find the adapter.
Do you think this is particularly risky?
Should we take any further actions beyond mentioning this prominently in the changelog?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev Not directly affecting users, but helping future development trigger-system-tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants