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

Average of Scalar of a cellset during the calculation for each time step

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By fcollonv
  • 1 Post By newOFuser

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 30, 2011, 06:20
Default Average of Scalar of a cellset during the calculation for each time step
  #1
New Member
 
Sam Fredriksson
Join Date: Dec 2010
Posts: 20
Rep Power: 15
safre is on a distinguished road
Hello

I would like to monitor as well as later on post process spatial averages of scalar fields. My strategy was to collect the cells to be averaged in different cellSets. I would then like to average a number of scalar fields for each of these cellSets during my computation.

Is there someone who have done this before and can give a hint on how to do this?

Best regards, Sam
safre is offline   Reply With Quote

Old   June 30, 2011, 09:26
Default
  #2
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,266
Blog Entries: 1
Rep Power: 24
nimasam is on a distinguished road
maybe swak4foam help you to do it, look for in openFOAM wiki
nimasam is offline   Reply With Quote

Old   June 30, 2011, 17:35
Default
  #3
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 21
marupio is on a distinguished road
I don't know much about cellSets, but you could add an IOdictionary to the createFields, except instead of MUST_READ and NO_WRITE, set it to NO_READ, and AUTO_WRITE, and put it in runTime.timeName() instead of constant. Then fill it with the average values for each variable for each cellSet at every time step. e.g. myDict.set(varName, average(scalarField)); << very rough

That way it will output your dictionary to the time directories with average values.
marupio is offline   Reply With Quote

Old   October 4, 2011, 17:13
Default Thank you for your help
  #4
New Member
 
Sam Fredriksson
Join Date: Dec 2010
Posts: 20
Rep Power: 15
safre is on a distinguished road
Thank you for your help!
safre is offline   Reply With Quote

Old   October 7, 2011, 11:15
Default Average a cellSet during the run with cellSource
  #5
Member
 
Frederic Collonval
Join Date: Apr 2009
Location: Technische Universitaet Munich - Lehrstuhl fuer Thermodynamik
Posts: 53
Rep Power: 17
fcollonv is on a distinguished road
Hello Sam,

There is a non-intrusive & nice way to do it by using the cellSource.

The explanation in the code is
Code:
00024 Class 
00025     Foam::fieldValues::cellSource 
00026  
00027 Description 
00028     Cell source variant of field value function object. Values of user- 00029     specified fields reported for collections of cells. 
00030  
00031     cellObj1                        // Name also used to identify output folder 
00032     { 
00033         type            cellSource; 
00034         functionObjectLibs ("libfieldValueFunctionObjects.so"); 
00035         enabled         true; 
00036         outputControl   outputTime; 
00037         log             true;       // log to screen? 
00038         valueOutput     true;       // Write values at run-time output times? 
00039         source          cellZone;   // Type of cell source or all for the full domain
00040         sourceName      c0; 
00041         operation       volAverage; 
00042         fields 
00043         ( 
00044             p 
00045             U 
00046         ); 
00047     } 
00048  
00049     where operation is one of: 
00050       - none 
00051       - sum 
00052       - volAverage 
00053       - volIntegrate 
00054       - weightedAverage
Personally I use it to compute the volume average of the heat release

HRR
{
type cellSource;
functionObjectLibs ("libfieldFunctionObjects.so");
enabled false;
outputControl timeStep;
outputInterval 1;
log true; // log to screen?
valueOutput false; // Write values at run-time output times?
source all; // cellZone or all
sourceName c0;
operation volIntegrate;
fields
(
dQf
);
}

Good luck

Frederic

N.B.: A cellSet is maybe not working directly, you may have to convert it into cellZone. For that there is the tool setsToZones
__________________
Frederic Collonval
Technische Universität München
Thermodynamics Dpt.
fcollonv is offline   Reply With Quote

Old   October 11, 2011, 10:28
Smile This looks very promising - thank you!
  #6
New Member
 
Sam Fredriksson
Join Date: Dec 2010
Posts: 20
Rep Power: 15
safre is on a distinguished road
This looks very promising - thank you!
safre is offline   Reply With Quote

Old   August 12, 2012, 03:31
Default
  #7
Member
 
ak
Join Date: May 2011
Posts: 64
Rep Power: 14
newOFuser is on a distinguished road
Hi Frederick,

I am a new user of OF, and would appreciate if you could clear the following doubts (based on the volume integral code provided):
How are the cell sources/cell zones defined? What does c0 refer to?

Thanks,
ak
newOFuser is offline   Reply With Quote

Old   August 14, 2012, 03:31
Default
  #8
Member
 
Frederic Collonval
Join Date: Apr 2009
Location: Technische Universitaet Munich - Lehrstuhl fuer Thermodynamik
Posts: 53
Rep Power: 17
fcollonv is on a distinguished road
Hi ak,

To create cell zone, you have to create cell set using 'setSet'. Then using the same tool, you can convert a cell set in cell zone.
Go to a case directory. Type the command 'setSet' - it looks like a console software. Type 'help' to get more information and examples.
N.B.: To know which 'source's are available, type something like
Code:
cellSet c0 new dummy
'c0' is simply a name given to the cell zone (in OpenFOAM every element is found based on a string).

Cheers,

Frederic
Mojtaba.a likes this.
__________________
Frederic Collonval
Technische Universität München
Thermodynamics Dpt.
fcollonv is offline   Reply With Quote

Old   August 14, 2012, 13:15
Default
  #9
Member
 
