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

[swak4Foam] PostProcessing for finished calculation

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By CFDelix
  • 2 Post By CFDelix

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 8, 2017, 03:04
Default PostProcessing for finished calculation
  #1
New Member
 
Felix S
Join Date: Jun 2017
Posts: 11
Rep Power: 8
CFDelix is on a distinguished road
Hi All,

I am wondering if it is possible to use the swak4Foam functionality for an already finished simulation.

I defined this Testfunction in my controlDict:

Code:
functions
{
    Testfunction
    {
        type swakExpression;
        valueType patch;
        patchName interface_name;
        outputControlMode outputTime;
        variables
        (
             "Profil=sum(sqrt(pow(U.x*area(),2)+pow(U.y*area(),2)+pow((U.z-4.5129)*area(),2)))/sum(area());"
        );
        accumulations ( average );
        expression "Profil";
        verbose true;
        writeStartTime no;
        autoInterpolate true;
        warnAutoInterpolate false;
        outputInterval 5000;
    }    
}
It works while the simulation in running (for outputControlMode timeStep and outputInterval 1).

Now I want to change the "Profil"-function and since I am only interested in the converged solution I only need to evaluate the function for my last timestep (5000).

1) Is there a way I can use the postProcess utility with swak4foam?

Code:
postProcess -fields '(U p)' -time 5000
results in no errors and creates a postProcessing/swakExpression_Testfunction/5000 folder which contains an empty file.

2) Is there a way I can use the sample utility with swak4foam?

When I create a sampleDict with the function "Testfunction" (+ adding "libs ("libsampling.so");") and use
Code:
postProcess -func sampleDict
I get this error
Code:
keyword type is undefined in dictionary ".functions.sampleDict"
3) I might have totally misunderstood the postProcess utility since for a different function

Code:
    Testfunction2
    {
        type expressionField;
        outputInterval 5000;
  pName p;
  Uname U;
        variables
        (
             "BM=0;"
             "XM=pos().x+BM;"
             "thetaAngle=(XM!=0) ? acos(XM/sqrt(pow(XM,2)+pow(pos().y,2)))*pos().y/mag(pos().y) : ((pos().y>0) ? 0 : 3.1416);"
        );
        fieldName Test;
        dimension [0 1 -1 0 0 0 0];
        expression "-U.x*sin(thetaAngle)+U.y*cos(thetaAngle)";
        autowrite true;
    }
is resulting in another error
Code:
Parser Error for driver FieldValueExpressionDriver at "1.2" :"field U not existing or of wrong type"
Thanks for your replies!
CFDelix is offline   Reply With Quote

Old   December 21, 2017, 08:19
Default Problem solved by funkyDoCalc
  #2
New Member
 
Felix S
Join Date: Jun 2017
Posts: 11
Rep Power: 8
CFDelix is on a distinguished road
Seems like I didn't read enough before asking...

Maybe it is still usefull to somebody else :

The funkyDoCalc utility does exactly what I was looking for.
Thanks to: http://openfoamwiki.net/images/2/2a/...esentation.pdf (page 111) and https://www.cfd-online.com/Forums/op...nkydocalc.html


