CFD Online Discussion Forums

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

Djub December 14, 2012 04: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 19: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 05: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 08: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 09: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 11: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 12: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 11: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!

cfd@kgp December 11, 2016 09:37

buoyantPimpleFoam fails with -withFunctionObjects
 
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?:eek:

Please help :(:confused:

Thanks and regards.

Esmaeelef September 10, 2017 19:32

Quote:

Originally Posted by gschaider (Post 403161)
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

gschaider September 11, 2017 17:01

Quote:

Originally Posted by Esmaeelef (Post 663868)
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)

Esmaeelef September 11, 2017 18:12

Quote:

Originally Posted by gschaider (Post 664014)
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

gschaider September 12, 2017 07:15

Quote:

Originally Posted by Esmaeelef (Post 664021)
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


All times are GMT -4. The time now is 15:36.