CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

How to select some variables not to be written into files?

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree5Likes
  • 3 Post By olivierG
  • 2 Post By ripperjack

Reply
 
LinkBack Thread Tools Display Modes
Old   May 21, 2013, 22:28
Default How to select some variables not to be written into files?
  #1
Member
 
Ping
Join Date: Dec 2011
Posts: 63
Rep Power: 5
ripperjack is on a distinguished road
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
ripperjack is offline   Reply With Quote

Old   May 22, 2013, 04:18
Default
  #2
Senior Member
 
Olivier
Join Date: Jun 2009
Location: France, grenoble
Posts: 237
Rep Power: 9
olivierG is on a distinguished road
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
fumiya, ripperjack and mgg like this.
olivierG is offline   Reply With Quote

Old   May 22, 2013, 04:38
Default
  #3
Senior Member
 
HECKMANN Frédéric
Join Date: Jul 2010
Posts: 236
Rep Power: 8
fredo490 is on a distinguished road
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"));
2) Set your fields as NO_WRITE

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();
	}
4) In you case, you need to add a new file in the Constant folder. This file has to take the name of your library (ExportData in this case) and put the following code inside:
Quote:
ExportDataThermo ExportDataThermo[ 0 0 0 0 0 0 0 ] 1;
ExportDataMomentum ExportDataMomentum[ 0 0 0 0 0 0 0 ] 0;


My solution works but it is not beautiful !! It's just a quick coding
fredo490 is offline   Reply With Quote

Old   May 23, 2013, 11:19
Default
  #4
Member
 
Ping
Join Date: Dec 2011
Posts: 63
Rep Power: 5
ripperjack is on a distinguished road
Quote:
Originally Posted by fredo490 View Post
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"));
2) Set your fields as NO_WRITE

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();
	}
4) In you case, you need to add a new file in the Constant folder. This file has to take the name of your library (ExportData in this case) and put the following code inside:




My solution works but it is not beautiful !! It's just a quick coding


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);
    }
nimasam and vbnhfylbh like this.
ripperjack is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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 22:13
Compiled library vs. inInclude Files, DSMC solver crashes after run GPesch OpenFOAM Programming & Development 8 April 18, 2013 07:17
How to call FORTRAN files as UDF? Ehsan-F Fluent UDF and Scheme Programming 6 September 11, 2012 11:03
Writing Case and Data Files Using Journal/Scheme Files svp Fluent UDF and Scheme Programming 0 April 5, 2011 11:04
Results saving in CFD hawk Main CFD Forum 16 July 21, 2005 20:51


All times are GMT -4. The time now is 23:27.