CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (http://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   RunTime Functions: combining "fieldMinMax" and "surface" (http://www.cfd-online.com/Forums/openfoam-post-processing/110564-runtime-functions-combining-fieldminmax-surface.html)

Djub December 14, 2012 05:16

RunTime Functions: combining "fieldMinMax" and "surface"
 
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

gschaider December 23, 2012 20:38

Quote:

Originally Posted by Djub (Post 397492)
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

Djub January 21, 2013 06:26

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?

gschaider January 21, 2013 09:49

Quote:

Originally Posted by Djub (Post 403071)
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).

Djub January 21, 2013 10:54

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?

gschaider January 21, 2013 12:23

Quote:

Originally Posted by Djub (Post 403136)
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 "(")

Djub January 21, 2013 13:33

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 February 11, 2013 12:31

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!


All times are GMT -4. The time now is 10:05.