CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Post-Processing

RunTime Functions: combining "fieldMinMax" and "surface"

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

Like Tree1Likes
  • 1 Post By Djub

Reply
 
LinkBack Thread Tools Display Modes
Old   December 14, 2012, 05:16
Default RunTime Functions: combining "fieldMinMax" and "surface"
  #1
Senior Member
 
Julien
Join Date: Jun 2012
Location: France
Posts: 153
Rep Power: 5
Djub is on a distinguished road
Hi dear community,

I want to extract from a large unsteady calculation some data, but focusing only on a part of my domain.
So I use the "surfaces" function in my controldict:
Code:
functions {
p_Maison    {
        type surfaces;
        functionObjectLibs ("libsampling.so");
        enabled         true;
        outputControl   timeStep;
        interpolationScheme cellPoint;
        surfaceFormat vtk;
        fields        (      p        );
        surfaces        (
            P_bati            {
                type            patch;
                patches         ( batiment_patch0 );
                interpolate     true;
                triangulate     false;
            }
        );
    }
}
First quesiton: I am quite surprised, because my case works fine, but the official website http://www.openfoam.com/features/run...processing.php does not mention this type ! Is this the same as sampledPatch ?

I want also to isolate the extreme values of this field. I know a bit about the fieldMinMax function.

Second question: I tried from the $FOAM_TUTORIAL folder the Linux command:
Code:
grep -r 'fieldMinMax'
But with no succes (when " grep -r 'fieldAverage' " works...) ! Where to find help about the fieldMinMax function ? More specirfically, what are the necessary entries in the subdictionary ?

Third question: how to combine these two functions ? More precisely, I want to have the min and max values of a given field (here, P) but only on one patch of my calculation. Is it possible to do this?

Thanks a lot for your help

Djub
mm.abdollahzadeh likes this.
Djub is offline   Reply With Quote

Old   December 23, 2012, 20:38
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,912
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Djub View Post
Hi dear community,

I want to extract from a large unsteady calculation some data, but focusing only on a part of my domain.
So I use the "surfaces" function in my controldict:
Code:
functions {
p_Maison    {
        type surfaces;
        functionObjectLibs ("libsampling.so");
        enabled         true;
        outputControl   timeStep;
        interpolationScheme cellPoint;
        surfaceFormat vtk;
        fields        (      p        );
        surfaces        (
            P_bati            {
                type            patch;
                patches         ( batiment_patch0 );
                interpolate     true;
                triangulate     false;
            }
        );
    }
}
First quesiton: I am quite surprised, because my case works fine, but the official website http://www.openfoam.com/features/run...processing.php does not mention this type ! Is this the same as sampledPatch ?

I want also to isolate the extreme values of this field. I know a bit about the fieldMinMax function.

Second question: I tried from the $FOAM_TUTORIAL folder the Linux command:
Code:
grep -r 'fieldMinMax'
But with no succes (when " grep -r 'fieldAverage' " works...) ! Where to find help about the fieldMinMax function ? More specirfically, what are the necessary entries in the subdictionary ?

Third question: how to combine these two functions ? More precisely, I want to have the min and max values of a given field (here, P) but only on one patch of my calculation. Is it possible to do this?

Thanks a lot for your help

Djub
@third question: there is always this annoying little voice here on the message board that says "swak4Foam may be the answer". That's be me ... the voice

@second question: one good strategy to find out which parameters are required is to not give any. Then one after one give them to OF until it stops complaining
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   January 21, 2013, 06:26
Default
  #3
Senior Member
 
Julien
Join Date: Jun 2012
Location: France
Posts: 153
Rep Power: 5
Djub is on a distinguished road
Hi!
I was mistaken with the fieldMinMax function: it gives the extreme value of one field. But I didnot want these values: I am looking for a field of min/max values in time. Saying, for a transient analysis, I would like the two fields Fm dans FM that gives:

for all space point (x,y,z), for all time t, Fm(x,y,z) < F(x,y,z,t) < FM(x,y,z)

These fields represent, for each location, the extreme values in time.

For the moment, I can do this by writing each time step on the hard drive, and then, read them (with MatLab) and calculate the extreme values. But this solution is quite heavy and "expensive" in terms of space disk. I thought it could be possible to calculate these two fields "inline", keeping only the currents field and the two extreme fields.

Any ideas?
Djub is offline   Reply With Quote

Old   January 21, 2013, 09:49
Default
  #4
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,912
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Djub View Post
Hi!
I was mistaken with the fieldMinMax function: it gives the extreme value of one field. But I didnot want these values: I am looking for a field of min/max values in time. Saying, for a transient analysis, I would like the two fields Fm dans FM that gives:

for all space point (x,y,z), for all time t, Fm(x,y,z) < F(x,y,z,t) < FM(x,y,z)

These fields represent, for each location, the extreme values in time.

For the moment, I can do this by writing each time step on the hard drive, and then, read them (with MatLab) and calculate the extreme values. But this solution is quite heavy and "expensive" in terms of space disk. I thought it could be possible to calculate these two fields "inline", keeping only the currents field and the two extreme fields.

