CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Creating symbolic link instead of copy of a field? (https://www.cfd-online.com/Forums/openfoam-programming-development/95448-creating-symbolic-link-instead-copy-field.html)

chegdan December 18, 2011 18:58

Creating symbolic link instead of copy of a field?
 
hello all,

I have a domain that is quite large and have found that using symbolically linked files save a lot of space. For example, a polymesh file is 5 GB in size and rather than having a 5 GB file in each of my cases...i symbolically link my polymesh folder in these cases to the "original" polymesh folder. Is there a way to have a field when it write at a certain timestep to write a symbolic link to the original directory? This is useful when say we want to provide a velocity field to scalarTransportFoam and have U present in each timestep (so that when the solver continues it has all the info it needs). Thoughts? I can do this after the fact, but maybe people have ideas how to add another option to a solver field declaration that is ALWAYS_WRITE to ALWAYS_LINK_TO_START_TIME or something of that nature.

Cheers,

marupio December 19, 2011 13:18

Hey Dan,

Interesting idea. Definitely possible. Just looking through src/OpenFOAM/include/OSspecific.H, the command you want to use is there: ln(source, destination).

To do it properly:

1. add another member data to IOobject holding the link-to path
2. add the link-to path as a parameter for the IOobject constructors, with default to fileName::null (or whatever) so as to not break the other million instances of IOobject constructors.
3. If you want to add an enumeration option "ALWAYS_LINK_TO_START_TIME", feel free, but you could also take the non-emptiness of this linkToPath_ to indicate such. (You know, you might want to have the linkToPath read in from an inputDictionary so the user can change its behaviour).
4. Change regIOobject.write so that it performs this ln() command if linkToPath != fileName::null, right before returning osGood;

That solution requires changes to the core of OpenFOAM. You could always hack it to make it work without that, using derived classes. Create a custom derived volScalarFieldWithLinking or whatever, inherit volScalarField, give it the linkToPath, and the constructor is entirely yours to command, so just add it to the parameter list. Override the writeData() function, and just before the end, use the ln() command. You should be able to use volScalarFieldWithLinking anywhere you can normally use a volScalarField.

Hope that helps!

chegdan December 19, 2011 13:46

Dave,

Thanks for the point in the right direction. I'll give it a try and see what I get.

Thanks again.


All times are GMT -4. The time now is 03:48.