ak
Join Date: May 2011
Posts: 64
Rep Power: 14
newOFuser is on a distinguished road
Hello

Thanks for the prompt reply. It is very useful.

I tried the following:

1. Created makeCellSets.setSet file with the following details:

cellSet combustor new boxToCell (-0.02 0 0) (0 0.025 0.04)
cellSet combustor add boxToCell (0 -0.025 0) (0.2 0.025 0.04)
cellZoneSet combustorZone new setToCellZone combustor

2. Then, using an Allrun script, the following was performed:

runApplication blockMesh
runApplication setSet -batch makeCellSets.setSet
rm -f constant/polyMesh/sets/*_old
runApplication setsToZones -noFlipMap

3. In system/controlDict, the following was included:

HRR
{
type cellSource;
functionObjectLibs ("libfieldFunctionObjects.so");
enabled true;
outputControl timeStep;
outputInterval 1;
log false; // log to screen?
valueOutput false; // Write values at run-time output times?
source cellZone; // cellZone or all
sourceName combustorZone;
operation volIntegrate;
fields
(
p // For testing
U // For testing
chemistrySh
);
}

While this worked for volIntegrate for p and U (just for testing code), the HRR/0/cellSource.dat file had no data for chemistrySh

# Source : cellZone combustorZone
# Cells : 258720
# Time sum(V) volIntegrate(p) volIntegrate(U) volIntegrate(chemistrySh)
2e-06 0.00042 41.9985 (-1.51726e-05 -1.78689e-07 9.04692e-20)
4e-06 0.00042 42.0006 (-1.95745e-05 -2.44872e-07 -1.95267e-19)
6e-06 0.00042 42.0038 (-8.04091e-06 -2.64433e-07 -2.09461e-16)

The cellSet and cellZone approach as you suggested works quite well. Thanks!

I am not sure though why it is not able to record the volume Integral of chemistrySh using this approach.
In the solver, when I use fvc::domainIntegrate(chemistrySh).value(), it works just fine and can output the result in the terminal as well.

Could you let me know how you define dQf in your code, or what could be wrong with my approach?

In my createFields, I have:
volScalarField chemistrySh
// DimensionedField<scalar, volMesh> chemistrySh
(
IOobject
(
"chemistry::Sh",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("chemistrySh", dimEnergy/dimTime/dimVolume, 0.0)
);


Thanks!
ak
Mojtaba.a likes this.
newOFuser is offline   Reply With Quote

Old   August 14, 2012, 14:06
Default
  #10
Member
 
ak
Join Date: May 2011
Posts: 64
Rep Power: 14
newOFuser is on a distinguished road
Hi

Got this figured out:

Defined chemistrySh as follows:
volScalarField chemistrySh
(
IOobject
(
"chemistrySh",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);

A 0/chemistrySh file was also required in the case directory.

I should also add another way to calculate the volume integral, as follows:
volHRR
{
type volumeIntegrate;
functionObjectLibs ("libsimpleFunctionObjects.so");
enabled true;
outputControl timeStep;
outputInterval 1;
log false; // log to screen?
valueOutput false; // Write values at run-time output times?
fields
(
chemistrySh
);
}

-ak
newOFuser is offline   Reply With Quote

Old   August 14, 2012, 16:38
Default
  #11
Member
 
ak
Join Date: May 2011
Posts: 64
Rep Power: 14
newOFuser is on a distinguished road
Hi

I am now having difficulty printing out the data when I run computations in parallel. Any ideas how to proceed?

ak

Edit. When I use the 2nd option above, it says: Can only probe registered volScalar, volVector, volSphericalTensor, volSymmTensor and volTensor fields

Last edited by newOFuser; August 14, 2012 at 17:16.
newOFuser is offline   Reply With Quote

Old   August 15, 2012, 04:11
Default Save heat release
  #12
Member
 
Frederic Collonval
Join Date: Apr 2009
Location: Technische Universitaet Munich - Lehrstuhl fuer Thermodynamik
Posts: 53
Rep Power: 17
fcollonv is on a distinguished road
Hi ak,

The second option is a good idea. But I advice you to use a name totally different like "heatRelease". Then it should work as you wrote it i.e. using a volScalarField storing Sh (the error can come when you try to integrate the DimensionedField<scalar, volMesh> for example).

To print output for all processors, you have to use 'Pout' instead of 'Info'.

Best regards,

Frederic
__________________
Frederic Collonval
Technische Universität München
Thermodynamics Dpt.
fcollonv is offline   Reply With Quote

Old   August 15, 2012, 10:32
Default
  #13
Member
 
ak
Join Date: May 2011
Posts: 64
Rep Power: 14
newOFuser is on a distinguished road
Hello

Thanks for the suggestions, and all the help!

I was able to get it to run in parallel mode.

Thanks,
ak

Last edited by newOFuser; August 15, 2012 at 16:22.
newOFuser 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
transsonic nozzle with rhoSimpleFoam Unseen OpenFOAM Running, Solving & CFD 8 July 1, 2022 06:54
Extrusion with OpenFoam problem No. Iterations 0 Lord Kelvin OpenFOAM Running, Solving & CFD 8 March 28, 2016 11:08
Full pipe 3D using icoFoam cyberbrain OpenFOAM 4 March 16, 2011 09:20
calculation of time step aamer Main CFD Forum 8 December 8, 2010 03:26
Unknown error sivakumar OpenFOAM Pre-Processing 9 September 9, 2008 12:53


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