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

fieldAverage function object does not average over all time?

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By wyldckat

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 16, 2015, 12:25
Default fieldAverage function object does not average over all time?
  #1
Senior Member
 
Pete Bachant
Join Date: Jun 2012
Location: Boston, MA
Posts: 173
Rep Power: 13
pbachant is on a distinguished road
I am running this on my case (2.4.x pimpleDyMFoam with rotating AMI region) using execFlowFunctionObjects:

Code:
    fieldAverage1
    {
        type            fieldAverage;
        functionObjectLibs ("libfieldFunctionObjects.so");
        enabled         true;
        outputControl       timeStep;
        outputInterval      1;
        resetOnRestart  false;
        resetOnOutput   false;

        fields
        (
            U
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }
        );
    }
If I run this with the solver at run time the mean fields look reasonable, but doing this in post-processing, the mean field looks just like the instantaneous (written) fields. I've tried things like executing with -noFlow, and putting a readFields function object before the fieldAverage, but nothing seems to work.

I noticed that I get this in fieldAveragingProperties file in every time directory:

Code:
U
{
    totalIter       2;
    totalTime       0.004;
}
So it looks like it starts re-averaging each time step, rather than keeping the fields for all time. I've tried similar functionObjects with some pimpleFoam tutorials and they work fine after the case has run. I am totally stumped. What gives?
__________________
Home | Twitter | GitHub
pbachant is offline   Reply With Quote

Old   July 18, 2015, 11:51
Default
  #2
Senior Member
 
Pete Bachant
Join Date: Jun 2012
Location: Boston, MA
Posts: 173
Rep Power: 13
pbachant is on a distinguished road
I reported a bug on the OpenFOAM Mantis, and apparently this is a known issue with moving meshes. Anyone have any idea how to fix up execFlowFunctionObjects to make it work?
__________________
Home | Twitter | GitHub
pbachant is offline   Reply With Quote

Old   July 19, 2015, 14:06
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 Pete,

I see that you've got 2 reports on this topic:
If I understand you correctly, you want to do a plain average of the fields over the existing time snapshots?

In addition, do you mean that the average results for a dynamic mesh are acceptable for doing an analysis? I ask this because there are regions in the mesh that probably stop existing on a specific location in 2 different time snapshots, which makes it somewhat impossible to do an actual average of the field

On the other hand, are you trying to do an average only on the static region?


I ask all of this because from what I can remember, the averaging mechanism needs to access the previous fields in time, which are usually created by the function object itself. But the "execFlowFunctionObjects" was designed for pretty much loading each time snapshot individually, which essentially "breaks the flow".

Therefore, if you can describe the exact averaging operation you want to perform, it might be easier to create a new application that helps you do this, hence my previous questions.

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   July 19, 2015, 14:17
Default
  #4
Senior Member
 
Pete Bachant
Join Date: Jun 2012
Location: Boston, MA
Posts: 173
Rep Power: 13
pbachant is on a distinguished road
Hi Bruno,

The two bug reports are somewhat different since the second one applies to static meshes as well. I don't think the second bug will affect the results, though, since my cases are written at a constant interval.

I do want to average over a specified amount of time directories, compute some mean gradients in the static region (wrote a custom coded functionObject for this), then plane-average these (using funkyDoCalc). I was trying to avoid re-running the case since it had to be done on a cluster. I don't think the results would be terribly affected by the "downsampling" from only using written directories for computing statistics.

I got the averaging to mimic what happens if you use fieldAverage at run-time by commenting out the part that reloads the functionObjects if the mesh changes, so that gets me somewhere, but writing every time step (one of my notes on the second bug) is going to take up a lot of disk space, though I may be able to afford it.

Thanks!
__________________
Home | Twitter | GitHub
pbachant is offline   Reply With Quote

Old   July 19, 2015, 15:05
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
So... the missing detail is that you need a new function object based on "fieldAverage" that uses the actual time step taken between 2 time snapshots.
From what I can see, in the file "src/postProcessing/functionObjects/field/fieldAverage/fieldAverage.C", you need to replace all occurrences of this:
Code:
obr_.time().deltaTValue()
with ... irgh, it'll be messy to do it through here.

OK, it's easier to do this in the "applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C" code, where after this line:
Code:
runTime.setTime(timeDirs[timeI], timeI);
you can add something like this:
Code:
if(timeI>0)
{
  runTime.setDeltaT(timeDirs[timeI]-timeDirs[timeI-1]);
}
Build and hope for the best
wyldckat is offline   Reply With Quote

Old   July 19, 2015, 15:20
Default
  #6
Senior Member
 
Pete Bachant
Join Date: Jun 2012
Location: Boston, MA
Posts: 173
Rep Power: 13
pbachant is on a distinguished road
Looks like the "-" operator is not implemented for Foam::instant, so I cannot do "timeI - 1".
__________________
Home | Twitter | GitHub
pbachant is offline   Reply With Quote

Old   July 19, 2015, 15:27
Default
  #7
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
Well... then after this:
Code:
Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args);
Add this:
Code:
Foam::instant prevTimeI = timeDirs.start();
or:
Code:
Foam::instant prevTimeI = timeDirs[0];
Then in the new "if" block:
Code:
if(timeI>0)
{
  runTime.setDeltaT(timeDirs[timeI]-timeDirs[prevTimeI]);
}
And before the end of the "forAll" loop:
Code:
prevTimeI = timeI;
wyldckat is offline   Reply With Quote

