First I want to say great thank for full-featured freeware CFD program. It was really surprising that Code_Saturne ran seamlessly on my first test without any tweaking of relaxation, time step e.t.c. and produced "physical" results for my "pure aerodynmic" test case with realistic geometry (boiler furnace). I tried OpenFOAM earlier without success. Even simplest "cavity" test case from OpenFOAM's examples ran only with preset timestep and diverged with increased timestep. Code_Saturne worked stable on different meshes with different timesteps (up to 0.05 s with inlet velocity 20 m/s). The only unsuccessful test case at this moment was due to very bad mesh (NetGen from Salome 7 produced tetra with 3D aspect ratios up to 400 ).
And now my question. I need to set the inlet BC with complex axisymmetric velocity profile (gas turbine outlet). So I made a user subroutines that calculate local velocity components (u, v, w) and feed them to BC parameter arrays (getfbr + rcodcl e.t.c.). User functions must be universal (to use them in various future cases). This means that profiles has to be read from file. I selected CSV format (compatible with other software) and made a reader that was tested and works well. But now I need to determine where my CSV file is located from user subroutine. It's not a main program so getarg cannot help. How can I determine the path to current Saturne's case within user function?
There is no reverse link from the execution directory to the case, but there are several solutions:
- if you place your CSV in your case's DATA directory, it will automatically be copied to the execution directory. So your reader can directly use your file's base name to open it.
- Using the above solution, if your file is large and you do not want to copy it each time, a symbolic link from your true file location to a case's DATA directory should work.
- If you use the same csv file for many studies, you may instead choose to use an absolute path in your reader (I'm not to fond of this, as moving directories later would break this, but it would work).
- By default, unless you edited the "scratch" option in the code_saturne.cfg file, your case directory will be "../.." relative to your execution directory (or "../../.." in coupled computations).
In C, you can use the "getcwd" function to query the working directory. In some Fortran versions, it is usable also.
Thanks!!!
The first method looks optimal in my case and it's reliable because we don't need to play with relative paths that can change in other versions/configurations. CSV profile files are usually not very large so they can easily be copied. I will try to use base file name and place file into DATA directory.
I thought about absolute path but this method has serious drawbacks:
1. Need to change not only CSV but also a source. It/s quite minor but not beautiful.
2. Mine field with cases that has different CSVs. You create first case and set absolute path. Then you copy it to second case, update CSV and forget about absolute path Everything look normal but inlet profile is wrong for second case. So I prefere to keep only one place to update (CSV file).
I used first method (CSV in ./DATA directory + base file name) and it worked OK. Thanks for solution. Now debugging my functions...
But it was also strange behaviour of Saturne. My test case was on flash drive. I created an "empty" case with code_saturne create Swirl, copied my cs_user_boundary_conditions.f90 to ./SRC/ and SwirlProfile.csv file to ./DATA. Setup was very simple (mesh.med + check mesh, Inlet, Outlet and Wall BCs with defaults, 100 iterations, 4 cores). Then I launched calculation from Saturne GUI and saw empty window (without any output). Creation of new case without user functions on flash or hard drive and reboot did not help. The same empty output (and no files in ./RESU). I successfully started calculation only when all files was on hard drive (including mesh), though, IMHO, there was no problems with path to flash.
But at first time Saturne sad that there is no mesh file (I picked mesh from GUI Window so I cannot get how could it be unreachable). I performed mesh check from GUI and it launched OK (no matter what's mesh quality for this test case, although it's more or less normal). Second try was successful, calculation began and I saw the output from my functions...
OS: Ubuntu 12.04 with current updates
Code_Saturne 4.0.0
Salome 7
We occasionally encounter the GUI "empty window" issue, though it is not always reproducible, and depends quite a bit on the machine (so I suspect more a PyQt issue than a Code_Saturne issue, though I would be happy if a Qt/PyQt/Qprocess expert were to identify an issue in the way we use it and make the problem go away).
The issues related to the flash drive are more surprising, because I do not see why the code would handle things in a different manner (except performance-wise), but I have not heard of anyone trying this before. Which filesystem does your flash drive use ? Is it an internal SSD, or a USB device ? On many current systems, external flash drives are mounted in such a manner that files are not exectubale (for security aspects). If this is the case, the "runcase" which is edited and run by the launcher may not be executable from a flash drive, which could explain the fact than nothing happened (we assume runcase is executable, as it is created this way, but don't check).
I tested Saturne this weekend and found some more details about blank window issue. It's not a flash drive related. It also appeared when the case and mesh was entirely on HDD. Just a minor bug somewhere, and can be worked around by clicking calculation start button again.
Issue with "invisible mesh file" didn't repeat.
Fortunately, I have debugged my "swirling" inlet functions and now they seem to work OK (attached two pictures for example). Maximum axial velocity is 5 m/s (peripheral), it lowers and becomes negative at the center (test case, profile resambling gas turbine outlet). Tangential velocity is relatively small (less than 0.7 m/s).
Sorry, cannot share the code, I do it for work (not for sell, I know about GPL) and not permitted to share.