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

RunTime Functions: combining "fieldMinMax" and "surface"

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Djub

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 14, 2012, 04:16
Default RunTime Functions: combining "fieldMinMax" and "surface"
  #1
Senior Member
 
Julien
Join Date: Jun 2012
Location: France
Posts: 152
Rep Power: 13
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, 19:38
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
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, 05:26
Default
  #3
Senior Member
 
Julien
Join Date: Jun 2012
Location: France
Posts: 152
Rep Power: 13
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, 08:49
Default
  #4
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
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, 09:54
Default
  #5
Senior Member
 
Julien
Join Date: Jun 2012
Location: France
Posts: 152
Rep Power: 13
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, 11:23
Default
  #6
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
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, 12:33
Default
  #7
Senior Member
 
Julien
Join Date: Jun 2012
Location: France
Posts: 152
Rep Power: 13
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, 11:31
Default
  #8
Senior Member
 
Julien
Join Date: Jun 2012
Location: France
Posts: 152
Rep Power: 13
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

Old   December 11, 2016, 09:37
Default buoyantPimpleFoam fails with -withFunctionObjects
  #9
Member
 
a
Join Date: Oct 2014
Posts: 49
Rep Power: 11
cfd@kgp is on a distinguished road
Dear All,

I have tried to create a new field using both---1. coded functions and
2. using expressionField as given below,

I am applying this quoted text to the standard tutorial of "hotRoom" in buoyantPimpleFoam