Create a i.e. "postDict" (file like
Code:
Testfunction
    {
        type swakExpression;
        valueType patch;
        patchName interface_name;
        variables
        (
             "Profil=sum(sqrt(pow(U.x*area(),2)+pow(U.y*area(),2)+pow((U.z-4.5129)*area(),2)))/sum(area());"
        );
        accumulations ( average );
        expression "Profil";
        verbose true;
        writeStartTime no;
        autoInterpolate true;
        warnAutoInterpolate false;
        autowrite true;
    }
and then execute
Code:
funkyDoCalc -time 5000: postDict -writeCsv
I am still not sure why expressionFields are not evaluated by this method.

And I am still confused why the "postProcess" utility isn't doing the same jobs. In the post I mentioned above the "execFlowFunctionObjects" command is described as doing nearly the same, but for my OF version (2.0) it says that
Code:
execFlowFunctionObjects has been superseded by the '-postProcess' solver command-line option, e.g.
simpleFoam -help -postProcess
so I couldn't test it.

Not all questions answered, but that is all I need for my case at the moment.
sourav90 likes this.
CFDelix is offline   Reply With Quote

Old   December 21, 2017, 09:05
Default Solved by funkyDoCalc
  #3
New Member
 
Felix S
Join Date: Jun 2017
Posts: 11
Rep Power: 8
CFDelix is on a distinguished road
I found a solution for my problems by the funkyDoCalc command. I probably just didn't search long enough, but maybe this helps someone else.

Solution:
http://openfoamwiki.net/images/2/2a/...esentation.pdf (page 111)

https://www.cfd-online.com/Forums/op...nkydocalc.html

I created a "postDict" file
Code:
Testfunction
{
        type swakExpression;
        valueType patch;
        patchName interface_name;        
        variables
        (
             "Profil=sum(sqrt(pow(U.x*area(),2)+pow(U.y*area(),2)+pow((U.z-4.5129)*area(),2)))/sum(area());"
        );
        accumulations ( average );
        expression "Profil";
        verbose true;
        writeStartTime no;
        autoInterpolate true;
        warnAutoInterpolate false;
        autowrite true;
}
and executed
Code:
funkyDoCalc -time 5000: postDict -writeCsv
Open questions:

I am still confused why the funkyDoCalc isn't working for expressionsFields.

I still don't understand the postProcess utilty. In the post that I mentioned above, the execFlowFunctionObjects is described and that it might help.
Problem is that in my OpenFOAM (Version 2.0) the execFlowFunctionObjects command give:
Code:
execFlowFunctionObjects has been superseded by the '-postProcess' solver command-line option, e.g.
simpleFoam -help -postProcess
My problems are solved for the moment. Hopefully it is also usefull to you!
gschaider and sourav90 like this.

Last edited by CFDelix; December 21, 2017 at 09:07. Reason: forgot something in the code
CFDelix is offline   Reply With Quote

Old   March 23, 2018, 07:43
Default funkyDoCalc error
  #4
New Member
 
Hungary (Ungarn)
Join Date: Sep 2017
Posts: 16
Rep Power: 8
miha23 is on a distinguished road
Dear Felix.

It happened, that I'm having the same issue as you, trying to use swak4Foam functions after simulation.
But in my case I am trying to use the swakExpressionAverageDistribution function.
Have you got any idea how it should look like?

What I tried this far is the following:

Function
{
type swakExpressionAverageDistribution;
libs (
"libOpenFOAM.so"
"libsimpleSwakFunctionObjects.so"
"libswakFunctionObjects.so"
"libgroovyBC.so"
);

writeStartTime no;
valueType internalField;
expression "T";
verbose true;
weight "vol()";
mask "1";
abscissa "pos().z";
dynamicExtremesAbscissa false;
minAbscissa 0;
maxAbscissa 150;
binNumber 75;
valueIfZero 0;
accumulations ( average );

}

But this turned out with an error messege which I can not solve:

--> FOAM FATAL ERROR:
The expected return type bool is different from the stored result type "scalar"



From function tmp<Field<Type> > ExpressionResult::getResult()
in file ../../Libraries/swak4FoamParsers/lnInclude/ExpressionResultI.H at line 250.

FOAM exiting

Thanks,

Gábor
miha23 is offline   Reply With Quote

Old   March 23, 2018, 08:20
Default
  #5
New Member
 
Felix S
Join Date: Jun 2017
Posts: 11
Rep Power: 8
CFDelix is on a distinguished road
The postDict file needs to be in the main (simulation) folder not within your system folder. (So that it is on the same folder level as your system folder.)

Maybe that will solve your problem.

Otherwise it would be helpful if you post your PostDict file and your folderstructure.
CFDelix is offline   Reply With Quote

Old   March 23, 2018, 08:27
Default
  #6
New Member
 
Hungary (Ungarn)
Join Date: Sep 2017
Posts: 16
Rep Power: 8
miha23 is on a distinguished road
Thanks Felix.
I have solved that problem succesfully, but on the meantime I edited the question above for an other problem which is now actual.
I would be thankfull is you could take a look at that.

Thanks,
Gábor
miha23 is offline   Reply With Quote

Old   March 23, 2018, 09:11
Default
  #7
New Member
 
Felix S
Join Date: Jun 2017
Posts: 11
Rep Power: 8
CFDelix is on a distinguished road
I haven't used swakExpressionAverageDistribution myself so I am not sure how to use it correctly.

I get the same error though.
Maybe you could use swakExpression and define your own "expression" for the averaging operation you want to do.
CFDelix is offline   Reply With Quote

Old   March 23, 2018, 09:15
Default
  #8
New Member
 
Felix S
Join Date: Jun 2017
Posts: 11
Rep Power: 8
CFDelix is on a distinguished road
Ok apparently the "mask "1";" is causing trouble.

Code:
averagePressureDistributionX {
 type swakExpressionAverageDistribution;
 verbose true;
 outputControlMode outputTime;
 valueType internalField;
 expression "p";
 weight "vol()";
 mask "p<1";
 abscissa "pos().x";
 binNumber 50;
 valueIfZero -100;
 accumulations ( max );
}
this example returns a value for my case
CFDelix is offline   Reply With Quote

Old   March 23, 2018, 13:09
Default
  #9
New Member
 
Hungary (Ungarn)
Join Date: Sep 2017
Posts: 16
Rep Power: 8
miha23 is on a distinguished road
I applied what you have suggested, and luckily I also got something as a result.
It seems like process, but as I see it correct, it is an average (or max/min) of the whole domain, and what is needed, is a list of these averages at different i.e "pos().z".
It seems like it do not handle this part:

abscissa "pos().z";
dynamicExtremesAbscissa false;
minAbscissa 0;
maxAbscissa 150;
binNumber 10;

Have you got any idea?
miha23 is offline   Reply With Quote

Old   March 26, 2018, 04:57
Default
  #10
New Member
 
Felix S
Join Date: Jun 2017
Posts: 11
Rep Power: 8
CFDelix is on a distinguished road
Since I am not familiar with swakExpressionAverageDistribution I would change the example I mentioned above for different surfaces.

You should check some examples (i.e. https://github.com/wyldckat/swak4foa...stCalculations)
One example for a surface plane:
Code:
 
surfacePlane{type swakExpression;valueType surface;surfaceName testPlane;surface {type plane;basePoint (0 0 0);normalVector (0 0 1);interpolate false;}verbose true;expression "mag(U)";accumulations (minmax);
You just need to change the expression to the average that you want to calculate, i.e.:
Code:
expression "sum(p*area())/sum(area())";
CFDelix is offline   Reply With Quote

Old   November 3, 2020, 11:45
Default
  #11
Senior Member
 
Join Date: Jul 2019
Posts: 148
Rep Power: 6
Bodo1993 is on a distinguished road
Quote:
Originally Posted by miha23 View Post
I applied what you have suggested, and luckily I also got something as a result.
It seems like process, but as I see it correct, it is an average (or max/min) of the whole domain, and what is needed, is a list of these averages at different i.e "pos().z".
It seems like it do not handle this part:

abscissa "pos().z";
dynamicExtremesAbscissa false;
minAbscissa 0;
maxAbscissa 150;
binNumber 10;

Have you got any idea?
Hi, I am wondering if you were able to resolve the issue (i.e. to output "a list of the averages at different i.e "pos().z"."). Thanks
Bodo1993 is offline   Reply With Quote

Old   November 27, 2020, 09:09
Default
  #12
Member
 
Eren
Join Date: Aug 2018
Posts: 86
Rep Power: 8
ErenC is on a distinguished road
Umm, is it possible to use funkyDoCalc for all* timeSteps? My simulation stopped due to power outage and when I restart simulation (dumb mistake, it started from timeStep 1) all my postProcess data overwriten. And It is really pain to do 1020(timesteps) "funkyDoCalc". When I use "noZero" for time, it gaves me same values for all timeSteps...


Code:
Time = 570

local :  weightedAverage=30.85399601
bulk :  weightedAverage=301.8301434


Time = 575

local:  weightedAverage=30.85399601
bulk :  weightedAverage=301.8301434

Last edited by ErenC; November 27, 2020 at 11:43.
ErenC is offline   Reply With Quote

Old   November 27, 2020, 14:12
Default
  #13
Member
 
Eren
Join Date: Aug 2018
Posts: 86
Rep Power: 8
ErenC is on a distinguished road
I also happened to realise when I use

Code:
funkyDoCalc -time '5,10,20' avgs
I get:
Code:
Time = 5
fraction : swak4Foam: Setting default mesh
swak4Foam: Allocating new repository for sampledMeshes
swak4Foam: Allocating new repository for sampledGlobalVariables
 average=0.01949977306


Time = 10
fraction :  average=0.01949977306


Time = 20
fraction :  average=0.01949977306

End
And it makes no sense to me. Those values should not be same obviously.
ErenC is offline   Reply With Quote

Old   December 13, 2020, 05:23
Default
  #14
Member
 
Eren
Join Date: Aug 2018
Posts: 86
Rep Power: 8
ErenC is on a distinguished road
@gschaider I still couldnt fix the problem in last entry. Could it be a bug for OF2006? (also -time 5:600 is giving me same values for all timesteps)

Last edited by ErenC; December 14, 2020 at 02:45.
ErenC is offline   Reply With Quote

Old   December 15, 2020, 14:31
Default
  #15
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 ErenC View Post
@gschaider I still couldnt fix the problem in last entry. Could it be a bug for OF2006? (also -time 5:600 is giving me same values for all timesteps)
Seems that the part that loads the new fields seems to be broken again



I'll have a look but don't hold your breath (end-of-year project rush etc)
__________________
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   December 16, 2020, 06:49
Default
  #16
Member
 
Eren
Join Date: Aug 2018
Posts: 86
Rep Power: 8
ErenC is on a distinguished road
Quote:
Originally Posted by gschaider View Post
Seems that the part that loads the new fields seems to be broken again



I'll have a look but don't hold your breath (end-of-year project rush etc)
Thank you! I'll be waiting in patience.
ErenC is offline   Reply With Quote

Reply

Tags
postprocessing, sampledict, swak4foam, swakexpression


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
Dynamic mesh adaption in parallel calculation xh110120 FLUENT 1 March 12, 2016 08:05
Determining the calculation sequence of the regions in multe regions calculation peterhess OpenFOAM Running, Solving & CFD 4 March 9, 2016 03:07
MRF and Heat transfer calculation Susan YU FLUENT 0 June 2, 2010 08:46
Warning 097- AB Siemens 6 November 15, 2004 04:41
Heat Flux Calculation under REPORTS Alberto Schroth FLUENT 0 May 16, 2000 08:19


All times are GMT -4. The time now is 23:13.