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
103 stars 105 forks source link

Make cleaning tools available for the command line #179

Closed davidscn closed 3 years ago

davidscn commented 3 years ago

We unified our cleaning strategies in #169 and all this works really well if we use the scripts/symlinks located in the individual directories. However, it would be very nice to have these tools also available on the command line so that I don't need to create any symlinks when working with custom cases. This is not really be meant to be used by our users but more as an optional thing for developer and everyone who would like to use it this way. In practice, it would already be possible, but the initial set -e -u triggers an exit in case something goes wrong. Opinions on this @MakisH ?

MakisH commented 3 years ago

In practice, it would already be possible, but the initial set -e -u triggers an exit in case something goes wrong.

I would see this as a separate issue. The only way I can think (and the one OpenFOAM applies) is to ask the user to set an environment variable from which we would load the tools. But this would make it more difficult for the user.

For a developer, since the solver-specific tools are functions, you could source cleaning-tools.sh in your ~/.bashrc and explicitly call functions such as clean_openfoam .. I guess these should work from any directory.

Could you please describe in steps a use case scenario and how you would like to use them?

I would like to keep the issue open and document our experiences here. The community may also suggest what works for them.

davidscn commented 3 years ago

For a developer, since the solver-specific tools are functions, you could source cleaning-tools.sh in your ~/.bashrc and explicitly call functions such as clean_openfoam .. I guess these should work from any directory.

This is exactly what I had in mind and what I did. One can simply source the cleaning tools. However, to cite from the set documentation

  -e  Exit immediately if a command exits with a non-zero status.

This means you can source the cleaning tools, but set -e is set globally in your shell environment and anything with a non-zero status (e.g. a command typo) will immediately kill your session, which makes it useless.

Could you please describe in steps a use case scenario and how you would like to use them?

I'm currently working on an OpenFOAM FSI case which is not part of our tutorials and in particular the removeObsoleteFolders is required when visualizing the data. Rough cleaning can be done manually as well, but the cleaning tools do a better and more comfortable job.

Once the sourcing is available we could add a tooltip on the website in order to tell everybody thinks it's useful.

MakisH commented 3 years ago

This means you can source the cleaning tools, but set -e is set globally in your shell environment and anything with a non-zero status (e.g. a command typo) will immediately kill your session, which makes it useless.

I see, this is a real issue. Would removing the -e there solve this issue? I think we could skip setting it there. (or maybe move it inside the functions?)

I will have a look today and try to find a solution.

davidscn commented 3 years ago

Would removing the -e there solve this issue? I think we could skip setting it there. (or maybe move it inside the functions?)

Yes, skipping it works. This was also what I tried to explain in the first place but I wanted to hear your opinion on this.

I will have a look today and try to find a solution.

Looking forward :)