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

Monitor Total Pressure in a running simulation using functionobjects

Register Blogs Community New Posts Updated Threads Search

Like Tree10Likes
  • 1 Post By CFD-Cat
  • 4 Post By wyldckat
  • 2 Post By CFD-Cat
  • 3 Post By AqeelAhmed168

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 22, 2013, 04:00
Default Monitor Total Pressure in a running simulation using functionobjects
  #1
New Member
 
Join Date: Oct 2012
Posts: 19
Rep Power: 13
CFD-Cat is on a distinguished road
Hi,
I'm new to Open Foam, so probably the solution of my problem will be really simple for other user but I couldn't find anything about this in the forum.
I'm running a simulation of something similar to a pipe in simpleFoam ( OpenFoam 2.2.0). I'd like to monitor the areaAverage of the total pressure on the outlet boundary as a parameter to judge when the simulation reaches a good convergence. I'm doing the same for the massflowrate with a functionobject and it works fine but when I try to do it using the new pressureTools I got this warning:


Code:
--> FOAM Warning :  
     From function probes::read() 
     in file patch/patchFieldFunctionObject/patchFieldFunctionObject.C at line 100 
     Unknown field total(p) when reading dictionary ".TotalPressureAveOutlet" 
     Can only probe registered volScalar, volVector, volSphericalTensor, volSymmTensor and volTensor fields
The simulation runs fine and it saves a folder total(p) every iterations but it doesn't calculate the areaAverage at Outlet.



this is my control dictionary function:

