How to select some variables not to be written into files?
Hi all,
I have defined so many variables in my solver and my mesh number is really huge, so I do not want to write some of my variables into output files. I know I can do this by setting the variables output option to NO_WRITE instead of AUTO_WRITE. But I do not want to modify my solver because sometime I want them to be written and sometime not to. So is there any other ways that I can do this? e.g. by add some lines in controlDict or other files. Many thanks! Ping |
hello,
If you are using 2.1 or later (not sure for older one), you can set to NO_WRITE almost all the variable, then using function Objects in controlDict, you can use the "writeRegisteredObject" to write the variable you want. regards, olivier |
Hello, I've done somthing similar to your request but it is a very simple/quick solution that doesn't look good:
1) create a library in the createFields and some "debug" variables: Code:
IOdictionary ExportData 3) In your code (at the end of your time loop for example) add: if the time step correspond to the writing time (= export of your case) and if your debut variable equal 1, then write the field "MyField1" and "MyField2". Code:
if((runTime.write()) && (ExportDataThermo.value() == 1)) Quote:
My solution works but it is not beautiful !! It's just a quick coding |
Quote:
Hi HECKMANN, Thanks very much for your code! I have tried the method suggestion by Olivier, it works and it is also simple to do it. I just need to set the all variables to NO_WRITE, and add the following lines in the controlDict to output the ones I need! Thanks anyway! Code:
dumpObjects |
How to set variables to NO_WRITE
I see in the process described above they suggest setting variables to NO_WRITE. Where do I do that? I don't see that option (or AUTO_WRITE) in any of my setup files for OpenFOAM, so do I need to create a new file in the system directory? I get how to then write the files by adding an object to my controlDict file... just now how to turn off writing them in the first place.
|
Quote:
It has been a while, but I wonder when you replace AUTO_WRITE with NO_WRITE, did you recompile your solver? For me, I am using OpenFOAM 6.0, I made modifications in createFields.H, and I added lines in controlDict. However, the code still outputs all variables for me. I feel like I need to recompile it to make it work. Also, in createFields.H, I only see p and U, but I have turbulent variables such as omega and nut, is replacing AUTO_WRITE with NO_WRITE for p and U enough to prevent those turbulent variables from being written as well? Thank you so much, and I really appreciate it. Best, Peter |
Hello, I have the exact same problem. Did you solve it ?
I am currently going through all .H files trying to find where I can change to NO_WRITE for the variables I want to stop writing. I think I have to recompile after having done all that. Can someone confirm ? |
Hello,
Don't change aAUTO_WRITE to NO_WRITE in core, or you should recomplie it. Simpler way is tu use function Object "writeObjects, like: Code:
writeObjects1 regards, |
Hello olivierG, thank you so much for your quick and clear reply.
I added in controlDict : Code:
writeObjects1 Am I missing something ? |
Hello,
Which OF version do you use ? (i.e writeObjects compatible ?) with this function, you could do the opposite: in controlDict, set writeInterval to something big, then use writeObjects to write fields when you want. Regards, |
Hello,
I use OpenFOAM v7, and I saw here : https://cfd.direct/openfoam/user-gui...processing-cli/ that it is indeed compatible. Actually, I forgot before to write the functions keyword at first, that's why it didn't work. With the writeObjects function, it does work, only it removes all of the fields, even the ones I wanted to keep. So I added a second function such that my controlDict is now : Code:
functions Have a great day, Best regards :) |
Hello,
I have a follow-up question : So with this solution I managed to write only the fields I wanted to write. But to reduce the total output size, I want to reduce the writing frequency. I tried changing writeControl in controlDict using adjustableRunTime (I use adjustTimeStep)but it has no effect : they are still written. So I figured I had to change this parameter within the functions : Code:
functions When I remove Code:
writeControl adjustableRunTime; I can't seem to be able to write the fields I want at the frequency I want. Does someone know how to make this work ? Thank you in advance |
Quote:
I don't really understand how to write that.. is it possible to have an example? thank you in advance |
All times are GMT -4. The time now is 16:25. |