|
[Sponsors] |
How to select some variables not to be written into files? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 21, 2013, 23:28 |
How to select some variables not to be written into files?
|
#1 |
Member
Jack
Join Date: Dec 2011
Posts: 94
Rep Power: 14 |
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 |
|
May 22, 2013, 05:18 |
|
#2 |
Senior Member
Olivier
Join Date: Jun 2009
Location: France, grenoble
Posts: 272
Rep Power: 18 |
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 |
|
May 22, 2013, 05:38 |
|
#3 | |
Senior Member
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 249
Rep Power: 17 |
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 ( IOobject ( "ExportData", runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE ) ); dimensionedScalar ExportDataThermo(IcingProperties.lookup("ExportDataThermo")); dimensionedScalar ExportDataMomentum(IcingProperties.lookup("ExportDataMomentum")); 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)) { MyField1.write(); } if((runTime.write()) && (ExportDataMomentum.value() == 1)) { MyField2.write(); } Quote:
My solution works but it is not beautiful !! It's just a quick coding |
||
May 23, 2013, 12:19 |
|
#4 | |
Member
Jack
Join Date: Dec 2011
Posts: 94
Rep Power: 14 |
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 { // Forcibly write registered objects. E.g. fields that have been // created with NO_WRITE. type writeRegisteredObject; // Where to load it from functionObjectLibs ("libIOFunctionObjects.so"); // Execute upon outputTime outputControl outputTime; // Objects to write objectNames (U T p); } |
||
May 24, 2017, 19:26 |
How to set variables to NO_WRITE
|
#5 |
New Member
JasonC
Join Date: May 2017
Posts: 2
Rep Power: 0 |
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.
|
|
March 5, 2019, 15:41 |
|
#6 | |
Senior Member
Peter Shi
Join Date: Feb 2017
Location: Davis
Posts: 102
Rep Power: 9 |
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 |
||
April 10, 2020, 09:31 |
|
#7 |
New Member
Philomène Vergnol
Join Date: Apr 2020
Posts: 11
Rep Power: 6 |
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 ? |
|
April 10, 2020, 09:50 |
|
#8 |
Senior Member
Olivier
Join Date: Jun 2009
Location: France, grenoble
Posts: 272
Rep Power: 18 |
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 { type writeObjects; libs ("libutilityFunctionObjects.so"); //writeControl writeTime; ... objects (obj1 obj2);// i.e fields you don't want writeOption noWrite;//anyWrite;autoWrite } regards, |
|
April 10, 2020, 10:31 |
|
#9 |
New Member
Philomène Vergnol
Join Date: Apr 2020
Posts: 11
Rep Power: 6 |
Hello olivierG, thank you so much for your quick and clear reply.
I added in controlDict : Code:
writeObjects1 { type writeObjects; libs ("libutilityFunctionObjects.so"); objects (rho nut alphat T.air T.water); writeOption noWrite; } Am I missing something ? |
|
April 10, 2020, 10:35 |
|
#10 |
Senior Member
Olivier
Join Date: Jun 2009
Location: France, grenoble
Posts: 272
Rep Power: 18 |
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, |
|
April 10, 2020, 11:07 |
|
#11 |
New Member
Philomène Vergnol
Join Date: Apr 2020
Posts: 11
Rep Power: 6 |
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 { writeObjects1 { type writeObjects; libs ("libutilityFunctionObjects.so"); objects (rho nut alphat alphaPhi0.water phi T.air T.water); writeOption noWrite; } writeObjects2 { type writeObjects; libs ("libutilityFunctionObjects.so"); objects (U p T alpha.water); writeOption autoWrite; } } Have a great day, Best regards |
|
April 14, 2020, 09:51 |
|
#12 |
New Member
Philomène Vergnol
Join Date: Apr 2020
Posts: 11
Rep Power: 6 |
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 { writeObjects1 { type writeObjects; libs ("libutilityFunctionObjects.so"); objects (rho nut alphat alphaPhi0.water phi T.air T.water); writeOption noWrite; writeControl adjustableRunTime; writeInterval 0.01; } writeObjects2 { type writeObjects; libs ("libutilityFunctionObjects.so"); objects (U p T alpha.water); writeOption autoWrite; writeControl adjustableRunTime; writeInterval 0.01; } } When I remove Code:
writeControl adjustableRunTime; writeInterval 0.01; 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 |
|
August 7, 2020, 12:15 |
|
#13 | |
New Member
Lucie Recurt
Join Date: Jun 2020
Posts: 17
Rep Power: 6 |
Quote:
I don't really understand how to write that.. is it possible to have an example? thank you in advance |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to open old mesh cmdb files in ANSYS CFX v13.0 ? | Sudharshani | CFX | 2 | May 12, 2013 23:13 |
Compiled library vs. inInclude Files, DSMC solver crashes after run | GPesch | OpenFOAM Programming & Development | 8 | April 18, 2013 08:17 |
How to call FORTRAN files as UDF? | Ehsan-F | Fluent UDF and Scheme Programming | 6 | September 11, 2012 12:03 |
Writing Case and Data Files Using Journal/Scheme Files | svp | Fluent UDF and Scheme Programming | 0 | April 5, 2011 12:04 |
Results saving in CFD | hawk | Main CFD Forum | 16 | July 21, 2005 21:51 |