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

[swak4Foam] Error using patchAverage from swak4Foam

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By gschaider
  • 1 Post By marluc
  • 1 Post By gschaider

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 8, 2014, 18:59
Default Error using patchAverage from swak4Foam
  #1
Member
 
Luca
Join Date: Mar 2011
Location: Italy
Posts: 62
Rep Power: 15
marluc is on a distinguished road
Dear all,

I want to write the an average field on two patches, namely inlet and outlet of a duct, using the functionObject patchAverage from swak4Foam.

The code I entered in controlDict file is the foloowing:
Code:
velAreaWeightAvg
       {
        type patchAverage;
        verbose true;
         fields
           (
               Uz
           );
         patches
           (
            inlet
             outlet
           );
         factor 1.0;
         outputControlMode   outputTime;
         outputInterval    1;
         allowCoupled true; // because the patches are cyclic coupled
       }
I always get the following warning message, independently from the field I want to average, and neither is a file written into the corresponding directory nor do I get printed values on the screen:
Code:
--> FOAM Warning : 
    From function probes::read()
    in file patch/patchFieldFunctionObject/patchFieldFunctionObject.C at line 100
    Unknown field Uz when reading dictionary ".patchAverage"
    Can only probe registered volScalar, volVector, volSphericalTensor, volSymmTensor and volTensor fields

Time = 17000
    Operating in no-flow mode; no models will be loaded. All vol, surface and point fields will be loaded.
Reading volScalarField Uz
Reading volScalarField Uy
Reading volScalarField nut
Reading volScalarField Ux
Reading volScalarField p
Reading volScalarField k
Reading volScalarField epsilon
Reading volVectorField wallShearStress
Reading volVectorField U
Reading surfaceScalarField phi
Could you please explain me my (probably stupid) mistake?

Thank you in advance,
Luca
marluc is offline   Reply With Quote

Old   June 9, 2014, 06:27
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 marluc View Post
Dear all,

I want to write the an average field on two patches, namely inlet and outlet of a duct, using the functionObject patchAverage from swak4Foam.

The code I entered in controlDict file is the foloowing:
Code:
velAreaWeightAvg
       {
        type patchAverage;
        verbose true;
         fields
           (
               Uz
           );
         patches
           (
            inlet
             outlet
           );
         factor 1.0;
         outputControlMode   outputTime;
         outputInterval    1;
         allowCoupled true; // because the patches are cyclic coupled
       }
I always get the following warning message, independently from the field I want to average, and neither is a file written into the corresponding directory nor do I get printed values on the screen:
Code:
--> FOAM Warning : 
    From function probes::read()
    in file patch/patchFieldFunctionObject/patchFieldFunctionObject.C at line 100
    Unknown field Uz when reading dictionary ".patchAverage"
    Can only probe registered volScalar, volVector, volSphericalTensor, volSymmTensor and volTensor fields

Time = 17000
    Operating in no-flow mode; no models will be loaded. All vol, surface and point fields will be loaded.
Reading volScalarField Uz
Reading volScalarField Uy
Reading volScalarField nut
Reading volScalarField Ux
Reading volScalarField p
Reading volScalarField k
Reading volScalarField epsilon
Reading volVectorField wallShearStress
Reading volVectorField U
Reading surfaceScalarField phi
Could you please explain me my (probably stupid) mistake?

Thank you in advance,
Luca
Which utility are you using? The problem is that at the time of construction/reading of the functionObject the field is not present in memory. The swak-utilities replayTransientBC and funkyPythonPostproc offer for that situation a entry "preloadFields" to make sure that the fields are in memory when the functionObjects are loaded.
__________________
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   June 9, 2014, 07:58
Default
  #3
Member
 
Luca
Join Date: Mar 2011
Location: Italy
Posts: 62
Rep Power: 15
marluc is on a distinguished road
Dear Bernhard,

first of all thank you very much for your quick reply.

I want to obtain an area weighted average value of some variables and therefore I opted for patchAverage from libSimpleFunctionObjects, as described at the following link:
http://openfoamwiki.net/index.php/Co...unctionObjects

Now I managed to solve the problem using the following code:
Code:
velAvg2
    {
        type patchExpression;
        variables 
            ( "UzAvg{patch'inlet}=sum(Uz*area())/sum(area());" );
        accumulations (
           min
           max
        );
        patches (
            inlet
        );
        expression "UzAvg";
        verbose true;
        allowCoupled true;
    }
I derived the above procedure from here: http://openfoamwiki.net/index.php/Co...sureDifference

Could you please make an example of how using the replayTransientBC and/or funkyPythonPostproc to "preload" the necessary fields for my problem?

