|
[Sponsors] |
[swak4Foam] Using fieldAverage together with swak4foam expressionField |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 8, 2014, 14:38 |
Using fieldAverage together with swak4foam expressionField
|
#1 |
Senior Member
Timofey Mukha
Join Date: Mar 2012
Location: Stockholm, Sweden
Posts: 118
Rep Power: 14 |
I have been messing with trying to use fieldAverage and swak generated expressionFields together, so I would like to share my experience and possibly get some tips about how to do this better. Maybe some of the stuff I'll write might seem trivial, but hey, is should save time for someone .
Let us amagine the following: we want to calculate the prime2Mean of U ourselves using an expressionField. We will use UMean from fieldAverage, calculate "(UMean-U)^2" at every timestep as an expressionField and then use fieldAverage to find the mean of the expressionField. Here are some points that I had to figure out along the way. 1) The order matters. The order in which we declare objects in the controlDict matters, because all the fields/IOobjects that a functionObject uses have to be available at the time of the objects declaration. For this reason we will not be able to have only one fieldAverage, but will have to declare two separate ones. 2) expressionFields are evaluated only at write-time Or at least that is the only way I can explain that my code didn't work , some comment from an experienced user is welcome here.. Can we enforce to update at every timestep in memory? This will screw up the averaging of the expressionField. A work around that I used was to run manipulateField on all the relevant expressionFields. This seems to work, but bloats the code. So for the xx component of the prime2Mean the following controlDict seems to work. Code:
//This will give UMean fieldAverage1 { type fieldAverage; functionObjectLibs ( "libfieldFunctionObjects.so" ); enabled true; outputControl outputTime; resetOnRestart true; fields ( U { mean on; prime2Mean on; //for testing base time; } ); } //This will calculate the X-component of the prime2Mean primeX { type expressionField; dimension [0 2 -2 0 0 0 0]; fieldName "primeX"; expression "sqr(UMean.x-U.x)"; verbose true; autowrite true; outputControl outputTime; } //This will force the update updatePrimeX { type manipulateField; fieldName "primeX"; mask "true"; expression "sqr(UMean.x-U.x)"; } //This will calculate the mean of primeX fieldAverage2 { type fieldAverage; functionObjectLibs ( "libfieldFunctionObjects.so" ); enabled true; outputControl outputTime; resetOnRestart true; fields ( primeX { mean on; prime2Mean off; base time; } ); } The whole thing is not extensively tested, so don't trust this code . All tips and comments, especially about why this might fail are more than welcome! |
|
Tags |
fieldaverage, functionobjects, swak4foam |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] problems with averaging a new field | fgarita | OpenFOAM Community Contributions | 1 | October 28, 2016 03:27 |
[swak4Foam] expressionField + execFlowFunctionObjects + AMI | pbachant | OpenFOAM Community Contributions | 0 | July 16, 2015 01:09 |
[swak4Foam] Using swak4foam to implement a BC for heat convection with h(Tamb,Twall) | zfaraday | OpenFOAM Community Contributions | 5 | January 19, 2015 14:05 |
[swak4Foam] expressionField | aylalisa | OpenFOAM Community Contributions | 1 | October 28, 2014 17:42 |
[swak4Foam] fails in parallel with -otherTime? | Phicau | OpenFOAM Community Contributions | 3 | June 26, 2013 13:00 |