CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Averaging in channelFoam (https://www.cfd-online.com/Forums/openfoam-solving/80601-averaging-channelfoam.html)

stevenvanharen September 30, 2010 10:10

Averaging in channelFoam
 
Dear Foamers,

I am trying to start the averaging after a certain time in my simulation. Acoording to the wiki this should be possible using the keyword "after":http://openfoamwiki.net/index.php/Co...unctionObjects

However, I can not get it to work.

Here is my function in the controlDict file:

functions
{
fieldAverage1
{
type fieldAverage;
functionObjectLibs ( "libfieldFunctionObjects.so" );
cleanRestart true;
enabled true;
outputControl outputTime;
after 5/1.8e-4;//5 non-dimensional time-units for Retau=180

fields
(
U
{
mean on;
prime2Mean on;
base time;
}

p
{
mean on;
prime2Mean on;
base time;
}
);

}
}

I have tried various different syntaxes for the keyword after but every time the program starts to average immidiately. Does anyone have an idea about how to use the keyword "after" correctly?

gschaider September 30, 2010 15:33

Quote:

Originally Posted by stevenvanharen (Post 277280)
Dear Foamers,

I am trying to start the averaging after a certain time in my simulation. Acoording to the wiki this should be possible using the keyword "after":http://openfoamwiki.net/index.php/Co...unctionObjects

However, I can not get it to work.

Here is my function in the controlDict file:

functions
{
fieldAverage1
{
type fieldAverage;
functionObjectLibs ( "libfieldFunctionObjects.so" );
cleanRestart true;
enabled true;
outputControl outputTime;
after 5/1.8e-4;//5 non-dimensional time-units for Retau=180

fields
(
U
{
mean on;
prime2Mean on;
base time;
}

p
{
mean on;
prime2Mean on;
base time;
}
);

}
}

I have tried various different syntaxes for the keyword after but every time the program starts to average immidiately. Does anyone have an idea about how to use the keyword "after" correctly?

The fieldAverage-functionObject is NOT part of the simpleFunction-Objects and therefor does things differently (probably ignores "after"). One of the OF-tutorials (can'T remember which) uses it. Have a look there how it is done

stevenvanharen October 1, 2010 08:53

Ok, thanks.

I'm now trying to rebuild the library for fieldAverage so that it can use this functionality.

I will look in the simplefunction objects which function has this feature and rebuild it using that as an example.

stevenvanharen October 4, 2010 11:05

Quote:

Originally Posted by gschaider (Post 277324)
The fieldAverage-functionObject is NOT part of the simpleFunction-Objects and therefor does things differently (probably ignores "after"). One of the OF-tutorials (can'T remember which) uses it. Have a look there how it is done

Dear Bernhard,

Ok, I got it working. Mainly thanks to your source-code for simpleFunctionObject.
So thank you for that.

I have another question, how do you control the calling of the member functions from the channelFoam? In the comments you give some information about the calling of "start" and "execute". But for the fieldAverage function the channelFoam calls the "constructor", but also "execute" and "write". How can you manipulate this? For instance add a new member function to the class which is called from the solver?

Testing the "libsampling.so" library it appears that the "execute" function is not called by the solver, but only the "write" function.

Thanks in advance,

Regards,

Steven

gschaider October 5, 2010 13:41

Quote:

Originally Posted by stevenvanharen (Post 277703)
Dear Bernhard,

Ok, I got it working. Mainly thanks to your source-code for simpleFunctionObject.
So thank you for that.

I have another question, how do you control the calling of the member functions from the channelFoam? In the comments you give some information about the calling of "start" and "execute". But for the fieldAverage function the channelFoam calls the "constructor", but also "execute" and "write". How can you manipulate this? For instance add a new member function to the class which is called from the solver?

Testing the "libsampling.so" library it appears that the "execute" function is not called by the solver, but only the "write" function.

Thanks in advance,

Regards,

Steven

Hi Steve!

Just a pointer for further research:
http://foam.sourceforge.net/doc/Doxy...2ab372ca5c257b
execute of all functionObjects get called whenever the time is increased. write is not in the interface of the functionObject http://foam.sourceforge.net/doc/Doxy...ionObject.html but a speciality of the simpleFunctionObjects

You can add any member function to your subclass, but only those in the standard-interface will be called at special times. So your own methods must be called from one of those. Not much you can do about it without rewritting the Time-class (which I wouldn'T advise)

Bernhard

stevenvanharen October 6, 2010 09:04

Quote:

Originally Posted by gschaider (Post 277933)
Hi Steve!

Just a pointer for further research:
http://foam.sourceforge.net/doc/Doxy...2ab372ca5c257b
execute of all functionObjects get called whenever the time is increased. write is not in the interface of the functionObject http://foam.sourceforge.net/doc/Doxy...ionObject.html but a speciality of the simpleFunctionObjects

You can add any member function to your subclass, but only those in the standard-interface will be called at special times. So your own methods must be called from one of those. Not much you can do about it without rewritting the Time-class (which I wouldn'T advise)

Bernhard

Ok, thanks! Indeed found the call to execute in the time class. Now at least I am sure about what is going on.

Thank you very much for your help!

Regards,

Steven


All times are GMT -4. The time now is 14:45.