Any ideas?
Yep ... swak4Foam. The expressionField together with the stored-variables feature. Add this function object:
Code:
calcMin {
   type expressionField;
   fieldName FMin;
   outputControl timeStep;
   outputInterval 1;
   expression "storedMin";
   autowrite true;
   variables (
       "storedMin=min(storedMin,F);"
   );
   storedVariables(
     {
       name storedMin;
       initialValue "1e20";
     }
   );
}
This writes a Field FMin. The value is calculated from the minimum until now. Declaring storedMin as a stored variable makes sure that the value until now is not forgotten (the min-expression wouldn't evaluate without that anyway).
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   January 21, 2013, 10:54
Default
  #5
Senior Member
 
Julien
Join Date: Jun 2012
Location: France
Posts: 153
Rep Power: 5
Djub is on a distinguished road
Hi Bernhard ,
thanks for quick reply. I added the libraries in my controldict, and I put your instructions within my functions { ... } . My controlDict looks like:
Code:
...
libs (       
      "libOpenFOAM.so"
      "libsimpleSwakFunctionObjects.so"
      "libswakFunctionObjects.so"
      "libgroovyBC.so"
    );
 
functions
{
    calcMin {
        type     expressionField;
        fieldName    FMin;
        outputControl   timeStep;
        outputInterval    1;
        expression     "storedMin";
        autowrite true;
        variables (    "storedMin=min(storedMin,F);"   );
        storedVariables(
           { name storedMin;
            initialValue "1e20";     
           }    // line 77
        ); 
    }
 
    speed {
        type probes; 
...
But Foam crashes. First a warning:
PHP Code:
From function entry::getKeyword(keyType&, Istream&)
    
in file db/dictionary/entry/entryIO.C at line 77
    Reading 
/home/julien/OpenFOAM/julien-2.1.x/run/Mur/processor0/../system/controlDict
    found on line 78 the punctuation token 
')'
    
expected either } or EOF 
and then an error:
PHP Code:
[7] --> FOAM FATAL ERROR
[
7Unknown function type expressionField
Table of functionObjects is 
empty 
Sorry for this mistake: I think it is a stupid typing error, but I don't see it! What did I make wrong?
Djub is offline   Reply With Quote

Old   January 21, 2013, 12:23
Default
  #6
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,912
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Djub View Post
Hi Bernhard ,
thanks for quick reply. I added the libraries in my controldict, and I put your instructions within my functions { ... } . My controlDict looks like:
Code:
...
libs (       
      "libOpenFOAM.so"
      "libsimpleSwakFunctionObjects.so"
      "libswakFunctionObjects.so"
      "libgroovyBC.so"
    );
 
functions
{
    calcMin {
        type     expressionField;
        fieldName    FMin;
        outputControl   timeStep;
        outputInterval    1;
        expression     "storedMin";
        autowrite true;
        variables (    "storedMin=min(storedMin,F);"   );
        storedVariables(
           { name storedMin;
            initialValue "1e20";     
           }    // line 77
        ); 
    }
 
    speed {
        type probes; 
...
But Foam crashes. First a warning:
PHP Code:
From function entry::getKeyword(keyType&, Istream&)
    
in file db/dictionary/entry/entryIO.C at line 77
    Reading 
/home/julien/OpenFOAM/julien-2.1.x/run/Mur/processor0/../system/controlDict
    found on line 78 the punctuation token 
')'
    
expected either } or EOF 
and then an error:
PHP Code:
[7] --> FOAM FATAL ERROR
[
7Unknown function type expressionField
Table of functionObjects is 
empty 
Sorry for this mistake: I think it is a stupid typing error, but I don't see it! What did I make wrong?
I should have added the disclaimer "typed this from the top of my memory. There may be typos". There should have been a space between "storedVariables" and "(". For OF "(" can be a valid component of a name (contrary what we're used to from C++) that's why the parser is confused when he encounters a ")" (because he "swa" no single "(")
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   January 21, 2013, 13:33
Default
  #7
Senior Member
 
Julien
Join Date: Jun 2012
Location: France
Posts: 153
Rep Power: 5
Djub is on a distinguished road
It is OK now for the warning, but the error is still there...

OH No! I realize I changed my computer! So I do not have installed swak4foam.

And again I have errors while compiling... (cf http://www.cfd-online.com/Forums/openfoam/103279-contrib-swak4foam.html#post367473)

I am working with GeekoCFD (http://susestudio.com/a/2qtLK2/geekocfd) and I thought sawk4Foam was allready installed...

Tomorrow I will try to fallow my own installation explainations...
Djub is offline   Reply With Quote

Old   February 11, 2013, 12:31
Default
  #8
Senior Member
 
Julien
Join Date: Jun 2012
Location: France
Posts: 153
Rep Power: 5
Djub is on a distinguished road
Hi Bernard,

1/ Finally, the use of swak4foam was very easy and quite straitforward. I did not had to modify nothing; it worked well on his own.

2/ Wonderfull! I can see my fields pmin and pmax changing in time. I suppose now I can use the sample utility on those two fields to restrict the field on focus the attention only in my patch.

Thanks a lot! I knew that swak4foam was awesome , know I know it will save me hours of coding!

Simple, efficient, clear: bravo to swak4foam!
Djub is offline   Reply With Quote

Reply

Tags
extraction of a field, functionobjects

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



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