Quote:
functions
{
compute_ptot
{
functionObjectLibs ( "libutilityFunctionObjects.so" );
type coded;
// enabled true;
redirectType ptot;
outputControl outputTime;
// outputInterval 1;
code
#{

const volVectorField& U = mesh().lookupObject<volVectorField>("U");
volScalarField mymagu
(
IOobject
(
"mymagu",
mesh().time().timeName(),
U.mesh(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mag(U)
);
mymagu.write();

#};
}

compute_ptot
{
type expressionField;
outputControl outputTime;
outputInterval 1;
fieldName ptot;
expression "(mag(U))";
autowrite true;
}
};
with following libraries

Quote:
libs (


"libsimpleSwakFunctionObjects.so"


"libswakFunctionObjects.so"


);
In both the method I can see the output files of the variables "mymagu" and "compute_ptot", but they are not readable in paraview.

I found out that when we run the application with " -withFunctionObjects " paraFoam know the new field written when I tried the same quoted text to the standard tutorial of "cylinder" in potentialFoam, I can isualize the new field in paraFoam.

But
" -withFunctionObjects " fails with buoyantPimpleFoam

Quote:
buoyantPimpleFoam -withFunctionObjects
produces following error,

Quote:


Usage: buoyantPimpleFoam [OPTIONS]
options:
-case <dir> specify alternate case directory, default is the cwd
-noFunctionObjects
do not execute functionObjects
-parallel run in parallel
-roots <(dir1 .. dirN)>
slave root directories for distributed running
-srcDoc display source code in browser
-doc display application documentation in browser
-help print the usage

Using: OpenFOAM-3.0.1 (see www.OpenFOAM.org)
Build: 3.0.1-18e358711b4e



--> FOAM FATAL ERROR:
Invalid option: -withFunctionObjects


FOAM exiting
Is this a bug in openfoam or I am making some mistake?

Please help

Thanks and regards.
cfd@kgp is offline   Reply With Quote

Old   September 10, 2017, 19:32
Default
  #10
New Member
 
Esmaeel Eftekharian
Join Date: Jan 2016
Location: Sydney, Australia
Posts: 16
Rep Power: 10
Esmaeelef is on a distinguished road
Quote:
Originally Posted by gschaider View Post
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 "(")
Hi Bernhard,

I am trying to use functionObject libraries in swak4foam to calculate some fields. I have successfully installed Openfoam 222 and the compatible version of swak4foam (https://github.com/Unofficial-Extend...-swak4Foam.git swak4Foam) on an HPC cluster. The problem is that I receive the following error while using swak4foam
"
Unknown function type expressionField

Valid functions are :

9
(
initSwakFunctionObject
partialWrite
patchProbes
probes
removeRegisteredObject
sets
surfaces
writeDictionary
writeRegisteredObject
)
"
Looking at the libraries compiled by Swak4FOAM, I found that FunctionObject is not in the list of compiled libraries, though Swak4FOAM has been correctly installed. Here is the list of compiled libraries:

libgroovyBC.so
libgroovyStandardBCs.so
libsimpleLagrangianFunctionObjects.so
libsimpleSearchableSurfaces.so
libswak4FoamParsers.so
libswakChemistryModelFunctionPlugin.so
libswakCoalCloudAdaptor.so
libswakDynamicMeshFunctionPlugin.so
libswakDynamicMesh.so
libswakFvcSchemesFunctionPlugin.so
libswakFvOptions.so
libswakLagrangianCloudSourcesFunctionPlugin.so
libswakLagrangianParser.so
libswakLocalCalculationsFunctionPlugin.so
libswakMeshQualityFunctionPlugin.so
libswakMeshWaveFunctionPlugin.so
libswakMRFFunctionPlugin.so
libswakQuantileFunctionPlugin.so
libswakRandomFunctionPlugin.so
libswakSourceFields.so
libswakSurfacesAndSetsFunctionPlugin.so
libswakThermoTurbFunctionPlugin.so
libswakTopoSources.so
libswakTransportTurbFunctionPlugin.so

Is there any specific reason why FunctionObject does not exist in the list of libraries?

Thank you in advance for your time and support.
Kind Regards
Esmaeel
Esmaeelef is offline   Reply With Quote

Old   September 11, 2017, 17:01
Default
  #11
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Esmaeelef View Post
Hi Bernhard,

I am trying to use functionObject libraries in swak4foam to calculate some fields. I have successfully installed Openfoam 222 and the compatible version of swak4foam (https://github.com/Unofficial-Extend...-swak4Foam.git swak4Foam) on an HPC cluster. The problem is that I receive the following error while using swak4foam
"
Unknown function type expressionField

Valid functions are :

9
(
initSwakFunctionObject
partialWrite
patchProbes
probes
removeRegisteredObject
sets
surfaces
writeDictionary
writeRegisteredObject
)
"
Looking at the libraries compiled by Swak4FOAM, I found that FunctionObject is not in the list of compiled libraries, though Swak4FOAM has been correctly installed. Here is the list of compiled libraries:

libgroovyBC.so
libgroovyStandardBCs.so
libsimpleLagrangianFunctionObjects.so
libsimpleSearchableSurfaces.so
libswak4FoamParsers.so
libswakChemistryModelFunctionPlugin.so
libswakCoalCloudAdaptor.so
libswakDynamicMeshFunctionPlugin.so
libswakDynamicMesh.so
libswakFvcSchemesFunctionPlugin.so
libswakFvOptions.so
libswakLagrangianCloudSourcesFunctionPlugin.so
libswakLagrangianParser.so
libswakLocalCalculationsFunctionPlugin.so
libswakMeshQualityFunctionPlugin.so
libswakMeshWaveFunctionPlugin.so
libswakMRFFunctionPlugin.so
libswakQuantileFunctionPlugin.so
libswakRandomFunctionPlugin.so
libswakSourceFields.so
libswakSurfacesAndSetsFunctionPlugin.so
libswakThermoTurbFunctionPlugin.so
libswakTopoSources.so
libswakTransportTurbFunctionPlugin.so

Is there any specific reason why FunctionObject does not exist in the list of libraries?

Thank you in advance for your time and support.
Kind Regards
Esmaeel
Have you added libswakFunctionObjects.so to the libs-list in controlDict? (BTW: I don't see that library in your list)
__________________
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   September 11, 2017, 18:12
Default
  #12
New Member
 
Esmaeel Eftekharian
Join Date: Jan 2016
Location: Sydney, Australia
Posts: 16
Rep Power: 10
Esmaeelef is on a distinguished road
Quote:
Originally Posted by gschaider View Post
Have you added libswakFunctionObjects.so to the libs-list in controlDict? (BTW: I don't see that library in your list)
Hi Bernhard,

Thanks for your response. Yes, I have added libswakFunctionObject.so to the controlDict:

libs ( "libIOFunctionObjects.so" "libOpenFOAM.so" "libgroovyBC.so" "libswakFunctionObjects.so");

Below is the list of libraries compiled after compiling swak4foam, I do not know why libswakFunctionObject is not in the list, while swak4foam was successfully compiled. Is there any way to add libswakFunctionObject to other compiled swak4foam libraries?

libgroovyBC.so
libgroovyStandardBCs.so
libsimpleLagrangianFunctionObjects.so
libsimpleSearchableSurfaces.so
libswak4FoamParsers.so
libswakChemistryModelFunctionPlugin.so
libswakCoalCloudAdaptor.so
libswakDynamicMeshFunctionPlugin.so
libswakDynamicMesh.so
libswakFvcSchemesFunctionPlugin.so
libswakFvOptions.so
libswakLagrangianCloudSourcesFunctionPlugin.so
libswakLagrangianParser.so
libswakLocalCalculationsFunctionPlugin.so
libswakMeshQualityFunctionPlugin.so
libswakMeshWaveFunctionPlugin.so
libswakMRFFunctionPlugin.so
libswakQuantileFunctionPlugin.so
libswakRandomFunctionPlugin.so
libswakSourceFields.so
libswakSurfacesAndSetsFunctionPlugin.so
libswakThermoTurbFunctionPlugin.so
libswakTopoSources.so
libswakTransportTurbFunctionPlugin.so
Esmaeelef is offline   Reply With Quote

Old   September 12, 2017, 07:15
Default
  #13
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Esmaeelef View Post
Hi Bernhard,

Thanks for your response. Yes, I have added libswakFunctionObject.so to the controlDict:

libs ( "libIOFunctionObjects.so" "libOpenFOAM.so" "libgroovyBC.so" "libswakFunctionObjects.so");

Below is the list of libraries compiled after compiling swak4foam, I do not know why libswakFunctionObject is not in the list, while swak4foam was successfully compiled. Is there any way to add libswakFunctionObject to other compiled swak4foam libraries?

libgroovyBC.so
libgroovyStandardBCs.so
libsimpleLagrangianFunctionObjects.so
libsimpleSearchableSurfaces.so
libswak4FoamParsers.so
libswakChemistryModelFunctionPlugin.so
libswakCoalCloudAdaptor.so
libswakDynamicMeshFunctionPlugin.so
libswakDynamicMesh.so
libswakFvcSchemesFunctionPlugin.so
libswakFvOptions.so
libswakLagrangianCloudSourcesFunctionPlugin.so
libswakLagrangianParser.so
libswakLocalCalculationsFunctionPlugin.so
libswakMeshQualityFunctionPlugin.so
libswakMeshWaveFunctionPlugin.so
libswakMRFFunctionPlugin.so
libswakQuantileFunctionPlugin.so
libswakRandomFunctionPlugin.so
libswakSourceFields.so
libswakSurfacesAndSetsFunctionPlugin.so
libswakThermoTurbFunctionPlugin.so
libswakTopoSources.so
libswakTransportTurbFunctionPlugin.so
There seems to be a problem with the compilation. Essential libraries like libsimpleFunctionObjects.so and libswakFunctionObjects.so are missing. Rerun Allwmake and check the output
__________________
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

Reply

Tags
extraction of a field, functionobjects


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 Off
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 19:54.