Code:
functions
(

  myFunctionObject    // user-defined name of function object entry
    {
        type            pressureTools;
        functionObjectLibs ("libutilityFunctionObjects.so");
    rhoRef 997; 
    pRef  101300;        
    //region          defaultRegion;       
        enabled         yes;
        //timeStart       0;
        //timeEnd         10;        
        outputControl timeStep;//outputTime;//
        outputInterval 1; // 5000;
        calcTotal   yes;
        calcCoeff   no;
    }
reloadTotalP
      {
          type        readFields;
          functionObjectLibs ("libfieldFunctionObjects.so");
          //region          defaultRegion;
          enabled         yes;
          //timeStart       0;
          //timeEnd         10;
          outputControl timeStep;//outputTime;//
          outputInterval 1; // 5000;
          fields
          (
              "total(p)"
          );
      }
 
TotalPressureAveOutlet
{
type patchAverage;
functionObjectLibs ("libsimpleFunctionObjects.so");
verbose true;
patches (outlet);
factor 1;
fields (
total(p)
);
outputControl   timeStep;
outputInterval  1;
outputControlMode timestep;
}
Thank you in advance for your help!



Ale
CFD-Cat is offline   Reply With Quote

Old   October 24, 2013, 12:15
Default
  #2
New Member
 
Join Date: Oct 2012
Posts: 19
Rep Power: 13
CFD-Cat is on a distinguished road
anybody can help me?

Did I do something wrong?
CFD-Cat is offline   Reply With Quote

Old   October 26, 2013, 07:39
Default
  #3
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings CFD-Cat,

Mmm... this looks sort-of familiar... OK, 2 details:
  1. In this part of the code:
    Code:
    TotalPressureAveOutlet
    {
    type patchAverage;
    functionObjectLibs ("libsimpleFunctionObjects.so");
    verbose true;
    patches (outlet);
    factor 1;
    fields (
    total(p)
    );
    outputControl   timeStep;
    outputInterval  1;
    outputControlMode timestep;
    }
    You should use quotes:
    Code:
    fields (
    "total(p)"
    );
    This is to avoid any other kind of interpretation.
  2. Secondly, the file name depends on several factors, as described on the Doxygen documentation: http://foam.sourceforge.net/docs/cpp...4.html#details
More specifically, I wrote about this here: http://www.cfd-online.com/Forums/ope...tml#post430031 post #4


Beyond this, I need an example case to test this for myself.

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   October 28, 2013, 05:21
Default
  #4
New Member
 
Join Date: Oct 2012
Posts: 19
Rep Power: 13
CFD-Cat is on a distinguished road
I added the quote but it gives the same error. :-(
CFD-Cat is offline   Reply With Quote

Old   November 2, 2013, 12:20
Default
  #5
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi CFD-Cat,

I finally managed to have a look into the case you sent me and it was fortunately rather simple!
A bit of a introduction - the idea behind "()" and "{}" is this:
  • The brackets "{}" are for gathering blocks of options, such as this:
    Code:
    {
    a 123;
    b 4564;
    c "word";
    }
  • The parenthesis "()" are for lists of values, such as:
    • Code:
      (1 2 3)
    • Code:
      ((0 1 2) (3 4 5))
      Which is the same as:
      Code:
      ((0 1 2) (3 4 5))
    • And the ultimate kind of list:
      Code:
      (
      {
      a 123;
      b 4564;
      c "word";
      }
      
      {
      a 534;
      b 57467;
      c "another word";
      }
      )
The reason why this didn't work:
Code:
functions
(

[...]

);
Is because lists with parenthesis cannot have a name or title. This is why "functions" should be a block list of blocks:
Code:
functions
{

[...]

};
Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   November 9, 2013, 14:43
Default
  #6
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi CFD-Cat,

To answer the question you've asked via private message, the full "functions" entry should look something like this:
Code:
functions
{

    myFunctionObject    // user-defined name of function object entry
    {
        type            pressureTools;
        functionObjectLibs ("libutilityFunctionObjects.so");
        rhoRef 997; 
        pRef  101300;        
        //region          defaultRegion;       
        enabled         yes;
        //timeStart       0;
        //timeEnd         10;        
        outputControl timeStep;//outputTime;//
        outputInterval 1; // 5000;
        calcTotal   yes;
        calcCoeff   no;
    }

    reloadTotalP
    {
        type        readFields;
        functionObjectLibs ("libfieldFunctionObjects.so");
        //region          defaultRegion;
        enabled         yes;
        //timeStart       0;
        //timeEnd         10;
        outputControl timeStep;//outputTime;//
        outputInterval 1; // 5000;
        fields
        (
          "total(p)"
        );
    }

    TotalPressureAveOutlet
    {
        type patchAverage;
        functionObjectLibs ("libsimpleFunctionObjects.so");
        verbose true;
        patches (outlet);
        factor 1;
        fields (
          "total(p)"
        );
        outputControl   timeStep;
        outputInterval  1;
        outputControlMode timestep;
    }

    massflow
    {
        type patchMassFlow;
        functionObjectLibs ("libsimpleFunctionObjects.so");
        verbose true;
        patches (outlet);
        factor 997;
        outputControl   timeStep;
        outputInterval  1;
        outputControlMode timestep;
    }
}
Notice that brackets "{}" are used for the "functions" block, and not parenthesis "()".

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   March 14, 2014, 13:23
Default
  #7
New Member
 
Join Date: Oct 2012
Posts: 19
Rep Power: 13
CFD-Cat is on a distinguished road
Hi,
I'm sorry to restart this old discussion but since when I installed OF2.2.2 instead of OF2.2.0 I'm facing a new problem with pressureTools function object.

I can't understand the reason why when i try to calculate the total(p) the output reports only the BC like if no internal field has been calculated. It I try to calculate the static(p) I got the same problem, while for the total(p)_coeff I got a field distribution(maybe wrong) even setting the pInf =0.

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.2.2                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       volScalarField;
    location    "160";
    object      total(p);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [1 -1 -2 0 0 0 0];

internalField   uniform 0;

boundaryField
{
    wall_sx
    {
        type            calculated;
        value           uniform 0;
    }
    floor
    {
        type            calculated;
        value           uniform 0;
    }
    wall_rear
    {
        type            calculated;
        value           uniform 0;
    }
    wall2
    {
        type            symmetryPlane;
    }
    inlet
    {
        type            calculated;
        value           uniform 0;
    }
    wall1
    {
        type            calculated;
        value           uniform 0;
    }
    wall_dx
    {
        type            calculated;
        value           uniform 0;
    }
    outlet
    {
        type            calculated;
        value           uniform 0;
    }
}


// ************************************************************************* //
I check if someone else found a similar problem but I wasn't able to find anything useful.

Except for this sentence that sincerely I don't understand completely:

"Where the function generates a field, e.g. wallShearStress, pressureTools, yPlusRAS, etc., the field is now stored on the mesh database so that it is available for further post-processing. " from http://www.openfoam.org/version2.2.2/
CFD-Cat is offline   Reply With Quote

Old   March 15, 2014, 02:51
Default
  #8
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi CFD-Cat,

I need more information in order to be able to help you, namely:
  1. How exactly did you configure the function objects section at "controlDict"?
  2. What type of simulation are you performing?
  3. Are you able to reproduce the error with a tutorial from OpenFOAM?
Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   March 15, 2014, 06:48
Default
  #9
New Member
 
Join Date: Oct 2012
Posts: 19
Rep Power: 13
CFD-Cat is on a distinguished road
I'm out of office. On monday I'll try the tutorial and I'll send you the file.thank you for your help
CFD-Cat is offline   Reply With Quote

Old   March 17, 2014, 04:46
Default
  #10
New Member
 
Join Date: Oct 2012
Posts: 19
Rep Power: 13
CFD-Cat is on a distinguished road
Hi wyldckat,

I reproduced it with the tutorial Tjunction. This is my controlDict

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.2.2                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

libs
(
    "libOpenFOAM.so"
    "libincompressibleTurbulenceModel.so"
    "libincompressibleRASModels.so"
);

application     pimpleFoam;

startFrom       startTime;

startTime       0;

stopAt          endTime;

endTime         1.5;

deltaT          0.001;

writeControl    adjustableRunTime;

writeInterval   0.1;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression uncompressed;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;

adjustTimeStep  yes;

maxCo           5;

functions
{
    probes
    {
        // Where to load it from
        functionObjectLibs ( "libsampling.so" );

        type            probes;

        // Name of the directory for probe data
        name            probes;

        // Write at same frequency as fields
        outputControl   outputTime;
        outputInterval  1;

        // Fields to be probed
        fields
        (
            p U
        );

        probeLocations
        (
            ( 1e-06 0 0.01 )        // at inlet
            ( 0.21 -0.20999 0.01 )  // at outlet1
            ( 0.21 0.20999 0.01 )   // at outlet2
            ( 0.21 0 0.01 )         // at central block
        );
    }
}

// ************************************************************************* //
functions
{
pressure    // user-defined name of function object entry
    {
        type            pressureTools;
        functionObjectLibs ("libutilityFunctionObjects.so");
	rhoRef 997; 
	pRef  0;        	
	//region          defaultRegion;       
        enabled         yes;
        timeStart       0;
        //timeEnd         10;        
        outputControl outputTime;
	//outputControl timeStep;//outputTime;
        //outputInterval 1; // 5000;
        calcTotal   yes;
        calcCoeff   no;
  }

pressurecoeff    // user-defined name of function object entry
    {
        type            pressureTools;
        functionObjectLibs ("libutilityFunctionObjects.so");
	rhoRef 997; 
	pRef  0;        	
	//region          defaultRegion;       
        enabled         yes;
        timeStart       0;
        //timeEnd         10;        
        outputControl outputTime;
	//outputControl timeStep;//outputTime;
        //outputInterval 1; // 5000;
        calcTotal   yes;
        calcCoeff   yes;
	pInf 0;
	UInf (1 1 1);
	rhoInf 997;
  }


reloadtotalP
      {
          type        readFields;
          functionObjectLibs ("libfieldFunctionObjects.so");
          //region          defaultRegion;
          enabled         yes;
          //timeStart       0;
          //timeEnd         10;
          outputControl outputTime;
	  //outputControl timeStep;//outputTime;//
          //outputInterval 1; // 5000;
	  outputControlMode timeStep;
          fields
          (
              "total(p)"
	  );
      }

outlet-total-pressure
    {
        type            faceSource;
        functionObjectLibs ("libfieldFunctionObjects.so");
        enabled         true;
        outputControl outputTime;
	//outputControl timeStep;
	//outputInterval  1;
	outputControlMode timeStep;
        log             true;
        valueOutput     false;
        source          patch;
        sourceName      outlet2;
        operation       areaAverage;
        //weightField        phi;        
        fields
        (
            "total(p)"
        );
    }
};
and this is the output :

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.2.2                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       volScalarField;
    location    "0.2";
    object      total(p);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [1 -1 -2 0 0 0 0];

internalField   uniform 0;

boundaryField
{
    inlet
    {
        type            calculated;
        value           uniform 0;
    }
    outlet1
    {
        type            calculated;
        value           uniform 0;
    }
    outlet2
    {
        type            calculated;
        value           uniform 0;
    }
    defaultFaces
    {
        type            calculated;
        value           uniform 0;
    }
}


// ************************************************************************* //
while the total(p)_coeff is like this:

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.2.2                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       volScalarField;
    location    "0.2";
    object      total(p)_coeff;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 0 0 0 0 0 0];

internalField   nonuniform List<scalar> 
3875
(
10.639
10.4919
10.4483
10.3811
10.313
10.2384
10.1689
10.0984
.......
)
;

boundaryField
{
    inlet
    {
        type            calculated;
        value           nonuniform List<scalar> 
25
(
10.6671
10.667
10.667
10.667
10.667
10.667

....
...
I run my case with simpleFoam too and I got the same result.

Best regards,

Ale
vsammartano likes this.
CFD-Cat is offline   Reply With Quote

Old   March 23, 2014, 15:21
Default
  #11
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Ale,

I finally managed to look into this. This should work:
Code:
pressure    // user-defined name of function object entry
    {
        type            pressureTools;
        functionObjectLibs ("libutilityFunctionObjects.so");
        rhoName    rhoInf;
        rhoInf 997; 
        pRef  0;          
  //region          defaultRegion;       
        enabled         yes;
        timeStart       0;
        //timeEnd         10;        
        outputControl outputTime;
  //outputControl timeStep;//outputTime;
        //outputInterval 1; // 5000;
        calcTotal   yes;
        calcCoeff   no;
  }
The missing details were these:
Code:
        rhoName    rhoInf;
        rhoInf 997;
"rhoRef" doesn't exist, it's "rhoInf" that should be used. And we have to indicated that the name of the field to be used for "rho" is "rhoInf", so that it knows that it should use the constant value, as there is no "rho" field.

Although a bit cryptic, this can be spotted if we look at the source code: https://github.com/OpenFOAM/OpenFOAM...reTools.C#L263
Quote:
Originally Posted by src/postProcessing/functionObjects/utilities/pressureTools/pressureTools.C
Code:
void Foam::pressureTools::read(const dictionary& dict)
{
    if (active_)
    {
        dict.readIfPresent("pName", pName_);
        dict.readIfPresent("UName", UName_);
        dict.readIfPresent("rhoName", rhoName_);

        if (rhoName_ == "rhoInf")
        {
            dict.lookup("rhoInf") >> rhoInf_;
        }

        dict.lookup("calcTotal") >> calcTotal_;
        if (calcTotal_)
        {
            dict.lookup("pRef") >> pRef_;
        }

        dict.lookup("calcCoeff") >> calcCoeff_;
        if (calcCoeff_)
        {
            dict.lookup("pInf") >> pInf_;
            dict.lookup("UInf") >> UInf_;
            dict.lookup("rhoInf") >> rhoInf_;
        }
    }
}
Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   March 24, 2014, 08:10
Default
  #12
New Member
 
Join Date: Oct 2012
Posts: 19
Rep Power: 13
CFD-Cat is on a distinguished road
Thank you very much Bruno. Now it works! I really appreciate your help.

I didn't check it because in OF2.2.0 it works fine without

Code:
 rhoName    rhoInf;
wyldckat and vsammartano like this.
CFD-Cat is offline   Reply With Quote

Old   February 23, 2019, 17:12
Default Monitor Total Pressure in a running simulation using functionobjects
  #13
New Member
 
Aqeel Ahmed
Join Date: Feb 2017
Posts: 5
Rep Power: 9
AqeelAhmed168 is on a distinguished road
For people looking for the same functionality in OpenFOAM version 6

Code:
functions
{

    totalPressureCalc
    {
        type              pressure;
        functionObjectlib ("libfieldFunctionObjects.so");
        rhoName           rhoInf;
        rhoInf            1000;
        pRef              0;
        enabled           yes;
        executeControl    timeStep;
        executeInterval   1;
        writeControl      writeTime;
        writeInterval     1;
        calcTotal         yes;
        calcCoeff         no;
    }
    
    reloadTotalP
    {
        type              readFields;
        functionObjectlib ("libfieldFunctionObjects.so");
        enabled           yes;
        executeControl    timeStep;
        executeInterval   1;
        writeControl      writeTime;
        writeInterval     1;
        fields
        (
            "total(p)"
        );
    }
    
    totalPressureAvgInlet
    {
        enabled         yes;
        type            surfaceFieldValue;
        surfaceFormat   false;
        libs            ("libfieldFunctionObjects.so");
        writeControl    timeStep;
        writeInterval   1;
        log             true;
        writeFields     false;
        regionType      patch;
        name            inlet;
        operation       areaAverage; //- options: sum, areaIntegrate
        mode            magnitude;
        fields
        (
            "total(p)"
        );
    }
    
}
AqeelAhmed168 is offline   Reply With Quote

Old   March 10, 2020, 04:06
Default
  #14
Senior Member
 
BastiL
Join Date: Mar 2009
Posts: 530
Rep Power: 20
bastil is on a distinguished road
Does anybody know how to do that in OpenFOAM-1906 and 1912? Does not seem to accept "pressure" as a function type. "unknown function type pressure"

Solved: needed to add "libfieldFunctionObjects.so" in the libs-section on top of "controlDict" to make it work.

Last edited by bastil; March 10, 2020 at 09:18.
bastil is offline   Reply With Quote

Reply

Tags
functionobjects, openfoam 2.2.0, pressuretools, totalpressure


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pressure BC for combustion chamber Giuki FLUENT 1 July 19, 2011 11:35
the role of operating pressure in flow simulation sunflower FLUENT 1 December 20, 2010 21:24
high pressure simulation mahi FLUENT 0 November 7, 2008 01:30
stagnation pressure in transient flow simulation K.S.Ravichandran Main CFD Forum 2 September 5, 2000 00:34
Hydrostatic pressure in 2-phase flow modeling (long) DS & HB Main CFD Forum 0 January 8, 2000 15:00


All times are GMT -4. The time now is 07:56.