precice / tutorials

Various tutorial cases for the coupling library preCICE with real solvers. These files are meant to be rendered on precice.org, so don't look at the README files here.
https://www.precice.org/
GNU Lesser General Public License v3.0
107 stars 111 forks source link

Duplicate .clang-format file in OpenFOAM cases #559

Open MakisH opened 2 months ago

MakisH commented 2 months ago

While we have a central .clang-format file for the tutorials, we also have such a file for the OpenFOAM solver in the partitioned heat conduction case. We need this mainly because the default format moves around header inclusions, which breaks OpenFOAM code. This is already a duplicate of the file used in the OpenFOAM adapter, and other PRs are introducing more duplication (such as https://github.com/precice/tutorials/pull/551).

We could maybe move the OpenFOAM-specific file to tools/ for now, and link to it from the various directories.

Note that we are also working on a community proposal, which we could maybe one day import.

fsimonis commented 2 months ago

A possibility which works in pre-commit but not IDEs is to define 2 clang-format hooks and explicitly pass the configuration file to format the OpenFOAM solvers. This way we could use a single clang format file for all openfoam solvers in the repo.

https://github.com/pre-commit/mirrors-clang-format/blob/7d85583be209cb547946c82fbe51f4bc5dd1d017/.pre-commit-hooks.yaml#L7

https://clang.llvm.org/docs/ClangFormatStyleOptions.html#configuring-style-with-clang-format

MakisH commented 2 months ago

I like the idea. If we also distribute the file as a separate repository, we could import it as a git submodule (I will eventually do this in the context of the OpenFOAM SIG RSE).

fsimonis commented 2 months ago

I like the idea.

I'll try it in #551 and link to the existing clang format in on of the openfoam solver directories.