Automatically set the exchange-directory
For some reason that we currently don't understand, the exchange-dir is not set correctly to the same values in the respective OpenFOAM-Code_Aster tutorial, requiring us to do something like:
<!-- TODO: Give an absolute path for the exchange-directory, as Code_Aster starts in /tmp/ -->
- <m2n:sockets from="Fluid" to="Solid" exchange-directory="/path/to/tutorials/CHT/flow-over-plate/buoyantSimpleFoam-aster"/>
+ <m2n:sockets from="Fluid" to="Solid" exchange-directory="/home/tester/tutorials/CHT/flow-over-plate/buoyantSimpleFoam-aster"/>
(both . and .. don't work).
I will have a look on this issue.
It looks like Code_Aster uses a subdirectory of /tmp/ as a working directory.
In solid.export, I see the following:
P proxy_dir /tmp
P rep_trav /tmp/tester-tester-VirtualBox-interactif_6834
@micheltakken any idea how to change this? (i.e. without modifying this file, but maybe through ASTK)
I cannot find any way to set a different rep_trav without changing this file, but if I set it to the working directory, it looks like it is working in the beginning, but at the end of the simulation, it deletes the complete directory. Therefore, let's not do this.
P rep_trav /home/tester/tutorials-CA_OpenFOAM/CHT/flow-over-plate/buoyantSimpleFoam-aster
The effort for fixing this seems to overcome the benefit at the moment.
I cannot find any way to set a different
rep_travwithout changing this file, but if I set it to the working directory, it looks like it is working in the beginning, but at the end of the simulation, it deletes the complete directory. Therefore, let's not do this.P rep_trav /home/tester/tutorials-CA_OpenFOAM/CHT/flow-over-plate/buoyantSimpleFoam-asterThe effort for fixing this seems to overcome the benefit at the moment.
I came across this solution on the Code_Aster forum. It might be worth it to try setting rep_trav in both the export file, and in ~/etc/codeaster/asrun (For me, however, changing rep_trav in the export file, crashes the Solid solver in the very beginning).
On the post redirects to a file ~/.astkrc/config, which doesn't exist on my Code_Aster installation, so it even seems to be an outdated solution.
In the end I agree that it's better to just set an absolute path in the preCICE config file, as the means defy the goal to use less absolute paths at this point.
Then I have another (a little bit crazy) idea.
Facts:
- The adapter finds
precice-config.xml, which is located in the same directory asprecice-run/ - We only need the adapter to know where precice-run/ is, we don't want to affect what Code_Aster does.
Idea:
We could ask the adapter to create a symbolic link from e.g. /tmp/my-simulation/precice-run/ to /path/to/precice-config/precice-run/.
We already know where precice-config.xml is (e.g. /path/to/config), so we can use os.symlink to create a link, e.g. (check):
os.symlink("/path/to/config/"+"precice-run", "precice-run", True, *, None)
If we directly have the file path and we need the folder path, we can split it. Maybe we need to define a code_aster file unit somewhere.
Furthermore, we should give the user the option to still specify a custom exchange-directory, so we could have an option to set this on or off (in config.comm).
@micheltakken what do you think?
On the post redirects to a file
~/.astkrc/config, which doesn't exist on my Code_Aster installation, so it even seems to be an outdated solution.
It is common that such .[something]rc files don't exist by default, as they are optional files where the user can define some user-specific options. See, e.g. .bashrc, .gitconfig, etc.