Thank you very much in advance.
Luca

P.S. I forgot to point out that I installed swak4Foam for OF 2.3.0
marluc is offline   Reply With Quote

Old   June 9, 2014, 09:34
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 marluc View Post
Dear Bernhard,

first of all thank you very much for your quick reply.

I want to obtain an area weighted average value of some variables and therefore I opted for patchAverage from libSimpleFunctionObjects, as described at the following link:
http://openfoamwiki.net/index.php/Co...unctionObjects

Now I managed to solve the problem using the following code:
Code:
velAvg2
    {
        type patchExpression;
        variables 
            ( "UzAvg{patch'inlet}=sum(Uz*area())/sum(area());" );
        accumulations (
           min
           max
        );
        patches (
            inlet
        );
        expression "UzAvg";
        verbose true;
        allowCoupled true;
    }
I derived the above procedure from here: http://openfoamwiki.net/index.php/Co...sureDifference

Could you please make an example of how using the replayTransientBC and/or funkyPythonPostproc to "preload" the necessary fields for my problem?

Thank you very much in advance.
Luca

P.S. I forgot to point out that I installed swak4Foam for OF 2.3.0
OK. But before we go on: WHICH utility/solver do you use? You only give inputs and part of the output but leave us in the dark about that. functionObjects live in the context of a solver and without that context everything is guesswork.
namsivag likes this.
__________________
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   June 9, 2014, 09:49
Default
  #5
Member
 
Luca
Join Date: Mar 2011
Location: Italy
Posts: 62
Rep Power: 15
marluc is on a distinguished road
Dear Bernhard,

I am sorry...you're perfectly right...I am using simpleFoam (actually a modified version that includes a constant pressure drop source term).
I use cyclic BC at the inlet and outlet patches of the duct. Here follows my controDict entries:

Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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

application     simplePeriodicP; // based entirely on simpleFoam

startFrom       startTime;

startTime       1;

stopAt          endTime;

endTime         20000;

deltaT          1;

writeControl    timeStep;

writeInterval   5;

purgeWrite      5;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;

functions
(   
       patchAverage
       {
        type patchAverage;
        verbose true;
         fields
           ( Uz );
         patches
           (
            inlet
            outlet
           );
         factor 1.0;
         outputControlMode   outputTime;
         outputInterval    1;
         allowCoupled true;
       }
);
Thank again for your help.
Luca
namsivag likes this.
marluc is offline   Reply With Quote

Old   June 10, 2014, 15:41
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 marluc View Post
Dear Bernhard,

I am sorry...you're perfectly right...I am using simpleFoam (actually a modified version that includes a constant pressure drop source term).
I use cyclic BC at the inlet and outlet patches of the duct. Here follows my controDict entries:

Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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

application     simplePeriodicP; // based entirely on simpleFoam

startFrom       startTime;

startTime       1;

stopAt          endTime;

endTime         20000;

deltaT          1;

writeControl    timeStep;

writeInterval   5;

purgeWrite      5;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;

functions
(   
       patchAverage
       {
        type patchAverage;
        verbose true;
         fields
           ( Uz );
         patches
           (
            inlet
            outlet
           );
         factor 1.0;
         outputControlMode   outputTime;
         outputInterval    1;
         allowCoupled true;
       }
);
Thank again for your help.
Luca
Uz is something you added in that modified solver. My guess ist the following: You added that field AFTER the time-loop is started. That's why one finds it and the other doesn't. The order of things is the following

1. usual fields are created in createFields.H
2. time-loop starts. The functionObjects are initialized. patchAverage doesn't find Uz in memory and removes it from the list (warning)
3. Uz gets created (or read)
4. Usual time-step calculations
5. patchExpression is evaluated. It finds Uz in memory and therefor produces a result
namsivag likes this.
__________________
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


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
InterDyMFoam+simpleFunctionObject Elham OpenFOAM Running, Solving & CFD 5 July 10, 2017 12:59
source term in near wall cell rajcfd OpenFOAM Pre-Processing 5 February 1, 2016 11:31
[swak4Foam] Install swak4Foam on OpenFOAM1.7.1 on Ubuntu 13.04 kobayashi OpenFOAM Community Contributions 2 January 5, 2014 18:33
[swak4Foam] Unknown function patchAverage in swak4Foam (Control Dict) franzi_ OpenFOAM Community Contributions 17 December 1, 2013 14:53
[swak4Foam] fails in parallel with -otherTime? Phicau OpenFOAM Community Contributions 3 June 26, 2013 14:00


All times are GMT -4. The time now is 01:21.