Old   July 19, 2015, 21:04
Default
  #8
Senior Member
 
Pete Bachant
Join Date: Jun 2012
Location: Boston, MA
Posts: 173
Rep Power: 13
pbachant is on a distinguished road
That didn't quite work, but I got things going by creating a new Time object for the previous time: https://github.com/petebachant/OpenF...5ddee3dfb676e8

However, the outputControl of the fieldAverage is still not working correctly when used in post-processing. I may be able to deal with this so long as I don't run out of disk space.
__________________
Home | Twitter | GitHub
pbachant is offline   Reply With Quote

Old   August 16, 2015, 18:16
Default
  #9
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 Pete,

I was curious about this and this on my to-do list. From the look of the commits you have on your repository, it seemed that you had this mostly working.
As far as I can figure out, I think I've got it working, along with a test case.

Attached are the following files:
  • "execFlowFunctionObjectsMod24.tar.gz" - This is the modified execFlowFunctionObjects utility from OpenFOAM 2.4.x. I'll detail the changes after this list.
  • "movingCone24.tar.gz" - This case is based on the tutorial "incompressible/pimpleDyMFoam/movingCone" from OpenFOAM 2.4.x. It's modified to use the following boundary condition in the file "0/pointMotionUx":
    Code:
        movingWall
        {
            type            uniformFixedValue;
            //uniformValue    constant 1;
            uniformValue     table
            (
                (  0     0.0)
                (0.0005  1.0)
                (0.001  -1.0)
                (0.0015  1.0)
                (0.002  -1.0)
                (0.0025  1.0)
                (0.003  -1.0)
                (0.0035  1.0)
                (0.004  -1.0)
                (0.0045  1.0)
                (0.005  -1.0)
                (0.0055  1.0)
                (0.006  -1.0)
                (0.0065  1.0)
                (0.007  -1.0)
                (0.0075  1.0)
                (0.008  -1.0)
                (0.0085  1.0)
                (0.009  -1.0)
            );        
        }
    This makes it oscillate in a way that allows us to sample specific time snapshots where the cone is in the same position.
  • "Overview of animation controls.jpg" - This shows how I had to configure ParaView to render only the time shots that matter to us, because the attached case generates a lot of time snapshots.
  • "Detail of animation controls.jpg" - This is the zoomed in version of the "Animation View" widget, visible with through the menu "View -> Animation View". If this is not configured like this, then the case reader will try to load the field "UMean" for time snapshots that doesn't have the field, resulting in breaking the animation.
Regarding the changes in the code, the two big change are:
  • Setting deltaT, as I had originally suggested and then based on the implementation you did (i.e to use "value()"):
    Code:
            if(timeI==0)
            {
              runTime.setDeltaT(timeDirs[timeI].value());
            }
            else
            {
              runTime.setDeltaT(timeDirs[timeI].value()-timeDirs[timeI-1].value());
            }
    The first if statement refers to the fact that we cannot sample the first time step, i.e. time=0, otherwise deltaT would be zero and possibly result in a division by zero.
  • Commented out the function object update for dynamic meshes, the same way you did in your repository:
    Code:
            if (mesh.readUpdate() != polyMesh::UNCHANGED)
            {
                // Update functionObjectList if mesh changes
                //folPtr = readFunctionObjects(args, runTime, folDict);
            }
As for the case, it can be run with the following commands:
Code:
foamRunTutorials
rm */*Mean
rm */uniform/fieldAveragingProperties 
execFlowFunctionObjectsMod -noFlow -time '0.00075,0.00175,0.00275,0.00375,0.00475,0.00575,0.00675,0.00775,0.00875'
  • The first command automatically runs blockMesh and pimpleDyMFoam;
  • the two rm commands are for removing the mean fields, because I didn't feel like having two "controlDict" files.
  • The execFlowFunctionObjectsMod command explicitly only runs for the time steps where the cone is at the right most position.
And I think that's all that's important to point out. Well, the settings in "controlDict" also help, because I made it write to disk every "5e-05" seconds, which is why I could select accurately each time step.


Adding this hack to OpenFOAM itself is too cumbersome and probably a pain to maintain in the future. Nonetheless, I'll leave a reference to this on the bug tracker: http://www.openfoam.org/mantisbt/view.php?id=1789


Best regards,
Bruno
Attached Images
File Type: jpg Overview of animation controls.jpg (51.0 KB, 107 views)
File Type: jpg Detail of animation controls.jpg (17.4 KB, 27 views)
Attached Files
File Type: gz execFlowFunctionObjectsMod24.tar.gz (3.8 KB, 6 views)
File Type: gz movingCone24.tar.gz (3.2 KB, 4 views)
pbachant likes this.
__________________
wyldckat 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
same geometry,structured and unstructured mesh,different behaviour. sharonyue OpenFOAM Running, Solving & CFD 13 January 2, 2013 22:40
Compile problem ivanyao OpenFOAM Running, Solving & CFD 1 October 12, 2012 09:31
plot over time fferroni OpenFOAM Post-Processing 7 June 8, 2012 07:56
[blockMesh] error message with modeling a cube with a hold at the center hsingtzu OpenFOAM Meshing & Mesh Conversion 2 March 14, 2012 09:56
Upgraded from Karmic Koala 9.10 to Lucid Lynx10.04.3 bookie56 OpenFOAM Installation 8 August 13, 2011 04:03


All times are GMT -4. The time now is 08:06.